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

Merged
merged 2 commits into from
Dec 19, 2024

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 force-pushed the ajob410@jstz-193-add-script branch from a694770 to 9106c11 Compare November 27, 2024 17:55
@johnyob johnyob force-pushed the ajob410@jstz-194-add-gcptr branch 2 times, most recently from e911862 to 96d3d75 Compare November 27, 2024 18:03
@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 58.59031% with 94 lines in your changes missing coverage. Please review.

Project coverage is 46.93%. Comparing base (4fd7190) to head (d874eaf).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/jstz_engine/src/gc/ptr.rs 51.96% 61 Missing ⚠️
crates/jstz_engine/src/script.rs 67.00% 32 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
crates/jstz_engine/src/lib.rs 100.00% <ø> (ø)
crates/jstz_engine/src/script.rs 23.42% <67.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 4fd7190...d874eaf. Read the comment docs.

@johnyob johnyob assigned zcabter and unassigned johnyob Nov 27, 2024
@johnyob johnyob force-pushed the ajob410@jstz-193-add-script branch from 9106c11 to 7cbd91a Compare December 11, 2024 14:29
@johnyob johnyob force-pushed the ajob410@jstz-194-add-gcptr branch from 96d3d75 to 94ddd2c Compare December 11, 2024 14:29
crates/jstz_engine/src/gc/ptr.rs Outdated Show resolved Hide resolved
crates/jstz_engine/src/gc/ptr.rs Show resolved Hide resolved
Copy link
Collaborator

@zcabter zcabter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor updates, LGTM otherwise.

@zcabter zcabter assigned johnyob and unassigned zcabter Dec 14, 2024
@johnyob johnyob force-pushed the ajob410@jstz-194-add-gcptr branch from 6a9c971 to d874eaf Compare December 19, 2024 09:52
Base automatically changed from ajob410@jstz-193-add-script to main December 19, 2024 10:02
@johnyob johnyob merged commit 2758a03 into main Dec 19, 2024
3 checks passed
@johnyob johnyob deleted the ajob410@jstz-194-add-gcptr branch December 19, 2024 10:04
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