Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(jstz_engine): implement a write-barriered GC pointer abstraction #661

Open
wants to merge 1 commit into
base: ajob410@jstz-193-add-script
Choose a base branch
from

Conversation

johnyob
Copy link
Collaborator

@johnyob johnyob commented Nov 14, 2024

Context

Problem: SpiderMonkey has an incremental garbage collector that relies on write barriers to maintain a consistency reachability set.

Intuitive view of incremental GC:

  1. Take snapshot of compartment
  2. Mark a bit, get interrupted
  3. Execute some code
  4. Mark a bit again, ...
    ...
  5. Compartment fully marked, do sweeping

However, in step 3, the reachability set of objects may change. Write barriers are a solution to notify the GC when the reachability set might change e.g. on a write to a pointer.

Description

This PR implements GcPtr, a safe write barriered pointer.
Dereferencing the pointer is still unsafe since the caller must guarentee that the object that the
pointer points to is valid.

Manually testing the PR

cargo nextest run --package jstz_engine

@johnyob johnyob self-assigned this Nov 14, 2024
@johnyob johnyob force-pushed the ajob410@jstz-193-add-script branch 3 times, most recently from 0a803c7 to a694770 Compare November 27, 2024 17:34
@johnyob johnyob force-pushed the ajob410@jstz-194-add-gcptr branch 2 times, most recently from f480385 to e660d95 Compare November 27, 2024 17:54
@johnyob johnyob marked this pull request as ready for review November 27, 2024 18:04
@johnyob johnyob requested a review from zcabter November 27, 2024 18:04
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 51.96850% with 61 lines in your changes missing coverage. Please review.

Project coverage is 45.73%. Comparing base (9106c11) to head (96d3d75).

Files with missing lines Patch % Lines
crates/jstz_engine/src/gc/ptr.rs 51.96% 61 Missing ⚠️
Files with missing lines Coverage Δ
crates/jstz_engine/src/lib.rs 100.00% <ø> (ø)
crates/jstz_engine/src/gc/ptr.rs 51.96% <51.96%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9106c11...96d3d75. Read the comment docs.

@johnyob johnyob assigned zcabter and unassigned johnyob Nov 27, 2024
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