Skip to content

Commit 1d68ae3

Browse files
author
Thomas Moore (CHAKRA)
committed
[MERGE #5515 @thomasmo] Add more debug fields to FunctionExecutionStateMachine
Merge pull request #5515 from thomasmo:simplejit_debug_110 Adding some temporary flags to help with debugging in automation
2 parents 1906b50 + 44e9b27 commit 1d68ae3

File tree

6 files changed

+48
-2
lines changed

6 files changed

+48
-2
lines changed

bin/NativeTests/FunctionExecutionTest.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ namespace Js
109109
static size_t Print(const char16 *form, ...) { UNREFERENCED_PARAMETER(form); return 0; }
110110
};
111111

112+
enum DebuggerMode : unsigned int
113+
{
114+
NotDebugging
115+
};
116+
112117
class FunctionBody
113118
{
114119
public:
@@ -118,6 +123,7 @@ namespace Js
118123
uint GetByteCodeCount() const { return 0; }
119124
uint GetByteCodeInLoopCount() const { return 0; }
120125
uint GetByteCodeWithoutLDACount() const { return 0; }
126+
Js::DebuggerMode GetDebuggerMode() { return (Js::DebuggerMode)0; }
121127
FunctionEntryPointInfo* GetDefaultFunctionEntryPointInfo() { return &defaultInfo; }
122128
FunctionEntryPointInfo *GetSimpleJitEntryPointInfo() { return &simpleInfo; }
123129
void TraceExecutionMode(const char *const eventDescription = nullptr) const { UNREFERENCED_PARAMETER(eventDescription); }

lib/Runtime/Base/FunctionBody.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9607,6 +9607,13 @@ namespace Js
96079607
{
96089608
return m_hasFirstTmpRegister ? this->GetCountField(CounterFields::FirstTmpRegister) : Constants::NoRegister;
96099609
}
9610+
9611+
#if DBG && defined(ENABLE_SCRIPT_DEBUGGING)
9612+
Js::DebuggerMode FunctionBody::GetDebuggerMode()
9613+
{
9614+
return this->GetScriptContext()->GetDebugContext()->GetDebuggerMode();
9615+
}
9616+
#endif
96109617
}
96119618

96129619
#if !DBG

lib/Runtime/Base/FunctionBody.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,6 +2470,9 @@ namespace Js
24702470
public:
24712471
#if DBG
24722472
int GetProfileSession() { return m_iProfileSession; }
2473+
#ifdef ENABLE_SCRIPT_DEBUGGING
2474+
Js::DebuggerMode GetDebuggerMode();
2475+
#endif
24732476
#endif
24742477
virtual void Finalize(bool isShutdown) override;
24752478
virtual void OnMark() override;

lib/Runtime/Base/FunctionExecutionStateMachine.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,25 @@ namespace Js
2424
lastInterpretedCount(0)
2525
#if DBG
2626
,initializedExecutionModeAndLimits(false)
27+
,hasBeenReinitialized(false)
28+
#ifdef ENABLE_SCRIPT_DEBUGGING
29+
,initDebuggerMode(DebuggerMode::NotDebugging)
30+
,reinitDebuggerMode(DebuggerMode::NotDebugging)
31+
#endif
2732
#endif
2833
{
2934
}
3035

3136
void FunctionExecutionStateMachine::InitializeExecutionModeAndLimits(FunctionBody* functionBody)
3237
{
3338
#if DBG
34-
initializedExecutionModeAndLimits = true;
39+
#ifdef ENABLE_SCRIPT_DEBUGGING
40+
if (!initializedExecutionModeAndLimits)
41+
{
42+
initDebuggerMode = functionBody->GetDebuggerMode();
43+
}
44+
#endif
45+
initializedExecutionModeAndLimits = true;
3546
#endif
3647
// Assert we're either uninitialized, or being reinitialized on the same FunctionBody
3748
Assert(owner == nullptr || owner == functionBody);
@@ -151,6 +162,12 @@ namespace Js
151162

152163
void FunctionExecutionStateMachine::ReinitializeExecutionModeAndLimits(FunctionBody* functionBody)
153164
{
165+
#if DBG
166+
hasBeenReinitialized = true;
167+
#ifdef ENABLE_SCRIPT_DEBUGGING
168+
reinitDebuggerMode = functionBody->GetDebuggerMode();
169+
#endif
170+
#endif
154171
// TODO: Investigate what it would take to make this invariant hold. Currently fails in AsmJS tests
155172
// Assert(initializedExecutionModeAndLimits);
156173

lib/Runtime/Base/FunctionExecutionStateMachine.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
namespace Js
88
{
9+
#if DBG && defined(ENABLE_SCRIPT_DEBUGGING)
10+
enum DebuggerMode : unsigned int;
11+
#endif
12+
913
class FunctionExecutionStateMachine
1014
{
1115
public:
@@ -113,6 +117,12 @@ namespace Js
113117

114118
#if DBG
115119
FieldWithBarrier(bool) initializedExecutionModeAndLimits;
120+
// Temporary debug flags for automation
121+
FieldWithBarrier(bool) hasBeenReinitialized;
122+
#ifdef ENABLE_SCRIPT_DEBUGGING
123+
FieldWithBarrier(Js::DebuggerMode) initDebuggerMode;
124+
FieldWithBarrier(Js::DebuggerMode) reinitDebuggerMode;
125+
#endif
116126
#endif
117127
};
118128
};

lib/Runtime/Debug/DebugContext.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class HostDebugContext
2424
namespace Js
2525
{
2626
// Represents the different modes that the debugger can be placed into.
27-
enum DebuggerMode
27+
enum DebuggerMode : unsigned int
2828
{
2929
// The debugger is not running so the engine can be running
3030
// in JITed mode.
@@ -53,6 +53,9 @@ namespace Js
5353
void SetHostDebugContext(HostDebugContext * hostDebugContext);
5454

5555
void SetDebuggerMode(DebuggerMode mode);
56+
#if DBG
57+
DebuggerMode GetDebuggerMode() const { return this->debuggerMode; }
58+
#endif
5659

5760
bool IsDebugContextInNonDebugMode() const { return this->debuggerMode == DebuggerMode::NotDebugging; }
5861
bool IsDebugContextInDebugMode() const { return this->debuggerMode == DebuggerMode::Debugging; }

0 commit comments

Comments
 (0)