Mars assembly: No way to directly call constructors

Bug #766796 reported by Matt Giuca
6
This bug affects 1 person
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.

Tags: ir

Related branches

Revision history for this message
Matt Giuca (mgiuca) wrote :

Fixed in no-ldfunc r1217; trunk r1215.

Changed in mars:
status: Triaged → Fix Committed
Matt Giuca (mgiuca)
Changed in mars:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.