mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-05-02 18:32:15 +00:00
Remove type checking from load/store for portable (#76)
This commit is contained in:
parent
d66f9d205c
commit
1013c21359
@ -3,16 +3,18 @@ module.exports = globalScope => {
|
||||
var HEAP_OFFSET = 0;
|
||||
|
||||
globalScope["allocate_memory"] = function allocate_memory(size) {
|
||||
if (!(size >>>= 0))
|
||||
return 0;
|
||||
if (!(size >>>= 0)) return 0;
|
||||
|
||||
if (HEAP_OFFSET + size > HEAP.length) {
|
||||
var oldHeap = HEAP;
|
||||
HEAP = new Uint8Array(Math.max(65536, HEAP.length + size, HEAP.length * 2));
|
||||
HEAP.set(oldHeap);
|
||||
}
|
||||
|
||||
var ptr = HEAP_OFFSET;
|
||||
if ((HEAP_OFFSET += size) & 7)
|
||||
HEAP_OFFSET = (HEAP_OFFSET | 7) + 1;
|
||||
|
||||
return ptr;
|
||||
};
|
||||
|
||||
@ -20,19 +22,15 @@ module.exports = globalScope => {
|
||||
// TODO
|
||||
};
|
||||
|
||||
globalScope["move_memory"] = function move_memory(dest, src, n) {
|
||||
HEAP.copyWithin(dest, src, src + n);
|
||||
globalScope["move_memory"] = function move_memory(dest, src, size) {
|
||||
HEAP.copyWithin(dest, src, src + size);
|
||||
};
|
||||
|
||||
globalScope["store"] = function store(ptr, val, off) {
|
||||
if (typeof off === "number")
|
||||
ptr += off;
|
||||
HEAP[ptr] = val;
|
||||
globalScope["store"] = function store(ptr, value, offset) {
|
||||
HEAP[ptr + (offset | 0)] = value;
|
||||
};
|
||||
|
||||
globalScope["load"] = function load(ptr) {
|
||||
if (typeof off === "number")
|
||||
ptr += off;
|
||||
return HEAP[ptr];
|
||||
globalScope["load"] = function load(ptr, offset) {
|
||||
return HEAP[ptr + (offset | 0)];
|
||||
};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user