Skip to content

Commit 4d4f566

Browse files
committed
[MERGE #6214 @MikeHolman] don't record call site info until call completes
Merge pull request #6214 from MikeHolman:callsiteprofile We can end up with partially initialized profile data which leads to failfast when JITing Fixes #6202
2 parents 4888b49 + c1f113d commit 4d4f566

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

lib/Runtime/Language/InterpreterStackFrame.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3960,22 +3960,26 @@ namespace Js
39603960
template <class T>
39613961
void InterpreterStackFrame::OP_ProfileCallCommon(const unaligned T * playout, RecyclableObject * function, unsigned flags, ProfileId profileId, InlineCacheIndex inlineCacheIndex, const Js::AuxArray<uint32> *spreadIndices)
39623962
{
3963+
JavascriptFunction * targetFunction = VarIs<JavascriptFunction>(m_outParams[0]) ? UnsafeVarTo<JavascriptFunction>(m_outParams[0]) : nullptr;
39633964
FunctionBody* functionBody = this->m_functionBody;
3964-
DynamicProfileInfo * dynamicProfileInfo = functionBody->GetDynamicProfileInfo();
39653965
FunctionInfo* functionInfo = function->GetTypeId() == TypeIds_Function ?
39663966
VarTo<JavascriptFunction>(function)->GetFunctionInfo() : nullptr;
3967+
DynamicProfileInfo* dynamicProfileInfo = functionBody->GetDynamicProfileInfo();
39673968
bool isConstructorCall = (CallFlags_New & flags) == CallFlags_New;
3968-
dynamicProfileInfo->RecordCallSiteInfo(functionBody, profileId, functionInfo, functionInfo ? static_cast<JavascriptFunction*>(function) : nullptr, playout->ArgCount, isConstructorCall, inlineCacheIndex);
3969-
3970-
JavascriptFunction * targetFunction = VarIs<JavascriptFunction>(m_outParams[0]) ? UnsafeVarTo<JavascriptFunction>(m_outParams[0]) : nullptr;
3971-
3969+
3970+
39723971
OP_CallCommon<T>(playout, function, flags, spreadIndices);
39733972

3973+
3974+
// Profile call site
3975+
3976+
dynamicProfileInfo->RecordCallSiteInfo(functionBody, profileId, functionInfo, functionInfo ? static_cast<JavascriptFunction*>(function) : nullptr, playout->ArgCount, isConstructorCall, inlineCacheIndex);
3977+
39743978
if (functionInfo && !functionInfo->HasBody())
39753979
{
39763980
if ((functionInfo->IsBuiltInApplyFunction() || functionInfo->IsBuiltInCallFunction()) && targetFunction)
39773981
{
3978-
Js::ProfileId * callSiteToCallApplyCallSiteMap = this->m_functionBody->GetCallSiteToCallApplyCallSiteArray();
3982+
Js::ProfileId* callSiteToCallApplyCallSiteMap = this->m_functionBody->GetCallSiteToCallApplyCallSiteArray();
39793983
if (callSiteToCallApplyCallSiteMap)
39803984
{
39813985
Js::ProfileId callApplyCallSiteId = callSiteToCallApplyCallSiteMap[profileId];

test/inlining/profilingbug.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
try {
7+
function f(){}
8+
function foo(){
9+
f.call();
10+
foo.call(0x1)++;
11+
}
12+
foo();
13+
} catch(e) { }
14+
15+
print("Pass")

test/inlining/rlexe.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,11 @@
285285
<files>bug11265991.js</files>
286286
</default>
287287
</test>
288+
<test>
289+
<default>
290+
<files>profilingbug.js</files>
291+
</default>
292+
</test>
288293
<test>
289294
<default>
290295
<files>bug12528802.js</files>

0 commit comments

Comments
 (0)