@@ -1403,6 +1403,7 @@ BailOutRecord::BailOutHelper(Js::JavascriptCallStackLayout * layout, Js::ScriptF
14031403 //
14041404 Js::Arguments generatorArgs = generator->GetArguments ();
14051405 Js::InterpreterStackFrame::Setup setup (function, generatorArgs, true , isInlinee);
1406+ Assert (setup.GetStackAllocationVarCount () == 0 );
14061407 size_t varAllocCount = setup.GetAllocationVarCount ();
14071408 size_t varSizeInBytes = varAllocCount * sizeof (Js::Var);
14081409 DWORD_PTR stackAddr = reinterpret_cast <DWORD_PTR>(&generator); // as mentioned above, use any stack address from this frame to ensure correct debugging functionality
@@ -1415,11 +1416,14 @@ BailOutRecord::BailOutHelper(Js::JavascriptCallStackLayout * layout, Js::ScriptF
14151416 // Allocate invalidVar on GC instead of stack since this InterpreterStackFrame will out live the current real frame
14161417 Js::Var invalidVar = (Js::RecyclableObject*)RecyclerNewPlusLeaf (functionScriptContext->GetRecycler (), sizeof (Js::RecyclableObject), Js::Var);
14171418 memset (invalidVar, 0xFE , sizeof (Js::RecyclableObject));
1418- newInstance = setup.InitializeAllocation (allocation, false , false , loopHeaderArray, stackAddr, invalidVar);
1419- #else
1420- newInstance = setup.InitializeAllocation (allocation, false , false , loopHeaderArray, stackAddr);
14211419#endif
14221420
1421+ newInstance = setup.InitializeAllocation (allocation, nullptr , false , false , loopHeaderArray, stackAddr
1422+ #if DBG
1423+ , invalidVar
1424+ #endif
1425+ );
1426+
14231427 newInstance->m_reader .Create (executeFunction);
14241428
14251429 generator->SetFrame (newInstance, varSizeInBytes);
@@ -1429,18 +1433,28 @@ BailOutRecord::BailOutHelper(Js::JavascriptCallStackLayout * layout, Js::ScriptF
14291433 {
14301434 Js::InterpreterStackFrame::Setup setup (function, args, true , isInlinee);
14311435 size_t varAllocCount = setup.GetAllocationVarCount ();
1432- size_t varSizeInBytes = varAllocCount * sizeof (Js::Var);
1436+ size_t stackVarAllocCount = setup.GetStackAllocationVarCount ();
1437+ size_t varSizeInBytes;
1438+ Js::Var *stackAllocation = nullptr ;
14331439
14341440 // If the locals area exceeds a certain limit, allocate it from a private arena rather than
14351441 // this frame. The current limit is based on an old assert on the number of locals we would allow here.
1436- if (varAllocCount > Js::InterpreterStackFrame::LocalsThreshold)
1442+ if (( varAllocCount + stackVarAllocCount) > Js::InterpreterStackFrame::LocalsThreshold)
14371443 {
14381444 ArenaAllocator *tmpAlloc = nullptr ;
14391445 fReleaseAlloc = functionScriptContext->EnsureInterpreterArena (&tmpAlloc);
1446+ varSizeInBytes = varAllocCount * sizeof (Js::Var);
14401447 allocation = (Js::Var*)tmpAlloc->Alloc (varSizeInBytes);
1448+ if (stackVarAllocCount != 0 )
1449+ {
1450+ size_t stackVarSizeInBytes = stackVarAllocCount * sizeof (Js::Var);
1451+ PROBE_STACK_PARTIAL_INITIALIZED_BAILOUT_FRAME (functionScriptContext, Js::Constants::MinStackInterpreter + stackVarSizeInBytes, returnAddress);
1452+ stackAllocation = (Js::Var*)_alloca (stackVarSizeInBytes);
1453+ }
14411454 }
14421455 else
14431456 {
1457+ varSizeInBytes = (varAllocCount + stackVarAllocCount) * sizeof (Js::Var);
14441458 PROBE_STACK_PARTIAL_INITIALIZED_BAILOUT_FRAME (functionScriptContext, Js::Constants::MinStackInterpreter + varSizeInBytes, returnAddress);
14451459 allocation = (Js::Var*)_alloca (varSizeInBytes);
14461460 }
@@ -1465,11 +1479,14 @@ BailOutRecord::BailOutHelper(Js::JavascriptCallStackLayout * layout, Js::ScriptF
14651479#if DBG
14661480 Js::Var invalidStackVar = (Js::RecyclableObject*)_alloca (sizeof (Js::RecyclableObject));
14671481 memset (invalidStackVar, 0xFE , sizeof (Js::RecyclableObject));
1468- newInstance = setup.InitializeAllocation (allocation, false , false , loopHeaderArray, frameStackAddr, invalidStackVar);
1469- #else
1470- newInstance = setup.InitializeAllocation (allocation, false , false , loopHeaderArray, frameStackAddr);
14711482#endif
14721483
1484+ newInstance = setup.InitializeAllocation (allocation, stackAllocation, false , false , loopHeaderArray, frameStackAddr
1485+ #if DBG
1486+ , invalidStackVar
1487+ #endif
1488+ );
1489+
14731490 newInstance->m_reader .Create (executeFunction);
14741491 }
14751492
0 commit comments