mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-26 05:01:52 +00:00
dummy gc
This commit is contained in:
35
std/assembly/collector/dummy.ts
Normal file
35
std/assembly/collector/dummy.ts
Normal file
@ -0,0 +1,35 @@
|
||||
// A dummy GC for looking at generated GC code without actually implementing it.
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@inline
|
||||
const TRACE = false;
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __gc_register(ref: usize): void {
|
||||
if (TRACE) trace("gc.register", 1, ref);
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __gc_retain(ref: usize, parentRef: usize): void {
|
||||
if (TRACE) trace("gc.retain", 2, ref, parentRef);
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __gc_release(ref: usize, parentRef: usize): void {
|
||||
if (TRACE) trace("gc.release", 2, ref, parentRef);
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __gc_move(ref: usize, oldParentRef: usize, newParentRef: usize): void {
|
||||
if (TRACE) trace("gc.move", 3, ref, oldParentRef, newParentRef);
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __gc_collect(): void {
|
||||
if (TRACE) trace("gc.collect");
|
||||
}
|
@ -214,7 +214,7 @@ function objToRef(obj: ManagedObject): usize {
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
export function __gc_register(ref: usize): void {
|
||||
if (TRACE) trace("gc.register", 2, ref);
|
||||
if (TRACE) trace("gc.register", 1, ref);
|
||||
step(); // also makes sure it's initialized
|
||||
var obj = refToObj(ref);
|
||||
obj.color = white;
|
||||
|
Reference in New Issue
Block a user