external gc interface

This commit is contained in:
dcode
2019-03-28 11:07:47 +01:00
parent 41abc0166c
commit 0dcfcc7935
8 changed files with 2573 additions and 17 deletions

File diff suppressed because it is too large Load Diff

39
tests/compiler/gc.ts Normal file
View File

@ -0,0 +1,39 @@
import "allocator/arena";
import { link_count, unlink_count, collect_count } from "./gc/_dummy";
export { gc };
class Ref {}
@start export function main(): void {
var ref = new Ref();
assert(gc.implemented);
var previous_link_count = link_count;
var previous_unlink_count = unlink_count;
var previous_collect_count = collect_count;
gc.retain(changetype<usize>(ref));
assert(link_count == previous_link_count + 1);
assert(unlink_count == previous_unlink_count);
assert(collect_count == previous_collect_count);
previous_link_count = link_count;
previous_unlink_count = unlink_count;
previous_collect_count = collect_count;
gc.release(changetype<usize>(ref));
assert(link_count == previous_link_count);
assert(unlink_count == previous_unlink_count + 1);
assert(collect_count == previous_collect_count);
previous_link_count = link_count;
previous_unlink_count = unlink_count;
previous_collect_count = collect_count;
gc.collect();
assert(link_count == previous_link_count);
assert(unlink_count == previous_unlink_count);
assert(collect_count == previous_collect_count + 1);
}

File diff suppressed because it is too large Load Diff