2018-07-19 02:10:04 +02:00
|
|
|
export namespace gc {
|
2018-07-19 02:16:20 +02:00
|
|
|
|
|
|
|
@builtin export declare function iterateRoots(fn: (ref: usize) => void): void; // tslint:disable-line
|
|
|
|
|
2018-07-19 16:15:56 +02:00
|
|
|
export function allocate(size: usize, visitFn: (ref: usize) => void): usize {
|
|
|
|
if (isDefined(__gc_allocate)) return __gc_allocate(size, visitFn); // tslint:disable-line
|
|
|
|
WARNING("Calling 'gc.allocate' requires a garbage collector to be present.");
|
|
|
|
return <usize>unreachable();
|
|
|
|
}
|
|
|
|
|
|
|
|
export function mark(ref: usize): void {
|
|
|
|
if (isDefined(__gc_mark)) return __gc_mark(ref); // tslint:disable-line
|
|
|
|
WARNING("Calling 'gc.mark' requires a garbage collector to be present.");
|
|
|
|
unreachable();
|
|
|
|
}
|
|
|
|
|
|
|
|
export function link(parentRef: usize, childRef: usize): void {
|
|
|
|
if (isDefined(__gc_link)) return __gc_link(parentRef, childRef); // tslint:disable-line
|
|
|
|
WARNING("Calling 'gc.link' requires a garbage collector to be present.");
|
|
|
|
unreachable();
|
|
|
|
}
|
|
|
|
|
|
|
|
export function collect(): void {
|
|
|
|
if (isDefined(__gc_collect)) return __gc_collect(); // tslint:disable-line
|
|
|
|
WARNING("Calling 'gc.collect' requires a garbage collector to be present.");
|
|
|
|
unreachable();
|
|
|
|
}
|
2018-07-19 02:10:04 +02:00
|
|
|
}
|