Skip to content

Commit b03c759

Browse files
committed
don't record call site info until call completes
1 parent 4ed51ed commit b03c759

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

lib/Runtime/Language/InterpreterStackFrame.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3958,22 +3958,26 @@ namespace Js
39583958
template <class T>
39593959
void InterpreterStackFrame::OP_ProfileCallCommon(const unaligned T * playout, RecyclableObject * function, unsigned flags, ProfileId profileId, InlineCacheIndex inlineCacheIndex, const Js::AuxArray<uint32> *spreadIndices)
39603960
{
3961+
JavascriptFunction * targetFunction = VarIs<JavascriptFunction>(m_outParams[0]) ? UnsafeVarTo<JavascriptFunction>(m_outParams[0]) : nullptr;
39613962
FunctionBody* functionBody = this->m_functionBody;
3962-
DynamicProfileInfo * dynamicProfileInfo = functionBody->GetDynamicProfileInfo();
39633963
FunctionInfo* functionInfo = function->GetTypeId() == TypeIds_Function ?
39643964
VarTo<JavascriptFunction>(function)->GetFunctionInfo() : nullptr;
3965+
DynamicProfileInfo* dynamicProfileInfo = functionBody->GetDynamicProfileInfo();
39653966
bool isConstructorCall = (CallFlags_New & flags) == CallFlags_New;
3966-
dynamicProfileInfo->RecordCallSiteInfo(functionBody, profileId, functionInfo, functionInfo ? static_cast<JavascriptFunction*>(function) : nullptr, playout->ArgCount, isConstructorCall, inlineCacheIndex);
3967-
3968-
JavascriptFunction * targetFunction = VarIs<JavascriptFunction>(m_outParams[0]) ? UnsafeVarTo<JavascriptFunction>(m_outParams[0]) : nullptr;
3969-
3967+
3968+
39703969
OP_CallCommon<T>(playout, function, flags, spreadIndices);
39713970

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

test/inlining/profilingbug.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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) { }

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)