Skip to content

Commit 7318a88

Browse files
committed
[MERGE #4590 @kfarnung] Update TTD replay to match recent JsCreate*Function changes
Merge pull request #4590 from kfarnung:ttdfunction
2 parents 2abdaab + c8b3958 commit 7318a88

File tree

6 files changed

+18
-34
lines changed

6 files changed

+18
-34
lines changed

Diff for: lib/Jsrt/Jsrt.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2822,7 +2822,7 @@ template <bool wrapNativeFunction, class T>
28222822
JsErrorCode JsCreateEnhancedFunctionHelper(_In_ T nativeFunction, _In_opt_ JsValueRef metadata, _In_opt_ void *callbackState, _Out_ JsValueRef *function)
28232823
{
28242824
return ContextAPIWrapper<JSRT_MAYBE_TRUE>([&](Js::ScriptContext *scriptContext, TTDRecorder& _actionEntryPopper) -> JsErrorCode {
2825-
PERFORM_JSRT_TTD_RECORD_ACTION(scriptContext, RecordJsRTAllocateFunction, true, metadata);
2825+
PERFORM_JSRT_TTD_RECORD_ACTION(scriptContext, RecordJsRTAllocateFunction, metadata);
28262826
PARAM_NOT_NULL(nativeFunction);
28272827
PARAM_NOT_NULL(function);
28282828
*function = nullptr;

Diff for: lib/Runtime/Debug/TTActionEvents.cpp

+11-19
Original file line numberDiff line numberDiff line change
@@ -361,32 +361,24 @@ namespace TTD
361361
void AllocateFunctionAction_Execute(const EventLogEntry* evt, ThreadContextTTD* executeContext)
362362
{
363363
TTD_REPLAY_ACTIVE_CONTEXT(executeContext);
364-
const JsRTSingleVarScalarArgumentAction* action = GetInlineEventDataAs<JsRTSingleVarScalarArgumentAction, EventKind::AllocateFunctionActionTag>(evt);
364+
const JsRTSingleVarArgumentAction* action = GetInlineEventDataAs<JsRTSingleVarArgumentAction, EventKind::AllocateFunctionActionTag>(evt);
365365

366-
Js::Var res = nullptr;
367-
if(!GetScalarItem_0(action))
366+
Js::Var metadata = InflateVarInReplay(executeContext, GetVarItem_0(action));
367+
368+
Js::JavascriptString* name = nullptr;
369+
if(metadata != nullptr)
368370
{
369-
res = ctx->GetLibrary()->CreateStdCallExternalFunction(&Js::JavascriptExternalFunction::TTDReplayDummyExternalMethod, 0, nullptr);
371+
TTD_REPLAY_VALIDATE_INCOMING_REFERENCE(metadata, ctx);
372+
name = Js::JavascriptConversion::ToString(metadata, ctx);
370373
}
371374
else
372375
{
373-
Js::Var nameVar = InflateVarInReplay(executeContext, GetVarItem_0(action));
374-
TTD_REPLAY_VALIDATE_INCOMING_REFERENCE(nameVar, ctx);
375-
376-
Js::JavascriptString* name = nullptr;
377-
if(nameVar != nullptr)
378-
{
379-
name = Js::JavascriptConversion::ToString(nameVar, ctx);
380-
}
381-
else
382-
{
383-
name = ctx->GetLibrary()->GetEmptyString();
384-
}
385-
386-
res = ctx->GetLibrary()->CreateStdCallExternalFunction(&Js::JavascriptExternalFunction::TTDReplayDummyExternalMethod, name, nullptr);
376+
name = ctx->GetLibrary()->GetEmptyString();
387377
}
388378

389-
JsRTActionHandleResultForReplay<JsRTSingleVarScalarArgumentAction, EventKind::AllocateFunctionActionTag>(executeContext, evt, res);
379+
Js::Var res = ctx->GetLibrary()->CreateStdCallExternalFunction(&Js::JavascriptExternalFunction::TTDReplayDummyExternalMethod, name, nullptr);
380+
381+
JsRTActionHandleResultForReplay<JsRTSingleVarArgumentAction, EventKind::AllocateFunctionActionTag>(executeContext, evt, res);
390382
}
391383

392384
void HostProcessExitAction_Execute(const EventLogEntry* evt, ThreadContextTTD* executeContext)

Diff for: lib/Runtime/Debug/TTEventLog.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ namespace TTD
540540
TTD_CREATE_EVENTLIST_VTABLE_ENTRY_COMMON(AllocateArrayActionTag, ContextAPINoScriptWrapper, JsRTIntegralArgumentAction, AllocateArrayAction_Execute);
541541
TTD_CREATE_EVENTLIST_VTABLE_ENTRY_COMMON(AllocateArrayBufferActionTag, ContextAPIWrapper, JsRTIntegralArgumentAction, AllocateArrayBufferAction_Execute);
542542
TTD_CREATE_EVENTLIST_VTABLE_ENTRY(AllocateExternalArrayBufferActionTag, ContextAPINoScriptWrapper, JsRTByteBufferAction, NSLogEvents::AllocateExternalArrayBufferAction_Execute, NSLogEvents::JsRTByteBufferAction_UnloadEventMemory<NSLogEvents::EventKind::AllocateExternalArrayBufferActionTag>, NSLogEvents::JsRTByteBufferAction_Emit<NSLogEvents::EventKind::AllocateExternalArrayBufferActionTag>, NSLogEvents::JsRTByteBufferAction_Parse<NSLogEvents::EventKind::AllocateExternalArrayBufferActionTag>);
543-
TTD_CREATE_EVENTLIST_VTABLE_ENTRY_COMMON(AllocateFunctionActionTag, ContextAPIWrapper, JsRTSingleVarScalarArgumentAction, AllocateFunctionAction_Execute);
543+
TTD_CREATE_EVENTLIST_VTABLE_ENTRY_COMMON(AllocateFunctionActionTag, ContextAPIWrapper, JsRTSingleVarArgumentAction, AllocateFunctionAction_Execute);
544544

545545
TTD_CREATE_EVENTLIST_VTABLE_ENTRY_COMMON(HostExitProcessTag, ContextAPIWrapper, JsRTIntegralArgumentAction, HostProcessExitAction_Execute);
546546
TTD_CREATE_EVENTLIST_VTABLE_ENTRY_COMMON(GetAndClearExceptionWithMetadataActionTag, None, JsRTResultOnlyAction, GetAndClearExceptionWithMetadataAction_Execute);
@@ -2104,12 +2104,11 @@ namespace TTD
21042104
actionPopper.InitializeWithEventAndEnterWResult(evt, &(cAction->Result));
21052105
}
21062106

2107-
void EventLog::RecordJsRTAllocateFunction(TTDJsRTActionResultAutoRecorder& actionPopper, bool isNamed, Js::Var optName)
2107+
void EventLog::RecordJsRTAllocateFunction(TTDJsRTActionResultAutoRecorder& actionPopper, Js::Var optMetadata)
21082108
{
2109-
NSLogEvents::JsRTSingleVarScalarArgumentAction* cAction = nullptr;
2110-
NSLogEvents::EventLogEntry* evt = this->RecordGetInitializedEvent<NSLogEvents::JsRTSingleVarScalarArgumentAction, NSLogEvents::EventKind::AllocateFunctionActionTag>(&cAction);
2111-
NSLogEvents::SetVarItem_0(cAction, TTD_CONVERT_JSVAR_TO_TTDVAR(optName));
2112-
NSLogEvents::SetScalarItem_0(cAction, isNamed);
2109+
NSLogEvents::JsRTSingleVarArgumentAction* cAction = nullptr;
2110+
NSLogEvents::EventLogEntry* evt = this->RecordGetInitializedEvent<NSLogEvents::JsRTSingleVarArgumentAction, NSLogEvents::EventKind::AllocateFunctionActionTag>(&cAction);
2111+
NSLogEvents::SetVarItem_0(cAction, TTD_CONVERT_JSVAR_TO_TTDVAR(optMetadata));
21132112

21142113
actionPopper.InitializeWithEventAndEnterWResult(evt, &(cAction->Result));
21152114
}

Diff for: lib/Runtime/Debug/TTEventLog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ namespace TTD
547547
void RecordJsRTAllocateBasicArray(TTDJsRTActionResultAutoRecorder& actionPopper, uint32 length);
548548
void RecordJsRTAllocateArrayBuffer(TTDJsRTActionResultAutoRecorder& actionPopper, uint32 size);
549549
void RecordJsRTAllocateExternalArrayBuffer(TTDJsRTActionResultAutoRecorder& actionPopper, byte* buff, uint32 size);
550-
void RecordJsRTAllocateFunction(TTDJsRTActionResultAutoRecorder& actionPopper, bool isNamed, Js::Var optName);
550+
void RecordJsRTAllocateFunction(TTDJsRTActionResultAutoRecorder& actionPopper, Js::Var optMetadata);
551551

552552
//Record GetAndClearException
553553
void RecordJsRTHostExitProcess(TTDJsRTActionResultAutoRecorder& actionPopper, int32 exitCode);

Diff for: lib/Runtime/Library/JavascriptLibrary.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -6842,12 +6842,6 @@ namespace Js
68426842
return RecyclerNewEnumClass(this->GetRecycler(), EnumFunctionClass, JavascriptAsyncFunction, type, nullptr);
68436843
}
68446844

6845-
JavascriptExternalFunction* JavascriptLibrary::CreateStdCallExternalFunction(StdCallJavascriptMethod entryPoint, PropertyId nameId, void *callbackState)
6846-
{
6847-
Assert(nameId == 0 || scriptContext->IsTrackedPropertyId(nameId));
6848-
return CreateStdCallExternalFunction(entryPoint, TaggedInt::ToVarUnchecked(nameId), callbackState);
6849-
}
6850-
68516845
JavascriptExternalFunction* JavascriptLibrary::CreateStdCallExternalFunction(StdCallJavascriptMethod entryPoint, Var name, void *callbackState)
68526846
{
68536847
Var functionNameOrId = name;

Diff for: lib/Runtime/Library/JavascriptLibrary.h

-1
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,6 @@ namespace Js
10901090
JavascriptAsyncFunction* CreateAsyncFunction(JavascriptMethod entryPoint, bool isAnonymousFunction);
10911091
JavascriptExternalFunction* CreateExternalFunction(ExternalMethod entryPointer, PropertyId nameId, Var signature, UINT64 flags, bool isLengthAvailable = false);
10921092
JavascriptExternalFunction* CreateExternalFunction(ExternalMethod entryPointer, Var nameId, Var signature, UINT64 flags, bool isLengthAvailable = false);
1093-
JavascriptExternalFunction* CreateStdCallExternalFunction(StdCallJavascriptMethod entryPointer, PropertyId nameId, void *callbackState);
10941093
JavascriptExternalFunction* CreateStdCallExternalFunction(StdCallJavascriptMethod entryPointer, Var name, void *callbackState);
10951094
JavascriptPromiseAsyncSpawnExecutorFunction* CreatePromiseAsyncSpawnExecutorFunction(JavascriptGenerator* generator, Var target);
10961095
JavascriptPromiseAsyncSpawnStepArgumentExecutorFunction* CreatePromiseAsyncSpawnStepArgumentExecutorFunction(JavascriptMethod entryPoint, JavascriptGenerator* generator, Var argument, Var resolve = nullptr, Var reject = nullptr, bool isReject = false);

0 commit comments

Comments
 (0)