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@aef2cfad40
Browse files Browse the repository at this point in the history
[MERGE #4719 @kfarnung] TTD support for externals with a prototype

Merge pull request #4719 from kfarnung:externalttd

Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
  • Loading branch information
kfarnung authored and chakrabot committed Feb 22, 2018
1 parent fafec98 commit bedeb29
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 37 deletions.
2 changes: 1 addition & 1 deletion deps/chakrashim/core/lib/Jsrt/ChakraCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ CHAKRA_API
JsCreateExternalObjectWithPrototype(
_In_opt_ void *data,
_In_opt_ JsFinalizeCallback finalizeCallback,
_In_ JsValueRef prototype,
_In_opt_ JsValueRef prototype,
_Out_ JsValueRef *object);

/// <summary>
Expand Down
43 changes: 16 additions & 27 deletions deps/chakrashim/core/lib/Jsrt/Jsrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,17 @@ JsErrorCode CreateContextCore(_In_ JsRuntimeHandle runtimeHandle, _In_ TTDRecord
}

#if ENABLE_TTD
void CALLBACK CreateExternalObject_TTDCallback(Js::ScriptContext* ctx, Js::Var* object)
void CALLBACK CreateExternalObject_TTDCallback(Js::ScriptContext* ctx, Js::Var prototype, Js::Var* object)
{
TTDAssert(object != nullptr, "This should always be a valid location");

*object = JsrtExternalObject::Create(nullptr, nullptr, nullptr, ctx);
Js::RecyclableObject * prototypeObject = nullptr;
if (prototype != JS_INVALID_REFERENCE)
{
prototypeObject = Js::RecyclableObject::FromVar(prototype);
}

*object = JsrtExternalObject::Create(nullptr, nullptr, prototypeObject, ctx);
}

void CALLBACK TTDDummyPromiseContinuationCallback(JsValueRef task, void *callbackState)
Expand Down Expand Up @@ -1287,34 +1293,18 @@ CHAKRA_API JsCreateObject(_Out_ JsValueRef *object)
});
}

CHAKRA_API JsCreateExternalObject(_In_opt_ void *data, _In_opt_ JsFinalizeCallback finalizeCallback, _Out_ JsValueRef *object)
{
return ContextAPINoScriptWrapper([&](Js::ScriptContext *scriptContext, TTDRecorder& _actionEntryPopper) -> JsErrorCode {
PERFORM_JSRT_TTD_RECORD_ACTION(scriptContext, RecordJsRTAllocateExternalObject);

PARAM_NOT_NULL(object);

*object = JsrtExternalObject::Create(data, finalizeCallback, nullptr, scriptContext);

PERFORM_JSRT_TTD_RECORD_ACTION_RESULT(scriptContext, object);

return JsNoError;
});
}

