Skip to content
Snippets Groups Projects
Commit ea436b6e authored by Joe Savona's avatar Joe Savona
Browse files

Update on "[compiler] Effects for Return/MaybeThrow terminals"

Adds explicit freeze effects for Return terminals and, more importantly, adds effects for MaybeThrow terminals. MaybeThrow is super interesting. The idea of the terminal is to represent that control-flow can break from nearly any instruction to the error handler (catch). InferMutableRanges has a pass that explicitly handles the corresponding data flow, saying that for any instruction in a block ending in MaybeThrow, to alias the instruction's lvalue to the catch handler. This is to handle cases like this:

```js
const x = [];
try {
  throwInput(x);
} catch (x_alias) {
  mutate(x_alias); // mutates x!
}
```

One realization is that this logic was overly pessimistic: most instruction types cannot actually throw their lvalue. In fact,  the only things that can throw their lvalue are call expressions! `c = a.b` can throw, for example, but only with an error generated by the runtime, not with a user value.

Doing this allows us to encode the data flow once and then not have to handle wiring up this data again later.

[ghstack-poisoned]
parents 0af33f42 1d211ccc
Showing
No files found.
with 0 additions and 0 deletions
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment