Skip to content

Fixes #398: Apple Clang Optimization Breaking Bytecode Mapping - #469

Closed
M-SE0K wants to merge 3 commits into
Samsung:mainfrom
M-SE0K:main
Closed

Fixes #398: Apple Clang Optimization Breaking Bytecode Mapping #469
M-SE0K wants to merge 3 commits into
Samsung:mainfrom
M-SE0K:main

Conversation

@M-SE0K

@M-SE0K M-SE0K commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Problem

| #398

When built on macOS (Apple Clang), the opcode labels of the computed goto interpreter are merged into a single address by tail merging. ByteCode::opcode() performs a reverse address → opcode lookup through m_addressToOpcodeTable, so once merging occurs, different opcodes end up sharing the same address, which corrupts this table and makes it return the wrong opcode.

Fix

  • Insert an __asm__ volatile barrier after each opcode label so that the labels are not merged even when their bodies are identical. (Since an extra label is introduced, -Wno-unused-label is added as well.)
  • Remove the existing workaround that intentionally reversed the field order in MoveFloat and others for the same purpose, restoring src/dst to their original order.
  • Assert m_addressToOpcodeTable.size() == OpcodeKindEnd at initialization time so that any recurrence of the merging is detected immediately.

Benchmark Results

aarch64 macOS, test/wasmBenchmarker, average of 10 runs for each of 31 benchmarks (unit: seconds)

  • tools/run-tests.py
Before After Ratio
Interpreter 4.536 4.406 0.971
JIT 0.363 0.364 1.005

M-SE0K added 3 commits August 8, 2026 17:43
Signed-off-by: M-SE0K <seg082911@gmail.com>
Signed-off-by: M-SE0K <seg082911@gmail.com>
Signed-off-by: M-SE0K <seg082911@gmail.com>
@M-SE0K M-SE0K closed this Aug 11, 2026
@M-SE0K

M-SE0K commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Closed in favor of PR #472. Reopened in a new PR to fix a few test failures I initially missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant