Hi,
Back on the horse.
My current plan is to use lazy tear-off, but not with activations.
Activations assume a fixed stack layout and have to worry about
arguments, which block scopes do not. Activations also have to support
eval-introduced bindings in non-strict mode, which block scopes do not.
I'll refactor JSStaticScope into something that uses lazy tear-off. It
will allocate registers like this, with apologies to Interpreter.cpp:
function f(x, y) {
var v1;
{ // scope 0
let b00, b01;
{ // scope 1
let b10;
}
}
function g() { }
var v2;
{ // scope 2
let b20;
}
return (x) * (y);
}
----------------------------------------------------------------
| x | y | g | v2 | v1 | s0 | b00 | b01 | s1 | s10 | t1 | t2 |
----------------------------------------------------------------
| -5 | -4 | -3 | -2 | -1 | +0 | +1 | +2 | +3 | +4 | +5 | +6 |
----------------------------------------------------------------
| params->|<-locals | scope 0 | scope 1 | temps |
This is the state of the call frame within scope 1. The block reserved
for block scopes will have as many registers as the maximum of (number
of block scope-bound variables + block scope depth). There will be a
register per block scope to use to hold the JSStaticScope object,
created lazily. Within scope 2, the stack looks like this:
--------------------------------------------------------------
| x | y | g | v2 | v1 | s2 | b20 | nothing | t1 | t2 |
--------------------------------------------------------------
| -5 | -4 | -3 | -2 | -1 | +0 | +1 | +2 | +3 | +4 | +5 | +6 |
--------------------------------------------------------------
| params->|<-locals | scope 2 | dead space | temps |
emitPushNewScope will emit code that zeroes the scope register, and in
the most general case poisons the registers allocated to block-scoped
vars. (This is the "temporal dead zone". In many cases we will be able
to elide this step in the bytecompiler, and the DFG will certainly be
able to do this dead-store elimination.) We'll have to add read
barriers as well. Leaving a scope will clear the registers so that they
don't prevent values from being collected.
There will be op_create_scope to lazily create a scope object, should
that be necessary, a la createActivationIfNecessary. There will be
op_tearoff_scope, to do the tearoff, if needed.
I hope to have something early next week; we'll see. In the meantime,
comments are most welcome.
Andy
_______________________________________________
squirrelfish-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/squirrelfish-dev