Skip to content

Commit

Permalink
chore: configure compile command
Browse files Browse the repository at this point in the history
  • Loading branch information
skostyrko committed Sep 8, 2024
1 parent 08d519b commit 288dc37
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 60 deletions.
22 changes: 0 additions & 22 deletions .devcontainer/devcontainer.json

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"prepublish": "npm run build",
"release": "np",
"lint": "eslint .",
"check-types": "tsc --noEmit"
"check-types": "tsc --noEmit",
"compile": "docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) emscripten/emsdk ./compile-wasm.sh"
},
"keywords": [
"qsp",
Expand Down
57 changes: 27 additions & 30 deletions src/qsplib/public/qsp-engine-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,15 @@ var createQspModule = (() => {
// Cordova or Electron apps are typically loaded from a file:// url.
// So use XHR on webview if URL is a file URL.
if (isFileURI(url)) {
return new Promise((reject, resolve) => {
return new Promise((resolve, reject) => {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = () => {
if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) {
// file URLs can return 0
resolve(xhr.response);
return;
}
reject(xhr.status);
};
Expand Down Expand Up @@ -323,10 +324,6 @@ var createQspModule = (() => {

legacyModuleProp('thisProgram', 'thisProgram');

if (Module['quit']) quit_ = Module['quit'];

legacyModuleProp('quit', 'quit_');

// perform assertions in shell.js after we set up out() and err(), as otherwise if an assertion fails it cannot print the message
// Assertions on removed incoming Module JS APIs.
assert(
Expand Down Expand Up @@ -410,9 +407,7 @@ var createQspModule = (() => {
// You can also build docs locally as HTML or other formats in site/
// An online HTML version (which may be of a different version of Emscripten)
// is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
var wasmBinary;

if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
var wasmBinary = Module['wasmBinary'];

legacyModuleProp('wasmBinary', 'wasmBinary');

Expand Down Expand Up @@ -616,17 +611,6 @@ var createQspModule = (() => {
}

// end include: runtime_stack_check.js
// include: runtime_assertions.js
// Endianness check
(function () {
var h16 = new Int16Array(1);
var h8 = new Int8Array(h16.buffer);
h16[0] = 25459;
if (h8[0] !== 115 || h8[1] !== 99)
throw 'Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)';
})();

// end include: runtime_assertions.js
var __ATPRERUN__ = [];

// functions called before the runtime is initialized
Expand Down Expand Up @@ -1415,6 +1399,15 @@ var createQspModule = (() => {
var tempI64;

// include: runtime_debug.js
// Endianness check
(function () {
var h16 = new Int16Array(1);
var h8 = new Int8Array(h16.buffer);
h16[0] = 25459;
if (h8[0] !== 115 || h8[1] !== 99)
throw 'Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)';
})();

function legacyModuleProp(prop, newName, incoming = true) {
if (!Object.getOwnPropertyDescriptor(Module, prop)) {
Object.defineProperty(Module, prop, {
Expand Down Expand Up @@ -2040,6 +2033,11 @@ var createQspModule = (() => {
return result ? result.line : 0;
};

var alignMemory = (size, alignment) => {
assert(alignment, 'alignment argument is required');
return Math.ceil(size / alignment) * alignment;
};

var growMemory = (size) => {
var b = wasmMemory.buffer;
var pages = (size - b.byteLength + 65535) / 65536;
Expand Down Expand Up @@ -2090,7 +2088,6 @@ var createQspModule = (() => {
);
return false;
}
var alignUp = (x, multiple) => x + ((multiple - (x % multiple)) % multiple);
// Loop through potential heap size increases. If we attempt a too eager
// reservation that fails, cut down on the attempted size and reserve a
// smaller bump instead. (max 3 times, chosen somewhat arbitrarily)
Expand All @@ -2101,7 +2098,7 @@ var createQspModule = (() => {
overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
var newSize = Math.min(
maxHeapSize,
alignUp(Math.max(requestedSize, overGrownHeapSize), 65536),
alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536),
);
var replacement = growMemory(newSize);
if (replacement) {
Expand Down Expand Up @@ -3173,10 +3170,6 @@ var createQspModule = (() => {
'getTempRet0',
'setTempRet0',
'zeroMemory',
'isLeapYear',
'ydayFromDate',
'arraySum',
'addDays',
'strError',
'inetPton4',
'inetNtop4',
Expand All @@ -3196,7 +3189,6 @@ var createQspModule = (() => {
'dynCall',
'asmjsMangle',
'asyncLoad',
'alignMemory',
'mmapAlloc',
'HandleAllocator',
'getNativeTypeSize',
Expand Down Expand Up @@ -3282,6 +3274,10 @@ var createQspModule = (() => {
'findMatchingCatch',
'Browser_asyncPrepareDataCounter',
'setMainLoop',
'isLeapYear',
'ydayFromDate',
'arraySum',
'addDays',
'getSocketFromFD',
'getSocketAddress',
'heapObjectForWebGLType',
Expand Down Expand Up @@ -3342,10 +3338,6 @@ var createQspModule = (() => {
'growMemory',
'ENV',
'setStackLimits',
'MONTH_DAYS_REGULAR',
'MONTH_DAYS_LEAP',
'MONTH_DAYS_REGULAR_CUMULATIVE',
'MONTH_DAYS_LEAP_CUMULATIVE',
'ERRNO_CODES',
'DNS',
'Protocols',
Expand All @@ -3362,6 +3354,7 @@ var createQspModule = (() => {
'runtimeKeepalivePop',
'callUserCallback',
'maybeExit',
'alignMemory',
'wasmTable',
'noExitRuntime',
'uleb128Encode',
Expand Down Expand Up @@ -3404,6 +3397,10 @@ var createQspModule = (() => {
'Browser',
'getPreloadedImageData__data',
'wget',
'MONTH_DAYS_REGULAR',
'MONTH_DAYS_LEAP',
'MONTH_DAYS_REGULAR_CUMULATIVE',
'MONTH_DAYS_LEAP_CUMULATIVE',
'SYSCALLS',
'tempFixedLengthArray',
'miniTempWebGLFloatBuffers',
Expand Down
Binary file modified src/qsplib/public/qsp-engine-debug.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion src/qsplib/public/qsp-engine-debug.wasm.map

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions src/qsplib/public/qsp-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ var createQspModule = (() => {
}
readAsync = (url) => {
if (isFileURI(url)) {
return new Promise((reject, resolve) => {
return new Promise((resolve, reject) => {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = () => {
if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) {
resolve(xhr.response);
return;
}
reject(xhr.status);
};
Expand All @@ -119,9 +120,7 @@ var createQspModule = (() => {
moduleOverrides = null;
if (Module['arguments']) arguments_ = Module['arguments'];
if (Module['thisProgram']) thisProgram = Module['thisProgram'];
if (Module['quit']) quit_ = Module['quit'];
var wasmBinary;
if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
var wasmBinary = Module['wasmBinary'];
var wasmMemory;
var ABORT = false;
var EXITSTATUS;
Expand Down Expand Up @@ -359,6 +358,7 @@ var createQspModule = (() => {
var __emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);
var _emscripten_date_now = () => Date.now();
var getHeapMax = () => 2147483648;
var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment;
var growMemory = (size) => {
var b = wasmMemory.buffer;
var pages = (size - b.byteLength + 65535) / 65536;
Expand All @@ -375,13 +375,12 @@ var createQspModule = (() => {
if (requestedSize > maxHeapSize) {
return false;
}
var alignUp = (x, multiple) => x + ((multiple - (x % multiple)) % multiple);
for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown);
overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
var newSize = Math.min(
maxHeapSize,
alignUp(Math.max(requestedSize, overGrownHeapSize), 65536),
alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536),
);
var replacement = growMemory(newSize);
if (replacement) {
Expand Down
Binary file modified src/qsplib/public/qsp-engine.wasm
Binary file not shown.

0 comments on commit 288dc37

Please sign in to comment.