Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for NPM test breaks. #4659

Merged
merged 1 commit into from
Feb 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions lib/Runtime/Debug/TTEventLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,15 +1007,15 @@ 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<NSLogEvents::ExternalCallEventLogEntry, NSLogEvents::EventKind::ExternalCallTag>(&ecEvent);

//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);
Expand All @@ -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.");
Expand All @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Runtime/Debug/TTEventLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 12 additions & 3 deletions lib/Runtime/Debug/TTEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExternalCallEventLogEntry, EventKind::ExternalCallTag>(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<TTDVar>(callEvt->ArgCount);
callEvt->ArgArray[0] = static_cast<TTDVar>(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<TTDVar>(args.GetNewTarget());
}
else
{
callEvt->NewTarget = nullptr;
}

callEvt->ReturnValue = nullptr;
callEvt->LastNestedEventTime = TTD_EVENT_MAXTIME;
Expand Down
5 changes: 4 additions & 1 deletion lib/Runtime/Debug/TTEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
39 changes: 21 additions & 18 deletions lib/Runtime/Debug/TTExecutionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Runtime/Library/JavascriptExternalFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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)
{
Expand All @@ -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
{
Expand All @@ -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],
Expand Down