Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
[Merge chakra-core/ChakraCore@0c739a73be] [1.6>1.7] [MERGE #3445 @ane…
Browse files Browse the repository at this point in the history
…eshdk] Keep the same register allocation path for debug and non-debug mode in generators

Merge pull request #3445 from aneeshdk:GeneratorDynamicAttach

In debug mode we have different register allocation logic for inner scope slots. In case of generators if the debugger is attached dynamically before the generator completes then this can cause issues. Current fix is to avoid the different paths for register allocation.
  • Loading branch information
chakrabot authored and kfarnung committed Aug 10, 2017
1 parent 8e87b75 commit 5a30daf
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
9 changes: 7 additions & 2 deletions deps/chakrashim/core/lib/Runtime/ByteCode/ByteCodeEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1744,9 +1744,13 @@ void ByteCodeGenerator::FinalizeRegisters(FuncInfo * funcInfo, Js::FunctionBody

this->SetClosureRegisters(funcInfo, byteCodeFunction);

if (this->IsInDebugMode())
if (this->IsInDebugMode() || byteCodeFunction->IsCoroutine())
{
// Give permanent registers to the inner scopes in debug mode.
// TODO: We create seperate debuggerscopes for each block which has own scope. These are stored in the var registers
// allocated below. Ideally we should change this logic to not allocate separate registers for these and save the debug
// info in corresponding symbols and use it from there. This will also affect the temp register allocation logic in
// EmitOneFunction.
uint innerScopeCount = funcInfo->InnerScopeCount();
byteCodeFunction->SetInnerScopeCount(innerScopeCount);
if (innerScopeCount)
Expand Down Expand Up @@ -3181,8 +3185,9 @@ void ByteCodeGenerator::EmitOneFunction(ParseNode *pnode)

// Reserve temp registers for the inner scopes. We prefer temps because the JIT will then renumber them
// and see different lifetimes. (Note that debug mode requires permanent registers. See FinalizeRegisters.)
// Need to revisit the condition when enabling JitES6Generators.
uint innerScopeCount = funcInfo->InnerScopeCount();
if (!this->IsInDebugMode())
if (!this->IsInDebugMode() && !byteCodeFunction->IsCoroutine())
{
byteCodeFunction->SetInnerScopeCount(innerScopeCount);
if (innerScopeCount)
Expand Down
22 changes: 22 additions & 0 deletions deps/chakrashim/core/test/DebuggerCommon/AsyncDynamicAttach.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

function attach(f) {
(function (r) {
WScript.Attach(r);
})(f);
}

async function mainTest(notAttachCall) {
if (notAttachCall) {
for (let i = 0; i < 1; ++i) {
await attach(mainTest);
}
} else {
var i = 10;/**bp:locals()**/
}
}
mainTest(true);
WScript.Echo("PASSED");
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"this": "Object {...}",
"arguments": "Object {...}",
"locals": {
"notAttachCall": "undefined undefined",
"i": "undefined undefined"
}
}
]
7 changes: 7 additions & 0 deletions deps/chakrashim/core/test/DebuggerCommon/rlexe.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1356,4 +1356,11 @@
<compile-flags>-debuglaunch -dbgbaseline:promisedisplay.js.dbg.baseline</compile-flags>
</default>
</test>
<test>
<default>
<files>AsyncDynamicAttach.js</files>
<compile-flags>-dbgbaseline:AsyncDynamicAttach.js.dbg.baseline</compile-flags>
<tags>exclude_dynapogo</tags>
</default>
</test>
</regress-exe>

0 comments on commit 5a30daf

Please sign in to comment.