Mars assembly: No way to directly call constructors
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mars |
Fix Released
|
Low
|
Matt Giuca |
Bug Description
There is no way for Mars assembly code to directly call a constructor function. Instead, it needs to do a ld_ctor (which creates a local variable with the constructor function) followed by a call (to the local variable). The same applies for parcall.
This is potentially quite inefficient on backends (which could potentially end up constructing a closure for the ld_ctor) and requires multi-instruction optimisation to fix. Therefore, add call_ctor and parcall_ctor instructions to directly call/parcall a constructor function, as parallels to call_global and parcall_global.
Note that this would then create a parallel of the situation in bug #766795, where ld_ctor is redundant for parcall_ctor with 0 arguments, and so ld_ctor should be removed. However, ld_ctor fills the constructor version of BOTH ld_func and ld_cgc -- only the function loading role is redundant. ld_ctor is still the only way to load a constructor constant symbol. Therefore, rename ld_ctor to ld_ctorsym, and change its semantics so it ONLY loads constructor constant symbols. For loading constructor functions, parcall_ctor should always be used.
Related branches
- Matt Giuca: Approve
-
Diff: 318 lines (+109/-57)8 files modifieddoc/dev/isa.rst (+31/-10)
src/ast_cfg.m (+31/-4)
src/callgraph.m (+0/-1)
src/interpret.m (+15/-4)
src/ir.m (+9/-6)
src/pretty.m (+15/-6)
src/typedict.m (+1/-23)
src/usedef.m (+7/-3)
Changed in mars: | |
status: | Fix Committed → Fix Released |
Fixed in no-ldfunc r1217; trunk r1215.