@@ -594,7 +594,7 @@ namespace Js
594
594
Js::DeferredTypeHandler<Js::JavascriptExternalFunction::DeferredConstructorInitializer>::GetDefaultInstance (), true , true );
595
595
596
596
boundFunctionType = DynamicType::New (scriptContext, TypeIds_Function, functionPrototype, BoundFunction::NewInstance,
597
- GetDeferredFunctionTypeHandler (), true , true );
597
+ GetDeferredFunctionWithLengthUnsetTypeHandler (), true , true );
598
598
crossSiteDeferredFunctionType = CreateDeferredFunctionTypeNoProfileThunk (
599
599
scriptContext->CurrentCrossSiteThunk , true /* isShared*/ );
600
600
crossSiteDeferredPrototypeFunctionType = CreateDeferredPrototypeFunctionTypeNoProfileThunk (
@@ -784,7 +784,7 @@ namespace Js
784
784
JavascriptArray::EnsureCalculationOfAllocationBuckets<Js::JavascriptArray>();
785
785
}
786
786
787
- template <bool addPrototype, bool addName, bool useLengthType>
787
+ template <bool addPrototype, bool addName, bool useLengthType, bool addLength >
788
788
bool JavascriptLibrary::InitializeFunction (DynamicObject *instance, DeferredTypeHandlerBase * typeHandler, DeferredInitializeMode mode)
789
789
{
790
790
JavascriptFunction * function = VarTo<JavascriptFunction>(instance);
@@ -833,7 +833,8 @@ namespace Js
833
833
{
834
834
ParseableFunctionInfo * funcInfo = scriptFunction->GetFunctionProxy ()->EnsureDeserialized ();
835
835
836
- if (useLengthType)
836
+ CompileAssert (!addLength || useLengthType);
837
+ if (addLength)
837
838
{
838
839
function->SetPropertyWithAttributes (PropertyIds::length, TaggedInt::ToVarUnchecked (funcInfo->GetReportedInParamsCount () - 1 ), PropertyConfigurable, nullptr , PropertyOperation_None, SideEffects_None);
839
840
}
@@ -914,10 +915,10 @@ namespace Js
914
915
}
915
916
};
916
917
917
- template <bool isNameAvailable, bool isPrototypeAvailable, bool isLengthAvailable>
918
+ template <bool isNameAvailable, bool isPrototypeAvailable, bool isLengthAvailable, bool addLength >
918
919
DynamicTypeHandler * JavascriptLibrary::GetDeferredFunctionTypeHandlerBase ()
919
920
{
920
- return DeferredTypeHandler<InitializeFunction<isPrototypeAvailable, isNameAvailable, isLengthAvailable>, InitializeFunctionDeferredTypeHandlerFilter<isNameAvailable, isPrototypeAvailable, isLengthAvailable>>::GetDefaultInstance ();
921
+ return DeferredTypeHandler<InitializeFunction<isPrototypeAvailable, isNameAvailable, isLengthAvailable, addLength >, InitializeFunctionDeferredTypeHandlerFilter<isNameAvailable, isPrototypeAvailable, isLengthAvailable>>::GetDefaultInstance ();
921
922
}
922
923
923
924
template <bool isNameAvailable, bool isPrototypeAvailable>
@@ -993,6 +994,11 @@ namespace Js
993
994
return GetDeferredFunctionTypeHandlerBase</* isNameAvailable*/ true , /* isPrototypeAvailable*/ false , /* isLengthAvailable */ true >();
994
995
}
995
996
997
+ DynamicTypeHandler * JavascriptLibrary::GetDeferredFunctionWithLengthUnsetTypeHandler ()
998
+ {
999
+ return GetDeferredFunctionTypeHandlerBase</* isNameAvailable*/ true , /* isPrototypeAvailable*/ false , /* isLengthAvailable */ true , /* addLength */ false >();
1000
+ }
1001
+
996
1002
DynamicTypeHandler * JavascriptLibrary::ScriptFunctionTypeHandler (bool noPrototypeProperty, bool isAnonymousFunction)
997
1003
{
998
1004
DynamicTypeHandler * scriptFunctionTypeHandler = nullptr ;
0 commit comments