Mark ancester code blocks as heap-allocated if code block has captured variables

**ref: ch10/10.4/10.4.3/10.4.3-1-102-s.js
This commit is contained in:
Junyoung Cho 2016-12-28 19:05:29 +09:00
commit 5d2a2927ae

View file

@ -51,6 +51,7 @@ CodeBlock* ScriptParser::generateCodeBlockTreeFromASTWalker(Context* ctx, String
}
}
bool hasCapturedIdentifier = false;
AtomicString arguments = ctx->staticStrings().arguments;
for (size_t i = 0; i < scopeCtx->m_usingNames.size(); i++) {
AtomicString uname = scopeCtx->m_usingNames[i];
@ -63,12 +64,22 @@ CodeBlock* ScriptParser::generateCodeBlockTreeFromASTWalker(Context* ctx, String
if (!codeBlock->hasName(uname)) {
CodeBlock* c = codeBlock->parentCodeBlock();
while (c) {
if (c->tryCaptureIdentifiersFromChildCodeBlock(uname))
if (c->tryCaptureIdentifiersFromChildCodeBlock(uname)) {
hasCapturedIdentifier = true;
break;
}
c = c->parentCodeBlock();
}
}
}
// FIXME: modify efficiently if possible. consider 10.4.3-1-102-s
if (hasCapturedIdentifier) {
CodeBlock* c = codeBlock->parentCodeBlock();
while (c && c->m_canAllocateEnvironmentOnStack) {
c->m_canAllocateEnvironmentOnStack = false;
c = c->parentCodeBlock();
}
}
}
for (size_t i = 0; i < scopeCtx->m_childScopes.size(); i++) {