зеркало из https://github.com/mozilla/pjs.git
Remove generation of closure icode for function statements as they are initialized at script/function start, not at point of declaration. This redundant closure icodes were effectively no-operation but caused bigger stack to be allocated then necessary.
This commit is contained in:
Родитель
10b47dddd6
Коммит
88ad54171f
|
@ -271,13 +271,20 @@ public class Interpreter {
|
|||
switch (type) {
|
||||
|
||||
case TokenStream.FUNCTION : {
|
||||
Node fn = (Node) node.getProp(Node.FUNCTION_PROP);
|
||||
int index = fn.getExistingIntProp(Node.FUNCTION_PROP);
|
||||
iCodeTop = addByte(TokenStream.CLOSURE, iCodeTop);
|
||||
iCodeTop = addIndex(index, iCodeTop);
|
||||
itsStackDepth++;
|
||||
if (itsStackDepth > itsData.itsMaxStack)
|
||||
itsData.itsMaxStack = itsStackDepth;
|
||||
FunctionNode fn
|
||||
= (FunctionNode) node.getProp(Node.FUNCTION_PROP);
|
||||
if (fn.itsFunctionType != FunctionNode.FUNCTION_STATEMENT) {
|
||||
// Only function expressions or function expression
|
||||
// statements needs closure code creating new function
|
||||
// object on stack as function statements are initialized
|
||||
// at script/function start
|
||||
int index = fn.getExistingIntProp(Node.FUNCTION_PROP);
|
||||
iCodeTop = addByte(TokenStream.CLOSURE, iCodeTop);
|
||||
iCodeTop = addIndex(index, iCodeTop);
|
||||
itsStackDepth++;
|
||||
if (itsStackDepth > itsData.itsMaxStack)
|
||||
itsData.itsMaxStack = itsStackDepth;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче