unify, stub impl

This commit is contained in:
dcode
2019-04-18 12:53:48 +02:00
parent 8216cf3361
commit 18c3f0c555
15 changed files with 346 additions and 141 deletions

View File

@@ -28,8 +28,8 @@ fetch("untouched.wasm").then(result =>
).then(result => {
exports = result.instance.exports;
U32 = new Uint32Array(exports.memory.buffer);
var first = exports.__mm_allocate(255);
exports.__mm_free(first);
var first = exports.__rt_allocate(255);
exports.__rt_free(first);
ROOT = first - 17;
while (!U32[ROOT >> 2]) --ROOT; // find tail
ROOT -= (1 + FL_BITS + HL_SIZE) << 2;
@@ -113,7 +113,7 @@ function update() {
}
function allocate(size) {
var ptr = exports.__mm_allocate(size);
var ptr = exports.__rt_allocate(size);
if (!ptr) {
alert("should not happen");
return;
@@ -127,7 +127,7 @@ function allocate(size) {
var er = document.createElement("button");
er.innerText = "realloc";
er.onclick = function() {
ptr = exports.__mm_reallocate(ptr, es.value >>> 0);
ptr = exports.__rt_reallocate(ptr, es.value >>> 0);
update();
};
el.appendChild(er);
@@ -136,7 +136,7 @@ function allocate(size) {
ef.className = "free";
el.appendChild(ef);
ef.onclick = function() {
exports.__mm_free(ptr);
exports.__rt_free(ptr);
document.getElementById("segs").removeChild(el);
update();
};