Skip to content

Commit 70ce10f

Browse files
committed
Some fixes
1 parent 7a284eb commit 70ce10f

File tree

5 files changed

+36
-16
lines changed

5 files changed

+36
-16
lines changed

lib/Backend/Inline.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2844,14 +2844,15 @@ bool Inline::TryGetCallApplyAndTargetLdInstrs(IR::Instr * callInstr, _Outptr_res
28442844
IR::Opnd* applyOpnd = callInstr->GetSrc1();
28452845
Assert(applyOpnd->IsRegOpnd());
28462846
StackSym* applySym = applyOpnd->AsRegOpnd()->m_sym->AsStackSym();
2847-
if (!applySym->IsSingleDef())
2847+
if (!applySym->IsSingleDef() ||
2848+
!applySym->GetInstrDef()->GetSrc1()->IsSymOpnd() ||
2849+
!applySym->GetInstrDef()->GetSrc1()->AsSymOpnd()->IsPropertySymOpnd())
28482850
{
28492851
*applyLdInstr = nullptr;
28502852
*applyTargetLdInstr = nullptr;
28512853
return false;
28522854
}
28532855

2854-
Assert(applySym->GetInstrDef()->GetSrc1()->IsSymOpnd() && applySym->GetInstrDef()->GetSrc1()->AsSymOpnd()->IsPropertySymOpnd());
28552856
StackSym * targetSym = applySym->GetInstrDef()->GetSrc1()->AsSymOpnd()->AsPropertySymOpnd()->GetObjectSym();
28562857
if (!targetSym->IsSingleDef())
28572858
{

lib/Backend/JITTimeFunctionBody.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,12 @@ JITTimeFunctionBody::InitializeJITFunctionData(
252252
jitBody->functionSlotsInCachedScopeCount = slotIdInCachedScopeToNestedIndexArray->count;
253253
jitBody->slotIdInCachedScopeToNestedIndexArray = slotIdInCachedScopeToNestedIndexArray->elements;
254254
}
255-
jitBody->callSiteToCallApplyCallSiteArray = functionBody->GetCallSiteToCallApplyCallSiteArrayWithLock();
255+
Js::ProfileId * callSiteToCallApplyCallSiteArray = functionBody->GetCallSiteToCallApplyCallSiteArrayWithLock();
256+
if (callSiteToCallApplyCallSiteArray)
257+
{
258+
jitBody->callSiteToCallApplyCallSiteArrayCount = jitBody->profiledCallSiteCount;
259+
jitBody->callSiteToCallApplyCallSiteArray = callSiteToCallApplyCallSiteArray;
260+
}
256261
#ifdef ASMJS_PLAT
257262
if (functionBody->GetIsAsmJsFunction())
258263
{
@@ -1058,8 +1063,12 @@ Js::ProfileId
10581063
JITTimeFunctionBody::GetCallApplyCallSiteIdForCallSiteId(Js::ProfileId callSiteId) const
10591064
{
10601065
AssertOrFailFast(callSiteId < m_bodyData.profiledCallSiteCount);
1061-
Js::ProfileId callApplyId = m_bodyData.callSiteToCallApplyCallSiteArray[callSiteId];
1062-
AssertOrFailFast(callApplyId < m_bodyData.profiledCallApplyCallSiteCount);
1066+
Js::ProfileId callApplyId = Js::Constants::NoProfileId;
1067+
if (m_bodyData.callSiteToCallApplyCallSiteArray)
1068+
{
1069+
callApplyId = m_bodyData.callSiteToCallApplyCallSiteArray[callSiteId];
1070+
AssertOrFailFast(callApplyId < m_bodyData.profiledCallApplyCallSiteCount);
1071+
}
10631072

10641073
return callApplyId;
10651074
}

lib/JITIDL/JITTypes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ typedef struct FunctionBodyDataIDL
568568
unsigned short inParamCount;
569569
unsigned short argUsedForBranch;
570570
unsigned short profiledCallSiteCount;
571+
unsigned short callSiteToCallApplyCallSiteArrayCount;
571572
unsigned short profiledCallApplyCallSiteCount;
572573
unsigned int funcNumber;
573574
unsigned int sourceContextId;
@@ -634,7 +635,7 @@ typedef struct FunctionBodyDataIDL
634635

635636
IDL_DEF([size_is(functionSlotsInCachedScopeCount)]) unsigned int * slotIdInCachedScopeToNestedIndexArray;
636637

637-
IDL_DEF([size_is(profiledCallApplyCallSiteCount)]) unsigned short * callSiteToCallApplyCallSiteArray;
638+
IDL_DEF([size_is(callSiteToCallApplyCallSiteArrayCount)]) unsigned short * callSiteToCallApplyCallSiteArray;
638639

639640
ProfileDataIDL * profileData;
640641

lib/Runtime/Language/DynamicProfileInfo.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,15 +1169,20 @@ namespace Js
11691169
Assert(callSiteId < callSiteCount);
11701170
Assert(functionBody->IsJsBuiltInCode() || functionBody->IsPublicLibraryCode() || HasCallSiteInfo(functionBody));
11711171

1172-
Js::ProfileId callApplyCallSiteId = functionBody->GetCallSiteToCallApplyCallSiteArray()[callSiteId];
1173-
Assert(callApplyCallSiteId < functionBody->GetProfiledCallApplyCallSiteCount());
1174-
1175-
if (callApplyTargetInfo[callApplyCallSiteId].isPolymorphic)
1172+
if (functionBody->GetCallSiteToCallApplyCallSiteArray())
11761173
{
1177-
return nullptr;
1174+
Js::ProfileId callApplyCallSiteId = functionBody->GetCallSiteToCallApplyCallSiteArray()[callSiteId];
1175+
Assert(callApplyCallSiteId < functionBody->GetProfiledCallApplyCallSiteCount());
1176+
1177+
if (callApplyTargetInfo[callApplyCallSiteId].isPolymorphic)
1178+
{
1179+
return nullptr;
1180+
}
1181+
1182+
return GetFunctionInfo(functionBody, callApplyTargetInfo[callApplyCallSiteId].u.functionData.sourceId, callApplyTargetInfo[callApplyCallSiteId].u.functionData.functionId);
11781183
}
11791184

1180-
return GetFunctionInfo(functionBody, callApplyTargetInfo[callApplyCallSiteId].u.functionData.sourceId, callApplyTargetInfo[callApplyCallSiteId].u.functionData.functionId);
1185+
return nullptr;
11811186
}
11821187

11831188
uint DynamicProfileInfo::GetLdFldCacheIndexFromCallSiteInfo(FunctionBody* functionBody, ProfileId callSiteId)

lib/Runtime/Language/InterpreterStackFrame.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3905,11 +3905,15 @@ namespace Js
39053905
{
39063906
if ((functionInfo->IsBuiltInApplyFunction() || functionInfo->IsBuiltInCallFunction()) && targetFunction)
39073907
{
3908-
Js::ProfileId callApplyCallSiteId = this->m_functionBody->GetCallSiteToCallApplyCallSiteArray()[profileId];
3909-
Assert(callApplyCallSiteId < functionBody->GetProfiledCallApplyCallSiteCount());
3910-
if (callApplyCallSiteId != Js::Constants::NoProfileId)
3908+
Js::ProfileId * callSiteToCallApplyCallSiteMap = this->m_functionBody->GetCallSiteToCallApplyCallSiteArray();
3909+
if (callSiteToCallApplyCallSiteMap)
39113910
{
3912-
dynamicProfileInfo->RecordCallApplyTargetInfo(functionBody, callApplyCallSiteId, targetFunction->GetFunctionInfo(), targetFunction);
3911+
Js::ProfileId callApplyCallSiteId = callSiteToCallApplyCallSiteMap[profileId];
3912+
Assert(callApplyCallSiteId < functionBody->GetProfiledCallApplyCallSiteCount());
3913+
if (callApplyCallSiteId != Js::Constants::NoProfileId)
3914+
{
3915+
dynamicProfileInfo->RecordCallApplyTargetInfo(functionBody, callApplyCallSiteId, targetFunction->GetFunctionInfo(), targetFunction);
3916+
}
39133917
}
39143918
}
39153919
}

0 commit comments

Comments
 (0)