Skip to content

[JSC] IsoCellSet::addSlow fences before storing a new bit set - #1075

Merged
dylan-conway merged 1 commit into
mainfrom
isocellset-store-order
Nov 18, 2026
Merged

dylan-conway merged 1 commit into
mainfrom
isocellset-store-order

Conversation

@dylan-conway

@dylan-conway dylan-conway commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

IsoCellSet::addSlow now builds the bit set for a block in a local, calls WTF::storeStoreFence(), and then stores the pointer in m_bits. JSC stores other lazily created members in this order, for example in CodeBlock::createRareDataIfNecessary() and the dynamic subspaces in Heap.cpp. The fence before m_blocksWithBits stays.

Cost

x86-64: no instruction. arm64: one dmb ishst for each new bit set.

Checked

  • arm64 ThinLTO disassembly (clang 23): zeroing stores, dmb ishst, pointer store, dmb ishst, m_blocksWithBits store.
  • x64 jsc with assertions, 7,926 files from JSTests (stress, modules, microbenchmarks) with GC stress options: same results with and without the change, except one file that is flaky on both.
  • arm64 jsc under qemu, 2,500 of those files: same results, except one file that passes on both with --usePollingTraps=1.

None of this ran on arm64 hardware. No test is added, since the change only orders stores.


Generated by Claude Code

Build the bit set in a local, call storeStoreFence(), then store the
pointer, as other lazily created members in JSC are stored.

@claude claude 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.

I reviewed this PR and didn't find any bugs. Because it changes memory ordering on a lock-free GC path in JavaScriptCore heap code, a human look would still be worthwhile.

What was reviewed:

  • The new sequence in addSlow (zero-init -> storeStoreFence -> pointer store -> storeStoreFence -> m_blocksWithBits) against the lock-free readers in IsoCellSetInlines.h (add/remove/contains load m_bits[i] and dereference via address dependency) and sweepToFreeList (loadLoadFence after m_blocksWithBits) — the added fence only strengthens ordering; nothing is reordered weaker.
  • Confirmed the pattern matches CodeBlock::createRareDataIfNecessary (local unique_ptr, storeStoreFence, move-assign).
  • Checked the didRemoveBlock / sweepToFreeList clear paths still run under m_lock, so the move-assign under the same lock cannot race a concurrent reset.
  • No build or test run was done in this review; it was conducted by reading only.
Extended reasoning...

The change is a 4-line edit to IsoCellSet::addSlow in Source/JavaScriptCore/heap/IsoCellSet.cpp that constructs the per-block BitSet in a local, issues a WTF::storeStoreFence, then move-assigns it into m_bits before the pre-existing fence and m_blocksWithBits store. It touches no security-sensitive surface (no injection, auth, or data exposure), only GC-internal memory ordering. The code is correct and strictly tightens ordering, and it mirrors an existing JSC pattern, but it sits on a concurrent GC path that is covered by the repository's CODEOWNERS entry for Source/JavaScriptCore and cannot be exercised by the TSan-free CI lanes, so a human look was preferred over automated approval.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

IsoCellSet::addSlow now stages the bit set in a local owner, saves its raw pointer, executes a store-store fence, and then transfers ownership to bitsPtrRef. The subsequent update to m_blocksWithBits remains unchanged.

Changes

Bit-set publication

Layer / File(s) Summary
Stage and publish bit-set ownership
Source/JavaScriptCore/heap/IsoCellSet.cpp
addSlow now saves the raw pointer and executes the store-store fence before moving ownership into bitsPtrRef. The update to m_blocksWithBits is unchanged.
Merge Risk: Minimal · up to 93e54

