From df36ec4a33fffb13177c05e005cb5f48f892bc1f Mon Sep 17 00:00:00 2001 From: Jimmy Thomson Date: Fri, 9 Feb 2018 03:08:46 -0800 Subject: [PATCH] deps: update ChakraCore to Microsoft/ChakraCore@f1a6b1015c [MERGE #4659 @MSLaguana] Fixes for NPM test breaks. Merge pull request #4659 from MSLaguana:fixTTD Some node-chakracore tests were throwing asserts when run with TTD. Reviewed-By: chakrabot --- .../core/lib/Runtime/Debug/TTEventLog.cpp | 24 +++++++++--- .../core/lib/Runtime/Debug/TTEventLog.h | 4 +- .../core/lib/Runtime/Debug/TTEvents.cpp | 15 +++++-- .../core/lib/Runtime/Debug/TTEvents.h | 5 ++- .../lib/Runtime/Debug/TTExecutionInfo.cpp | 39 ++++++++++--------- .../Library/JavascriptExternalFunction.cpp | 8 ++-- 6 files changed, 61 insertions(+), 34 deletions(-) diff --git a/deps/chakrashim/core/lib/Runtime/Debug/TTEventLog.cpp b/deps/chakrashim/core/lib/Runtime/Debug/TTEventLog.cpp index 7c0598ac26c..e02bc4060e4 100644 --- a/deps/chakrashim/core/lib/Runtime/Debug/TTEventLog.cpp +++ b/deps/chakrashim/core/lib/Runtime/Debug/TTEventLog.cpp @@ -1007,7 +1007,7 @@ namespace TTD return wcEvent->ContainsValue; } - NSLogEvents::EventLogEntry* EventLog::RecordExternalCallEvent(Js::JavascriptFunction* func, int32 rootDepth, uint32 argc, Js::Var* argv, bool checkExceptions) + NSLogEvents::EventLogEntry* EventLog::RecordExternalCallEvent(Js::JavascriptFunction* func, int32 rootDepth, const Js::Arguments& args, bool checkExceptions) { NSLogEvents::ExternalCallEventLogEntry* ecEvent = nullptr; NSLogEvents::EventLogEntry* evt = this->RecordGetInitializedEvent(&ecEvent); @@ -1015,7 +1015,7 @@ namespace TTD //We never fail with an exception (instead we set the HasRecordedException in script context) evt->ResultStatus = 0; - NSLogEvents::ExternalCallEventLogEntry_ProcessArgs(evt, rootDepth, func, argc, argv, checkExceptions, this->m_eventSlabAllocator); + NSLogEvents::ExternalCallEventLogEntry_ProcessArgs(evt, rootDepth, func, args, checkExceptions, this->m_eventSlabAllocator); #if ENABLE_TTD_INTERNAL_DIAGNOSTICS NSLogEvents::ExternalCallEventLogEntry_ProcessDiagInfoPre(evt, func, this->m_eventSlabAllocator); @@ -1037,7 +1037,7 @@ namespace TTD #endif } - void EventLog::ReplayExternalCallEvent(Js::JavascriptFunction* function, uint32 argc, Js::Var* argv, Js::Var* result) + void EventLog::ReplayExternalCallEvent(Js::JavascriptFunction* function, const Js::Arguments& args, Js::Var* result) { TTDAssert(result != nullptr, "Must be non-null!!!"); TTDAssert(*result == nullptr, "And initialized to a default value."); @@ -1054,18 +1054,30 @@ namespace TTD #endif //make sure we log all of the passed arguments in the replay host - TTDAssert(argc + 1 == ecEvent->ArgCount, "Mismatch in args!!!"); + TTDAssert(args.Info.Count + 1 == ecEvent->ArgCount, "Mismatch in args!!!"); TTDVar recordedFunction = ecEvent->ArgArray[0]; NSLogEvents::PassVarToHostInReplay(executeContext, recordedFunction, function); - for(uint32 i = 0; i < argc; ++i) + for(uint32 i = 0; i < args.Info.Count; ++i) { - Js::Var replayVar = argv[i]; + Js::Var replayVar = args.Values[i]; TTDVar recordedVar = ecEvent->ArgArray[i + 1]; NSLogEvents::PassVarToHostInReplay(executeContext, recordedVar, replayVar); } + if (args.HasNewTarget()) + { + TTDAssert(ecEvent->NewTarget != nullptr, "Mismatch in new.target!!!"); + Js::Var replayVar = args.GetNewTarget(); + TTDVar recordedVar = ecEvent->NewTarget; + NSLogEvents::PassVarToHostInReplay(executeContext, recordedVar, replayVar); + } + else + { + TTDAssert(ecEvent->NewTarget == nullptr, "Mismatch in new.target!!!"); + } + //replay anything that happens in the external call BEGIN_LEAVE_SCRIPT(ctx) { diff --git a/deps/chakrashim/core/lib/Runtime/Debug/TTEventLog.h b/deps/chakrashim/core/lib/Runtime/Debug/TTEventLog.h index 60385031fae..ff254b4672a 100644 --- a/deps/chakrashim/core/lib/Runtime/Debug/TTEventLog.h +++ b/deps/chakrashim/core/lib/Runtime/Debug/TTEventLog.h @@ -430,11 +430,11 @@ namespace TTD bool ReplayWeakCollectionContainsEvent(); //Log a value event for return from an external call - NSLogEvents::EventLogEntry* RecordExternalCallEvent(Js::JavascriptFunction* func, int32 rootDepth, uint32 argc, Js::Var* argv, bool checkExceptions); + NSLogEvents::EventLogEntry* RecordExternalCallEvent(Js::JavascriptFunction* func, int32 rootDepth, const Js::Arguments& args, bool checkExceptions); void RecordExternalCallEvent_Complete(Js::JavascriptFunction* efunction, NSLogEvents::EventLogEntry* evt, Js::Var result); //replay an external return event (which should be the current event) - void ReplayExternalCallEvent(Js::JavascriptFunction* function, uint32 argc, Js::Var* argv, Js::Var* result); + void ReplayExternalCallEvent(Js::JavascriptFunction* function, const Js::Arguments& args, Js::Var* result); NSLogEvents::EventLogEntry* RecordEnqueueTaskEvent(Js::Var taskVar); void RecordEnqueueTaskEvent_Complete(NSLogEvents::EventLogEntry* evt); diff --git a/deps/chakrashim/core/lib/Runtime/Debug/TTEvents.cpp b/deps/chakrashim/core/lib/Runtime/Debug/TTEvents.cpp index 0d559f0bc25..56e2e458b12 100644 --- a/deps/chakrashim/core/lib/Runtime/Debug/TTEvents.cpp +++ b/deps/chakrashim/core/lib/Runtime/Debug/TTEvents.cpp @@ -444,18 +444,27 @@ namespace TTD return callEvt->LastNestedEventTime; } - void ExternalCallEventLogEntry_ProcessArgs(EventLogEntry* evt, int32 rootDepth, Js::JavascriptFunction* function, uint32 argc, Js::Var* argv, bool checkExceptions, UnlinkableSlabAllocator& alloc) + void ExternalCallEventLogEntry_ProcessArgs(EventLogEntry* evt, int32 rootDepth, Js::JavascriptFunction* function, const Js::Arguments& args, bool checkExceptions, UnlinkableSlabAllocator& alloc) { ExternalCallEventLogEntry* callEvt = GetInlineEventDataAs(evt); callEvt->RootNestingDepth = rootDepth; - callEvt->ArgCount = argc + 1; + callEvt->ArgCount = args.Info.Count + 1; static_assert(sizeof(TTDVar) == sizeof(Js::Var), "These need to be the same size (and have same bit layout) for this to work!"); callEvt->ArgArray = alloc.SlabAllocateArray(callEvt->ArgCount); callEvt->ArgArray[0] = static_cast(function); - js_memcpy_s(callEvt->ArgArray + 1, (callEvt->ArgCount - 1) * sizeof(TTDVar), argv, argc * sizeof(Js::Var)); + js_memcpy_s(callEvt->ArgArray + 1, args.Info.Count * sizeof(TTDVar), args.Values, args.Info.Count * sizeof(Js::Var)); + + if (args.HasNewTarget()) + { + callEvt->NewTarget = static_cast(args.GetNewTarget()); + } + else + { + callEvt->NewTarget = nullptr; + } callEvt->ReturnValue = nullptr; callEvt->LastNestedEventTime = TTD_EVENT_MAXTIME; diff --git a/deps/chakrashim/core/lib/Runtime/Debug/TTEvents.h b/deps/chakrashim/core/lib/Runtime/Debug/TTEvents.h index ace613b7a6a..dfed9e8c34b 100644 --- a/deps/chakrashim/core/lib/Runtime/Debug/TTEvents.h +++ b/deps/chakrashim/core/lib/Runtime/Debug/TTEvents.h @@ -437,6 +437,9 @@ namespace TTD uint32 ArgCount; TTDVar* ArgArray; + //the value of new.target if present + TTDVar NewTarget; + //The return value of the external call TTDVar ReturnValue; @@ -458,7 +461,7 @@ namespace TTD int64 ExternalCallEventLogEntry_GetLastNestedEventTime(const EventLogEntry* evt); - void ExternalCallEventLogEntry_ProcessArgs(EventLogEntry* evt, int32 rootDepth, Js::JavascriptFunction* function, uint32 argc, Js::Var* argv, bool checkExceptions, UnlinkableSlabAllocator& alloc); + void ExternalCallEventLogEntry_ProcessArgs(EventLogEntry* evt, int32 rootDepth, Js::JavascriptFunction* function, const Js::Arguments& args, bool checkExceptions, UnlinkableSlabAllocator& alloc); void ExternalCallEventLogEntry_ProcessReturn(EventLogEntry* evt, Js::Var res, int64 lastNestedEvent); void ExternalCallEventLogEntry_UnloadEventMemory(EventLogEntry* evt, UnlinkableSlabAllocator& alloc); diff --git a/deps/chakrashim/core/lib/Runtime/Debug/TTExecutionInfo.cpp b/deps/chakrashim/core/lib/Runtime/Debug/TTExecutionInfo.cpp index 8be9da5a8dc..6ad45fc7c69 100644 --- a/deps/chakrashim/core/lib/Runtime/Debug/TTExecutionInfo.cpp +++ b/deps/chakrashim/core/lib/Runtime/Debug/TTExecutionInfo.cpp @@ -887,32 +887,35 @@ namespace TTD else { Js::FunctionBody* fb = cfinfo.Function; + TTDAssert(fb->GetUtf8SourceInfo() != nullptr, "Should always have a source info."); - int32 cIndex = fb->GetEnclosingStatementIndexFromByteCode(bytecodeOffset, true); - TTDAssert(cIndex != -1, "Should always have a mapping."); - - //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) + if (!fb->GetUtf8SourceInfo()->GetIsLibraryCode()) { - cfinfo.LastStatementIndex = cfinfo.CurrentStatementIndex; - cfinfo.LastStatementLoopTime = cfinfo.CurrentStatementLoopTime; + int32 cIndex = fb->GetEnclosingStatementIndexFromByteCode(bytecodeOffset, true); + + //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) + { + cfinfo.LastStatementIndex = cfinfo.CurrentStatementIndex; + cfinfo.LastStatementLoopTime = cfinfo.CurrentStatementLoopTime; - cfinfo.CurrentStatementIndex = cIndex; - cfinfo.CurrentStatementLoopTime = cfinfo.LoopTime; + cfinfo.CurrentStatementIndex = cIndex; + cfinfo.CurrentStatementLoopTime = cfinfo.LoopTime; - cfinfo.CurrentStatementBytecodeMin = (uint32)pstmt->byteCodeSpan.begin; - cfinfo.CurrentStatementBytecodeMax = (uint32)pstmt->byteCodeSpan.end; + cfinfo.CurrentStatementBytecodeMin = (uint32)pstmt->byteCodeSpan.begin; + cfinfo.CurrentStatementBytecodeMax = (uint32)pstmt->byteCodeSpan.end; #if ENABLE_FULL_BC_TRACE - ULONG srcLine = 0; - LONG srcColumn = -1; - uint32 startOffset = cfinfo.Function->GetFunctionBody()->GetStatementStartOffset(cfinfo.CurrentStatementIndex); - cfinfo.Function->GetFunctionBody()->GetSourceLineFromStartOffset_TTD(startOffset, &srcLine, &srcColumn); + ULONG srcLine = 0; + LONG srcColumn = -1; + uint32 startOffset = cfinfo.Function->GetFunctionBody()->GetStatementStartOffset(cfinfo.CurrentStatementIndex); + cfinfo.Function->GetFunctionBody()->GetSourceLineFromStartOffset_TTD(startOffset, &srcLine, &srcColumn); - this->m_diagnosticLogger.WriteStmtIndex((uint32)srcLine, (uint32)srcColumn); + this->m_diagnosticLogger.WriteStmtIndex((uint32)srcLine, (uint32)srcColumn); #endif + } } } } diff --git a/deps/chakrashim/core/lib/Runtime/Library/JavascriptExternalFunction.cpp b/deps/chakrashim/core/lib/Runtime/Library/JavascriptExternalFunction.cpp index b1f711a3a24..f4b6adbf0cc 100644 --- a/deps/chakrashim/core/lib/Runtime/Library/JavascriptExternalFunction.cpp +++ b/deps/chakrashim/core/lib/Runtime/Library/JavascriptExternalFunction.cpp @@ -386,7 +386,7 @@ namespace Js if(scriptContext->ShouldPerformReplayAction()) { TTD::TTDNestingDepthAutoAdjuster logPopper(scriptContext->GetThreadContext()); - scriptContext->GetThreadContext()->TTDLog->ReplayExternalCallEvent(externalFunction, args.Info.Count, args.Values, &result); + scriptContext->GetThreadContext()->TTDLog->ReplayExternalCallEvent(externalFunction, args, &result); } else { @@ -395,7 +395,7 @@ namespace Js TTD::EventLog* elog = scriptContext->GetThreadContext()->TTDLog; TTD::TTDNestingDepthAutoAdjuster logPopper(scriptContext->GetThreadContext()); - TTD::NSLogEvents::EventLogEntry* callEvent = elog->RecordExternalCallEvent(externalFunction, scriptContext->GetThreadContext()->TTDRootNestingCount, args.Info.Count, args.Values, false); + TTD::NSLogEvents::EventLogEntry* callEvent = elog->RecordExternalCallEvent(externalFunction, scriptContext->GetThreadContext()->TTDRootNestingCount, args, false); BEGIN_LEAVE_SCRIPT_WITH_EXCEPTION(scriptContext) { @@ -420,7 +420,7 @@ namespace Js if(scriptContext->ShouldPerformReplayAction()) { TTD::TTDNestingDepthAutoAdjuster logPopper(scriptContext->GetThreadContext()); - scriptContext->GetThreadContext()->TTDLog->ReplayExternalCallEvent(externalFunction, args.Info.Count, args.Values, &result); + scriptContext->GetThreadContext()->TTDLog->ReplayExternalCallEvent(externalFunction, args, &result); } else { @@ -429,7 +429,7 @@ namespace Js TTD::EventLog* elog = scriptContext->GetThreadContext()->TTDLog; TTD::TTDNestingDepthAutoAdjuster logPopper(scriptContext->GetThreadContext()); - TTD::NSLogEvents::EventLogEntry* callEvent = elog->RecordExternalCallEvent(externalFunction, scriptContext->GetThreadContext()->TTDRootNestingCount, args.Info.Count, args.Values, true); + TTD::NSLogEvents::EventLogEntry* callEvent = elog->RecordExternalCallEvent(externalFunction, scriptContext->GetThreadContext()->TTDRootNestingCount, args, true); StdCallJavascriptMethodInfo info = { args[0],