Optimise known type dictionaries

Bug #720588 reported by Matt Giuca
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mars
Fix Committed
Wishlist
Matt Giuca

Bug Description

Using the 'show' and 'eq' functions (since we added type dictionaries) is taking a huge performance hit. This is because to call 'show' or 'eq', you now need to find the type dictionary for the type in question (a CGC, which requires evaluation), then do a lookup of the method in the dictionary (costly), and then call the method dynamically (inefficient).

For example, inside the 'ge' function is a call to 'eq' for integers. The generated assembly code (partial) is this:

        $T:0:4 = ~@dict:Int
        $T:0:3 = @:Dict:eq:ref($T:0:4)
        $T:0 = $T:0:3($T:0:1, $T:0:2)

Note that the first line is evaluating a CGC (call to a function or a thunk lookup), and the second line features an entire call to another function (which will be efficiently inlined in LLVM, but still, this is a method lookup). Even in fully-optimised LLVM, this still needs to evaluate a thunk, dereference a pointer, pull a function pointer out of it, then call it indirectly.

For known type dictionaries, this should be replaced with a simple reference to the method:

        $T:0 = @eq:Int($T:0:1, $T:0:2)

Related branches

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

Fixed in trunk r1355.

Changed in mars:
status: Triaged → Fix Committed
Matt Giuca (mgiuca)
Changed in mars:
milestone: none → 1.0
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.