Optimize script initialization performance (#458)

* Store child {ASTFunctionContext, InterpretedCodeBlock} as linked-list
* Reduce size of ScannerResult
* Remove Parser::scopeContexts
* Fix compile error in old system

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
This commit is contained in:
Patrick Kim 2019-10-14 13:07:28 +09:00 committed by Boram Bae
commit 4bb343552e
21 changed files with 444 additions and 362 deletions

View file

@ -166,9 +166,13 @@ InterpretedCodeBlock* ScriptParser::generateCodeBlockTreeFromASTWalker(Context*
}
}
codeBlock->m_childBlocks.resizeWithUninitializedValues(scopeCtx->m_childScopes.size());
for (size_t i = 0; i < scopeCtx->m_childScopes.size(); i++) {
codeBlock->m_childBlocks[i] = generateCodeBlockTreeFromASTWalker(ctx, source, script, scopeCtx->m_childScopes[i], codeBlock, isEvalCode, isEvalCodeInFunction);
ASTFunctionScopeContext* child = scopeCtx->firstChild();
InterpretedCodeBlock* refer = nullptr;
while (child) {
InterpretedCodeBlock* newBlock = generateCodeBlockTreeFromASTWalker(ctx, source, script, child, codeBlock, isEvalCode, isEvalCodeInFunction);
codeBlock->appendChild(newBlock, refer);
refer = newBlock;
child = child->nextSibling();
}
return codeBlock;
@ -182,8 +186,10 @@ InterpretedCodeBlock* ScriptParser::generateCodeBlockTreeFromAST(Context* ctx, S
void ScriptParser::generateCodeBlockTreeFromASTWalkerPostProcess(InterpretedCodeBlock* cb)
{
for (size_t i = 0; i < cb->m_childBlocks.size(); i++) {
generateCodeBlockTreeFromASTWalkerPostProcess(cb->m_childBlocks[i]);
InterpretedCodeBlock* child = cb->firstChild();
while (child) {
generateCodeBlockTreeFromASTWalkerPostProcess(child);
child = child->nextSibling();
}
cb->computeVariables();
if (cb->m_identifierOnStackCount > VARIABLE_LIMIT || cb->m_identifierOnHeapCount > VARIABLE_LIMIT || cb->m_lexicalBlockStackAllocatedIdentifierMaximumDepth > VARIABLE_LIMIT) {
@ -341,8 +347,10 @@ void ScriptParser::dumpCodeBlockTree(InterpretedCodeBlock* topCodeBlock)
puts("");
for (size_t i = 0; i < cb->m_childBlocks.size(); i++) {
fn(cb->m_childBlocks[i], depth + 1);
InterpretedCodeBlock* child = cb->firstChild();
while (child) {
fn(child, depth + 1);
child = child->nextSibling();
}
};