@@ -53,6 +53,8 @@ namespace Js
53
53
bits = NotNativeIntBit | NotNativeFloatBit;
54
54
}
55
55
56
+ CriticalSection DynamicProfileInfo::callSiteInfoCS;
57
+
56
58
DynamicProfileInfo* DynamicProfileInfo::New (Recycler* recycler, FunctionBody* functionBody, bool persistsAcrossScriptContexts)
57
59
{
58
60
size_t totalAlloc = 0 ;
@@ -541,12 +543,14 @@ namespace Js
541
543
#ifdef ASMJS_PLAT
542
544
void DynamicProfileInfo::RecordAsmJsCallSiteInfo (FunctionBody* callerBody, ProfileId callSiteId, FunctionBody* calleeBody)
543
545
{
546
+ AutoCriticalSection cs (&this ->callSiteInfoCS );
547
+
544
548
if (!callerBody || !callerBody->GetIsAsmjsMode () || !calleeBody || !calleeBody->GetIsAsmjsMode ())
545
549
{
546
550
AssertMsg (UNREACHED, " Call to RecordAsmJsCallSiteInfo without two asm.js/wasm FunctionBody" );
547
551
return ;
548
552
}
549
-
553
+
550
554
#if DBG_DUMP || defined(DYNAMIC_PROFILE_STORAGE) || defined(RUNTIME_DATA_COLLECTION)
551
555
// If we persistsAcrossScriptContext, the dynamic profile info may be referred to by multiple function body from
552
556
// different script context
@@ -688,6 +692,8 @@ namespace Js
688
692
689
693
void DynamicProfileInfo::RecordCallSiteInfo (FunctionBody* functionBody, ProfileId callSiteId, FunctionInfo* calleeFunctionInfo, JavascriptFunction* calleeFunction, uint actualArgCount, bool isConstructorCall, InlineCacheIndex ldFldInlineCacheId)
690
694
{
695
+ AutoCriticalSection cs (&this ->callSiteInfoCS );
696
+
691
697
#if DBG_DUMP || defined(DYNAMIC_PROFILE_STORAGE) || defined(RUNTIME_DATA_COLLECTION)
692
698
// If we persistsAcrossScriptContext, the dynamic profile info may be referred to by multiple function body from
693
699
// different script context
@@ -788,6 +794,7 @@ namespace Js
788
794
localPolyCallSiteInfo->functionIds [i] = CallSiteNoInfo;
789
795
}
790
796
797
+ Assert (this ->callSiteInfoCS .IsLocked ());
791
798
callSiteInfo[callSiteId].isPolymorphic = true ;
792
799
callSiteInfo[callSiteId].u .polymorphicCallSiteInfo = localPolyCallSiteInfo;
793
800
funcBody->SetPolymorphicCallSiteInfoHead (localPolyCallSiteInfo);
@@ -797,6 +804,8 @@ namespace Js
797
804
{
798
805
if (dynamicProfileFunctionInfo)
799
806
{
807
+ AutoCriticalSection cs (&this ->callSiteInfoCS );
808
+
800
809
for (ProfileId i = 0 ; i < dynamicProfileFunctionInfo->callSiteInfoCount ; i++)
801
810
{
802
811
if (callSiteInfo[i].isPolymorphic )
@@ -809,6 +818,8 @@ namespace Js
809
818
810
819
void DynamicProfileInfo::ResetPolymorphicCallSiteInfo (ProfileId callSiteId, Js::LocalFunctionId functionId)
811
820
{
821
+ Assert (this ->callSiteInfoCS .IsLocked ());
822
+
812
823
callSiteInfo[callSiteId].isPolymorphic = false ;
813
824
callSiteInfo[callSiteId].u .functionData .sourceId = CurrentSourceId;
814
825
callSiteInfo[callSiteId].u .functionData .functionId = functionId;
@@ -991,6 +1002,7 @@ namespace Js
991
1002
992
1003
FunctionInfo * DynamicProfileInfo::GetFunctionInfo (FunctionBody* functionBody, Js::SourceId sourceId, Js::LocalFunctionId functionId)
993
1004
{
1005
+ Assert (ThreadContext::GetContextForCurrentThread ());
994
1006
if (sourceId == BuiltInSourceId)
995
1007
{
996
1008
return JavascriptBuiltInFunction::GetFunctionInfo (functionId);
@@ -1048,8 +1060,30 @@ namespace Js
1048
1060
return nullptr ;
1049
1061
}
1050
1062
1063
+ bool DynamicProfileInfo::MayHaveNonBuiltinCallee (ProfileId callSiteId)
1064
+ {
1065
+ AutoCriticalSection cs (&this ->callSiteInfoCS );
1066
+
1067
+ if (this ->callSiteInfo [callSiteId].dontInline )
1068
+ {
1069
+ return true ;
1070
+ }
1071
+
1072
+ if (!this ->callSiteInfo [callSiteId].isPolymorphic )
1073
+ {
1074
+ Js::SourceId sourceId = this ->callSiteInfo [callSiteId].u .functionData .sourceId ;
1075
+ if (sourceId == BuiltInSourceId)
1076
+ {
1077
+ return false ;
1078
+ }
1079
+ }
1080
+
1081
+ return true ;
1082
+ }
1083
+
1051
1084
FunctionInfo * DynamicProfileInfo::GetCallSiteInfo (FunctionBody* functionBody, ProfileId callSiteId, bool *isConstructorCall, bool *isPolymorphicCall)
1052
1085
{
1086
+ Assert (ThreadContext::GetContextForCurrentThread ());
1053
1087
Assert (functionBody);
1054
1088
const auto callSiteCount = functionBody->GetProfiledCallSiteCount ();
1055
1089
Assert (callSiteId < callSiteCount);
0 commit comments