-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instrumenter to observe behavior of nodes with UUID
- Loading branch information
1 parent
7ba1621
commit 99cb39e
Showing
10 changed files
with
572 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
engine/polyglot-api/src/main/java/org/enso/polyglot/debugger/IdExecutionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.enso.polyglot.debugger; | ||
|
||
import com.oracle.truffle.api.CallTarget; | ||
import com.oracle.truffle.api.instrumentation.EventBinding; | ||
import com.oracle.truffle.api.instrumentation.ExecutionEventNodeFactory; | ||
import com.oracle.truffle.api.interop.TruffleObject; | ||
import java.util.UUID; | ||
|
||
public interface IdExecutionService { | ||
String INSTRUMENT_ID = "id-value-extractor"; | ||
|
||
public interface Callbacks { | ||
/** | ||
* Finds out previously computed result for given id. If a result is returned, then the | ||
* execution of given node is skipped and the value is returned back. | ||
* | ||
* @param nodeId identification of the node to be computed | ||
* @return {@code null} should the execution of the node be performed; any other value to skip | ||
* the execution and return the value as a result. | ||
*/ | ||
Object findCachedResult(UUID nodeId); | ||
|
||
/** | ||
* Notifies when an execution of a node is over. | ||
* | ||
* @param nodeId identification of the node to be computed | ||
* @param result the just computed result | ||
* @param isPanic was the result a panic? | ||
* @param nanoElapsedTime how long it took to compute the result? | ||
*/ | ||
void updateCachedResult(UUID nodeId, Object result, boolean isPanic, long nanoElapsedTime); | ||
|
||
/** | ||
* Notification when a returned value is a function. | ||
* | ||
* @param nodeId identification of the node to be computed | ||
* @param result info about function call | ||
* @return {@code null} should the execution of the node be performed; any other value to skip | ||
* the execution and return the value as a result. | ||
*/ | ||
Object onFunctionReturn(UUID nodeId, TruffleObject result); | ||
|
||
/** | ||
* Notification on an exception. | ||
* | ||
* @param e the reported exception | ||
*/ | ||
void onExceptionalCallback(Exception e); | ||
} | ||
|
||
/** | ||
* Attach a new event node factory to observe identified nodes within given function. | ||
* | ||
* @param module module that contains the code | ||
* @param entryCallTarget the call target being observed. | ||
* @param callbacks the interface to receive notifications | ||
* @param timer the execution timer. | ||
* @return a reference to the attached event node factory. | ||
*/ | ||
EventBinding<ExecutionEventNodeFactory> bind( | ||
TruffleObject module, CallTarget entryCallTarget, Callbacks callbacks, Object timer); | ||
} |
Oops, something went wrong.