Skip to content

Commit

Permalink
TTD fixes for Await Object
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuanjl committed Jan 6, 2021
1 parent 9c60dc4 commit 13caeb4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
22 changes: 20 additions & 2 deletions lib/Runtime/Debug/TTSnapObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace TTD
TTDAssert(!obj->IsExternal(), "We are not prepared for custom external objects yet");

sobj->ObjectPtrId = TTD_CONVERT_VAR_TO_PTR_ID(obj);
sobj->SnapObjectTag = obj->GetSnapTag_TTD();
sobj->SnapObjectTag = obj->GetTypeId() == Js::TypeId::TypeIds_AwaitObject ? SnapObjectType::SnapAwaitObject : obj->GetSnapTag_TTD();

TTD_WELLKNOWN_TOKEN lookupToken = isWellKnown ? obj->GetScriptContext()->TTDWellKnownInfo->ResolvePathForKnownObject(obj) : TTD_INVALID_WELLKNOWN_TOKEN;
sobj->OptWellKnownToken = alloc.CopyRawNullTerminatedStringInto(lookupToken);
Expand All @@ -39,7 +39,10 @@ namespace TTD
NSSnapObjects::StdPropertyExtract_DynamicType(sobj, static_cast<Js::DynamicObject*>(obj), alloc);
}

obj->ExtractSnapObjectDataInto(sobj, alloc);
if (sobj->SnapObjectTag != SnapObjectType::SnapAwaitObject)
{
obj->ExtractSnapObjectDataInto(sobj, alloc);
}
}

void StdPropertyExtract_StaticType(SnapObject* snpObject, Js::RecyclableObject* obj)
Expand Down Expand Up @@ -681,6 +684,21 @@ namespace TTD
}
#endif

Js::RecyclableObject* DoObjectInflation_SnapAwaitObject(const SnapObject* snpObject, InflateMap* inflator)
{
Js::DynamicObject* rcObj = ReuseObjectCheckAndReset(snpObject, inflator);
if(rcObj != nullptr)
{
return rcObj;
}
else
{
Js::ScriptContext* ctx = inflator->LookupScriptContext(snpObject->SnapType->ScriptContextLogId);

return Js::DynamicObject::New(ctx->GetRecycler(), ctx->GetLibrary()->GetAwaitObjectType());
}
}

Js::RecyclableObject* DoObjectInflation_SnapDynamicObject(const SnapObject* snpObject, InflateMap* inflator)
{
Js::DynamicObject* rcObj = ReuseObjectCheckAndReset(snpObject, inflator);
Expand Down
2 changes: 2 additions & 0 deletions lib/Runtime/Debug/TTSnapObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ namespace TTD
//ParseAddtlInfo is a nop
//AssertSnapEquiv is a nop

Js::RecyclableObject* DoObjectInflation_SnapAwaitObject(const SnapObject* snpObject, InflateMap* inflator);

//////////////////

//A struct that represents a script function object
Expand Down
1 change: 1 addition & 0 deletions lib/Runtime/Debug/TTSnapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ namespace TTD
//For the objects that have inflators

this->m_snapObjectVTableArray[(uint32)NSSnapObjects::SnapObjectType::SnapDynamicObject] = { &NSSnapObjects::DoObjectInflation_SnapDynamicObject, nullptr, nullptr, nullptr };
this->m_snapObjectVTableArray[(uint32)NSSnapObjects::SnapObjectType::SnapAwaitObject] = { &NSSnapObjects::DoObjectInflation_SnapAwaitObject, nullptr, nullptr, nullptr };
this->m_snapObjectVTableArray[(uint32)NSSnapObjects::SnapObjectType::SnapExternalObject] = { &NSSnapObjects::DoObjectInflation_SnapExternalObject, nullptr, nullptr, nullptr };

this->m_snapObjectVTableArray[(uint32)NSSnapObjects::SnapObjectType::SnapScriptFunctionObject] = { &NSSnapObjects::DoObjectInflation_SnapScriptFunctionInfo, &NSSnapObjects::DoAddtlValueInstantiation_SnapScriptFunctionInfo, &NSSnapObjects::EmitAddtlInfo_SnapScriptFunctionInfo, &NSSnapObjects::ParseAddtlInfo_SnapScriptFunctionInfo };
Expand Down
1 change: 1 addition & 0 deletions lib/Runtime/Debug/TTSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ namespace TTD
SnapGeneratorVirtualScriptFunction,
SnapAsyncFunction,
SnapGenerator,
SnapAwaitObject,
JavascriptAsyncSpawnExecutorFunction,
JavascriptAsyncSpawnStepFunction,

Expand Down

0 comments on commit 13caeb4

Please sign in to comment.