mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-24 12:11:50 +00:00
Rename memory instructions; Rework constant handling (#177)
* Rename memory instructions as proposed by the bulk-memory-operations spec. * Rename memory manager functions to memory.* as well * Remove automatic inlining of constant globals (Binaryen does this now) * Improve 'const' enum compatibility * Improve module-level export generation * Enable the inline decorator for constant variables * Add ERROR, WARNING and INFO macros that emit a user-defined diagnostic * Reintroduce builtin decorator so these can appear anywhere in stdlib again * Inline isNaN and isFinite by default * Make an interface around gc.* similar to memory.* * Emit an error when trying to inline a mutable variable * Slim down CI stages * Add a more convenient tracing utility for debugging * Implement some prequesites for an eventual bundled GC
This commit is contained in:
28
std/assembly/gc.ts
Normal file
28
std/assembly/gc.ts
Normal file
@ -0,0 +1,28 @@
|
||||
@builtin export declare function iterateRoots(fn: (ref: usize) => void): void; // tslint:disable-line
|
||||
|
||||
export namespace gc {
|
||||
|
||||
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 collect(): void {
|
||||
if (isDefined(__gc_collect)) { __gc_collect(); return; } // tslint:disable-line
|
||||
WARNING("Calling 'gc.collect' requires a garbage collector to be present.");
|
||||
unreachable();
|
||||
}
|
||||
|
||||
export function link(parentRef: usize, childRef: usize): void {
|
||||
if (isDefined(__gc_link)) { __gc_link(parentRef, childRef); return; } // tslint:disable-line
|
||||
WARNING("Calling 'gc.link' requires a garbage collector to be present.");
|
||||
unreachable();
|
||||
}
|
||||
|
||||
export function mark(ref: usize): void {
|
||||
if (isDefined(__gc_mark)) { __gc_mark(ref); return; } // tslint:disable-line
|
||||
WARNING("Calling 'gc.mark' requires a garbage collector to be present.");
|
||||
unreachable();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user