Don't use heap allocated lexical environment if possible (#378)

- We should not heap allocated env on...
  * functions uses variable on upper function
  * functions have `typeof` operation
  * functions have unmapped arguments object
- Improve calling function performance by remove accessing vtable once in interpreter(from isCallable, call to just call)

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
This commit is contained in:
Patrick Kim 2019-08-20 10:41:06 +09:00 committed by Hyukwoo Park
commit 3c0a1cfddd
23 changed files with 297 additions and 65 deletions

View file

@ -132,7 +132,9 @@ InterpretedCodeBlock* ScriptParser::generateCodeBlockTreeFromASTWalker(Context*
if (argumentsVariableHolder) {
argumentsVariableHolder->captureArguments();
}
codeBlock->markHeapAllocatedEnvironmentFromHere(blockIndex, argumentsVariableHolder);
if (!codeBlock->isKindOfFunction() || codeBlock->isArrowFunctionExpression()) {
codeBlock->markHeapAllocatedEnvironmentFromHere(blockIndex, argumentsVariableHolder);
}
}
}
}
@ -150,10 +152,16 @@ InterpretedCodeBlock* ScriptParser::generateCodeBlockTreeFromASTWalker(Context*
if (r.first) {
usingNameIsResolvedOnCompileTime = true;
// if variable is global variable, we don't need capture it
// if variable is global variable, we don't need to capture it
if (!codeBlock->hasAncestorUsesNonIndexedVariableStorage() && !c->isKindOfFunction() && (r.second == SIZE_MAX || c->blockInfos()[r.second]->m_parentBlockIndex == LEXICAL_BLOCK_INDEX_MAX)) {
} else {
codeBlock->markHeapAllocatedEnvironmentFromHere(blockIndex, c);
if (r.second == SIZE_MAX) {
// captured variable is `var` declared variable
c->markHeapAllocatedEnvironmentFromHere(LEXICAL_BLOCK_INDEX_MAX, c);
} else {
// captured variable is `let` declared variable
c->markHeapAllocatedEnvironmentFromHere(r.second, c);
}
}
break;
}
@ -161,10 +169,6 @@ InterpretedCodeBlock* ScriptParser::generateCodeBlockTreeFromASTWalker(Context*
c = c->parentCodeBlock();
}
}
if (!usingNameIsResolvedOnCompileTime && codeBlock->hasAncestorUsesNonIndexedVariableStorage()) {
// {Load, Store}ByName needs this
codeBlock->markHeapAllocatedEnvironmentFromHere(blockIndex);
}
}
}
}