-
Notifications
You must be signed in to change notification settings - Fork 6
feat: upgrade tinygo to 0.40.1
#35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
297a9d4
afbed53
4e3d3a3
f337ee4
d69559b
1b1975d
02a1ff9
5039570
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||||||||||||||||||||||||||||||||||||||
| // See: https://github.com/tinygo-org/tinygo/blob/v0.40.1/targets/wasm_exec.js. | ||||||||||||||||||||||||||||||||||||||||
| // Copyright 2018 The Go Authors. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||
| // Use of this source code is governed by a BSD-style | ||||||||||||||||||||||||||||||||||||||||
| // license that can be found in the LICENSE file. | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -8,6 +9,7 @@ const encoder = new TextEncoder(); | |||||||||||||||||||||||||||||||||||||||
| const decoder = new TextDecoder("utf-8"); | ||||||||||||||||||||||||||||||||||||||||
| const reinterpretBuf = new DataView(new ArrayBuffer(8)); | ||||||||||||||||||||||||||||||||||||||||
| let logLine: any[] = []; | ||||||||||||||||||||||||||||||||||||||||
| const wasmExit = {}; // thrown to exit via proc_exit (not an error) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| export class Go { | ||||||||||||||||||||||||||||||||||||||||
| importObject: any; | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -17,6 +19,7 @@ export class Go { | |||||||||||||||||||||||||||||||||||||||
| _ids: any; | ||||||||||||||||||||||||||||||||||||||||
| _idPool: any; | ||||||||||||||||||||||||||||||||||||||||
| exited: any; | ||||||||||||||||||||||||||||||||||||||||
| exitCode: any; | ||||||||||||||||||||||||||||||||||||||||
| _resolveExitPromise: any; | ||||||||||||||||||||||||||||||||||||||||
| _resolveCallbackPromise: any; | ||||||||||||||||||||||||||||||||||||||||
| _pendingEvent: any; | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -127,6 +130,19 @@ export class Go { | |||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| this.importObject = { | ||||||||||||||||||||||||||||||||||||||||
| wasi_snapshot_preview1: { | ||||||||||||||||||||||||||||||||||||||||
| clock_time_get: (_id: any, _precision: any, time_ptr: any) => { | ||||||||||||||||||||||||||||||||||||||||
| const now = BigInt(Date.now() * 1e6); | ||||||||||||||||||||||||||||||||||||||||
| mem().setBigUint64(time_ptr, now, true); | ||||||||||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
| args_sizes_get: (argc_ptr: any, argv_buf_size_ptr: any) => { | ||||||||||||||||||||||||||||||||||||||||
| mem().setUint32(argc_ptr, 0, true); | ||||||||||||||||||||||||||||||||||||||||
| mem().setUint32(argv_buf_size_ptr, 0, true); | ||||||||||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
| args_get: () => { | ||||||||||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
| // https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#fd_write | ||||||||||||||||||||||||||||||||||||||||
| fd_write: function ( | ||||||||||||||||||||||||||||||||||||||||
| fd: any, | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -167,35 +183,63 @@ export class Go { | |||||||||||||||||||||||||||||||||||||||
| fd_fdstat_get: () => 0, // dummy | ||||||||||||||||||||||||||||||||||||||||
| fd_seek: () => 0, // dummy | ||||||||||||||||||||||||||||||||||||||||
| proc_exit: (code: any) => { | ||||||||||||||||||||||||||||||||||||||||
| // Can't exit in a browser. | ||||||||||||||||||||||||||||||||||||||||
| throw "trying to exit with code " + code; | ||||||||||||||||||||||||||||||||||||||||
| this.exited = true; | ||||||||||||||||||||||||||||||||||||||||
| this.exitCode = code; | ||||||||||||||||||||||||||||||||||||||||
| this._resolveExitPromise(); | ||||||||||||||||||||||||||||||||||||||||
| throw wasmExit; | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
185
to
+189
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard
🔧 Suggested fix@@
proc_exit: (code: any) => {
this.exited = true;
this.exitCode = code;
- this._resolveExitPromise();
+ if (this._resolveExitPromise) {
+ this._resolveExitPromise();
+ }
throw wasmExit;
},
@@
this.exited = false; // whether the Go program has exited
this.exitCode = 0;
+ this._resolveExitPromise = undefined;
@@
- if (this.exited) {
+ if (this.exited && this._resolveExitPromise) {
this._resolveExitPromise();
}Also applies to: 450-471, 485-487 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
| random_get: (bufPtr: any, bufLen: any) => { | ||||||||||||||||||||||||||||||||||||||||
| crypto.getRandomValues(loadSlice(bufPtr, bufLen)); | ||||||||||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
| gojs: { | ||||||||||||||||||||||||||||||||||||||||
| // func ticks() float64 | ||||||||||||||||||||||||||||||||||||||||
| // func ticks() int64 | ||||||||||||||||||||||||||||||||||||||||
| "runtime.ticks": () => { | ||||||||||||||||||||||||||||||||||||||||
| return Date.now(); | ||||||||||||||||||||||||||||||||||||||||
| return BigInt(Date.now() * 1e6); | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+197
to
200
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's check the actual file content around lines 197-200
cat -n src/component/lib/goRuntime.ts | sed -n '190,210p'Repository: get-convex/geospatial Length of output: 812 🏁 Script executed: # Search for timeOrigin in the file
rg "timeOrigin" src/component/lib/goRuntime.tsRepository: get-convex/geospatial Length of output: 47 🏁 Script executed: # Get broader context around the runtime.ticks implementation
rg -A 5 -B 5 "runtime\.ticks" src/component/lib/goRuntime.tsRepository: get-convex/geospatial Length of output: 328 🌐 Web query:
💡 Result: In TinyGo 0.40.1, the wasm_exec.js file (located at $(tinygo env TINYGOROOT)/targets/wasm_exec.js) provides the JavaScript runtime environment for WASM/JS targets (built with GOOS=js GOARCH=wasm or -target=wasm). It defines the Go class and importObject.env with runtime functions imported by the WASM module, including gojs::runtime.ticks (seen in errors when misconfigured, e.g., using js target imports in wasip1). runtime.ticks likely returns high-resolution ticks (monotonic time) for the Go runtime time package, implemented using browser performance.now for precise timing (microsecond resolution vs Date.now's millisecond). timeOrigin is probably performance.timeOrigin, providing the absolute timestamp when performance.now started (Unix epoch ms). Recent changes (PR Citations:
🏁 Script executed: # Look at the full goRuntime.ts file to understand the class structure
wc -l src/component/lib/goRuntime.tsRepository: get-convex/geospatial Length of output: 99 🏁 Script executed: # Check the constructor and initialization area
head -100 src/component/lib/goRuntime.ts | tail -50Repository: get-convex/geospatial Length of output: 1298 🏁 Script executed: # Look for where variables are declared in the gojs object
rg -B 20 "runtime\.ticks" src/component/lib/goRuntime.ts | head -30Repository: get-convex/geospatial Length of output: 679 🏁 Script executed: # Check the constructor and instance variable declarations
sed -n '1,100p' src/component/lib/goRuntime.tsRepository: get-convex/geospatial Length of output: 2703 🏁 Script executed: # Look for any timeOrigin setup or initialization
rg -i "timeorigin\|performance.now\|date.now" src/component/lib/goRuntime.ts -B 2 -A 2Repository: get-convex/geospatial Length of output: 47 🏁 Script executed: # Check TinyGo 0.40.1 actual implementation directly
curl -s https://raw.githubusercontent.com/tinygo-org/tinygo/v0.40.1/targets/wasm_exec.js | grep -A 10 "runtime.ticks" | head -20Repository: get-convex/geospatial Length of output: 432 Use monotonic time for Line 199 diverges from TinyGo 0.40.1's implementation. Upstream uses 🔧 Suggested fix const loadSlice = (addr: any, len: any) => {
return new Uint8Array(mem().buffer, addr, len);
};
+
+ const timeOrigin = Date.now() - performance.now();
this.importObject = { gojs: {
// func ticks() int64
"runtime.ticks": () => {
- return BigInt(Date.now() * 1e6);
+ return BigInt((timeOrigin + performance.now()) * 1e6);
},📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // func sleepTicks(timeout float64) | ||||||||||||||||||||||||||||||||||||||||
| // func sleepTicks(timeout int64) | ||||||||||||||||||||||||||||||||||||||||
| "runtime.sleepTicks": (timeout: any) => { | ||||||||||||||||||||||||||||||||||||||||
| // Do not sleep, only reactivate scheduler after the given timeout. | ||||||||||||||||||||||||||||||||||||||||
| setTimeout(this._inst.exports.go_scheduler, timeout); | ||||||||||||||||||||||||||||||||||||||||
| setTimeout( | ||||||||||||||||||||||||||||||||||||||||
| () => { | ||||||||||||||||||||||||||||||||||||||||
| if (this.exited) { | ||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||
| this._inst.exports.go_scheduler(); | ||||||||||||||||||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||||||||||||||||||
| if (e !== wasmExit) { | ||||||||||||||||||||||||||||||||||||||||
| throw e; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
| Number(timeout) / 1e6, | ||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // func finalizeRef(v ref) | ||||||||||||||||||||||||||||||||||||||||
| "syscall/js.finalizeRef": (_v_ref: any) => { | ||||||||||||||||||||||||||||||||||||||||
| // Note: TinyGo does not support finalizers so this should never be | ||||||||||||||||||||||||||||||||||||||||
| // called. | ||||||||||||||||||||||||||||||||||||||||
| console.error("syscall/js.finalizeRef not implemented"); | ||||||||||||||||||||||||||||||||||||||||
| "syscall/js.finalizeRef": (v_ref: any) => { | ||||||||||||||||||||||||||||||||||||||||
| // Note: TinyGo does not support finalizers so this is only called | ||||||||||||||||||||||||||||||||||||||||
| // for one specific case, by js.go:jsString. and can/might leak memory. | ||||||||||||||||||||||||||||||||||||||||
| const id = v_ref & 0xffffffffn; | ||||||||||||||||||||||||||||||||||||||||
| if (this._goRefCounts?.[id as any] !== undefined) { | ||||||||||||||||||||||||||||||||||||||||
| this._goRefCounts[id as any]--; | ||||||||||||||||||||||||||||||||||||||||
| if (this._goRefCounts[id as any] === 0) { | ||||||||||||||||||||||||||||||||||||||||
| const v = this._values[id as any]; | ||||||||||||||||||||||||||||||||||||||||
| this._values[id as any] = null; | ||||||||||||||||||||||||||||||||||||||||
| this._ids.delete(v); | ||||||||||||||||||||||||||||||||||||||||
| this._idPool.push(id); | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||
| console.error("syscall/js.finalizeRef: unknown id", id); | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // func stringVal(value string) ref | ||||||||||||||||||||||||||||||||||||||||
| "syscall/js.stringVal": (value_ptr: any, value_len: any) => { | ||||||||||||||||||||||||||||||||||||||||
| value_ptr >>>= 0; | ||||||||||||||||||||||||||||||||||||||||
| const s = loadString(value_ptr, value_len); | ||||||||||||||||||||||||||||||||||||||||
| return boxValue(s); | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -403,31 +447,41 @@ export class Go { | |||||||||||||||||||||||||||||||||||||||
| this._ids = new Map(); // mapping from JS values to reference ids | ||||||||||||||||||||||||||||||||||||||||
| this._idPool = []; // unused ids that have been garbage collected | ||||||||||||||||||||||||||||||||||||||||
| this.exited = false; // whether the Go program has exited | ||||||||||||||||||||||||||||||||||||||||
| this.exitCode = 0; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if (this._inst.exports._start) { | ||||||||||||||||||||||||||||||||||||||||
| const exitPromise = new Promise((resolve, _reject) => { | ||||||||||||||||||||||||||||||||||||||||
| this._resolveExitPromise = resolve; | ||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // Run program, but catch the wasmExit exception that's thrown | ||||||||||||||||||||||||||||||||||||||||
| // to return back here. | ||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||
| this._inst.exports._start(); | ||||||||||||||||||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||||||||||||||||||
| if (e !== wasmExit) { | ||||||||||||||||||||||||||||||||||||||||
| throw e; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // while (true) { | ||||||||||||||||||||||||||||||||||||||||
| // const callbackPromise = new Promise((resolve) => { | ||||||||||||||||||||||||||||||||||||||||
| // this._resolveCallbackPromise = () => { | ||||||||||||||||||||||||||||||||||||||||
| // if (this.exited) { | ||||||||||||||||||||||||||||||||||||||||
| // throw new Error("bad callback: Go program has already exited"); | ||||||||||||||||||||||||||||||||||||||||
| // } | ||||||||||||||||||||||||||||||||||||||||
| // setTimeout(resolve, 0); // make sure it is asynchronous | ||||||||||||||||||||||||||||||||||||||||
| // }; | ||||||||||||||||||||||||||||||||||||||||
| // }); | ||||||||||||||||||||||||||||||||||||||||
| // console.log(this._inst) | ||||||||||||||||||||||||||||||||||||||||
| // this._inst.exports._start(); | ||||||||||||||||||||||||||||||||||||||||
| // if (this.exited) { | ||||||||||||||||||||||||||||||||||||||||
| // break; | ||||||||||||||||||||||||||||||||||||||||
| // } | ||||||||||||||||||||||||||||||||||||||||
| // await callbackPromise; | ||||||||||||||||||||||||||||||||||||||||
| // } | ||||||||||||||||||||||||||||||||||||||||
| this._inst.exports._start(); | ||||||||||||||||||||||||||||||||||||||||
| await exitPromise; | ||||||||||||||||||||||||||||||||||||||||
| return this.exitCode; | ||||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||
| this._inst.exports._initialize(); | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| _resume() { | ||||||||||||||||||||||||||||||||||||||||
| if (this.exited) { | ||||||||||||||||||||||||||||||||||||||||
| throw new Error("Go program has already exited"); | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| this._inst.exports.resume(); | ||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||
| this._inst.exports.resume(); | ||||||||||||||||||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||||||||||||||||||
| if (e !== wasmExit) { | ||||||||||||||||||||||||||||||||||||||||
| throw e; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| if (this.exited) { | ||||||||||||||||||||||||||||||||||||||||
| this._resolveExitPromise(); | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,4 @@ | ||
| github.com/golang/geo v0.0.0-20230421003525-6adc56603217 h1:HKlyj6in2JV6wVkmQ4XmG/EIm+SCYlPZ+V4GWit7Z+I= | ||
| github.com/golang/geo v0.0.0-20230421003525-6adc56603217/go.mod h1:8wI0hitZ3a1IxZfeH3/5I97CI8i5cLGsYe7xNhQGs9U= | ||
| github.com/golang/geo v0.0.0-20260120070133-792bb8583fbb h1:OhyJ/wXEqRssvvFcXP8Wzoyn0fbiqWgjHXLKj3ZOU+4= | ||
| github.com/golang/geo v0.0.0-20260120070133-792bb8583fbb/go.mod h1:Mymr9kRGDc64JPr03TSZmuIBODZ3KyswLzm1xL0HFA8= | ||
| github.com/golang/geo v0.0.0-20260129164528-943061e2742c h1:ysO2h2Odnl1AJM1I2Lm/fa6JvO0pECMSt2CwBaa+ITo= | ||
| github.com/golang/geo v0.0.0-20260129164528-943061e2742c/go.mod h1:Mymr9kRGDc64JPr03TSZmuIBODZ3KyswLzm1xL0HFA8= | ||
| github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= | ||
| github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 918
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 733
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 290
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 267
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 2310
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 1880
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 1572
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 413
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 270
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 1842
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 225
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 691
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 185
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 556
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 448
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 2029
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 547
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 649
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 47
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 47
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 760
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 1046
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 47
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 47
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 935
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 47
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 372
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 1475
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 917
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 47
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 1402
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 47
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 252
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 92
🏁 Script executed:
Repository: get-convex/geospatial
Length of output: 2915
Add unsigned coercion for pointer parameters in WASI import functions.
WebAssembly exports i32 values to JavaScript as signed 32-bit numbers. When high-bit pointer values are used directly as offsets in
DataView.setUint32(),mem().setBigUint64(), or theUint8Arrayconstructor (inloadSlice), they causeRangeErrorat runtime. This pattern is already applied insyscall/js.stringVal(line 242) and should be applied consistently across all WASI pointer parameters.🔧 Suggested fix
clock_time_get: (_id: any, _precision: any, time_ptr: any) => { + time_ptr >>>= 0; const now = BigInt(Date.now() * 1e6); mem().setBigUint64(time_ptr, now, true); return 0; }, args_sizes_get: (argc_ptr: any, argv_buf_size_ptr: any) => { + argc_ptr >>>= 0; + argv_buf_size_ptr >>>= 0; mem().setUint32(argc_ptr, 0, true); mem().setUint32(argv_buf_size_ptr, 0, true); return 0; },Also apply the same normalization to
fd_write(bothiovs_ptrandnwritten_ptr) andrandom_get(bufPtr).📝 Committable suggestion
🤖 Prompt for AI Agents