Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Directly use FunctionBuilder when we do not need WasmExpressionBuilder. #124

Merged
merged 3 commits into from
May 14, 2024

Conversation

sjrd
Copy link
Collaborator

@sjrd sjrd commented May 10, 2024

This way, we use WasmFunctionContext+WasmExpressionContext only when we need to translate user-defined IR trees. In that case, the WasmFunctionContext is responsible for local name management: encoding from IR local names and generation of synthetic local names.

Otherwise, when we generate Wasm code independent of IR trees, we directly use FunctionBuilder. Local name management is left to the user code.

sjrd added 2 commits May 10, 2024 08:55
In addition to the likely performance benefit, it allows us to use
them in constant expressions, without support for the expression
builder. We use that opportunity when creating the field values in
`newDefault` functions, like we already did for static fields.
Before, we created synthetic IR trees that we sent to the expression
builder. Now, we instead directly emit the appropriate Wasm
instructions.

This adds a bit of duplication of logic on how arrays are built,
but it removes the direct dependency of the `Emitter` on
`WasmExpressionBuilder`.
This way, we use `WasmFunctionContext`+`WasmExpressionContext` only
when we need to translate user-defined IR trees. In that case, the
`WasmFunctionContext` is responsible for local name management:
encoding from IR local names and generation of synthetic local names.

Otherwise, when we generate Wasm code independent of IR trees, we
directly use `FunctionBuilder`. Local name management is left to
the user code.
@sjrd sjrd force-pushed the use-function-builder-when-we-can branch from 7d371bd to dab625a Compare May 11, 2024 11:10
@sjrd sjrd mentioned this pull request May 11, 2024
@tanishiking tanishiking merged commit 71e51cd into tanishiking:main May 14, 2024
1 check passed
@sjrd sjrd deleted the use-function-builder-when-we-can branch May 14, 2024 07:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants