@onda-lang/binaryen-web 0.8.5 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/api.md +16 -3
- package/package.json +2 -2
- package/src/compiler/core.js +1 -1
- package/src/compiler/event-input.js +3 -2
- package/src/compiler/lowering.js +15 -2
package/README.md
CHANGED
|
@@ -50,10 +50,14 @@ and overflow handling.
|
|
|
50
50
|
|
|
51
51
|
Each `onda_event_N` receives a pointer to the ABI's 16-byte wasm32 `EventInput` descriptor before
|
|
52
52
|
the ordinary processor storage arguments. The backend validates the complete little-endian wire
|
|
53
|
-
payload and aligned workspace before touching handler state
|
|
53
|
+
payload and aligned workspace after resetting call-scoped output and before touching handler state.
|
|
54
|
+
Truncated or trailing
|
|
54
55
|
payloads, invalid slice lengths, out-of-bounds regions, misalignment, and insufficient workspace
|
|
55
|
-
return `PROCESSOR_EXECUTION_INPUT_REJECTED` (`2`) and leave the processor usable;
|
|
56
|
-
structured values are exposed to generated code through aligned leaf tensors.
|
|
56
|
+
return `PROCESSOR_EXECUTION_INPUT_REJECTED` (`2`) with empty output and leave the processor usable;
|
|
57
|
+
accepted structured values are exposed to generated code through aligned leaf tensors.
|
|
58
|
+
The WebAssembly profile does not export the native `onda_event_views_N` unchecked entry. Browser
|
|
59
|
+
events cross JavaScript/worklet and linear-memory boundaries, so dispatch remains on this packed,
|
|
60
|
+
checked entry and its preallocated workspace.
|
|
57
61
|
|
|
58
62
|
`createProcessorArtifactFiles()` validates the final module, computes a SHA-256 digest, and returns
|
|
59
63
|
a reusable `.wasm` plus `.onda.json` descriptor pair. `validateProcessorArtifact`,
|
package/api.md
CHANGED
|
@@ -135,12 +135,14 @@ endpoints, apply linear, logarithmic, or curved scale, and clamp and snap to the
|
|
|
135
135
|
|
|
136
136
|
Complete wasm32 processor exports receive an optional execution-output descriptor containing
|
|
137
137
|
independently nullable delegate and print batches. Allocate all descriptors and storage before
|
|
138
|
-
real-time execution.
|
|
138
|
+
real-time execution. Their linear-memory regions must be mutually disjoint and must not overlap any
|
|
139
|
+
other region accessed by the processor call, matching the processor ABI's execution-output
|
|
140
|
+
contract.
|
|
139
141
|
|
|
140
142
|
`writeDelegateBatch` and `writePrintBatch` initialize reusable batch descriptors.
|
|
141
143
|
`writeExecutionOutput` connects their addresses. Call `resetExecutionOutput` immediately before
|
|
142
|
-
every generated init or process entry. Generated event entries reset
|
|
143
|
-
|
|
144
|
+
every generated init or process entry. Generated event entries reset before input preflight, so
|
|
145
|
+
rejected input returns empty batches. After a successful generated call,
|
|
144
146
|
`readDelegateBatch` or `readPrintBatch` validates the result counters.
|
|
145
147
|
`decodeDelegateRecords` converts delegate payloads using `metadata.delegates`.
|
|
146
148
|
`decodePrintRecords` preserves primitive types and source sites; `formatPrintRecords` and
|
|
@@ -303,6 +305,7 @@ OndaPayloadSchema
|
|
|
303
305
|
OndaPayloadDefault
|
|
304
306
|
OndaPayloadValue
|
|
305
307
|
OndaPayloadSizes
|
|
308
|
+
OndaPayloadTensorMetadata
|
|
306
309
|
PayloadPlan
|
|
307
310
|
canonicalF32Number
|
|
308
311
|
EVENT_INPUT_SIZE_BYTES
|
|
@@ -432,11 +435,21 @@ are rejected. Missing event arguments use declared constant defaults.
|
|
|
432
435
|
Supply `i64` as `bigint`, an exact safe integer, or a decimal string. `decode(bytes)` returns named
|
|
433
436
|
nested values with `bigint` for `i64`. Plans own immutable schema snapshots.
|
|
434
437
|
|
|
438
|
+
`tensorMetadata` exposes the schema's flattened SoA contract without reparsing JSON. Each immutable
|
|
439
|
+
record contains `path`, `encoding`, fixed `shape`, `parameterIndex`, `isSlice`, and
|
|
440
|
+
`fixedElementCount`. Tuple path components use `__0`, `__1`, and so on. A slice's runtime tensor
|
|
441
|
+
length is its logical length times `fixedElementCount`; the dynamic outer axis is therefore not
|
|
442
|
+
repeated in `shape`.
|
|
443
|
+
|
|
435
444
|
`requiredWorkspace(bytes)` preflights packed little-endian input. `sizes(lengths)` reports wire
|
|
436
445
|
and aligned workspace sizes without allocating payload storage. Low-level wasm hosts provision
|
|
437
446
|
both regions and a 16-byte descriptor, then call `writeEventInput` before invoking the event.
|
|
438
447
|
Rejected input returns `PROCESSOR_EXECUTION_INPUT_REJECTED` (2) and leaves processor state usable.
|
|
439
448
|
`OndaAudioProcessor.trigger` performs logical encoding before transferring bytes to the worklet.
|
|
449
|
+
Web hosts intentionally have no unchecked tensor-view event entry: JavaScript values must cross the
|
|
450
|
+
main-thread/worklet and Wasm linear-memory boundaries, so native borrowed addresses cannot be
|
|
451
|
+
preserved end to end. Web event dispatch remains the packed, checked `onda_event_N` path and uses
|
|
452
|
+
its preallocated workspace.
|
|
440
453
|
Decoded `f32` leaves use `canonicalF32Number(value)`: the returned JavaScript number has the
|
|
441
454
|
shortest decimal representation that round-trips to the same `f32`, so JSON and controls do not
|
|
442
455
|
expose an irrelevant widened binary tail.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onda-lang/binaryen-web",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Binaryen backend for versioned Onda MIR in browsers and Node.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"verify-mir": "node ./scripts/verify-mir.mjs"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@onda-lang/processor-abi": "0.8.
|
|
49
|
+
"@onda-lang/processor-abi": "0.8.6",
|
|
50
50
|
"binaryen": "130.0.0"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
package/src/compiler/core.js
CHANGED
|
@@ -2534,7 +2534,6 @@ export class MirCompilerCore {
|
|
|
2534
2534
|
const wrapperName = `$onda.abi.event.${eventId}`;
|
|
2535
2535
|
const prepared = prepareEventInput(this, this.eventPlans[eventId]);
|
|
2536
2536
|
const body = this.module.block(null, [
|
|
2537
|
-
...prepared.statements,
|
|
2538
2537
|
this.module.global.set(
|
|
2539
2538
|
POINTER_GLOBALS.delegateBatch,
|
|
2540
2539
|
this.executionOutputBatch(7, EXECUTION_OUTPUT_DELEGATE_BATCH_OFFSET),
|
|
@@ -2548,6 +2547,7 @@ export class MirCompilerCore {
|
|
|
2548
2547
|
this.executionOutputSequence(7),
|
|
2549
2548
|
),
|
|
2550
2549
|
...this.resetExecutionOutput(),
|
|
2550
|
+
...prepared.statements,
|
|
2551
2551
|
...this.resetRuntimeFailure(event.handler),
|
|
2552
2552
|
this.module.global.set(
|
|
2553
2553
|
POINTER_GLOBALS.eventPayload,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import binaryen from "binaryen";
|
|
2
2
|
import { PROCESSOR_EXECUTION_INPUT_REJECTED } from "@onda-lang/processor-abi";
|
|
3
3
|
|
|
4
|
-
// Emit preflight separately from transfer so rejection cannot change workspace
|
|
5
|
-
//
|
|
4
|
+
// Emit preflight separately from transfer so rejection cannot change workspace
|
|
5
|
+
// or processor state. The event entry resets its call-scoped output first. All
|
|
6
|
+
// generated metadata is per tensor.
|
|
6
7
|
export function prepareEventInput(compiler, plan) {
|
|
7
8
|
const m = compiler.module;
|
|
8
9
|
const locals = [];
|
package/src/compiler/lowering.js
CHANGED
|
@@ -793,6 +793,7 @@ export class MirCompilerLowering extends MirCompilerCore {
|
|
|
793
793
|
}
|
|
794
794
|
|
|
795
795
|
compilePackedSliceCopy(slice, count, scalar, destination, counterLocal) {
|
|
796
|
+
const elementSize = this.scalarSize(scalar);
|
|
796
797
|
const loopLabel = `$onda.delegate.copy.${this.nextLabel++}`;
|
|
797
798
|
const counter = () => this.module.local.get(counterLocal, binaryen.i32);
|
|
798
799
|
const sourceAddress = () =>
|
|
@@ -805,10 +806,10 @@ export class MirCompilerLowering extends MirCompilerCore {
|
|
|
805
806
|
destination(),
|
|
806
807
|
this.module.i32.mul(
|
|
807
808
|
counter(),
|
|
808
|
-
this.module.i32.const(
|
|
809
|
+
this.module.i32.const(elementSize),
|
|
809
810
|
),
|
|
810
811
|
);
|
|
811
|
-
|
|
812
|
+
const elementwise = this.module.block(null, [
|
|
812
813
|
this.module.local.set(counterLocal, this.module.i32.const(0)),
|
|
813
814
|
this.module.loop(
|
|
814
815
|
loopLabel,
|
|
@@ -829,6 +830,18 @@ export class MirCompilerLowering extends MirCompilerCore {
|
|
|
829
830
|
),
|
|
830
831
|
),
|
|
831
832
|
]);
|
|
833
|
+
return this.module.if(
|
|
834
|
+
this.module.i32.ne(count(), this.module.i32.const(0)),
|
|
835
|
+
this.module.if(
|
|
836
|
+
this.module.i32.eq(slice()[3], this.module.i32.const(elementSize)),
|
|
837
|
+
this.module.memory.copy(
|
|
838
|
+
destination(),
|
|
839
|
+
slice()[0],
|
|
840
|
+
this.module.i32.mul(count(), this.module.i32.const(elementSize)),
|
|
841
|
+
),
|
|
842
|
+
elementwise,
|
|
843
|
+
),
|
|
844
|
+
);
|
|
832
845
|
}
|
|
833
846
|
|
|
834
847
|
compileOutputStore(data, context) {
|