Skip to content

fix(jsc): detect usable AVX on Darwin x64 - #36

Merged
steipete merged 1 commit into
openclaw:sync/replay-5e3554fa-nativefrom
steipete:fix/darwin-x64-avx-detection
Oct 25, 2026
Merged

steipete merged 1 commit into
openclaw:sync/replay-5e3554fa-nativefrom
steipete:fix/darwin-x64-avx-detection

Conversation

@steipete

Copy link
Copy Markdown

Refs openclaw/openclaw#181032 and openclaw/openclaw#181123.

Darwin x64 assumes AVX is available and always selects a VEX-encoded probe trampoline. On macOS 14.8.9 under Rosetta, CPUID reports no AVX/OSXSAVE and XCR0 is zero, but the unpatched engine reports AVX available. Published Bun 807211511f (OpenClaw’s pin during verification) exits with SIGILL at vmovq %rax, %xmm0, followed by vsqrtsd, in the specialized sqrt thunk.

Use the existing CPUID + OSXSAVE + XCR0 XMM/YMM-state checks on Darwin, gate AVX2 on usable AVX and its leaf-7 feature bit, and select the existing SSE probe trampoline when AVX is absent. All JIT tiers remain enabled. Upstream WebKit main at 29f79271764c9175cbfbce28a6b99348d5e2c394 still has the Darwin assumption, so there was no upstream fix to port.

Proof Result
Published baseline on macOS 14.8.9 / Rosetta Signed Bun 807211511f, executable SHA-256 2025e02c7a28a41f1fee69f6a16c7af8c01da796532f870e949721e66a0c3403, exits 132. LLDB captures the faulting VEX instructions. Debug-enabled copy and original have identical executable-text SHA-256 e0301e2c0c60c91a92fa727edb2f7af996e76ddc8a184e730c42c20bc5f7ba10.
Patched engine on the same host AVX=0/AVX2=0; startup and numeric/regexp smoke pass in default and eager FTL modes, with FTL compilation evidence. Checksum 109117749.261702.
Release x64 JSC stress subset 1,847/1,847 PASS, 16 child processes, --no-retry, authoritative results checked. Required fixture variant counts: 17/17/17/17/1.
FFI and assembler 1,509,853 FFI checks, zero failed. Probe, comparison, double-move, and integer-to-double subsets: 7/12/98/4 tests passed.
Matched x64 Bun Release-harness source 7f836a97af610dd0e949e49658156321430fd4bd, linked to this engine: startup, JIT-heavy smoke and libc FFI pass under Rosetta. Engine version verified. Executable SHA-256 decf67b14739579af369edef3c2894bec52f41ed107d46067a024da52d303746; macOS minimum 13.0.
Native AVX x64 control Linux x86_64, AVX=1/AVX2=1; emitted sqrt bytes c5 fb 51 c0 (vsqrtsd) in both variants. Ten interleaved pairs, one warmup per variant, CPU-affined numerical JIT benchmark: median candidate/baseline 0.999995652, gate ≤1.02, all checksums match. Baseline/candidate MacroAssembler objects and JSC executables are byte-identical; preprocessed text differs only by one blank line.
Review Two independent Codex reviews of the final translation unit and diff are scoped-clean through P2.

The engine build incrementally replaces this translation unit in the released 419b5a0470fc059a610e98697691bf6f7cedd841 ThinLTO archives and relinks the native proof tools. Its Source, stress harness and build recipe are identical to replay base 3ab47948f3. The replacement object uses LLVM 23.1.4; native tool compilation, linking and the matched Bun build use LLVM 23.1.1. SDK metadata warnings from the released archives are retained in the proof logs. The Mac test build uses the repository's existing Darwin cross-link options with ld64.lld and an explicit x64/macOS 13 target.

Release-note context: restore Bun/JSC compatibility with supported x64 macOS CPUs that lack AVX. Thanks to @MacOSX4ever for the original report. The app supervisor change in openclaw/openclaw#181123 only mitigates repeated restarts; this addresses the engine's instruction selection.

Use CPUID and OSXSAVE/XCR0 checks on Darwin, with the existing SSE probe trampoline when AVX is unavailable. Gate AVX2 on usable AVX and its CPUID feature bit.

Refs openclaw/openclaw#181032.
@steipete
steipete marked this pull request as ready for review October 25, 2026 03:06
@steipete
steipete merged commit 27c7030 into openclaw:sync/replay-5e3554fa-native Oct 25, 2026
7 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-25T03:15:23.045782Z
We couldn’t complete this review. Comment @codex review to try again.
d16407b Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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