Skip to content

Commit 7defc63

Browse files
Revert GC enable/disable interface
1 parent 0fd7c12 commit 7defc63

File tree

7 files changed

+7
-42
lines changed

7 files changed

+7
-42
lines changed

ext/witapi/bindgen/rb-abi-guest.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,3 @@ __attribute__((export_name("rb-vm-bugreport: func() -> ()")))
205205
void __wasm_export_rb_abi_guest_rb_vm_bugreport(void) {
206206
rb_abi_guest_rb_vm_bugreport();
207207
}
208-
__attribute__((export_name("rb-gc-enable: func() -> bool")))
209-
int32_t __wasm_export_rb_abi_guest_rb_gc_enable(void) {
210-
bool ret = rb_abi_guest_rb_gc_enable();
211-
return ret;
212-
}
213-
__attribute__((export_name("rb-gc-disable: func() -> bool")))
214-
int32_t __wasm_export_rb_abi_guest_rb_gc_disable(void) {
215-
bool ret = rb_abi_guest_rb_gc_disable();
216-
return ret;
217-
}

ext/witapi/bindgen/rb-abi-guest.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ extern "C"
6868
void rb_abi_guest_rb_clear_errinfo(void);
6969
void rb_abi_guest_rstring_ptr(rb_abi_guest_rb_abi_value_t value, rb_abi_guest_string_t *ret0);
7070
void rb_abi_guest_rb_vm_bugreport(void);
71-
bool rb_abi_guest_rb_gc_enable(void);
72-
bool rb_abi_guest_rb_gc_disable(void);
7371
#ifdef __cplusplus
7472
}
7573
#endif

ext/witapi/bindgen/rb-abi-guest.wit

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,3 @@ rb-clear-errinfo: func()
1818
rstring-ptr: func(value: rb-abi-value) -> string
1919

2020
rb-vm-bugreport: func()
21-
22-
rb-gc-enable: func() -> bool
23-
rb-gc-disable: func() -> bool

ext/witapi/witapi-core.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,4 @@ void rb_vm_bugreport(const void *);
303303

304304
void rb_abi_guest_rb_vm_bugreport(void) { rb_vm_bugreport(NULL); }
305305

306-
bool rb_abi_guest_rb_gc_enable(void) {
307-
return rb_gc_enable() == Qtrue;
308-
}
309-
bool rb_abi_guest_rb_gc_disable(void) {
310-
return rb_gc_disable() == Qtrue;
311-
}
312-
313306
void Init_witapi(void) {}

packages/npm-packages/ruby-wasm-wasi/src/bindgen/rb-abi-guest.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ export class RbAbiGuest {
8080
rbClearErrinfo(): void;
8181
rstringPtr(value: RbAbiValue): string;
8282
rbVmBugreport(): void;
83-
rbGcEnable(): boolean;
84-
rbGcDisable(): boolean;
8583
}
8684

8785
export class RbIseq {

packages/npm-packages/ruby-wasm-wasi/src/bindgen/rb-abi-guest.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { data_view, to_uint32, UTF8_DECODER, utf8_encode, UTF8_ENCODED_LEN, Slab, throw_invalid_bool } from './intrinsics.js';
1+
import { data_view, to_uint32, UTF8_DECODER, utf8_encode, UTF8_ENCODED_LEN, Slab } from './intrinsics.js';
22
export class RbAbiGuest {
33
constructor() {
44
this._resource0_slab = new Slab();
@@ -161,16 +161,6 @@ export class RbAbiGuest {
161161
rbVmBugreport() {
162162
this._exports['rb-vm-bugreport: func() -> ()']();
163163
}
164-
rbGcEnable() {
165-
const ret = this._exports['rb-gc-enable: func() -> bool']();
166-
const bool0 = ret;
167-
return bool0 == 0 ? false : (bool0 == 1 ? true : throw_invalid_bool());
168-
}
169-
rbGcDisable() {
170-
const ret = this._exports['rb-gc-disable: func() -> bool']();
171-
const bool0 = ret;
172-
return bool0 == 0 ? false : (bool0 == 1 ? true : throw_invalid_bool());
173-
}
174164
}
175165

176166
export class RbIseq {

packages/npm-packages/ruby-wasm-wasi/src/index.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class RubyVM {
3838
// Wrap exported functions from Ruby VM to prohibit nested VM operation
3939
// if the call stack has sandwitched JS frames like JS -> Ruby -> JS -> Ruby.
4040
const proxyExports = (exports: RbAbi.RbAbiGuest) => {
41-
const excludedMethods: (keyof RbAbi.RbAbiGuest)[] = ["addToImports", "instantiate", "rbGcEnable", "rbGcDisable"];
41+
const excludedMethods: (keyof RbAbi.RbAbiGuest)[] = ["addToImports", "instantiate"];
4242
const excluded = ["constructor"].concat(excludedMethods);
4343
// wrap all methods in RbAbi.RbAbiGuest class
4444
for (const key of Object.getOwnPropertyNames(RbAbi.RbAbiGuest.prototype)) {
@@ -107,10 +107,10 @@ export class RubyVM {
107107
}
108108
};
109109
}
110-
// NOTE: The imported functions must disable Ruby GC if they call
111-
// Ruby API that may trigger GC. Otherwise, the GC may collect
112-
// objects that are still referenced by Wasm locals because Asyncify
113-
// cannot scan the Wasm stack above the JS frame.
110+
// NOTE: The GC may collect objects that are still referenced by Wasm
111+
// locals because Asyncify cannot scan the Wasm stack above the JS frame.
112+
// So we need to keep track whether the JS frame is sandwitched by Ruby
113+
// frames or not, and prohibit nested VM operation if it is.
114114
const proxyImports = (imports: RbJsAbiHost) => {
115115
for (const [key, value] of Object.entries(imports)) {
116116
if (typeof value === "function") {
@@ -343,8 +343,7 @@ export class RubyVM {
343343
type RbAbiInterfaceState = {
344344
/**
345345
* Track if the last JS frame that was created by a Ruby frame
346-
* to determine if we need to disable Ruby GC during nested
347-
* JS->Ruby->JS->Ruby calls
346+
* to determine if we have a sandwitched JS frame between Ruby frames.
348347
**/
349348
hasJSFrameAfterRbFrame: boolean;
350349
}

0 commit comments

Comments
 (0)