Просмотр исходного кода

More comments related to ExecutionMode transition

Thomas Moore 8 лет назад
Родитель
Сommit
a6f4bbcd1f

+ 7 - 0
lib/Runtime/Base/FunctionBody.cpp

@@ -6750,6 +6750,7 @@ namespace Js
     //       |      v
     //       +-> FullJit
     //
+    // Transition to the next mode occurs when the limit for the current execution mode reaches 0.
     // Returns true when a transition occurs (i.e., the execution mode was updated since the beginning of
     // this function call). Otherwise, returns false to indicate no change in state.
     // See more details of each mode in ExecutionModes.h
@@ -6781,6 +6782,9 @@ namespace Js
 
             case ExecutionMode::AutoProfilingInterpreter:
             {
+                // autoProfilingInterpreter0Limit is the default limit for this mode
+                // autoProfilingInterpreter1Limit becomes the limit for this mode when this FunctionBody has
+                // already previously run in ProfilingInterpreter and AutoProfilingInterpreter
                 uint16 &autoProfilingInterpreterLimit =
                     autoProfilingInterpreter0Limit == 0 && profilingInterpreter0Limit == 0
                         ? autoProfilingInterpreter1Limit
@@ -6814,6 +6818,9 @@ namespace Js
 
             case ExecutionMode::ProfilingInterpreter:
             {
+                // profilingInterpreter0Limit is the default limit for this mode
+                // profilingInterpreter1Limit becomes the limit for this mode when this FunctionBody has already
+                // previously run in ProfilingInterpreter, AutoProfilingInterpreter, and SimpleJIT
                 uint16 &profilingInterpreterLimit =
                     profilingInterpreter0Limit == 0 && autoProfilingInterpreter1Limit == 0 && simpleJitLimit == 0
                         ? profilingInterpreter1Limit

+ 17 - 3
lib/Runtime/Base/FunctionBody.h

@@ -2362,20 +2362,34 @@ namespace Js
 
         FieldWithBarrier(byte) inlineDepth; // Used by inlining to avoid recursively inlining functions excessively
 
+        // Tracks the current execution mode. See ExecutionModes.h for more info.
         FieldWithBarrier(ExecutionMode) executionMode;
+
+        // Each of the following limits below is decremented when transitioning from its related mode:
+        // Number of times to run interpreter (no profiling) before advancing to next mode
         FieldWithBarrier(uint16) interpreterLimit;
+        // Number of times to run interpreter (min profiling) before advancing to next mode
         FieldWithBarrier(uint16) autoProfilingInterpreter0Limit;
+        // Number of times to run interpreter (full profiling) before advancing to next mode
         FieldWithBarrier(uint16) profilingInterpreter0Limit;
+        // Number of times to run interpreter (min profiling) after already running min and full profiling
         FieldWithBarrier(uint16) autoProfilingInterpreter1Limit;
+        // Number of times to run simple JIT before advancing to next mode
         FieldWithBarrier(uint16) simpleJitLimit;
+        // Number of times to run interpreter (full profiling) before advancing to next mode
         FieldWithBarrier(uint16) profilingInterpreter1Limit;
+
+        // Total limit to run in non-full JIT execution mode. Typically the sum of the other limits
         FieldWithBarrier(uint16) fullJitThreshold;
+        // Number of attempts to schedule FullJIT until it becomes forced
         FieldWithBarrier(uint16) fullJitRequeueThreshold;
+        // Total number of times this function has run under the interpreter with full profiling
         FieldWithBarrier(uint16) committedProfiledIterations;
-
-        FieldWithBarrier(uint) m_depth; // Indicates how many times the function has been entered (so increases by one on each recursive call, decreases by one when we're done)
-
+        // Indicates how many times the function has been entered (so increases by one on each recursive call, decreases by one when we're done)
+        FieldWithBarrier(uint) m_depth;
+        // Number of times this function has run under the interpreter in the current execution mode
         FieldWithBarrier(uint32) interpretedCount;
+        // Used to detect when interpretedCount changed from a particular call
         FieldWithBarrier(uint32) lastInterpretedCount;
         FieldWithBarrier(uint32) loopInterpreterLimit;
         FieldWithBarrier(uint32) debuggerScopeIndex;

+ 1 - 1
lib/Runtime/Language/ExecutionModes.h

@@ -5,7 +5,7 @@
 
 // Non-profiling interpreter
 //     - For instance, it is used for NoNative mode
-//     - Does not transition to other execution modes
+//     - Can only transition to FullJIT
 EXECUTION_MODE(Interpreter)
 
 // Auto-profiling interpreter