@@ -573,6 +573,11 @@ namespace Js
573573 }
574574 functionId = calleeFunctionProxy->GetLocalFunctionId ();
575575 }
576+ else if (calleeFunctionProxy->GetHostSourceContext () == Js::Constants::JsBuiltInSourceContext)
577+ {
578+ sourceId = JsBuiltInSourceId;
579+ functionId = calleeFunctionProxy->GetLocalFunctionId ();
580+ }
576581 else
577582 {
578583 // Pretend that we are cross context when call is crossing script file.
@@ -768,7 +773,7 @@ namespace Js
768773 Assert (functionBody);
769774 const auto callSiteCount = functionBody->GetProfiledCallSiteCount ();
770775 Assert (callSiteId < callSiteCount);
771- Assert (HasCallSiteInfo (functionBody));
776+ Assert (functionBody-> IsJsBuiltInCode () || HasCallSiteInfo (functionBody));
772777 Assert (functionBodyArray);
773778 Assert (functionBodyArrayLength == DynamicProfileInfo::maxPolymorphicInliningSize);
774779
@@ -859,7 +864,7 @@ namespace Js
859864 Assert (functionBody);
860865 const auto callSiteCount = functionBody->GetProfiledCallSiteCount ();
861866 Assert (callSiteId < callSiteCount);
862- Assert (HasCallSiteInfo (functionBody));
867+ Assert (functionBody-> IsJsBuiltInCode () || HasCallSiteInfo (functionBody));
863868
864869 *isConstructorCall = callSiteInfo[callSiteId].isConstructorCall ;
865870 if (callSiteInfo[callSiteId].dontInline )
@@ -875,12 +880,37 @@ namespace Js
875880 return JavascriptBuiltInFunction::GetFunctionInfo (functionId);
876881 }
877882
878- if (sourceId == CurrentSourceId) // caller and callee in same file
883+ if (sourceId == CurrentSourceId) // caller and callee in same file
879884 {
880885 FunctionProxy *inlineeProxy = functionBody->GetUtf8SourceInfo ()->FindFunction (functionId);
881886 return inlineeProxy ? inlineeProxy->GetFunctionInfo () : nullptr ;
882887 }
883888
889+ if (sourceId == JsBuiltInSourceId)
890+ {
891+ // For call across files find the function from the right source
892+ JsUtil::List<RecyclerWeakReference<Utf8SourceInfo>*, Recycler, false , Js::FreeListedRemovePolicy> * sourceList = functionBody->GetScriptContext ()->GetSourceList ();
893+ for (int i = 0 ; i < sourceList->Count (); i++)
894+ {
895+ if (sourceList->IsItemValid (i))
896+ {
897+ Utf8SourceInfo *srcInfo = sourceList->Item (i)->Get ();
898+ if (srcInfo && srcInfo->GetHostSourceContext () == Js::Constants::JsBuiltInSourceContext)
899+ {
900+ FunctionProxy *inlineeProxy = srcInfo->FindFunction (functionId);
901+ if (inlineeProxy && inlineeProxy->IsJsBuiltInCode ())
902+ {
903+ return inlineeProxy->GetFunctionInfo ();
904+ }
905+ else
906+ {
907+ return nullptr ;
908+ }
909+ }
910+ }
911+ }
912+ }
913+
884914 if (sourceId != NoSourceId && sourceId != InvalidSourceId)
885915 {
886916 // For call across files find the function from the right source
@@ -911,7 +941,7 @@ namespace Js
911941 Assert (functionBody);
912942 const auto callSiteCount = functionBody->GetProfiledCallSiteCount ();
913943 Assert (callSiteId < callSiteCount);
914- Assert (HasCallSiteInfo (functionBody));
944+ Assert (functionBody-> IsJsBuiltInCode () || HasCallSiteInfo (functionBody));
915945
916946 return callSiteInfo[callSiteId].ldFldInlineCacheId ;
917947 }
0 commit comments