From 43e487188b016d60b54421afdd751e4ac1ff0e5c Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Thu, 5 Jun 2025 14:17:19 -0700 Subject: [PATCH] Update base for 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]