@@ -583,7 +583,7 @@ namespace Js
583
583
functionWithPrototypeTypeHandler->SetHasKnownSlot0 ();
584
584
585
585
externalFunctionWithDeferredPrototypeType = CreateDeferredPrototypeFunctionTypeNoProfileThunk (JavascriptExternalFunction::ExternalFunctionThunk, true /* isShared*/ );
586
- externalFunctionWithLengthAndDeferredPrototypeType = CreateDeferredPrototypeFunctionTypeNoProfileThunk (JavascriptExternalFunction::ExternalFunctionThunk, true /* isShared*/ , /* isLengthAvailable */ true );
586
+ externalFunctionWithLengthAndDeferredPrototypeType = CreateDeferredLengthPrototypeFunctionTypeNoProfileThunk (JavascriptExternalFunction::ExternalFunctionThunk, true /* isShared*/ );
587
587
wrappedFunctionWithDeferredPrototypeType = CreateDeferredPrototypeFunctionTypeNoProfileThunk (JavascriptExternalFunction::WrappedFunctionThunk, true /* isShared*/ );
588
588
stdCallFunctionWithDeferredPrototypeType = CreateDeferredPrototypeFunctionTypeNoProfileThunk (JavascriptExternalFunction::StdCallExternalFunctionThunk, true /* isShared*/ );
589
589
idMappedFunctionWithPrototypeType = DynamicType::New (scriptContext, TypeIds_Function, functionPrototype, JavascriptExternalFunction::ExternalFunctionThunk,
@@ -595,6 +595,8 @@ namespace Js
595
595
596
596
boundFunctionType = DynamicType::New (scriptContext, TypeIds_Function, functionPrototype, BoundFunction::NewInstance,
597
597
GetDeferredFunctionTypeHandler (), true , true );
598
+ crossSiteDeferredFunctionType = CreateDeferredFunctionTypeNoProfileThunk (
599
+ scriptContext->CurrentCrossSiteThunk , true /* isShared*/ );
598
600
crossSiteDeferredPrototypeFunctionType = CreateDeferredPrototypeFunctionTypeNoProfileThunk (
599
601
scriptContext->CurrentCrossSiteThunk , true /* isShared*/ );
600
602
crossSiteIdMappedFunctionWithPrototypeType = DynamicType::New (scriptContext, TypeIds_Function, functionPrototype, scriptContext->CurrentCrossSiteThunk ,
@@ -1022,20 +1024,51 @@ namespace Js
1022
1024
isAnonymousFunction ? GetDeferredAnonymousPrototypeAsyncFunctionTypeHandler () : GetDeferredPrototypeAsyncFunctionTypeHandler (scriptContext), isShared, isShared);
1023
1025
}
1024
1026
1027
+ DynamicType * JavascriptLibrary::CreateDeferredFunctionType (JavascriptMethod entrypoint)
1028
+ {
1029
+ return CreateDeferredFunctionTypeNoProfileThunk (this ->inDispatchProfileMode ? ProfileEntryThunk : entrypoint);
1030
+ }
1031
+
1025
1032
DynamicType * JavascriptLibrary::CreateDeferredPrototypeFunctionType (JavascriptMethod entrypoint)
1026
1033
{
1027
1034
return CreateDeferredPrototypeFunctionTypeNoProfileThunk (this ->inDispatchProfileMode ? ProfileEntryThunk : entrypoint);
1028
1035
}
1029
1036
1030
- DynamicType * JavascriptLibrary::CreateDeferredPrototypeFunctionTypeNoProfileThunk (JavascriptMethod entrypoint, bool isShared, bool isLengthAvailable)
1037
+ DynamicType * JavascriptLibrary::CreateDeferredFunctionTypeNoProfileThunk (JavascriptMethod entryPoint, bool isShared)
1038
+ {
1039
+ return CreateDeferredFunctionTypeNoProfileThunk_Internal<false , false >(entryPoint, isShared);
1040
+ }
1041
+
1042
+ DynamicType * JavascriptLibrary::CreateDeferredLengthFunctionTypeNoProfileThunk (JavascriptMethod entryPoint, bool isShared)
1043
+ {
1044
+ return CreateDeferredFunctionTypeNoProfileThunk_Internal<true , false >(entryPoint, isShared);
1045
+ }
1046
+
1047
+ DynamicType * JavascriptLibrary::CreateDeferredPrototypeFunctionTypeNoProfileThunk (JavascriptMethod entryPoint, bool isShared)
1048
+ {
1049
+ return CreateDeferredFunctionTypeNoProfileThunk_Internal<false , true >(entryPoint, isShared);
1050
+ }
1051
+
1052
+ DynamicType * JavascriptLibrary::CreateDeferredLengthPrototypeFunctionTypeNoProfileThunk (JavascriptMethod entryPoint, bool isShared)
1053
+ {
1054
+ return CreateDeferredFunctionTypeNoProfileThunk_Internal<true , true >(entryPoint, isShared);
1055
+ }
1056
+
1057
+ template <bool isLengthAvailable, bool isPrototypeAvailable>
1058
+ DynamicType * JavascriptLibrary::CreateDeferredFunctionTypeNoProfileThunk_Internal (JavascriptMethod entrypoint, bool isShared)
1031
1059
{
1032
1060
// Note: the lack of TypeHandler switching here based on the isAnonymousFunction flag is intentional.
1033
1061
// We can't switch shared typeHandlers and RuntimeFunctions do not produce script code for us to know if a function is Anonymous.
1034
1062
// As a result we may have an issue where hasProperty would say you have a name property but getProperty returns undefined
1035
- return DynamicType::New (scriptContext, TypeIds_Function, functionPrototype, entrypoint,
1036
- isLengthAvailable ? GetDeferredPrototypeFunctionWithLengthTypeHandler (scriptContext) : GetDeferredPrototypeFunctionTypeHandler (scriptContext),
1037
- isShared, isShared);
1063
+ DynamicTypeHandler * typeHandler =
1064
+ isLengthAvailable ?
1065
+ (isPrototypeAvailable ?
1066
+ GetDeferredPrototypeFunctionWithLengthTypeHandler (scriptContext) : GetDeferredFunctionWithLengthTypeHandler ()) :
1067
+ (isPrototypeAvailable ?
1068
+ GetDeferredPrototypeFunctionTypeHandler (scriptContext) : GetDeferredFunctionTypeHandler ());
1069
+ return DynamicType::New (scriptContext, TypeIds_Function, functionPrototype, entrypoint, typeHandler, isShared, isShared);
1038
1070
}
1071
+
1039
1072
DynamicType * JavascriptLibrary::CreateFunctionType (JavascriptMethod entrypoint, RecyclableObject* prototype)
1040
1073
{
1041
1074
if (prototype == nullptr )
@@ -5243,11 +5276,7 @@ namespace Js
5243
5276
{
5244
5277
Assert (function->GetDynamicType ()->GetIsLocked ());
5245
5278
5246
- if (VarIs<ScriptFunction>(function))
5247
- {
5248
- this ->SetCrossSiteForLockedNonBuiltInFunctionType (function);
5249
- }
5250
- else if (VarIs<BoundFunction>(function))
5279
+ if (VarIs<ScriptFunction>(function) || VarIs<BoundFunction>(function))
5251
5280
{
5252
5281
this ->SetCrossSiteForLockedNonBuiltInFunctionType (function);
5253
5282
}
@@ -5259,6 +5288,11 @@ namespace Js
5259
5288
{
5260
5289
function->ReplaceType (crossSiteDeferredPrototypeFunctionType);
5261
5290
}
5291
+ else if (typeHandler == JavascriptLibrary::GetDeferredFunctionTypeHandler ()
5292
+ || typeHandler == JavascriptLibrary::GetDeferredFunctionWithLengthTypeHandler ())
5293
+ {
5294
+ function->ReplaceType (crossSiteDeferredFunctionType);
5295
+ }
5262
5296
else if (typeHandler == Js::DeferredTypeHandler<Js::JavascriptExternalFunction::DeferredConstructorInitializer>::GetDefaultInstance ())
5263
5297
{
5264
5298
function->ReplaceType (crossSiteExternalConstructFunctionWithPrototypeType);
@@ -5276,16 +5310,58 @@ namespace Js
5276
5310
5277
5311
void JavascriptLibrary::SetCrossSiteForLockedNonBuiltInFunctionType (JavascriptFunction * function)
5278
5312
{
5313
+ FunctionProxy * functionProxy = function->GetFunctionProxy ();
5279
5314
DynamicTypeHandler *typeHandler = function->GetTypeHandler ();
5280
- if (typeHandler->IsPathTypeHandler ())
5315
+ if (typeHandler->IsDeferredTypeHandler ())
5281
5316
{
5282
- PathTypeHandlerBase::FromTypeHandler (typeHandler)->ConvertToNonShareableTypeHandler (function);
5317
+ if (functionProxy && functionProxy->GetCrossSiteDeferredFunctionType ())
5318
+ {
5319
+ function->ReplaceType (functionProxy->GetCrossSiteDeferredFunctionType ());
5320
+ }
5321
+ else
5322
+ {
5323
+ function->ChangeType ();
5324
+ function->SetEntryPoint (scriptContext->CurrentCrossSiteThunk );
5325
+ if (functionProxy && !PHASE_OFF1 (ShareCrossSiteFuncTypesPhase))
5326
+ {
5327
+ function->ShareType ();
5328
+ functionProxy->SetCrossSiteDeferredFunctionType (UnsafeVarTo<ScriptFunction>(function)->GetScriptFunctionType ());
5329
+ }
5330
+ }
5283
5331
}
5284
- else
5332
+ else
5285
5333
{
5286
- function->ChangeType ();
5334
+ if (functionProxy && functionProxy->GetCrossSiteUndeferredFunctionType ())
5335
+ {
5336
+ function->ReplaceType (functionProxy->GetCrossSiteUndeferredFunctionType ());
5337
+ }
5338
+ else
5339
+ {
5340
+ if (typeHandler->IsPathTypeHandler ())
5341
+ {
5342
+ if (!PHASE_OFF1 (ShareCrossSiteFuncTypesPhase))
5343
+ {
5344
+ DynamicType *type = function->DuplicateType ();
5345
+ PathTypeHandlerBase::FromTypeHandler (typeHandler)->BuildPathTypeFromNewRoot (function, &type);
5346
+ function->ReplaceType (type);
5347
+ }
5348
+ else
5349
+ {
5350
+ PathTypeHandlerBase::FromTypeHandler (typeHandler)->ConvertToNonShareableTypeHandler (function);
5351
+ }
5352
+ }
5353
+ else
5354
+ {
5355
+ function->ChangeType ();
5356
+ }
5357
+ function->SetEntryPoint (scriptContext->CurrentCrossSiteThunk );
5358
+ if (functionProxy && function->GetTypeHandler ()->GetMayBecomeShared () && !PHASE_OFF1 (ShareCrossSiteFuncTypesPhase))
5359
+ {
5360
+ function->ShareType ();
5361
+ functionProxy->SetCrossSiteUndeferredFunctionType (UnsafeVarTo<ScriptFunction>(function)->GetScriptFunctionType ());
5362
+ }
5363
+ }
5287
5364
}
5288
- function->SetEntryPoint (scriptContext->CurrentCrossSiteThunk );
5289
5365
}
5290
5366
5291
5367
JavascriptExternalFunction*
0 commit comments