Skip to content

Commit

Permalink
Document expression and statement callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjordan committed Jul 13, 2020
1 parent aa9be8d commit 08628be
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Difference.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ this.newSource = function (name, source) {
Examples can be found:
[1](https://github.com/Haiyang-Sun/nodeprof.js/blob/master/src/ch.usi.inf.nodeprof/js/analysis/extra-features/extra.js), [2](https://github.com/Haiyang-Sun/nodeprof.js/blob/master/src/ch.usi.inf.nodeprof/js/analysis/builtin-feature/analysis.js)

#### Expressions and Statements (endExpression replacement)
NodeProf adds the following callbacks in favor of `endExpression`:

```
this.startExpression = function (iid, type) {
};
this.endExpression = function (iid, type) {
};
this.startStatement = function (iid, type) {
};
this.endStatement = function (iid, type) {
};
```

Note that the callback behavior may depend on Graal.js internals and NodeProf
cannot guarantee that type values will remain stable over time. Analyses
relying on these callbacks should be defensive and check that their behavior
and `type` values are consistent with expectations.


#### Source selection (selective instrumentation)

NodeProf supports selecting source files for instrumentation if their name is matched by a string
Expand Down Expand Up @@ -83,8 +103,6 @@ Jalangi can change the return value of an event by returning a specific object,

- ``` this._with = function (iid, val) ```

- ``` this.endExpression = function (iid) ```

- ``` this.onReady = function (cb) ```

#### Discarded callbacks due to the difference in instrumentation:
Expand Down
26 changes: 26 additions & 0 deletions src/ch.usi.inf.nodeprof/js/analysis/trivial/emptyTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,32 @@
this.declare = function (iid, name, type, kind) {
};

/**
* Callbacks triggered before and after an expression.
* Note that callback behavior may depend on Graal.js internals and NodeProf cannot guarantee that type values will
* remain stable over time.
*
* @param iid {integer} source code location id
* @param type {string} Graal.js internal AST type of the expression
**/
this.startExpression = function (iid, type) {
};
this.endExpression = function (iid, type) {
};

/**
* Callbacks triggered before and after a statement.
* Note that callback behavior may depend on Graal.js internals and NodeProf cannot guarantee that type values will
* remain stable over time.
*
* @param iid {integer} source code location id
* @param type {string} Graal.js internal AST type of the stamenent
**/
this.startStatement = function (iid, type) {
};
this.endStatement = function (iid, type) {
};

/**
* forin or forof support
* the object being iterated can be known by checking the last expression's result (via endExpression)
Expand Down

0 comments on commit 08628be

Please sign in to comment.