@@ -569,7 +569,7 @@ namespace Js
569
569
functionWithPrototypeTypeHandler->SetHasKnownSlot0 ();
570
570
571
571
externalFunctionWithDeferredPrototypeType = CreateDeferredPrototypeFunctionTypeNoProfileThunk (JavascriptExternalFunction::ExternalFunctionThunk, true /* isShared*/ );
572
- externalFunctionWithLengthAndDeferredPrototypeType = CreateDeferredPrototypeFunctionTypeNoProfileThunk (JavascriptExternalFunction::ExternalFunctionThunk, true /* isShared*/ , /* isLengthAvailable */ true );
572
+ externalFunctionWithLengthAndDeferredPrototypeType = CreateDeferredLengthPrototypeFunctionTypeNoProfileThunk (JavascriptExternalFunction::ExternalFunctionThunk, true /* isShared*/ );
573
573
wrappedFunctionWithDeferredPrototypeType = CreateDeferredPrototypeFunctionTypeNoProfileThunk (JavascriptExternalFunction::WrappedFunctionThunk, true /* isShared*/ );
574
574
stdCallFunctionWithDeferredPrototypeType = CreateDeferredPrototypeFunctionTypeNoProfileThunk (JavascriptExternalFunction::StdCallExternalFunctionThunk, true /* isShared*/ );
575
575
idMappedFunctionWithPrototypeType = DynamicType::New (scriptContext, TypeIds_Function, functionPrototype, JavascriptExternalFunction::ExternalFunctionThunk,
@@ -581,6 +581,8 @@ namespace Js
581
581
582
582
boundFunctionType = DynamicType::New (scriptContext, TypeIds_Function, functionPrototype, BoundFunction::NewInstance,
583
583
GetDeferredFunctionTypeHandler (), true , true );
584
+ crossSiteDeferredFunctionType = CreateDeferredFunctionTypeNoProfileThunk (
585
+ scriptContext->CurrentCrossSiteThunk , true /* isShared*/ );
584
586
crossSiteDeferredPrototypeFunctionType = CreateDeferredPrototypeFunctionTypeNoProfileThunk (
585
587
scriptContext->CurrentCrossSiteThunk , true /* isShared*/ );
586
588
crossSiteIdMappedFunctionWithPrototypeType = DynamicType::New (scriptContext, TypeIds_Function, functionPrototype, scriptContext->CurrentCrossSiteThunk ,
@@ -1008,20 +1010,51 @@ namespace Js
1008
1010
isAnonymousFunction ? GetDeferredAnonymousPrototypeAsyncFunctionTypeHandler () : GetDeferredPrototypeAsyncFunctionTypeHandler (scriptContext), isShared, isShared);
1009
1011
}
1010
1012
1013
+ DynamicType * JavascriptLibrary::CreateDeferredFunctionType (JavascriptMethod entrypoint)
1014
+ {
1015
+ return CreateDeferredFunctionTypeNoProfileThunk (this ->inDispatchProfileMode ? ProfileEntryThunk : entrypoint);
1016
+ }
1017
+
1011
1018
DynamicType * JavascriptLibrary::CreateDeferredPrototypeFunctionType (JavascriptMethod entrypoint)
1012
1019
{
1013
1020
return CreateDeferredPrototypeFunctionTypeNoProfileThunk (this ->inDispatchProfileMode ? ProfileEntryThunk : entrypoint);
1014
1021
}
1015
1022
1016
- DynamicType * JavascriptLibrary::CreateDeferredPrototypeFunctionTypeNoProfileThunk (JavascriptMethod entrypoint, bool isShared, bool isLengthAvailable)
1023
+ DynamicType * JavascriptLibrary::CreateDeferredFunctionTypeNoProfileThunk (JavascriptMethod entryPoint, bool isShared)
1024
+ {
1025
+ return CreateDeferredFunctionTypeNoProfileThunk_Internal<false , false >(entryPoint, isShared);
1026
+ }
1027
+
1028
+ DynamicType * JavascriptLibrary::CreateDeferredLengthFunctionTypeNoProfileThunk (JavascriptMethod entryPoint, bool isShared)
1029
+ {
1030
+ return CreateDeferredFunctionTypeNoProfileThunk_Internal<true , false >(entryPoint, isShared);
1031
+ }
1032
+
1033
+ DynamicType * JavascriptLibrary::CreateDeferredPrototypeFunctionTypeNoProfileThunk (JavascriptMethod entryPoint, bool isShared)
1034
+ {
1035
+ return CreateDeferredFunctionTypeNoProfileThunk_Internal<false , true >(entryPoint, isShared);
1036
+ }
1037
+
1038
+ DynamicType * JavascriptLibrary::CreateDeferredLengthPrototypeFunctionTypeNoProfileThunk (JavascriptMethod entryPoint, bool isShared)
1039
+ {
1040
+ return CreateDeferredFunctionTypeNoProfileThunk_Internal<true , true >(entryPoint, isShared);
1041
+ }
1042
+
1043
+ template <bool isLengthAvailable, bool isPrototypeAvailable>
1044
+ DynamicType * JavascriptLibrary::CreateDeferredFunctionTypeNoProfileThunk_Internal (JavascriptMethod entrypoint, bool isShared)
1017
1045
{
1018
1046
// Note: the lack of TypeHandler switching here based on the isAnonymousFunction flag is intentional.
1019
1047
// We can't switch shared typeHandlers and RuntimeFunctions do not produce script code for us to know if a function is Anonymous.
1020
1048
// As a result we may have an issue where hasProperty would say you have a name property but getProperty returns undefined
1021
- return DynamicType::New (scriptContext, TypeIds_Function, functionPrototype, entrypoint,
1022
- isLengthAvailable ? GetDeferredPrototypeFunctionWithLengthTypeHandler (scriptContext) : GetDeferredPrototypeFunctionTypeHandler (scriptContext),
1023
- isShared, isShared);
1049
+ DynamicTypeHandler * typeHandler =
1050
+ isLengthAvailable ?
1051
+ (isPrototypeAvailable ?
1052
+ GetDeferredPrototypeFunctionWithLengthTypeHandler (scriptContext) : GetDeferredFunctionWithLengthTypeHandler ()) :
1053
+ (isPrototypeAvailable ?
1054
+ GetDeferredPrototypeFunctionTypeHandler (scriptContext) : GetDeferredFunctionTypeHandler ());
1055
+ return DynamicType::New (scriptContext, TypeIds_Function, functionPrototype, entrypoint, typeHandler, isShared, isShared);
1024
1056
}
1057
+
1025
1058
DynamicType * JavascriptLibrary::CreateFunctionType (JavascriptMethod entrypoint, RecyclableObject* prototype)
1026
1059
{
1027
1060
if (prototype == nullptr )
@@ -5200,11 +5233,7 @@ namespace Js
5200
5233
{
5201
5234
Assert (function->GetDynamicType ()->GetIsLocked ());
5202
5235
5203
- if (VarIs<ScriptFunction>(function))
5204
- {
5205
- this ->SetCrossSiteForLockedNonBuiltInFunctionType (function);
5206
- }
5207
- else if (VarIs<BoundFunction>(function))
5236
+ if (VarIs<ScriptFunction>(function) || VarIs<BoundFunction>(function))
5208
5237
{
5209
5238
this ->SetCrossSiteForLockedNonBuiltInFunctionType (function);
5210
5239
}
@@ -5216,6 +5245,11 @@ namespace Js
5216
5245
{
5217
5246
function->ReplaceType (crossSiteDeferredPrototypeFunctionType);
5218
5247
}
5248
+ else if (typeHandler == JavascriptLibrary::GetDeferredFunctionTypeHandler ()
5249
+ || typeHandler == JavascriptLibrary::GetDeferredFunctionWithLengthTypeHandler ())
5250
+ {
5251
+ function->ReplaceType (crossSiteDeferredFunctionType);
5252
+ }
5219
5253
else if (typeHandler == Js::DeferredTypeHandler<Js::JavascriptExternalFunction::DeferredConstructorInitializer>::GetDefaultInstance ())
5220
5254
{
5221
5255
function->ReplaceType (crossSiteExternalConstructFunctionWithPrototypeType);
@@ -5233,16 +5267,58 @@ namespace Js
5233
5267
5234
5268
void JavascriptLibrary::SetCrossSiteForLockedNonBuiltInFunctionType (JavascriptFunction * function)
5235
5269
{
5270
+ FunctionProxy * functionProxy = function->GetFunctionProxy ();
5236
5271
DynamicTypeHandler *typeHandler = function->GetTypeHandler ();
5237
- if (typeHandler->IsPathTypeHandler ())
5272
+ if (typeHandler->IsDeferredTypeHandler ())
5238
5273
{
5239
- PathTypeHandlerBase::FromTypeHandler (typeHandler)->ConvertToNonShareableTypeHandler (function);
5274
+ if (functionProxy && functionProxy->GetCrossSiteDeferredFunctionType ())
5275
+ {
5276
+ function->ReplaceType (functionProxy->GetCrossSiteDeferredFunctionType ());
5277
+ }
5278
+ else
5279
+ {
5280
+ function->ChangeType ();
5281
+ function->SetEntryPoint (scriptContext->CurrentCrossSiteThunk );
5282
+ if (functionProxy && functionProxy->HasParseableInfo () && !PHASE_OFF1 (ShareCrossSiteFuncTypesPhase))
5283
+ {
5284
+ function->ShareType ();
5285
+ functionProxy->SetCrossSiteDeferredFunctionType (UnsafeVarTo<ScriptFunction>(function)->GetScriptFunctionType ());
5286
+ }
5287
+ }
5240
5288
}
5241
- else
5289
+ else
5242
5290
{
5243
- function->ChangeType ();
5291
+ if (functionProxy && functionProxy->GetCrossSiteUndeferredFunctionType ())
5292
+ {
5293
+ function->ReplaceType (functionProxy->GetCrossSiteUndeferredFunctionType ());
5294
+ }
5295
+ else
5296
+ {
5297
+ if (typeHandler->IsPathTypeHandler ())
5298
+ {
5299
+ if (!PHASE_OFF1 (ShareCrossSiteFuncTypesPhase))
5300
+ {
5301
+ DynamicType *type = function->DuplicateType ();
5302
+ PathTypeHandlerBase::FromTypeHandler (typeHandler)->BuildPathTypeFromNewRoot (function, &type);
5303
+ function->ReplaceType (type);
5304
+ }
5305
+ else
5306
+ {
5307
+ PathTypeHandlerBase::FromTypeHandler (typeHandler)->ConvertToNonShareableTypeHandler (function);
5308
+ }
5309
+ }
5310
+ else
5311
+ {
5312
+ function->ChangeType ();
5313
+ }
5314
+ function->SetEntryPoint (scriptContext->CurrentCrossSiteThunk );
5315
+ if (functionProxy && functionProxy->HasParseableInfo () && function->GetTypeHandler ()->GetMayBecomeShared () && !PHASE_OFF1 (ShareCrossSiteFuncTypesPhase))
5316
+ {
5317
+ function->ShareType ();
5318
+ functionProxy->SetCrossSiteUndeferredFunctionType (UnsafeVarTo<ScriptFunction>(function)->GetScriptFunctionType ());
5319
+ }
5320
+ }
5244
5321
}
5245
- function->SetEntryPoint (scriptContext->CurrentCrossSiteThunk );
5246
5322
}
5247
5323
5248
5324
JavascriptExternalFunction*
0 commit comments