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

Commit

Permalink
deps: update ChakraCore to chakra-core/ChakraCore@f58e17fd23
Browse files Browse the repository at this point in the history
[MERGE #4796 @mrkmarron] Fixes for step-back with async

Merge pull request #4796 from mrkmarron:asyncfixes19

Add missing snapshot visit location.
Fix previous line logic for inline awaits.

Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
  • Loading branch information
mrkmarron authored and chakrabot committed Mar 13, 2018
1 parent 2b4f308 commit f2d4209
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 15 deletions.
2 changes: 1 addition & 1 deletion deps/chakrashim/core/lib/Jsrt/Jsrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4606,7 +4606,7 @@ CHAKRA_API JsTTDReplayExecution(_Inout_ JsTTDMoveMode* moveMode, _Out_ int64_t*
*moveMode = (JsTTDMoveMode)abortException.GetMoveMode();
*rootEventTime = abortException.GetTargetEventTime();

//Check if we are tracking execution and, if so, set the exception locaiton so we can access it later
//Check if we are tracking execution and, if so, set the exception location so we can access it later
if(emanager != nullptr && abortException.IsTopLevelException())
{
emanager->SetPendingTTDUnhandledException();
Expand Down
30 changes: 17 additions & 13 deletions deps/chakrashim/core/lib/Runtime/Debug/TTExecutionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ namespace TTD
this->m_lastReturnLocation.SetExceptionLocation(this->m_callStack.Last());
}

if(!m_lastExceptionPropagating)
if(!this->m_lastExceptionPropagating)
{
this->m_lastExceptionLocation.SetLocationFromFrame(this->m_topLevelCallbackEventTime, this->m_callStack.Last());
this->m_lastExceptionPropagating = true;
Expand Down Expand Up @@ -893,10 +893,15 @@ namespace TTD
{
int32 cIndex = fb->GetEnclosingStatementIndexFromByteCode(bytecodeOffset, true);

//we moved to a new statement
//We moved to a new statement
Js::FunctionBody::StatementMap* pstmt = fb->GetStatementMaps()->Item(cIndex);
bool newstmt = (cIndex != cfinfo.CurrentStatementIndex && pstmt->byteCodeSpan.begin <= (int)bytecodeOffset && (int)bytecodeOffset <= pstmt->byteCodeSpan.end);
if (newstmt)

//Make sure async step back is ok -- We always step back to the first location in a statement and in most cases a function body must start at the first location in a statement.
//However an await can be in the middle of a statment/expression and is implicitly the start of a function body. So, we must check for that case.
bool functionBodyStartUnalignedWithStatementCase = (cfinfo.CurrentStatementIndex == -1) && (pstmt->byteCodeSpan.begin != (int)bytecodeOffset);

if (newstmt && !functionBodyStartUnalignedWithStatementCase)
{
cfinfo.LastStatementIndex = cfinfo.CurrentStatementIndex;
cfinfo.LastStatementLoopTime = cfinfo.CurrentStatementLoopTime;
Expand Down Expand Up @@ -997,9 +1002,15 @@ namespace TTD
{
SingleCallCounter cfinfoCaller = { 0 };
bool hasCaller = this->TryGetTopCallCallerCounter(cfinfoCaller);
if (hasCaller)
{
ftime = cfinfoCaller.FunctionTime;
ltime = cfinfoCaller.CurrentStatementLoopTime;

//check if we are at the first statement in the callback event
if(!hasCaller)
fbody = cfinfoCaller.Function;
statementIndex = cfinfoCaller.CurrentStatementIndex;
}
else
{
//Set the position info to the current statement and return true
noPrevious = true;
Expand All @@ -1010,14 +1021,6 @@ namespace TTD
fbody = cfinfo.Function;
statementIndex = cfinfo.CurrentStatementIndex;
}
else
{
ftime = cfinfoCaller.FunctionTime;
ltime = cfinfoCaller.CurrentStatementLoopTime;

fbody = cfinfoCaller.Function;
statementIndex = cfinfoCaller.CurrentStatementIndex;
}
}
else
{
Expand All @@ -1041,6 +1044,7 @@ namespace TTD
void ExecutionInfoManager::GetLastExecutedTimeAndPositionForDebugger(TTDebuggerSourceLocation& sourceLocation) const
{
const TTLastReturnLocationInfo& cframe = this->m_lastReturnLocation;

if(!cframe.IsDefined())
{
sourceLocation.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,13 @@ namespace Js
}
}

void GeneratorVirtualScriptFunction::MarkVisitKindSpecificPtrs(TTD::SnapshotExtractor* extractor)
{
this->ScriptFunction::MarkVisitKindSpecificPtrs(extractor);

extractor->MarkVisitVar(this->realFunction);
}

TTD::NSSnapObjects::SnapObjectType GeneratorVirtualScriptFunction::GetSnapTag_TTD() const
{
return TTD::NSSnapObjects::SnapObjectType::SnapGeneratorVirtualScriptFunction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ namespace Js
void SetRealGeneratorFunction(JavascriptGeneratorFunction* realFunction) { this->realFunction = realFunction; }

#if ENABLE_TTD
virtual void MarkVisitKindSpecificPtrs(TTD::SnapshotExtractor* extractor) override;
virtual TTD::NSSnapObjects::SnapObjectType GetSnapTag_TTD() const override;
virtual void ExtractSnapObjectDataInto(TTD::NSSnapObjects::SnapObject* objData, TTD::SlabAllocator& alloc) override;
#endif
Expand Down
23 changes: 23 additions & 0 deletions deps/chakrashim/core/test/TTBasic/asyncAwait2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

function resolveWait(x) {
return new Promise(resolve => {
WScript.SetTimeout(() => {
resolve(x);
}, 100);
});
}

async function awaitImm(x) {
const a = await resolveWait(1);
const b = await resolveWait(2);
return x + a + b;
}

awaitImm(1).then(v => {
telemetryLog(v.toString(), true);
emitTTDLog(ttdLogURI);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
4

Reached end of Execution -- Exiting.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
4

Reached end of Execution -- Exiting.
25 changes: 25 additions & 0 deletions deps/chakrashim/core/test/TTBasic/asyncAwait3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

function resolveWait(x) {
return new Promise(resolve => {
WScript.SetTimeout(() => {
resolve(x);
}, 100);
});
}

async function awaitLater(x) {
const p_a = resolveWait(10);
const p_b = resolveWait(20);
return x + await p_a + await p_b;
}

WScript.SetTimeout(function () {
awaitLater(10).then(v => {
telemetryLog(v.toString(), true);
emitTTDLog(ttdLogURI);
});
}, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
40
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
40

Reached end of Execution -- Exiting.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
40

Reached end of Execution -- Exiting.
50 changes: 49 additions & 1 deletion deps/chakrashim/core/test/TTBasic/rlexe.xml
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@
<tags>exclude_dynapogo,exclude_jshost,exclude_snap,exclude_serialized</tags>
</default>
</test>
<test>
<test>
<default>
<files>asyncAwaitBasic.js</files>
<compile-flags>-TTRecord=asyncAwaitBasicTest -TTSnapInterval=0</compile-flags>
Expand Down Expand Up @@ -1024,4 +1024,52 @@
<tags>exclude_dynapogo,exclude_jshost,exclude_snap,exclude_serialized</tags>
</default>
</test>
<test>
<default>
<files>asyncAwait2.js</files>
<compile-flags>-TTRecord=asyncAwait2Test -TTSnapInterval=0</compile-flags>
<baseline>asyncAwait2Record.baseline</baseline>
<tags>exclude_dynapogo,exclude_jshost,exclude_snap,exclude_serialized</tags>
</default>
</test>
<test>
<default>
<files>ttdSentinal.js</files>
<compile-flags>-TTReplay=asyncAwait2Test -TTDStartEvent=1</compile-flags>
<baseline>asyncAwait2Replay_1.baseline</baseline>
<tags>exclude_dynapogo,exclude_jshost,exclude_snap,exclude_serialized</tags>
</default>
</test>
<test>
<default>
<files>ttdSentinal.js</files>
<compile-flags>-TTReplay=asyncAwait2Test -TTDStartEvent=5</compile-flags>
<baseline>asyncAwait2Replay_2.baseline</baseline>
<tags>exclude_dynapogo,exclude_jshost,exclude_snap,exclude_serialized</tags>
</default>
</test>
<test>
<default>
<files>asyncAwait3.js</files>
<compile-flags>-TTRecord=asyncAwait3Test -TTSnapInterval=0</compile-flags>
<baseline>asyncAwait3Record.baseline</baseline>
<tags>exclude_dynapogo,exclude_jshost,exclude_snap,exclude_serialized</tags>
</default>
</test>
<test>
<default>
<files>ttdSentinal.js</files>
<compile-flags>-TTReplay=asyncAwait3Test -TTDStartEvent=1</compile-flags>
<baseline>asyncAwait3Replay_1.baseline</baseline>
<tags>exclude_dynapogo,exclude_jshost,exclude_snap,exclude_serialized</tags>
</default>
</test>
<test>
<default>
<files>ttdSentinal.js</files>
<compile-flags>-TTReplay=asyncAwait3Test -TTDStartEvent=5</compile-flags>
<baseline>asyncAwait3Replay_2.baseline</baseline>
<tags>exclude_dynapogo,exclude_jshost,exclude_snap,exclude_serialized</tags>
</default>
</test>
</regress-exe>

0 comments on commit f2d4209

Please sign in to comment.