directize

This commit is contained in:
dcode
2019-04-02 10:12:57 +02:00
parent 1ada854830
commit 3bcd32f3ba
91 changed files with 4225 additions and 4615 deletions

View File

@ -1,7 +1,7 @@
/// <reference path="./collector/index.d.ts" />
import { HASH } from "./util/hash";
import { classId } from "./runtime";
import { __runtime_id } from "./runtime";
// A deterministic hash map based on CloseTable from https://github.com/jorendorff/dht
@ -268,10 +268,10 @@ export class Map<K,V> {
// GC integration
@unsafe private __iterate(fn: (ref: usize) => void): void {
fn(changetype<usize>(this.buckets));
@unsafe private __traverse(): void {
__ref_mark(changetype<usize>(this.buckets));
var entries = this.entries;
fn(changetype<usize>(entries));
__ref_mark(changetype<usize>(entries));
if (isManaged<K>() || isManaged<V>()) {
let cur = changetype<usize>(entries);
let end = cur + <usize>this.entriesOffset * ENTRY_SIZE<K,V>();
@ -282,24 +282,24 @@ export class Map<K,V> {
let val = changetype<usize>(entry.key);
if (isNullable<K>()) {
if (val) {
fn(val);
call_indirect(classId<K>(), val, fn);
__ref_mark(val);
call_direct(__runtime_id<K>(), val);
}
} else {
fn(val);
call_indirect(classId<K>(), val, fn);
__ref_mark(val);
call_direct(__runtime_id<K>(), val);
}
}
if (isManaged<V>()) {
let val = changetype<usize>(entry.value);
if (isNullable<V>()) {
if (val) {
fn(val);
call_indirect(classId<V>(), val, fn);
__ref_mark(val);
call_direct(__runtime_id<V>(), val);
}
} else {
fn(val);
call_indirect(classId<V>(), val, fn);
__ref_mark(val);
call_direct(__runtime_id<V>(), val);
}
}
}