You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* The {@link ExecutionEventNode} class let's us define several events
291
+
* that we can intercept. The one of interest to us is {@link ExecutionEventNode#onReturnValue(com.oracle.truffle.api.frame.VirtualFrame, java.lang.Object)
292
+
* } as we wish to remove this nodes {@link #instrumentedSourceSection}
293
+
* from the {@link #sourceToUncoveredSections set of uncovered nodes}
294
+
* only once the node is successfully executed (as oppose to, for
295
+
* example, {@link ExecutionEventNode#onReturnExceptional(com.oracle.truffle.api.frame.VirtualFrame, java.lang.Throwable)
296
+
* }).
297
+
*
298
+
* Each node keeps a {@link #covered} flag so that the removal only
299
+
* happens once. The fact that the flag is annotated with
300
+
* {@link CompilationFinal} means that this flag will be treated as
301
+
* {@code final} during compilation of instrumented source code (i.e.
302
+
* the {@code false} branch of the if statement can be optimized away).
303
+
*
304
+
* The way it's used in this method is a pattern when writing Truffle
305
+
* nodes:
306
+
* <ul>
307
+
* <li> If we are compiling a covered node, the if condition will
308
+
* evaluate to false and the if-guarded code will be optimized away.
309
+
* This means that once this {@link SourceSection} is confirmed to be
310
+
* covered, there is no further instrumentation overhead on performance.
311
+
* <li> If we are compiling a not-yet-covered node, the if condition
312
+
* will evaluate to true, and the if-guarded code will be included for
313
+
* compilation. The first statement in this block is a
314
+
* {@link CompilerDirectives#transferToInterpreterAndInvalidate() directive to the compiler}
315
+
* to make sure that if this point in the execution is reached, the
316
+
* execution should return to the interpreter and the existing compiled
317
+
* code is no longer valid (since once the covered flag is set to true,
318
+
* the check is unnecessary). The code following the directive is thus
319
+
* always executed in the interpreter: We set the {@link #covered} flag
320
+
* to true, ensuring that the next compilation will have no
0 commit comments