mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-20 10:16:37 +00:00
fix export star module exports, shiftify
This commit is contained in:
@ -6,7 +6,7 @@ import { ROOT, Block, BLOCK_OVERHEAD, initializeRoot, allocateBlock, reallocateB
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __rt_allocate(size: usize, id: u32): usize {
|
||||
export function __rt_allocate(size: usize, id: u32): usize {
|
||||
var root = ROOT;
|
||||
if (!root) {
|
||||
initializeRoot();
|
||||
@ -19,7 +19,7 @@ function __rt_allocate(size: usize, id: u32): usize {
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __rt_reallocate(ref: usize, size: usize): usize {
|
||||
export function __rt_reallocate(ref: usize, size: usize): usize {
|
||||
if (DEBUG) assert(ROOT); // must be initialized
|
||||
assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned
|
||||
return changetype<usize>(reallocateBlock(ROOT, changetype<Block>(ref - BLOCK_OVERHEAD), size)) + BLOCK_OVERHEAD;
|
||||
@ -27,7 +27,7 @@ function __rt_reallocate(ref: usize, size: usize): usize {
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __rt_free(ref: usize): void {
|
||||
export function __rt_free(ref: usize): void {
|
||||
if (DEBUG) assert(ROOT); // must be initialized
|
||||
assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned
|
||||
freeBlock(ROOT, changetype<Block>(ref - BLOCK_OVERHEAD));
|
||||
@ -39,18 +39,20 @@ import { increment, decrement, collectCycles } from "./pure";
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __rt_retain(ref: usize): void {
|
||||
export function __rt_retain(ref: usize): void {
|
||||
if (ref) increment(changetype<Block>(ref - BLOCK_OVERHEAD));
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __rt_release(ref: usize): void {
|
||||
export function __rt_release(ref: usize): void {
|
||||
if (ref) decrement(changetype<Block>(ref - BLOCK_OVERHEAD));
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __rt_collect(): void {
|
||||
export function __rt_collect(): void {
|
||||
collectCycles();
|
||||
}
|
||||
|
||||
export { __rt_typeinfo };
|
||||
|
@ -20,7 +20,7 @@ var offset: usize = startOffset;
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@unsafe @global
|
||||
function __rt_allocate(size: usize, id: u32): usize {
|
||||
export function __rt_allocate(size: usize, id: u32): usize {
|
||||
if (size > BLOCK_MAXSIZE) unreachable();
|
||||
var ptr = offset + BLOCK_OVERHEAD;
|
||||
var newPtr = (ptr + max<usize>(size, 1) + AL_MASK) & ~AL_MASK;
|
||||
@ -41,7 +41,7 @@ function __rt_allocate(size: usize, id: u32): usize {
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@unsafe @global
|
||||
function __rt_reallocate(ref: usize, size: usize): usize {
|
||||
export function __rt_reallocate(ref: usize, size: usize): usize {
|
||||
var block = changetype<CommonBlock>(ref - BLOCK_OVERHEAD);
|
||||
var oldSize = <usize>block.rtSize;
|
||||
if (size > oldSize) {
|
||||
@ -56,12 +56,12 @@ function __rt_reallocate(ref: usize, size: usize): usize {
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@unsafe @global
|
||||
function __rt_free(ref: usize): void {
|
||||
export function __rt_free(ref: usize): void {
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@unsafe @global
|
||||
function __rt_reset(): void { // special
|
||||
export function __rt_reset(): void { // special
|
||||
offset = startOffset;
|
||||
}
|
||||
|
||||
@ -69,15 +69,17 @@ function __rt_reset(): void { // special
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __rt_retain(ref: usize): void {
|
||||
export function __rt_retain(ref: usize): void {
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __rt_release(ref: usize): void {
|
||||
export function __rt_release(ref: usize): void {
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __rt_collect(): void {
|
||||
export function __rt_collect(): void {
|
||||
}
|
||||
|
||||
export { __rt_typeinfo };
|
||||
|
@ -146,37 +146,60 @@ import { AL_BITS, AL_SIZE, AL_MASK, DEBUG, CommonBlock } from "./common";
|
||||
/** Gets the second level map of the specified first level. */
|
||||
// @ts-ignore: decorator
|
||||
@inline function GETSL(root: Root, fl: usize): u32 {
|
||||
return load<u32>(changetype<usize>(root) + (fl << alignof<u32>()), SL_START);
|
||||
return load<u32>(
|
||||
changetype<usize>(root) + (fl << alignof<u32>()),
|
||||
SL_START
|
||||
);
|
||||
}
|
||||
|
||||
/** Sets the second level map of the specified first level. */
|
||||
// @ts-ignore: decorator
|
||||
@inline function SETSL(root: Root, fl: usize, slMap: u32): void {
|
||||
store<u32>(changetype<usize>(root) + (fl << alignof<u32>()), slMap, SL_START);
|
||||
store<u32>(
|
||||
changetype<usize>(root) + (fl << alignof<u32>()),
|
||||
slMap,
|
||||
SL_START
|
||||
);
|
||||
}
|
||||
|
||||
/** Gets the head of the free list for the specified combination of first and second level. */
|
||||
// @ts-ignore: decorator
|
||||
@inline function GETHEAD(root: Root, fl: usize, sl: u32): Block | null {
|
||||
return changetype<Block>(load<usize>(changetype<usize>(root) + (fl * SL_SIZE + <usize>sl) * sizeof<usize>(), HL_START));
|
||||
return changetype<Block>(
|
||||
load<usize>(
|
||||
changetype<usize>(root) + (((fl << SL_BITS) + <usize>sl) << alignof<usize>()),
|
||||
HL_START
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/** Sets the head of the free list for the specified combination of first and second level. */
|
||||
// @ts-ignore: decorator
|
||||
@inline function SETHEAD(root: Root, fl: usize, sl: u32, head: Block | null): void {
|
||||
store<usize>(changetype<usize>(root) + (fl * SL_SIZE + <usize>sl) * sizeof<usize>() , changetype<usize>(head), HL_START);
|
||||
store<usize>(
|
||||
changetype<usize>(root) + (((fl << SL_BITS) + <usize>sl) << alignof<usize>()),
|
||||
changetype<usize>(head),
|
||||
HL_START
|
||||
);
|
||||
}
|
||||
|
||||
/** Gets the tail block.. */
|
||||
// @ts-ignore: decorator
|
||||
@inline function GETTAIL(root: Root): Block {
|
||||
return load<Block>(changetype<usize>(root), HL_END);
|
||||
return load<Block>(
|
||||
changetype<usize>(root),
|
||||
HL_END
|
||||
);
|
||||
}
|
||||
|
||||
/** Sets the tail block. */
|
||||
// @ts-ignore: decorator
|
||||
@inline function SETTAIL(root: Root, tail: Block): void {
|
||||
store<Block>(changetype<usize>(root), tail, HL_END);
|
||||
store<Block>(
|
||||
changetype<usize>(root),
|
||||
tail,
|
||||
HL_END
|
||||
);
|
||||
}
|
||||
|
||||
/** Inserts a previously used block back into the free list. */
|
||||
@ -229,7 +252,7 @@ function insertBlock(root: Root, block: Block): void {
|
||||
var fl: usize, sl: u32;
|
||||
if (size < SB_SIZE) {
|
||||
fl = 0;
|
||||
sl = <u32>(size / AL_SIZE);
|
||||
sl = <u32>(size >> AL_BITS);
|
||||
} else {
|
||||
const inv: usize = sizeof<usize>() * 8 - 1;
|
||||
fl = inv - clz<usize>(size);
|
||||
@ -261,7 +284,7 @@ function removeBlock(root: Root, block: Block): void {
|
||||
var fl: usize, sl: u32;
|
||||
if (size < SB_SIZE) {
|
||||
fl = 0;
|
||||
sl = <u32>(size / AL_SIZE);
|
||||
sl = <u32>(size >> AL_BITS);
|
||||
} else {
|
||||
const inv: usize = sizeof<usize>() * 8 - 1;
|
||||
fl = inv - clz<usize>(size);
|
||||
@ -302,7 +325,7 @@ function searchBlock(root: Root, size: usize): Block | null {
|
||||
var fl: usize, sl: u32;
|
||||
if (size < SB_SIZE) {
|
||||
fl = 0;
|
||||
sl = <u32>(size / AL_SIZE);
|
||||
sl = <u32>(size >> AL_BITS);
|
||||
} else {
|
||||
const halfMaxSize = BLOCK_MAXSIZE >> 1; // don't round last fl
|
||||
const inv: usize = sizeof<usize>() * 8 - 1;
|
||||
|
Reference in New Issue
Block a user