Skip to content

[wasm-ctor-eval] Keep localExprs on failed eval - #9340

Merged
tlively merged 2 commits into
mainfrom
ctor-eval-partial-local-serialization
Nov 3, 2026
Merged

tlively merged 2 commits into
mainfrom
ctor-eval-partial-local-serialization

Conversation

@tlively

@tlively tlively commented Nov 3, 2026

Copy link
Copy Markdown
Member

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.sets overwriting parameters with default values.

Serialize locals into a temporary nextLocalExprs vector and only move it into localExprs once all locals have been serialized.

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.
@tlively
tlively requested a review from a team as a code owner November 3, 2026 00:03
@tlively
tlively requested a review from kripken November 3, 2026 00:03

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/tools/wasm-ctor-eval.cpp Resolved
@tlively
tlively merged commit 6acb26e into main Nov 3, 2026
18 checks passed
@tlively
tlively deleted the ctor-eval-partial-local-serialization branch November 3, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants