From 4f1a971a61d9985a8f70b218b1ddbb0a15b2f190 Mon Sep 17 00:00:00 2001 From: dcode Date: Sat, 9 Mar 2019 01:06:45 +0100 Subject: [PATCH] make it test again --- std/assembly/collector/itcm.ts | 1 + std/assembly/internal/runtime.ts | 3 ++- tests/compiler/std/gc-integration.optimized.wat | 2 +- tests/compiler/std/gc-integration.ts | 4 +++- tests/compiler/std/gc-integration.untouched.wat | 14 +++++++++++++- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/std/assembly/collector/itcm.ts b/std/assembly/collector/itcm.ts index 95ae1e24..bd1d37f9 100644 --- a/std/assembly/collector/itcm.ts +++ b/std/assembly/collector/itcm.ts @@ -12,6 +12,7 @@ @inline export const HEADER_SIZE: usize = (offsetof() + AL_MASK) & ~AL_MASK; import { AL_MASK, MAX_SIZE_32 } from "../internal/allocator"; +import { __rt_iterateroots } from "../builtins"; /** Collector states. */ const enum State { diff --git a/std/assembly/internal/runtime.ts b/std/assembly/internal/runtime.ts index 37a9c4af..3841fd8b 100644 --- a/std/assembly/internal/runtime.ts +++ b/std/assembly/internal/runtime.ts @@ -1,4 +1,5 @@ import { AL_MASK } from "./allocator"; +import { __rt_classid } from "../builtins"; /** Common runtime header of all objects. */ @unmanaged @@ -100,7 +101,7 @@ export function FREE(ref: usize): void { export function REGISTER(ref: usize, parentRef: usize): void { var header = UNREF(ref); header.classId = __rt_classid(); - if (GC) __REGISTER_IMPL(ref, parentRef); + if (GC) __REGISTER_IMPL(ref, parentRef); // tslint:disable-line } /** ArrayBuffer base class. */ diff --git a/tests/compiler/std/gc-integration.optimized.wat b/tests/compiler/std/gc-integration.optimized.wat index c26e47dd..e8848207 100644 --- a/tests/compiler/std/gc-integration.optimized.wat +++ b/tests/compiler/std/gc-integration.optimized.wat @@ -28,7 +28,7 @@ i32.const 0 i32.const 8 i32.const 18 - i32.const 37 + i32.const 42 call $~lib/env/abort unreachable end diff --git a/tests/compiler/std/gc-integration.ts b/tests/compiler/std/gc-integration.ts index bbb92c70..2510e497 100644 --- a/tests/compiler/std/gc-integration.ts +++ b/tests/compiler/std/gc-integration.ts @@ -15,5 +15,7 @@ var a_ref: A | null = changetype(24); // global root, nullable var b_ref: B = changetype(32); // global root, non-nullable var i: i32 = 0; -iterateRoots((ref: usize): void => { assert(ref == ++i << 3); }); +__rt_iterateroots((ref: usize): void => { assert(ref == ++i << 3); }); assert(i == 4); + +assert(__rt_classid() != __rt_classid()); diff --git a/tests/compiler/std/gc-integration.untouched.wat b/tests/compiler/std/gc-integration.untouched.wat index af4c2a25..3257d456 100644 --- a/tests/compiler/std/gc-integration.untouched.wat +++ b/tests/compiler/std/gc-integration.untouched.wat @@ -34,7 +34,7 @@ i32.const 0 i32.const 8 i32.const 18 - i32.const 37 + i32.const 42 call $~lib/env/abort unreachable end @@ -58,6 +58,18 @@ call $~lib/env/abort unreachable end + i32.const 43 + i32.const 44 + i32.ne + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 21 + i32.const 0 + call $~lib/env/abort + unreachable + end ) (func $start (; 3 ;) (type $FUNCSIG$v) call $start:std/gc-integration