llvm-like naming of __heap_base, definition fixes, update examples

This commit is contained in:
dcode
2019-06-01 01:14:04 +02:00
parent b19005f5bb
commit e65d875ebc
81 changed files with 3135 additions and 1995 deletions

View File

@ -1,3 +1,3 @@
export { __alloc } from "rt/tlsf";
export { __retain, __release, __collect } from "rt/pure";
export { RTTI_BASE as __rtti } from "rt";
export { __rtti_base } from "rt";

View File

@ -1,2 +1,2 @@
export { __alloc, __retain, __release, __collect } from "rt/stub";
export { RTTI_BASE as __rtti } from "rt";
export { __rtti_base } from "rt";

View File

@ -64,7 +64,7 @@ import { onincrement, ondecrement, onfree, onalloc } from "./rtrace";
// @ts-ignore: decorator
@global @unsafe
function __visit(ref: usize, cookie: i32): void {
if (ref < HEAP_BASE) return;
if (ref < __heap_base) return;
var s = changetype<Block>(ref - BLOCK_OVERHEAD);
switch (cookie) {
case VISIT_DECREMENT: {
@ -251,12 +251,12 @@ function collectWhite(s: Block): void {
// @ts-ignore: decorator
@global @unsafe
export function __retain(ref: usize): usize {
if (ref > HEAP_BASE) increment(changetype<Block>(ref - BLOCK_OVERHEAD));
if (ref > __heap_base) increment(changetype<Block>(ref - BLOCK_OVERHEAD));
return ref;
}
// @ts-ignore: decorator
@global @unsafe
export function __release(ref: usize): void {
if (ref > HEAP_BASE) decrement(changetype<Block>(ref - BLOCK_OVERHEAD));
if (ref > __heap_base) decrement(changetype<Block>(ref - BLOCK_OVERHEAD));
}

View File

@ -2,7 +2,7 @@ import { AL_MASK, BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "rt/common";
// @ts-ignore: decorator
@lazy
var startOffset: usize = (HEAP_BASE + AL_MASK) & ~AL_MASK;
var startOffset: usize = (__heap_base + AL_MASK) & ~AL_MASK;
// @ts-ignore: decorator
@lazy

View File

@ -450,7 +450,7 @@ function prepareSize(size: usize): usize {
/** Initilizes the root structure. */
export function initializeRoot(): void {
var rootOffset = (HEAP_BASE + AL_MASK) & ~AL_MASK;
var rootOffset = (__heap_base + AL_MASK) & ~AL_MASK;
var pagesBefore = memory.size();
var pagesNeeded = <i32>((((rootOffset + ROOT_SIZE) + 0xffff) & ~0xffff) >>> 16);
if (pagesNeeded > pagesBefore && memory.grow(pagesNeeded - pagesBefore) < 0) unreachable();