const { exports } = new WebAssembly.Instance(module, {
env: {
abort: (msg: any, file: any, row: any, col: any) => {
+ const getString = (pointer: number): string | null => {
+ const end = pointer + new Uint32Array(exports.memory.buffer)[pointer - 4 >>> 2] >>> 1
+ const buf = new Uint16Array(exports.memory.buffer)
+ let start = pointer >>> 1
+ let string = ''
+ while (end - start > 1024) {
+ string += String.fromCharCode(...buf.subarray(start, start += 1024))
+ }
+ return string + String.fromCharCode(...buf.subarray(start, end))
+ }
// ~lib/builtins/abort(~lib/string/String | null?, ~lib/string/String | null?, u32?, u32?) => void
- msg = msg >>> 0
- file = file >>> 0
- row = row >>> 0
- col = col >>> 0
- console.error('wasm abort:', `msg ${msg}`, `file ${file}`, `row ${row}`, `col ${col}`)
- throw new Error(msg, { cause: { file, row, col } })
+ msg >>>= 0
+ file >>>= 0
+ row >>>= 0
+ col >>>= 0
+ const message = 'nano25519/async wasm abort'
+ console.error(message, getString(msg), getString(file), { msg, file, row, col })
+ throw new Error(message)
},
"performance.now" () {
// ~lib/bindings/dom/performance.now() => f64