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

Optimize (WasmRoot|WasmExternalRoot).clear #77521

Merged
merged 3 commits into from
Nov 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/mono/wasm/runtime/roots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,10 @@ class WasmJsOwnedRoot<T extends MonoObject> implements WasmRoot<T> {
}

clear(): void {
this.set(<any>0);
// .set performs an expensive write barrier, and that is not necessary in most cases
// for clear since clearing a root cannot cause new objects to survive a GC
const address32 = this.__buffer.get_address_32(this.__index);
Module.HEAPU32[address32] = 0;
}

release(): void {
Expand Down Expand Up @@ -420,7 +423,9 @@ class WasmExternalRoot<T extends MonoObject> implements WasmRoot<T> {
}

clear(): void {
this.set(<any>0);
// .set performs an expensive write barrier, and that is not necessary in most cases
// for clear since clearing a root cannot cause new objects to survive a GC
Module.HEAPU32[<any>this.__external_address >>> 2] = 0;
}

release(): void {
Expand All @@ -432,4 +437,4 @@ class WasmExternalRoot<T extends MonoObject> implements WasmRoot<T> {
toString(): string {
return `[external root @${this.address}]`;
}
}
}