Repository navigation
[wasm-ctor-eval] Keep localExprs on failed eval - #9340
Merged
Merged
Conversation
When evaluating top-level statements in `evalCtor`, local values were previously serialized directly into `localExprs`. If `getSerialization` failed (e.g. because it tried to serialize a continuation), `localExprs` lost the serialized local state from the last successfully evaluated statement. This could leave previously initialized non-nullable locals uninitialized in the partially evaluated function. It could also cause `evalCtor` to spuriously emit `local.set`s overwriting parameters with default values. Serialize locals into a temporary `nextLocalExprs` vector and only move it into `localExprs` once all locals have been serialized.
There was a problem hiding this comment.
Code Review
This pull request updates src/tools/wasm-ctor-eval.cpp to serialize local expressions into a temporary vector first, only updating localExprs once all locals succeed. This prevents partial serialization failures from corrupting the previous state. The changes are accompanied by new test cases in test/lit/ctor-eval/cont-noserial.wast. The review feedback suggests a performance improvement to reserve capacity for the temporary vector upfront to avoid dynamic reallocations.
kripken
approved these changes
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When evaluating top-level statements in
evalCtor, local values were previously serialized directly intolocalExprs. IfgetSerializationfailed (e.g. because it tried to serialize a continuation),localExprslost the serialized local state from the last successfully evaluated statement. This could leave previously initialized non-nullable locals uninitialized in the partially evaluated function. It could also causeevalCtorto spuriously emitlocal.sets overwriting parameters with default values.Serialize locals into a temporary
nextLocalExprsvector and only move it intolocalExprsonce all locals have been serialized.