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
Rewrite StackNesting to be a non-iterative single-pass algorithm.
The previous algorithm was doing an iterative forward data flow
analysis followed by a reverse data flow analysis. I suspect the
history here is that it was a reverse analysis, and that didn't
really work for infinite loops, and so complexity kindof accumulated.
The new algorithm is quite straightforward and relies on the
allocations being properly jointly post-dominated, just not nested.
We simply walk forward through the blocks in consistent-with-dominance
order, maintaining the stack of active allocations and deferring
deallocations that are improperly nested until we deallocate the
allocations above it.
The reason I'm doing this, besides it just being a simpler, faster
algorithm, is that modeling some of the uses of the async stack
allocator properly requires builtins that cannot just be semantically
reordered. That should be somewhat easier to handle with the new
approach, although really (1) we should not have runtime functions
that need this and (2) we're going to need a conservatively-correct
solution that's different from this anyway because hoisting
allocations is *also* limited in its own way.
The test cases that changed are... I don't think the new output
is wrong under the current rules that are being enforced, but
really we should be enforcing different rules, because it's not
really okay to have broken stack nesting in blocks just because
they don't lead to an exit. But it's broken coming into
StackNesting, and I don't think the rewrite actually makes it
worse, so...
The thing that concerns me most about the rewritten pass is that
it isn't actually validating joint post-dominance on input, so
if you give it bad input, it might be a little mystifying to
debug the verifier failures.
0 commit comments