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:
igor%mir2.org 2002-12-05 21:04:30 +00:00
Родитель 10b47dddd6
Коммит 88ad54171f
1 изменённых файлов: 14 добавлений и 7 удалений

Просмотреть файл

@ -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;
}