From ed32a4c8baa97101cfde16ad6d7b78317f40db2b Mon Sep 17 00:00:00 2001 From: dcode Date: Thu, 4 Apr 2019 12:53:42 +0200 Subject: [PATCH] notes on gc.collect that I don't yet know how to work around --- std/assembly/runtime.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/std/assembly/runtime.ts b/std/assembly/runtime.ts index 18a38f1b..b2f5e73f 100644 --- a/std/assembly/runtime.ts +++ b/std/assembly/runtime.ts @@ -144,8 +144,19 @@ export namespace runtime { } } - /** Performs a full garbage collection cycle. */ + /** Performs a full garbage collection cycle.*/ + // @ts-ignore: decorator + @unsafe export function collect(): void { + // FIXME: annotated unsafe because calling it in the middle of a function collects inner + // references prematurely with a tracing GC, which is pretty bad actually. + + // function explode(): Ref { + // var ref = new Ref(); + // gc.collect(); // collects ref + // return ref; + // } + if (isDefined(__ref_collect)) __ref_collect(); else throw new Error(E_NOTIMPLEMENTED); }