#ifndef NTBUILD
CHAKRA_API JsCreateExternalObjectWithPrototype(_In_opt_ void *data,
_In_opt_ JsFinalizeCallback finalizeCallback,
_In_ JsValueRef prototype,
_In_opt_ JsValueRef prototype,
_Out_ JsValueRef *object)
{
return ContextAPINoScriptWrapper([&](Js::ScriptContext *scriptContext, TTDRecorder& _actionEntryPopper) -> JsErrorCode {
PERFORM_JSRT_TTD_RECORD_ACTION(scriptContext, RecordJsRTAllocateExternalObject);
PERFORM_JSRT_TTD_RECORD_ACTION(scriptContext, RecordJsRTAllocateExternalObject, prototype);

PARAM_NOT_NULL(object);

Js::RecyclableObject * prototypeObject = nullptr;
if (prototype != nullptr)
if (prototype != JS_INVALID_REFERENCE)
{
VALIDATE_INCOMING_OBJECT(prototype, scriptContext);
prototypeObject = Js::RecyclableObject::FromVar(prototype);
Expand All @@ -1324,15 +1314,14 @@ CHAKRA_API JsCreateExternalObjectWithPrototype(_In_opt_ void *data,

PERFORM_JSRT_TTD_RECORD_ACTION_RESULT(scriptContext, object);

if (prototypeObject != nullptr)
{
PERFORM_JSRT_TTD_RECORD_ACTION(scriptContext, RecordJsRTSetPrototype, *object, prototypeObject);
}

return JsNoError;
});
}
#endif

CHAKRA_API JsCreateExternalObject(_In_opt_ void *data, _In_opt_ JsFinalizeCallback finalizeCallback, _Out_ JsValueRef *object)
{
return JsCreateExternalObjectWithPrototype(data, finalizeCallback, JS_INVALID_REFERENCE, object);
}

CHAKRA_API JsConvertValueToObject(_In_ JsValueRef value, _Out_ JsValueRef *result)
{
Expand Down
6 changes: 4 additions & 2 deletions deps/chakrashim/core/lib/Runtime/Debug/TTActionEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,13 @@ namespace TTD
void AllocateExternalObject_Execute(const EventLogEntry* evt, ThreadContextTTD* executeContext)
{
TTD_REPLAY_ACTIVE_CONTEXT(executeContext);
const JsRTSingleVarArgumentAction* action = GetInlineEventDataAs<JsRTSingleVarArgumentAction, EventKind::AllocateExternalObjectActionTag>(evt);
Js::Var prototype = InflateVarInReplay(executeContext, GetVarItem_0(action));

Js::Var res = nullptr;
executeContext->TTDExternalObjectFunctions.pfCreateExternalObject(ctx, &res);
executeContext->TTDExternalObjectFunctions.pfCreateExternalObject(ctx, prototype, &res);

JsRTActionHandleResultForReplay<JsRTResultOnlyAction, EventKind::AllocateExternalObjectActionTag>(executeContext, evt, res);
JsRTActionHandleResultForReplay<JsRTSingleVarArgumentAction, EventKind::AllocateExternalObjectActionTag>(executeContext, evt, res);
}

void AllocateArrayAction_Execute(const EventLogEntry* evt, ThreadContextTTD* executeContext)
Expand Down
9 changes: 5 additions & 4 deletions deps/chakrashim/core/lib/Runtime/Debug/TTEventLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ namespace TTD
TTD_CREATE_EVENTLIST_VTABLE_ENTRY_COMMON(AddWeakRootRefActionTag, GlobalAPIWrapper, JsRTSingleVarArgumentAction, AddWeakRootRef_Execute);

TTD_CREATE_EVENTLIST_VTABLE_ENTRY_COMMON(AllocateObjectActionTag, ContextAPINoScriptWrapper, JsRTResultOnlyAction, AllocateObject_Execute);
TTD_CREATE_EVENTLIST_VTABLE_ENTRY_COMMON(AllocateExternalObjectActionTag, ContextAPINoScriptWrapper, JsRTResultOnlyAction, AllocateExternalObject_Execute);
TTD_CREATE_EVENTLIST_VTABLE_ENTRY_COMMON(AllocateExternalObjectActionTag, ContextAPINoScriptWrapper, JsRTSingleVarArgumentAction, AllocateExternalObject_Execute);
TTD_CREATE_EVENTLIST_VTABLE_ENTRY_COMMON(AllocateArrayActionTag, ContextAPINoScriptWrapper, JsRTIntegralArgumentAction, AllocateArrayAction_Execute);
TTD_CREATE_EVENTLIST_VTABLE_ENTRY_COMMON(AllocateArrayBufferActionTag, ContextAPIWrapper, JsRTIntegralArgumentAction, AllocateArrayBufferAction_Execute);
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>);
Expand Down Expand Up @@ -2085,10 +2085,11 @@ namespace TTD
actionPopper.InitializeWithEventAndEnterWResult(evt, &(cAction->Result));
}

void EventLog::RecordJsRTAllocateExternalObject(TTDJsRTActionResultAutoRecorder& actionPopper)
void EventLog::RecordJsRTAllocateExternalObject(TTDJsRTActionResultAutoRecorder& actionPopper, Js::Var prototype)
{
NSLogEvents::JsRTResultOnlyAction* cAction = nullptr;
NSLogEvents::EventLogEntry* evt = this->RecordGetInitializedEvent<NSLogEvents::JsRTResultOnlyAction, NSLogEvents::EventKind::AllocateExternalObjectActionTag>(&cAction);
NSLogEvents::JsRTSingleVarArgumentAction* cAction = nullptr;
NSLogEvents::EventLogEntry* evt = this->RecordGetInitializedEvent<NSLogEvents::JsRTSingleVarArgumentAction, NSLogEvents::EventKind::AllocateExternalObjectActionTag>(&cAction);
NSLogEvents::SetVarItem_0(cAction, TTD_CONVERT_JSVAR_TO_TTDVAR(prototype));

actionPopper.InitializeWithEventAndEnterWResult(evt, &(cAction->Result));
}
Expand Down
2 changes: 1 addition & 1 deletion deps/chakrashim/core/lib/Runtime/Debug/TTEventLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ namespace TTD

//Record object allocate operations
void RecordJsRTAllocateBasicObject(TTDJsRTActionResultAutoRecorder& actionPopper);
void RecordJsRTAllocateExternalObject(TTDJsRTActionResultAutoRecorder& actionPopper);
void RecordJsRTAllocateExternalObject(TTDJsRTActionResultAutoRecorder& actionPopper, Js::Var prototype);
void RecordJsRTAllocateBasicArray(TTDJsRTActionResultAutoRecorder& actionPopper, uint32 length);
void RecordJsRTAllocateArrayBuffer(TTDJsRTActionResultAutoRecorder& actionPopper, uint32 size);
void RecordJsRTAllocateExternalArrayBuffer(TTDJsRTActionResultAutoRecorder& actionPopper, byte* buff, uint32 size);
Expand Down
2 changes: 1 addition & 1 deletion deps/chakrashim/core/lib/Runtime/Debug/TTSnapObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ namespace TTD
{
Js::ScriptContext* ctx = inflator->LookupScriptContext(snpObject->SnapType->ScriptContextLogId);
Js::Var res = nullptr;
ctx->GetThreadContext()->TTDContext->TTDExternalObjectFunctions.pfCreateExternalObject(ctx, &res);
ctx->GetThreadContext()->TTDContext->TTDExternalObjectFunctions.pfCreateExternalObject(ctx, nullptr, &res);

return Js::RecyclableObject::FromVar(res);
}
Expand Down
2 changes: 1 addition & 1 deletion deps/chakrashim/core/lib/Runtime/Debug/TTSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ namespace TTD
};

//Function pointer definitions for creating/interacting with external objects
typedef void(CALLBACK *TTDCreateExternalObjectCallback)(Js::ScriptContext* ctx, Js::Var* object);
typedef void(CALLBACK *TTDCreateExternalObjectCallback)(Js::ScriptContext* ctx, Js::Var prototype, Js::Var* object);

typedef void(CALLBACK *TTDCreateJsRTContextCallback)(void* runtimeHandle, Js::ScriptContext** ctx); //Create and pin the context so it does not get GC'd
typedef void(CALLBACK *TTDReleaseJsRTContextCallback)(FinalizableObject* jsrtCtx); //Release an un-needed context during replay
Expand Down

0 comments on commit bedeb29

Please sign in to comment.