Track nested meta-tracing states. #1582
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously we -- well, this one is entirely my fault, so "I"! -- tracked per-thread meta-tracing state as a single
MTThreadState
that we updates as necessary. This doesn't work when we have nested execution, tracing and the like, as the bug in #1571 highlighted.This commit moves us to a stack of
MTThreadState
s. The basic idea is that the stack always has at least one element:Interpreting
. As we go through other states, we push / pop as appropriate. The test below (from Edd and Lukas) fails onmaster
but is fixed by this commit.The implementation is a bit more awkward than one might hope as naive implementations either:
This commit gets around this in two phases:
MTThread
which can peek at the currentMTThreadState
(which isn'tCopy
!).This is a bit awkward, and perhaps there's a better API, but this one is at least safe.
Fixes #1571.