Skip to content

Commit 7e08c4a

Browse files
committed
Disable auto-profiling interpreter mode for generator (always collect profiling data)
1 parent 55ac99f commit 7e08c4a

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

bin/NativeTests/FunctionExecutionTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ namespace Js
127127
FunctionEntryPointInfo* GetDefaultFunctionEntryPointInfo() { return &defaultInfo; }
128128
FunctionEntryPointInfo *GetSimpleJitEntryPointInfo() { return &simpleInfo; }
129129
void TraceExecutionMode(const char *const eventDescription = nullptr) const { UNREFERENCED_PARAMETER(eventDescription); }
130+
// Dummy implementation to match the real FunctionBody's method
131+
bool SkipAutoProfileForCoroutine() const { return false; }
130132

131133
FunctionBody(bool interpreterProfile, bool interpreterAutoProfile, bool simpleJit):
132134
doInterpreterProfile(interpreterProfile),

lib/Runtime/Base/FunctionBody.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,12 @@ namespace Js
333333
return FALSE;
334334
}
335335

336+
bool
337+
FunctionBody::SkipAutoProfileForCoroutine() const
338+
{
339+
return this->IsCoroutine() && CONFIG_ISENABLED(Js::JitES6GeneratorsFlag);
340+
}
341+
336342
bool
337343
FunctionBody::IsGeneratorAndJitIsDisabled() const
338344
{

lib/Runtime/Base/FunctionBody.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3408,6 +3408,8 @@ namespace Js
34083408
return IsJitLoopBodyPhaseForced() && !this->GetHasTry();
34093409
}
34103410

3411+
bool SkipAutoProfileForCoroutine() const;
3412+
34113413
bool IsGeneratorAndJitIsDisabled() const;
34123414

34133415
FunctionBodyFlags * GetAddressOfFlags() { return &this->flags; }

lib/Runtime/Base/FunctionExecutionStateMachine.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,16 @@ namespace Js
5050

5151
const ConfigFlagsTable &configFlags = Configuration::Global.flags;
5252

53+
// AutoProfilingInterpreter might decide to not profile on the first run. For generator
54+
// functions, that means we will miss the profiling information on the first run when we resume
55+
// back to the function. This might result in lots of BailOnNoProfile even though we should have
56+
// profiling information. So always collect profile data for generators
57+
const bool skipAutoProfileForGenerator = functionBody->SkipAutoProfileForCoroutine();
58+
5359
interpreterLimit = 0;
54-
autoProfilingInterpreter0Limit = static_cast<uint16>(configFlags.AutoProfilingInterpreter0Limit);
60+
autoProfilingInterpreter0Limit = skipAutoProfileForGenerator ? 0 : static_cast<uint16>(configFlags.AutoProfilingInterpreter0Limit);
5561
profilingInterpreter0Limit = static_cast<uint16>(configFlags.ProfilingInterpreter0Limit);
56-
autoProfilingInterpreter1Limit = static_cast<uint16>(configFlags.AutoProfilingInterpreter1Limit);
62+
autoProfilingInterpreter1Limit = skipAutoProfileForGenerator ? 0 : static_cast<uint16>(configFlags.AutoProfilingInterpreter1Limit);
5763
simpleJitLimit = static_cast<uint16>(configFlags.SimpleJitLimit);
5864
profilingInterpreter1Limit = static_cast<uint16>(configFlags.ProfilingInterpreter1Limit);
5965

@@ -105,9 +111,9 @@ namespace Js
105111

106112
uint16 fullJitThresholdConfig =
107113
static_cast<uint16>(
108-
configFlags.AutoProfilingInterpreter0Limit +
114+
(skipAutoProfileForGenerator ? 0 : configFlags.AutoProfilingInterpreter0Limit) +
109115
configFlags.ProfilingInterpreter0Limit +
110-
configFlags.AutoProfilingInterpreter1Limit +
116+
(skipAutoProfileForGenerator ? 0 : configFlags.AutoProfilingInterpreter1Limit) +
111117
configFlags.SimpleJitLimit +
112118
configFlags.ProfilingInterpreter1Limit);
113119
if (!configFlags.EnforceExecutionModeLimits)

0 commit comments

Comments
 (0)