This change fixes the order in which a new bit set becomes visible to other threads. It costs nothing on x86-64 and one cheap barrier per new bit set on arm64. No merge-blocking risk is evident.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description states the change clearly: IsoCellSet::addSlow builds the bit set in a local, calls WTF::storeStoreFence(), then stores the pointer in m_bits, with the existing m_blocksWithBits fence … Rewrite the description in the WebKit template format: add the Bugzilla bug title and the show_bug.cgi?id=##### link, add the 'Reviewed by' line (set to NOBODY (OOPS!) until review), keep the explanation of the fix, and add the changed-file…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: IsoCellSet::addSlow now issues a store-store fence before it stores the new bit set pointer. The raw summary confirms this reordering, and the objectives describe the …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: IsoCellSet::addSlow now issues a store-store fence before it stores the new bit set pointer. The raw summary confirms this reordering, and the objectives describe the same change. The title is specific and matches the changeset.

Full details: Description check

Explanation

The description states the change clearly: IsoCellSet::addSlow builds the bit set in a local, calls WTF::storeStoreFence(), then stores the pointer in m_bits, with the existing m_blocksWithBits fence kept. It gives the cost on x86-64 and arm64, the verification done (x64 and arm64/qemu JSTests runs, arm64 disassembly), and why no test was added. It does not follow the WebKit template: it has no bug link (the template requires a Bugzilla bug title and URL), no 'Reviewed by' line, and no changed-files list with function names. The template also asks for the commit-message format. The PR objectives cite PR #1075, but the description itself does not reference a bug ID.

Resolution

Rewrite the description in the WebKit template format: add the Bugzilla bug title and the show_bug.cgi?id=##### link, add the 'Reviewed by' line (set to NOBODY (OOPS!) until review), keep the explanation of the fix, and add the changed-files list with the affected function (IsoCellSet::addSlow). Mention the Bugzilla bug in the PR, since the template requires it. Remove the 'Generated by Claude Code' footer if the repository's commit format does not allow it.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Library detection encountered an error. Review will continue without library-specific context.

The configuration directory could not be loaded. This review used the available YAML and UI settings; directory instructions and checks were not evaluated.

Git: CodeRabbit could not clone the repository, so clone-backed analysis was skipped and this review may be incomplete. Verify repository clone access, such as SSH credentials, before requesting another full review. If clone access is intentionally unavailable, use path_filters to narrow the review scope.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: af9781ad-d81f-4f11-9b7b-ea1bc4bf1521
Commits

Reviewing files that changed from the base of the PR and between f7edf88 and 93e5472.

Files selected for processing: 1

  • Source/JavaScriptCore/heap/IsoCellSet.cpp

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@dylan-conway
dylan-conway merged commit f63f601 into main Nov 18, 2026
81 checks passed
@github-actions

Copy link
Copy Markdown

Preview build of 93e5472: autobuild-preview-pr-1075-93e54724

dylan-conway added a commit to oven-sh/bun that referenced this pull request Nov 18, 2026
### What does this PR do?

Moves `WEBKIT_VERSION` from `a8d825d8a049` to `0befb64c5f30`, the head
of oven-sh/WebKit `main`. The release for that commit is published, with
every asset name of the previous one.

oven-sh/WebKit changes picked up:

- Build lto-hardened-aot-no-webassembly for Linux arm64
(oven-sh/WebKit#1073)
- [JSC] IsoCellSet::addSlow fences before storing a new bit set
(oven-sh/WebKit#1075)
- AOT: fix localeCompare in hardened builds, and generators where loop
polls do not fault (oven-sh/WebKit#1076)

### How did you verify your code works?

A debug build on Linux x64, with WebKit compiled from that commit,
reports it in `process.versions.webkit`. It passes
`webkit-prebuilt-url.test.ts`, `internal-module-blob.test.ts`,
`bun-jsc.test.ts`, `test/js/bun/gc/` and 20 programs of
`test/aot/parallel` that use `localeCompare` or loop over generators.

The prebuilt libraries and hardened builds were not run locally. CI is
their check. No test is added.

---
_Generated by [Claude Code](https://claude.ai/code)_

Co-authored-by: Claude <[email protected]>
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.

2 participants