mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-14 16:35:03 +01:00
Remove memory intrinsics
This commit is contained in:
parent
9270f52e6b
commit
1e97275cf2
5 changed files with 15 additions and 19 deletions
|
|
@ -15,9 +15,9 @@ function allocate(size: I32, align: I32): I32 = (
|
|||
let alignedPtr = std.alignUp(HEAD_PTR, align);
|
||||
let newHeadPtr = alignedPtr + size;
|
||||
|
||||
if newHeadPtr > __memory_size() then (
|
||||
if newHeadPtr > std.rt.memorySize() then (
|
||||
// 16 pages, very arbitrary.
|
||||
let result = __memory_grow(16_I32);
|
||||
let result = std.rt.memoryGrow(16_I32);
|
||||
// If allocation failed we get -1. We don't have negative numbers yet, lol.
|
||||
if result > 4294967295_I32 then (
|
||||
std.abort("failed to grow memory");
|
||||
|
|
|
|||
|
|
@ -9,3 +9,16 @@ function memcpy(_dst: I32, _src: I32, _n: I32) =
|
|||
"local.get 0",
|
||||
"memory.copy",
|
||||
);
|
||||
|
||||
function memoryGrow(_size: I32): I32 =
|
||||
___asm(
|
||||
__locals(),
|
||||
"local.get 0",
|
||||
"memory.grow",
|
||||
);
|
||||
|
||||
function memorySize(): I32 =
|
||||
___asm(
|
||||
__locals(),
|
||||
"memory.size",
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue