xbintsc 0.3.35 → 0.3.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/dist/src/codegen/generator/module.js +10 -0
- package/dist/src/codegen/generator/module.js.map +1 -1
- package/dist/src/codegen/generator/state.js +4 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/tests/e2e/gc.test.d.ts +1 -0
- package/dist/tests/e2e/gc.test.js +168 -0
- package/dist/tests/e2e/gc.test.js.map +1 -0
- package/dist/tests/e2e/harness.d.ts +2 -0
- package/dist/tests/e2e/harness.js +1 -0
- package/dist/tests/e2e/harness.js.map +1 -1
- package/package.json +3 -2
- package/runtime/ext_gui/dom_api_proto.cpp +5 -0
- package/runtime/ext_gui/window.cpp +1 -0
- package/runtime/ext_node/buffer/parts/prototype.inc +1 -0
- package/runtime/ext_node/dgram/dgram.c +1 -0
- package/runtime/ext_node/events/events.c +1 -0
- package/runtime/ext_node/fs/fs_ops.c +10 -25
- package/runtime/ext_node/fs/glob.c +13 -30
- package/runtime/ext_node/fs/promises.c +1 -0
- package/runtime/ext_node/http/parts/prototypes.inc +5 -0
- package/runtime/ext_node/net/parts/prototypes.inc +2 -0
- package/runtime/ext_node/process/process.c +9 -7
- package/runtime/ext_node/stream/stream.c +1 -0
- package/runtime/ext_node/util/util.c +6 -6
- package/runtime/rt.h +10 -0
- package/runtime/rt_internal.h +63 -2
- package/runtime/xt_alloc.c +442 -5
- package/runtime/xt_generator.c +95 -1
- package/runtime/xt_loop.c +35 -1
- package/runtime/xt_promise.c +46 -0
- package/runtime/xt_stdlib2/error.inc +1 -0
- package/runtime/xt_stdlib2/regexp-match.inc +8 -7
- package/runtime/xt_symbol.c +2 -0
- package/runtime/xt_typed_array/construction.inc +142 -0
- package/runtime/xt_typed_array/elements.inc +92 -0
- package/runtime/xt_typed_array/methods.inc +329 -0
- package/runtime/xt_typed_array.c +6 -548
- package/runtime/xt_values/number-format.inc +26 -0
- package/scripts/check-file-length.ts +85 -0
- package/src/codegen/generator/module.ts +10 -0
- package/src/codegen/generator/state.ts +4 -0
|
@@ -227,9 +227,19 @@ export const moduleMethods: ModuleMethods = {
|
|
|
227
227
|
|
|
228
228
|
emitMain(): void {
|
|
229
229
|
const moduleName = this.functionName(this.binding.moduleFunction);
|
|
230
|
+
// Module bindings and class constructors live in globals; register them as
|
|
231
|
+
// GC roots before the module body runs so a collection cannot free them.
|
|
232
|
+
const roots = [...this.classGlobals.values(), ...this.moduleGlobals.values()];
|
|
233
|
+
const rootLines = roots.map((name) => ` call void @xt_gc_add_root(i64* ${name})`);
|
|
230
234
|
this.functions.push(
|
|
231
235
|
[
|
|
232
236
|
"define i32 @main(i32 %argc, i8** %argv) {",
|
|
237
|
+
" %stackbase = alloca i64",
|
|
238
|
+
" %stackbase.ptr = bitcast i64* %stackbase to i8*",
|
|
239
|
+
" call void @xt_gc_set_stack_base(i8* %stackbase.ptr)",
|
|
240
|
+
" call void @xt_gc_init()",
|
|
241
|
+
...rootLines,
|
|
242
|
+
" call void @xt_gc_arm()",
|
|
233
243
|
" call void @xt_set_program_args(i32 %argc, i8** %argv)",
|
|
234
244
|
` %result = call i64 @${moduleName}(i64 ${i64(XT_UNDEFINED)}, i64 ${i64(XT_UNDEFINED)}, i32 0, i64* null)`,
|
|
235
245
|
" call void @xt_drain_microtasks()",
|
|
@@ -103,6 +103,10 @@ export const RUNTIME_DECLARATIONS: readonly string[] = [
|
|
|
103
103
|
"declare i64 @xt_await(i64)",
|
|
104
104
|
"declare void @xt_drain_microtasks()",
|
|
105
105
|
"declare void @xt_run_event_loop()",
|
|
106
|
+
"declare void @xt_gc_init()",
|
|
107
|
+
"declare void @xt_gc_set_stack_base(i8*)",
|
|
108
|
+
"declare void @xt_gc_arm()",
|
|
109
|
+
"declare void @xt_gc_add_root(i64*)",
|
|
106
110
|
"declare i64 @xt_promise_resolve(i64)",
|
|
107
111
|
"declare i64 @xt_promise_reject(i64)",
|
|
108
112
|
"declare i64 @xt_promise_ctor(i32, i64*)",
|