void CrossSite::MarshalDynamicObject(ScriptContext * scriptContext, DynamicObject * object) { Assert(!object->IsExternal() && !object->IsCrossSiteObject()); TTD_XSITE_LOG(scriptContext, "MarshalDynamicObject", object); object->MarshalToScriptContext(scriptContext); if (object->GetTypeId() == TypeIds_Function) { AssertMsg(object != object->GetScriptContext()->GetLibrary()->GetDefaultAccessorFunction(), "default accessor marshalled"); JavascriptFunction * function = JavascriptFunction::FromVar(object); //TODO: this may be too aggressive and create x-site thunks that are't technically needed -- see uglify-2js test. // See if this function is one that the host needs to handle HostScriptContext * hostScriptContext = scriptContext->GetHostScriptContext(); if (!hostScriptContext || !hostScriptContext->SetCrossSiteForFunctionType(function)) { if (function->GetDynamicType()->GetIsLocked()) { TTD_XSITE_LOG(scriptContext, "SetCrossSiteForLockedFunctionType ", object); function->GetLibrary()->SetCrossSiteForLockedFunctionType(function); } else { TTD_XSITE_LOG(scriptContext, "setEntryPoint->CurrentCrossSiteThunk ", object); function->SetEntryPoint(function->GetScriptContext()->CurrentCrossSiteThunk); } } } else if (object->GetTypeId() == TypeIds_Proxy) { RecyclableObject * target = JavascriptProxy::FromVar(object)->GetTarget(); if (JavascriptConversion::IsCallable(target)) { Assert(JavascriptProxy::FunctionCallTrap == object->GetEntryPoint()); TTD_XSITE_LOG(scriptContext, "setEntryPoint->CrossSiteProxyCallTrap ", object); object->GetDynamicType()->SetEntryPoint(CrossSite::CrossSiteProxyCallTrap); } } }
void CrossSite::MarshalCrossSite_TTDInflate(DynamicObject* obj) { obj->MarshalCrossSite_TTDInflate(); if(obj->GetTypeId() == TypeIds_Function) { AssertMsg(obj != obj->GetScriptContext()->GetLibrary()->GetDefaultAccessorFunction(), "default accessor marshalled -- I don't think this should ever happen as it is marshalled in a special case?"); JavascriptFunction * function = JavascriptFunction::FromVar(obj); // //TODO: what happens if the gaurd in marshal (MarshalDynamicObject) isn't true? // if(function->GetTypeHandler()->GetIsLocked()) { function->GetLibrary()->SetCrossSiteForLockedFunctionType(function); } else { function->SetEntryPoint(function->GetScriptContext()->CurrentCrossSiteThunk); } } }