mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
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:
parent
6db46a1f27
commit
5d2a2927ae
1 changed files with 12 additions and 1 deletions
|
|
@ -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++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue