Skip to content

Commit b4a6ac6

Browse files
committed
Disable stack nested functions for split scope
When we have non-escaping functions in both param and body scope we are trying to create stack nested functions for them. The problem is we try to reuse the local frame display. In case of split scope we cannot do that as both functions should get different frame displays. This changelist disables stack nested functions inside split scoped functions.
1 parent 5f0a0a2 commit b4a6ac6

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

lib/Runtime/ByteCode/ByteCodeGenerator.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,6 +1819,17 @@ bool ByteCodeGenerator::CanStackNestedFunc(FuncInfo * funcInfo, bool trace)
18191819
return false;
18201820
}
18211821

1822+
if (funcInfo->paramScope && !funcInfo->paramScope->GetCanMergeWithBodyScope())
1823+
{
1824+
if (trace)
1825+
{
1826+
PHASE_PRINT_TESTTRACE(Js::StackFuncPhase, funcInfo->byteCodeFunction,
1827+
_u("CanStackNestedFunc: %s (Split Scope)\n"),
1828+
funcInfo->byteCodeFunction->GetDisplayName());
1829+
}
1830+
return false;
1831+
}
1832+
18221833
if (trace && funcInfo->byteCodeFunction->GetNestedCount())
18231834
{
18241835
// Only print functions that actually have nested functions, although we will still mark

test/es6/default-splitscope.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ var tests = [
7070
return b;
7171
}
7272
assert.areEqual(10, f7().iFnc(), "Function definition inside the object literal should capture the formal from the param scope");
73+
74+
var f8 = function (a, b = ((function() { assert.areEqual('string1', a, "First arguemnt receives the right value"); })(), 1), c) {
75+
var d = 'string3';
76+
(function () { assert.areEqual('string3', d, "Var declaration in the body is initialized properly"); })();
77+
return c;
78+
};
79+
80+
assert.areEqual('string2', f8('string1', undefined, 'string2'), "Function returns the third argument properly");
7381
}
7482
},
7583
{

0 commit comments

Comments
 (0)