Skip to content

Commit 10808ce

Browse files
committed
Refactoring an assert
1 parent 96a00e6 commit 10808ce

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

lib/Runtime/Language/DynamicProfileInfo.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,8 +1172,13 @@ namespace Js
11721172
if (functionBody->GetCallSiteToCallApplyCallSiteArray())
11731173
{
11741174
Js::ProfileId callApplyCallSiteId = functionBody->GetCallSiteToCallApplyCallSiteArray()[callSiteId];
1175+
if (callApplyCallSiteId == Js::Constants::NoProfileId)
1176+
{
1177+
return nullptr;
1178+
}
1179+
11751180
Assert(callApplyCallSiteId < functionBody->GetProfiledCallApplyCallSiteCount());
1176-
1181+
11771182
if (callApplyTargetInfo[callApplyCallSiteId].isPolymorphic)
11781183
{
11791184
return nullptr;

lib/Runtime/Language/InterpreterStackFrame.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3909,11 +3909,14 @@ namespace Js
39093909
if (callSiteToCallApplyCallSiteMap)
39103910
{
39113911
Js::ProfileId callApplyCallSiteId = callSiteToCallApplyCallSiteMap[profileId];
3912-
Assert(callApplyCallSiteId < functionBody->GetProfiledCallApplyCallSiteCount());
3913-
if (callApplyCallSiteId != Js::Constants::NoProfileId)
3912+
if (callApplyCallSiteId < functionBody->GetProfiledCallApplyCallSiteCount())
39143913
{
39153914
dynamicProfileInfo->RecordCallApplyTargetInfo(functionBody, callApplyCallSiteId, targetFunction->GetFunctionInfo(), targetFunction);
39163915
}
3916+
else
3917+
{
3918+
Assert(callApplyCallSiteId == Js::Constants::NoProfileId);
3919+
}
39173920
}
39183921
}
39193922
}

test/inlining/callTarget.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,26 @@ function test3(a, b)
8080
test3("foobar", /foo/i)
8181
test3("foobar", /foo/i)
8282
test3("foobar", /foo/i)
83+
print("passed")
84+
85+
function test4()
86+
{
87+
function bar(a)
88+
{
89+
return 'call'
90+
}
91+
function test()
92+
{
93+
return this;
94+
}
95+
function foo()
96+
{
97+
test[bar('1')](this);
98+
test.call(this);
99+
}
100+
foo()
101+
foo()
102+
foo()
103+
}
104+
test4()
83105
print("passed")

0 commit comments

Comments
 (0)