Skip to content

refactor: make Trace an unsafe trait for boa_engine compatibility#93

Open
shruti2522 wants to merge 1 commit into
boa-dev:mainfrom
shruti2522:unsafe
Open

refactor: make Trace an unsafe trait for boa_engine compatibility#93
shruti2522 wants to merge 1 commit into
boa-dev:mainfrom
shruti2522:unsafe

Conversation

@shruti2522

Copy link
Copy Markdown
Contributor

updated the Trace trait in both null_collector_branded and mark_sweep_branded to be an unsafe trait so we can
integrate it into boa_engine

my initial thought was to keep it a safe trait, but doing so broke the engine's closure type inference. Trace must be an unsafe trait, because if an implementor forgets to trace a GC pointer, it causes a UAF bug that the compiler can't catch.

I also changed the method signature from trace(&mut self) to trace(&self). This is necessary because gc objects frequently form reference cycles.

  • changed fn trace(&mut self) to unsafe fn trace(&self)
  • upgraded all impl Trace blocks to unsafe impl Trace
  • updated bounds to accept ?Sized types, added an as_ptr() helper to Gc

this ensures oscars is compatible with boa_engine, allowing to drop it in as a backend without changing any core engine code

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