Re: Allocation sinking in git HEAD

  • From: Mike Pall <mike-1207@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 4 Jul 2012 01:37:01 +0200

Geoff Leyland wrote:
> I imagine it's more a case of whether the object is contained
> within a single trace than about functions.  Presumably some
> objects are materialized just before trace exits.  Are then then
> un-materialised if the side trace's use of the object later
> proves tractable to the optimization?

The first few exits from a trace are handled by a data-driven
approach that rematerializes the allocated objects on-the-fly.

When the same exit is taken often enough, the JIT-compiler
compiles a side trace for it. The first part of the side trace is
filled with the replayed allocations and stores, that have been
sunk in the parent trace.

Of course, the side trace is then passed through the same kind of
optimizations. So all of those allocations and stores may (or may
not) be sunk again, together with any other allocations you do in
that side trace. And so on ...

Simple example:

 for i=1,200 do
   local a = {i}         -- Sunk
   if i > 100 then
                         -- Rematerialized here and sunk again
     local b = {a[1]}    -- Sunk, too

Have a look at the output of -jdump=rism and compare it with
or without -O-sink to see its effect.


Other related posts: