Skip to content

Commit

Permalink
Release: Update WebAssembly files
Browse files Browse the repository at this point in the history
  • Loading branch information
BaseMax committed Nov 18, 2024
1 parent 155af9c commit bbb3d23
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 41 deletions.
140 changes: 99 additions & 41 deletions public/assets/salam/salam-wa.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,10 @@ function writeStackCookie() {
// The stack grow downwards towards _emscripten_stack_get_end.
// We write cookies to the final two words in the stack and detect if they are
// ever overwritten.
HEAPU32[((max)>>2)] = 0x02135467;
HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;
HEAPU32[((max)>>2)] = 0x02135467;checkInt32(0x02135467);
HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;checkInt32(0x89BACDFE);
// Also test the global address 0 for integrity.
HEAPU32[((0)>>2)] = 1668509029;
HEAPU32[((0)>>2)] = 1668509029;checkInt32(1668509029);
}

function checkStackCookie() {
Expand Down Expand Up @@ -399,6 +399,8 @@ function initRuntime() {

checkStackCookie();

setStackLimits();


if (!Module['noFSInit'] && !FS.initialized)
FS.init();
Expand Down Expand Up @@ -872,6 +874,31 @@ function unexportedRuntimeSymbol(sym) {
}
}

var MAX_UINT8 = (2 ** 8) - 1;
var MAX_UINT16 = (2 ** 16) - 1;
var MAX_UINT32 = (2 ** 32) - 1;
var MAX_UINT53 = (2 ** 53) - 1;
var MAX_UINT64 = (2 ** 64) - 1;

var MIN_INT8 = - (2 ** ( 8 - 1));
var MIN_INT16 = - (2 ** (16 - 1));
var MIN_INT32 = - (2 ** (32 - 1));
var MIN_INT53 = - (2 ** (53 - 1));
var MIN_INT64 = - (2 ** (64 - 1));

function checkInt(value, bits, min, max) {
assert(Number.isInteger(Number(value)), `attempt to write non-integer (${value}) into integer heap`);
assert(value <= max, `value (${value}) too large to write as ${bits}-bit value`);
assert(value >= min, `value (${value}) too small to write as ${bits}-bit value`);
}

var checkInt1 = (value) => checkInt(value, 1, 1);
var checkInt8 = (value) => checkInt(value, 8, MIN_INT8, MAX_UINT8);
var checkInt16 = (value) => checkInt(value, 16, MIN_INT16, MAX_UINT16);
var checkInt32 = (value) => checkInt(value, 32, MIN_INT32, MAX_UINT32);
var checkInt53 = (value) => checkInt(value, 53, MIN_INT53, MAX_UINT53);
var checkInt64 = (value) => checkInt(value, 64, MIN_INT64, MAX_UINT64);

// Used by XXXXX_DEBUG settings to output debug messages.
function dbg(...args) {
// TODO(sbc): Make this configurable somehow. Its not always convenient for
Expand Down Expand Up @@ -927,6 +954,12 @@ function dbg(...args) {
return '0x' + ptr.toString(16).padStart(8, '0');
};

var setStackLimits = () => {
var stackLow = _emscripten_stack_get_base();
var stackHigh = _emscripten_stack_get_end();
___set_stack_limits(stackLow, stackHigh);
};


/**
* @param {number} ptr
Expand All @@ -936,10 +969,10 @@ function dbg(...args) {
function setValue(ptr, value, type = 'i8') {
if (type.endsWith('*')) type = '*';
switch (type) {
case 'i1': HEAP8[ptr] = value; break;
case 'i8': HEAP8[ptr] = value; break;
case 'i16': HEAP16[((ptr)>>1)] = value; break;
case 'i32': HEAP32[((ptr)>>2)] = value; break;
case 'i1': HEAP8[ptr] = value;checkInt8(value); break;
case 'i8': HEAP8[ptr] = value;checkInt8(value); break;
case 'i16': HEAP16[((ptr)>>1)] = value;checkInt16(value); break;
case 'i32': HEAP32[((ptr)>>2)] = value;checkInt32(value); break;
case 'i64': abort('to do setValue(i64) use WASM_BIGINT');
case 'float': HEAPF32[((ptr)>>2)] = value; break;
case 'double': HEAPF64[((ptr)>>3)] = value; break;
Expand All @@ -961,6 +994,16 @@ function dbg(...args) {
}
};



var ___handle_stack_overflow = (requested) => {
var base = _emscripten_stack_get_base();
var end = _emscripten_stack_get_end();
abort(`stack overflow (Attempt to set SP to ${ptrToString(requested)}` +
`, with stack limits [${ptrToString(end)} - ${ptrToString(base)}` +
']). If you require more stack space build with -sSTACK_SIZE=<bytes>');
};

/** @suppress {duplicate } */
var syscallGetVarargI = () => {
assert(SYSCALLS.varargs != undefined);
Expand Down Expand Up @@ -3662,25 +3705,25 @@ function dbg(...args) {
},
doStat(func, path, buf) {
var stat = func(path);
HEAP32[((buf)>>2)] = stat.dev;
HEAP32[(((buf)+(4))>>2)] = stat.mode;
HEAPU32[(((buf)+(8))>>2)] = stat.nlink;
HEAP32[(((buf)+(12))>>2)] = stat.uid;
HEAP32[(((buf)+(16))>>2)] = stat.gid;
HEAP32[(((buf)+(20))>>2)] = stat.rdev;
(tempI64 = [stat.size>>>0,(tempDouble = stat.size,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(24))>>2)] = tempI64[0],HEAP32[(((buf)+(28))>>2)] = tempI64[1]);
HEAP32[(((buf)+(32))>>2)] = 4096;
HEAP32[(((buf)+(36))>>2)] = stat.blocks;
HEAP32[((buf)>>2)] = stat.dev;checkInt32(stat.dev);
HEAP32[(((buf)+(4))>>2)] = stat.mode;checkInt32(stat.mode);
HEAPU32[(((buf)+(8))>>2)] = stat.nlink;checkInt32(stat.nlink);
HEAP32[(((buf)+(12))>>2)] = stat.uid;checkInt32(stat.uid);
HEAP32[(((buf)+(16))>>2)] = stat.gid;checkInt32(stat.gid);
HEAP32[(((buf)+(20))>>2)] = stat.rdev;checkInt32(stat.rdev);
(tempI64 = [stat.size>>>0,(tempDouble = stat.size,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(24))>>2)] = tempI64[0],HEAP32[(((buf)+(28))>>2)] = tempI64[1]);checkInt64(stat.size);
HEAP32[(((buf)+(32))>>2)] = 4096;checkInt32(4096);
HEAP32[(((buf)+(36))>>2)] = stat.blocks;checkInt32(stat.blocks);
var atime = stat.atime.getTime();
var mtime = stat.mtime.getTime();
var ctime = stat.ctime.getTime();
(tempI64 = [Math.floor(atime / 1000)>>>0,(tempDouble = Math.floor(atime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(40))>>2)] = tempI64[0],HEAP32[(((buf)+(44))>>2)] = tempI64[1]);
HEAPU32[(((buf)+(48))>>2)] = (atime % 1000) * 1000 * 1000;
(tempI64 = [Math.floor(mtime / 1000)>>>0,(tempDouble = Math.floor(mtime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(56))>>2)] = tempI64[0],HEAP32[(((buf)+(60))>>2)] = tempI64[1]);
HEAPU32[(((buf)+(64))>>2)] = (mtime % 1000) * 1000 * 1000;
(tempI64 = [Math.floor(ctime / 1000)>>>0,(tempDouble = Math.floor(ctime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(72))>>2)] = tempI64[0],HEAP32[(((buf)+(76))>>2)] = tempI64[1]);
HEAPU32[(((buf)+(80))>>2)] = (ctime % 1000) * 1000 * 1000;
(tempI64 = [stat.ino>>>0,(tempDouble = stat.ino,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(88))>>2)] = tempI64[0],HEAP32[(((buf)+(92))>>2)] = tempI64[1]);
(tempI64 = [Math.floor(atime / 1000)>>>0,(tempDouble = Math.floor(atime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(40))>>2)] = tempI64[0],HEAP32[(((buf)+(44))>>2)] = tempI64[1]);checkInt64(Math.floor(atime / 1000));
HEAPU32[(((buf)+(48))>>2)] = (atime % 1000) * 1000 * 1000;checkInt32((atime % 1000) * 1000 * 1000);
(tempI64 = [Math.floor(mtime / 1000)>>>0,(tempDouble = Math.floor(mtime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(56))>>2)] = tempI64[0],HEAP32[(((buf)+(60))>>2)] = tempI64[1]);checkInt64(Math.floor(mtime / 1000));
HEAPU32[(((buf)+(64))>>2)] = (mtime % 1000) * 1000 * 1000;checkInt32((mtime % 1000) * 1000 * 1000);
(tempI64 = [Math.floor(ctime / 1000)>>>0,(tempDouble = Math.floor(ctime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(72))>>2)] = tempI64[0],HEAP32[(((buf)+(76))>>2)] = tempI64[1]);checkInt64(Math.floor(ctime / 1000));
HEAPU32[(((buf)+(80))>>2)] = (ctime % 1000) * 1000 * 1000;checkInt32((ctime % 1000) * 1000 * 1000);
(tempI64 = [stat.ino>>>0,(tempDouble = stat.ino,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(88))>>2)] = tempI64[0],HEAP32[(((buf)+(92))>>2)] = tempI64[1]);checkInt64(stat.ino);
return 0;
},
doMsync(addr, stream, len, flags, offset) {
Expand Down Expand Up @@ -3736,7 +3779,7 @@ function dbg(...args) {
var arg = syscallGetVarargP();
var offset = 0;
// We're always unlocked.
HEAP16[(((arg)+(offset))>>1)] = 2;
HEAP16[(((arg)+(offset))>>1)] = 2;checkInt16(2);
return 0;
}
case 13:
Expand Down Expand Up @@ -3766,12 +3809,12 @@ function dbg(...args) {
if (stream.tty.ops.ioctl_tcgets) {
var termios = stream.tty.ops.ioctl_tcgets(stream);
var argp = syscallGetVarargP();
HEAP32[((argp)>>2)] = termios.c_iflag || 0;
HEAP32[(((argp)+(4))>>2)] = termios.c_oflag || 0;
HEAP32[(((argp)+(8))>>2)] = termios.c_cflag || 0;
HEAP32[(((argp)+(12))>>2)] = termios.c_lflag || 0;
HEAP32[((argp)>>2)] = termios.c_iflag || 0;checkInt32(termios.c_iflag || 0);
HEAP32[(((argp)+(4))>>2)] = termios.c_oflag || 0;checkInt32(termios.c_oflag || 0);
HEAP32[(((argp)+(8))>>2)] = termios.c_cflag || 0;checkInt32(termios.c_cflag || 0);
HEAP32[(((argp)+(12))>>2)] = termios.c_lflag || 0;checkInt32(termios.c_lflag || 0);
for (var i = 0; i < 32; i++) {
HEAP8[(argp + i)+(17)] = termios.c_cc[i] || 0;
HEAP8[(argp + i)+(17)] = termios.c_cc[i] || 0;checkInt8(termios.c_cc[i] || 0);
}
return 0;
}
Expand Down Expand Up @@ -3804,7 +3847,7 @@ function dbg(...args) {
case 21519: {
if (!stream.tty) return -59;
var argp = syscallGetVarargP();
HEAP32[((argp)>>2)] = 0;
HEAP32[((argp)>>2)] = 0;checkInt32(0);
return 0;
}
case 21520: {
Expand All @@ -3822,8 +3865,8 @@ function dbg(...args) {
if (stream.tty.ops.ioctl_tiocgwinsz) {
var winsize = stream.tty.ops.ioctl_tiocgwinsz(stream.tty);
var argp = syscallGetVarargP();
HEAP16[((argp)>>1)] = winsize[0];
HEAP16[(((argp)+(2))>>1)] = winsize[1];
HEAP16[((argp)>>1)] = winsize[0];checkInt16(winsize[0]);
HEAP16[(((argp)+(2))>>1)] = winsize[1];checkInt16(winsize[1]);
}
return 0;
}
Expand Down Expand Up @@ -3861,6 +3904,10 @@ function dbg(...args) {
}
}

var __abort_js = () => {
abort('native code called abort()');
};

var __emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);

var getHeapMax = () =>
Expand All @@ -3871,6 +3918,8 @@ function dbg(...args) {
2147483648;


var _emscripten_get_now = () => performance.now();

var growMemory = (size) => {
var b = wasmMemory.buffer;
var pages = ((size - b.byteLength + 65535) / 65536) | 0;
Expand Down Expand Up @@ -3928,7 +3977,10 @@ function dbg(...args) {

var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));

var t0 = _emscripten_get_now();
var replacement = growMemory(newSize);
var t1 = _emscripten_get_now();
dbg(`Heap resize call from ${oldSize} to ${newSize} took ${(t1 - t0)} msecs. Success: ${!!replacement}`);
if (replacement) {

return true;
Expand Down Expand Up @@ -3978,16 +4030,16 @@ function dbg(...args) {
var stringToAscii = (str, buffer) => {
for (var i = 0; i < str.length; ++i) {
assert(str.charCodeAt(i) === (str.charCodeAt(i) & 0xff));
HEAP8[buffer++] = str.charCodeAt(i);
HEAP8[buffer++] = str.charCodeAt(i);checkInt8(str.charCodeAt(i));
}
// Null-terminate the string
HEAP8[buffer] = 0;
HEAP8[buffer] = 0;checkInt8(0);
};
var _environ_get = (__environ, environ_buf) => {
var bufSize = 0;
getEnvStrings().forEach((string, i) => {
var ptr = environ_buf + bufSize;
HEAPU32[(((__environ)+(i*4))>>2)] = ptr;
HEAPU32[(((__environ)+(i*4))>>2)] = ptr;checkInt32(ptr);
stringToAscii(string, ptr);
bufSize += string.length + 1;
});
Expand All @@ -3996,10 +4048,10 @@ function dbg(...args) {

var _environ_sizes_get = (penviron_count, penviron_buf_size) => {
var strings = getEnvStrings();
HEAPU32[((penviron_count)>>2)] = strings.length;
HEAPU32[((penviron_count)>>2)] = strings.length;checkInt32(strings.length);
var bufSize = 0;
strings.forEach((string) => bufSize += string.length + 1);
HEAPU32[((penviron_buf_size)>>2)] = bufSize;
HEAPU32[((penviron_buf_size)>>2)] = bufSize;checkInt32(bufSize);
return 0;
};

Expand Down Expand Up @@ -4068,7 +4120,7 @@ function dbg(...args) {

var stream = SYSCALLS.getStreamFromFD(fd);
var num = doReadv(stream, iov, iovcnt);
HEAPU32[((pnum)>>2)] = num;
HEAPU32[((pnum)>>2)] = num;checkInt32(num);
return 0;
} catch (e) {
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
Expand All @@ -4091,7 +4143,7 @@ function dbg(...args) {
if (isNaN(offset)) return 61;
var stream = SYSCALLS.getStreamFromFD(fd);
FS.llseek(stream, offset, whence);
(tempI64 = [stream.position>>>0,(tempDouble = stream.position,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[((newOffset)>>2)] = tempI64[0],HEAP32[(((newOffset)+(4))>>2)] = tempI64[1]);
(tempI64 = [stream.position>>>0,(tempDouble = stream.position,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[((newOffset)>>2)] = tempI64[0],HEAP32[(((newOffset)+(4))>>2)] = tempI64[1]);checkInt64(stream.position);
if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null; // reset readdir state
return 0;
} catch (e) {
Expand Down Expand Up @@ -4127,7 +4179,7 @@ function dbg(...args) {

var stream = SYSCALLS.getStreamFromFD(fd);
var num = doWritev(stream, iov, iovcnt);
HEAPU32[((pnum)>>2)] = num;
HEAPU32[((pnum)>>2)] = num;checkInt32(num);
return 0;
} catch (e) {
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
Expand Down Expand Up @@ -4176,13 +4228,17 @@ function checkIncomingModuleAPI() {
ignoredModuleProp('fetchSettings');
}
var wasmImports = {
/** @export */
__handle_stack_overflow: ___handle_stack_overflow,
/** @export */
__syscall_fcntl64: ___syscall_fcntl64,
/** @export */
__syscall_ioctl: ___syscall_ioctl,
/** @export */
__syscall_openat: ___syscall_openat,
/** @export */
_abort_js: __abort_js,
/** @export */
_emscripten_memcpy_js: __emscripten_memcpy_js,
/** @export */
emscripten_resize_heap: _emscripten_resize_heap,
Expand Down Expand Up @@ -4217,12 +4273,14 @@ var _emscripten_stack_get_end = () => (_emscripten_stack_get_end = wasmExports['
var __emscripten_stack_restore = (a0) => (__emscripten_stack_restore = wasmExports['_emscripten_stack_restore'])(a0);
var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'])(a0);
var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
var ___set_stack_limits = Module['___set_stack_limits'] = createExportWrapper('__set_stack_limits', 2);
var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji', 5);


// include: postamble.js
// === Auto-generated postamble setup entry stuff ===

Module['callMain'] = callMain;
var missingLibrarySymbols = [
'writeI53ToI64',
'writeI53ToI64Clamped',
Expand Down Expand Up @@ -4402,7 +4460,6 @@ var unexportedSymbols = [
'removeRunDependency',
'out',
'err',
'callMain',
'abort',
'wasmMemory',
'wasmExports',
Expand All @@ -4418,6 +4475,7 @@ var unexportedSymbols = [
'getHeapMax',
'growMemory',
'ENV',
'setStackLimits',
'ERRNO_CODES',
'strError',
'DNS',
Expand Down
Binary file modified public/assets/salam/salam-wa.wasm
Binary file not shown.

0 comments on commit bbb3d23

Please sign in to comment.