2019-03-29 18:56:32 +01:00
|
|
|
@global const GC_TRACE = true;
|
2019-04-06 20:17:48 +02:00
|
|
|
import "allocator/arena";
|
2019-03-29 18:56:32 +01:00
|
|
|
import "collector/itcm";
|
|
|
|
|
2019-04-02 10:12:57 +02:00
|
|
|
import { HEADER_SIZE } from "util/runtime";
|
2019-03-29 18:56:32 +01:00
|
|
|
|
|
|
|
assert(HEADER_SIZE == 16);
|
|
|
|
|
2019-03-30 13:58:20 +01:00
|
|
|
class Ref {
|
|
|
|
inner: Ref;
|
|
|
|
}
|
2019-03-29 18:56:32 +01:00
|
|
|
|
2019-04-02 16:18:44 +02:00
|
|
|
function makeGarbage(): void {
|
|
|
|
trace("# ref = new Ref()");
|
|
|
|
var ref = new Ref();
|
|
|
|
trace("# arr = new Array(1)");
|
|
|
|
var arr = new Array<Ref | null>(1);
|
|
|
|
trace("# arr[0] = ref");
|
|
|
|
arr[0] = ref;
|
|
|
|
trace("# arr[0] = null");
|
|
|
|
arr[0] = null;
|
|
|
|
trace("# new Ref()");
|
|
|
|
new Ref();
|
|
|
|
}
|
|
|
|
|
|
|
|
makeGarbage();
|
2019-04-04 02:25:22 +02:00
|
|
|
runtime.collect();
|
2019-03-29 18:56:32 +01:00
|
|
|
|
2019-04-02 16:18:44 +02:00
|
|
|
// should have sweeped four objects (incl. arr.buffer)
|
2019-03-29 18:56:32 +01:00
|
|
|
|
|
|
|
@start export function main(): void {}
|