From 93bb69a8f55b60e3c5e995111aafe6f35b738b8a Mon Sep 17 00:00:00 2001 From: Adrien Aury <44274230+adrienaury@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:04:55 +0200 Subject: [PATCH] fix: regression pimo play (#328) * fix: pimo play wasm * fix: pimo play wasm --- CHANGELOG.md | 4 ++++ go.mod | 2 +- web/play/src/wasm_exec.js | 15 +++++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a65a98e..d58791bb 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ Types of changes - `Added` parameter `maxstrlen` to `sha3` and `haqhInCSV` masks +## [1.26.2] + +- `Fixed` regression in pimo play WASM (web version) + ## [1.26.1] - `Fixed` performance issues on JSON serialization diff --git a/go.mod b/go.mod index c1e6ed66..283ddfca 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cgi-fr/pimo -go 1.21 +go 1.22 toolchain go1.22.2 diff --git a/web/play/src/wasm_exec.js b/web/play/src/wasm_exec.js index 9ce6a20c..bc6f2102 100644 --- a/web/play/src/wasm_exec.js +++ b/web/play/src/wasm_exec.js @@ -19,8 +19,8 @@ outputBuf += decoder.decode(buf); const nl = outputBuf.lastIndexOf("\n"); if (nl != -1) { - console.log(outputBuf.substr(0, nl)); - outputBuf = outputBuf.substr(nl + 1); + console.log(outputBuf.substring(0, nl)); + outputBuf = outputBuf.substring(nl + 1); } return buf.length; }, @@ -113,6 +113,10 @@ this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true); } + const setInt32 = (addr, v) => { + this.mem.setUint32(addr + 0, v, true); + } + const getInt64 = (addr) => { const low = this.mem.getUint32(addr + 0, true); const high = this.mem.getInt32(addr + 4, true); @@ -206,7 +210,10 @@ const timeOrigin = Date.now() - performance.now(); this.importObject = { - go: { + _gotest: { + add: (a, b) => a + b, + }, + gojs: { // Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters) // may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported // function. A goroutine can switch to a new stack if the current stack is too small (see morestack function). @@ -269,7 +276,7 @@ this._resume(); } }, - getInt64(sp + 8) + 1, // setTimeout has been seen to fire up to 1 millisecond early + getInt64(sp + 8), )); this.mem.setInt32(sp + 16, id, true); },