Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce code bloat around declaration chaining #1041

Open
tanyongkiam opened this issue Aug 9, 2024 · 0 comments
Open

Reduce code bloat around declaration chaining #1041

tanyongkiam opened this issue Aug 9, 2024 · 0 comments

Comments

@tanyongkiam
Copy link
Contributor

The stubs for function declarations should be cleaned up to reduce code bloat:

Example from the explorer output:

(func dec@59 ()
   (let
      (a <-
         (op (SetGlobal 3)
            (op (Cons 30) (op (Const 0)) (op (Label fst_clos@424)))))
      (call dec@60)))

(func dec@60 ()
   (let
      (a <-
         (op (SetGlobal 7)
            (op (Cons 30) (op (Const 2)) (op (Label o_clos@426)))))
      (call dec@61)))

These stubs become quite large later:

(dec@246
   (asm (Arith (Binop Sub 12 12 (Imm 0x10))))
   (jump_cmp (Lower 12 (Reg 13)) _Halt2@2 0)
   (label dec@246 1)
   (asm (Mem Load 7 (Addr 13 0xFFFFFFFFFFFFFFD8)))
   (asm (Mem Load 6 (Addr 13 0xFFFFFFFFFFFFFFF8)))
   (asm (Arith (Binop Sub 7 7 (Reg 6))))
   (jump_cmp (NotLower 7 (Imm 0x18)) dec@246 4)
   (asm (Const 7 0x18))
   (asm (Mem Store 0 (Addr 12 0x8)))
   (asm (Const 11 0x161))
   (asm (Mem Store 11 (Addr 12 0x0)))
   (loc_value 0 dec@246 2)
   (jump _GC@4 0)
   (label dec@246 2)
   (asm (Mem Load 0 (Addr 12 0x8)))
   (label dec@246 4)
   (asm (Const 7 0x0))
   (loc_value 2 fst_clos@1341 0)
   (asm (Mem Load 6 (Addr 13 0xFFFFFFFFFFFFFFF8)))
   (asm (Const 1 0x2000001E3))
   (asm (Mem Store 1 (Addr 6 0x0)))
   (asm (Mem Store 2 (Addr 6 0x8)))
   (asm (Mem Store 7 (Addr 6 0x10)))
   (asm (Arith (Binop Or 7 6 (Reg 6))))
   (asm (Arith (Binop Sub 7 7 (Reg 14))))
   (asm (Arith (Shift Lsl 7 7 9)))
   (asm (Arith (Binop Or 7 7 (Imm 0x1E5))))
   (asm (Arith (Binop Add 6 6 (Imm 0x18))))
   (asm (Mem Store 6 (Addr 13 0xFFFFFFFFFFFFFFF8)))
   (asm (Mem Load 6 (Addr 13 0xFFFFFFFFFFFFFFB8)))
   (asm (Mem Store 7 (Addr 6 0x28)))
   (jump dec@249 1)
   (label dec@246 5))

(dec@249
   (asm (Arith (Binop Sub 12 12 (Imm 0x10))))
   (jump_cmp (Lower 12 (Reg 13)) _Halt2@2 0)
   (label dec@249 1)
   (asm (Mem Load 7 (Addr 13 0xFFFFFFFFFFFFFFD8)))
   (asm (Mem Load 6 (Addr 13 0xFFFFFFFFFFFFFFF8)))
   (asm (Arith (Binop Sub 7 7 (Reg 6))))
   (jump_cmp (NotLower 7 (Imm 0x18)) dec@249 4)
   (asm (Const 7 0x18))
   (asm (Mem Store 0 (Addr 12 0x8)))
   (asm (Const 11 0x162))
   (asm (Mem Store 11 (Addr 12 0x0)))
   (loc_value 0 dec@249 2)
   (jump _GC@4 0)
   (label dec@249 2)
   (asm (Mem Load 0 (Addr 12 0x8)))
   (label dec@249 4)
   (asm (Const 7 0x8))
   (loc_value 2 o_clos@1347 0)
   (asm (Mem Load 6 (Addr 13 0xFFFFFFFFFFFFFFF8)))
   (asm (Const 1 0x2000001E3))
   (asm (Mem Store 1 (Addr 6 0x0)))
   (asm (Mem Store 2 (Addr 6 0x8)))
   (asm (Mem Store 7 (Addr 6 0x10)))
   (asm (Arith (Binop Or 7 6 (Reg 6))))
   (asm (Arith (Binop Sub 7 7 (Reg 14))))
   (asm (Arith (Shift Lsl 7 7 9)))
   (asm (Arith (Binop Or 7 7 (Imm 0x1E5))))
   (asm (Arith (Binop Add 6 6 (Imm 0x18))))
   (asm (Mem Store 6 (Addr 13 0xFFFFFFFFFFFFFFF8)))
   (asm (Mem Load 6 (Addr 13 0xFFFFFFFFFFFFFFB8)))
   (asm (Mem Store 7 (Addr 6 0x48)))
   (jump dec@252 1)
   (label dec@249 5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant