mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-16 16:31:32 +00:00
external gc interface
This commit is contained in:
1118
tests/compiler/gc.optimized.wat
Normal file
1118
tests/compiler/gc.optimized.wat
Normal file
File diff suppressed because it is too large
Load Diff
39
tests/compiler/gc.ts
Normal file
39
tests/compiler/gc.ts
Normal 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);
|
||||
}
|
1349
tests/compiler/gc.untouched.wat
Normal file
1349
tests/compiler/gc.untouched.wat
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user