[wasmparser] add atomic validator feature #2429
Open
+272
−18
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.
This PR adds an
atomicfeature to the validator, exposing aFuncValidator::atomic_opfunction that tries to validate an operator and leaves the validator unchanged if the operator is invalid.The feature adds a "rollback log" to the OperatorValidator; the log keeps track of any information destroyed during validation of the operator, so that the validator can be rolled back to its initial state if the operator turns out to be invalid. I tried to make this basically performance-neutral for anybody who doesn't need this. The rollback log is only present if the
atomicfeature is enabled, and it's only used ifatomic_opis being used (i.e. the visit functions andFuncValidator::opdon't use it).We're using this as part of a Wasm development/teaching environment where we'd like the validator to be in a predictable state after an invalid operator.