Skip to content

docs(gc): document boa_gc API surface used by the engine#38

Open
mrhapile wants to merge 2 commits intoboa-dev:mainfrom
mrhapile:docs/gc-api-surface
Open

docs(gc): document boa_gc API surface used by the engine#38
mrhapile wants to merge 2 commits intoboa-dev:mainfrom
mrhapile:docs/gc-api-surface

Conversation

@mrhapile
Copy link
Contributor

@mrhapile mrhapile commented Mar 6, 2026

This PR documents the subset of the boa_gc API that the Boa engine
currently depends on.

ref - #27

Understanding the exact API surface used by the engine is important for:

  • future GC improvements
  • experimentation with alternative collectors
  • maintaining compatibility between the engine and the collector

The document describes pointer types, tracing traits, weak references,
interior mutability primitives, and runtime utilities relied upon by
the engine.

The goal is to provide a clear compatibility contract for any garbage
collector implementation that aims to replace boa_gc.

The document deliberately avoids internal implementation details (heap vectors, Box allocation, mark-stack internals) and focuses exclusively on the engine → GC interface boundary, making it suitable for inclusion in repository documentation.

Copilot AI review requested due to automatic review settings March 6, 2026 20:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds repository documentation that defines the Boa engine’s boa_gc dependency contract, capturing the specific public API surface that a replacement collector would need to support.

Changes:

  • Adds docs/boa_gc_api_surface.md describing the engine-facing boa_gc pointer types, traits, weak references/collections, macros, and runtime utilities.
  • Adds a small mark-sweep test that smoke-tests creating an oscars WeakGc from a strong Gc.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
oscars/src/collectors/mark_sweep/tests.rs Adds a minimal WeakGc creation smoke test for the mark-sweep collector.
docs/boa_gc_api_surface.md New documentation describing the intended boa_gc API compatibility contract used by the Boa engine.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +34 to +40
```rust
// Allocate a new GC-managed value.
Gc::new(value: T) -> Gc<T>

// Allocate a value that may reference itself through a weak pointer.
Gc::new_cyclic<F>(data_fn: F) -> Gc<T>
where F: FnOnce(&WeakGc<T>) -> T
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The fenced snippet is labeled as ```rust but uses pseudo-signatures (e.g., Gc::new(value: T) -> Gc<T>), which isn’t valid Rust syntax. Consider rewriting these as valid Rust items (`pub fn ...`) or changing the fence to `text`/`rust,ignore` so it’s clear the snippet is illustrative.

Copilot uses AI. Check for mistakes.
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