@onda-lang/binaryen-web 0.8.5 → 0.8.7
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 +78 -13
- package/package.json +2 -2
- package/src/artifact.d.ts +1 -20
- package/src/compiler/core.js +3 -3
- package/src/compiler/event-input.js +3 -2
- package/src/compiler/lowering.js +15 -2
- package/src/compiler/shared.js +2 -1
- package/src/index.d.ts +7 -0
- package/src/index.js +6 -0
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
|
@@ -121,8 +121,10 @@ versions rather than guessing layout compatibility.
|
|
|
121
121
|
`createParamControl(metadata)` validates one scalar parameter descriptor and returns a reusable
|
|
122
122
|
`OndaPreparedParamControl`. For an array, `createParamControl(metadata, index)` prepares one element;
|
|
123
123
|
`paramElementMetadata(metadata, index)` projects its scalar descriptor, default, and storage offset.
|
|
124
|
-
The Web Audio adapter
|
|
125
|
-
`
|
|
124
|
+
The Web Audio adapter exposes `setParamElement(nameOrIndex, element, value)` and
|
|
125
|
+
`setParamElementNormalized(nameOrIndex, element, normalized)` for individual scalar or fixed-array
|
|
126
|
+
elements. Indexed names such as `offsets[1]` remain accepted by `setParam` and
|
|
127
|
+
`setParamNormalized`; exact-length arrays use `setParam("offsets", values)`.
|
|
126
128
|
`createParamDomain(domain)` does the same from already-decoded values.
|
|
127
129
|
Prepared controls expose `constrainPlain`, `normalizedToPlain`, and `plainToNormalized` methods.
|
|
128
130
|
|
|
@@ -135,14 +137,17 @@ endpoints, apply linear, logarithmic, or curved scale, and clamp and snap to the
|
|
|
135
137
|
|
|
136
138
|
Complete wasm32 processor exports receive an optional execution-output descriptor containing
|
|
137
139
|
independently nullable delegate and print batches. Allocate all descriptors and storage before
|
|
138
|
-
real-time execution.
|
|
140
|
+
real-time execution. Their linear-memory regions must be mutually disjoint and must not overlap any
|
|
141
|
+
other region accessed by the processor call, matching the processor ABI's execution-output
|
|
142
|
+
contract.
|
|
139
143
|
|
|
140
144
|
`writeDelegateBatch` and `writePrintBatch` initialize reusable batch descriptors.
|
|
141
145
|
`writeExecutionOutput` connects their addresses. Call `resetExecutionOutput` immediately before
|
|
142
|
-
every generated init or process entry. Generated event entries reset
|
|
143
|
-
|
|
146
|
+
every generated init or process entry. Generated event entries reset before input preflight, so
|
|
147
|
+
rejected input returns empty batches. After a successful generated call,
|
|
144
148
|
`readDelegateBatch` or `readPrintBatch` validates the result counters.
|
|
145
|
-
`
|
|
149
|
+
`decodeDelegateBatch` validates and decodes a complete delegate batch in one call;
|
|
150
|
+
`decodeDelegateRecords` decodes an already-isolated storage region using `metadata.delegates`.
|
|
146
151
|
`decodePrintRecords` preserves primitive types and source sites; `formatPrintRecords` and
|
|
147
152
|
`formatPrintBatch` add canonical text formatting. Both decoded record types expose a `sequence` from
|
|
148
153
|
the host-reset call-local counter; merge that call's two arrays by this field when presenting one
|
|
@@ -184,27 +189,36 @@ The package root re-exports the common artifact validation and file helpers. The
|
|
|
184
189
|
- `compileOndaProcessorModule(artifact)` validates and compiles a reusable module off the render thread.
|
|
185
190
|
- `ondaAudioWorkletNodeOptions(artifact, options?)` builds low-level node options.
|
|
186
191
|
- `createOndaAudioProcessor(context, artifact, options?)` allocates an uninitialized adapter.
|
|
187
|
-
- `createOndaAudioProcessorInitialized(context, artifact, options?)` allocates
|
|
192
|
+
- `createOndaAudioProcessorInitialized(context, artifact, options?)` allocates it, requests full
|
|
193
|
+
initialization through the status-bearing control protocol, and resolves only on success.
|
|
188
194
|
- `flattenedAudioChannelCount(ports?)` totals declared physical channels with validation.
|
|
189
195
|
|
|
190
196
|
`OndaAudioProcessorOptions` accepts initial plain parameter values, external buffers, event,
|
|
191
197
|
delegate, and print capacities, an optional construction-time `onPrint` listener, a precompiled
|
|
192
198
|
module, custom node options, and an `AudioWorkletNode` constructor. Pass `onPrint` when using the
|
|
193
|
-
initialized
|
|
199
|
+
initialized factory if initialization output must be observed; registering a listener after
|
|
194
200
|
construction cannot replay output from an execution that has already completed. The artifact sample
|
|
195
201
|
rate must equal the context sample rate and it must expose at least one audio input or output.
|
|
196
202
|
Print and delegate delivery uses a bounded `SharedArrayBuffer` ring and requires cross-origin
|
|
197
203
|
isolation in browsers; ordinary audio processing remains available when shared memory is absent.
|
|
198
204
|
Low-level callers that manually pair the returned node options with `OndaAudioProcessor` must pass
|
|
199
|
-
|
|
205
|
+
the artifact metadata as the adapter constructor's second argument and
|
|
206
|
+
`processorOptions.executionOutputRing` as its fourth argument. Event encoding and numeric
|
|
207
|
+
unknown-index classification require that metadata.
|
|
200
208
|
|
|
201
209
|
### `OndaAudioProcessor`
|
|
202
210
|
|
|
203
211
|
The adapter exposes its `node` and validated `metadata`, plus these operations:
|
|
204
212
|
|
|
205
|
-
- `setParam(nameOrIndex, plain)` and `setParamNormalized(nameOrIndex, normalized)
|
|
206
|
-
|
|
207
|
-
- `
|
|
213
|
+
- `setParam(nameOrIndex, plain)` and `setParamNormalized(nameOrIndex, normalized)` for whole
|
|
214
|
+
parameters.
|
|
215
|
+
- `setParamElement(nameOrIndex, element, plain)` and
|
|
216
|
+
`setParamElementNormalized(nameOrIndex, element, normalized)` for one scalar or fixed-array
|
|
217
|
+
element.
|
|
218
|
+
- `trigger(nameOrIndex, values?)` for input events. Unknown nonnegative numeric indices are
|
|
219
|
+
successful no-ops, matching native dispatch; unknown names and negative indices are rejected.
|
|
220
|
+
- `onExecutionError(listener)`, `onDelegates(listener)`, and `onPrint(listener)`, each returning an
|
|
221
|
+
unsubscribe function.
|
|
208
222
|
- `init(mode)`, `snapshot()`, and `restoreSnapshot(bytes)`.
|
|
209
223
|
- `readControlOutputs()` and `readBuffer(nameOrIndex)`.
|
|
210
224
|
- `request(type, fields?, transfer?)` for adapter protocol extensions.
|
|
@@ -222,7 +236,24 @@ each init, event, or process segment.
|
|
|
222
236
|
|
|
223
237
|
`ONDA_INIT_FULL` clears and initializes all physical state. `ONDA_INIT_PRESERVE_PINNED` retains
|
|
224
238
|
pinned state according to the processor ABI. The package also re-exports the prepared and one-shot
|
|
225
|
-
parameter conversion helpers.
|
|
239
|
+
parameter conversion helpers. Snapshot restoration performs its internal full initialization
|
|
240
|
+
silently, without delivering init prints or delegates.
|
|
241
|
+
|
|
242
|
+
Raw WebAssembly exports use the same generated status values as native processor objects:
|
|
243
|
+
`PROCESSOR_EXECUTION_OK` (`0`), `PROCESSOR_EXECUTION_RUNTIME_SAFETY_FAILURE` (`1`), and event-only
|
|
244
|
+
`PROCESSOR_EXECUTION_INPUT_REJECTED` (`2`). The Web Audio adapter translates host-side validation
|
|
245
|
+
problems into rejected promises before generated execution. It also rejects init and event promises
|
|
246
|
+
when generated code returns a nonzero status: status `1` invalidates the live processor, while event
|
|
247
|
+
status `2` preserves it. These generated failures use `OndaExecutionError`, whose `operation` and
|
|
248
|
+
`status` fields retain the machine-readable failure. The Web Audio root re-exports all three
|
|
249
|
+
`PROCESSOR_EXECUTION_*` constants for direct comparison. Render-time process failure invalidates the
|
|
250
|
+
processor and silences subsequent callbacks. `onExecutionError(listener)` receives its typed
|
|
251
|
+
`OndaExecutionError`; requested init and event failures remain on their promise rejection path and
|
|
252
|
+
are not reported twice.
|
|
253
|
+
The raw `@onda-lang/processor-abi` package exposes `PROCESSOR_BEGIN_BLOCK`,
|
|
254
|
+
`PROCESSOR_END_BLOCK`, and `PROCESSOR_FULL_BLOCK` for native and direct WebAssembly hosts that use
|
|
255
|
+
segmented processing. Web Audio schedules render quanta internally and has no segmented-process
|
|
256
|
+
method.
|
|
226
257
|
|
|
227
258
|
`@onda-lang/webaudio/worklet` is the side-effect-only AudioWorklet registration module and has no
|
|
228
259
|
named exports.
|
|
@@ -269,8 +300,11 @@ PRINT_RECORD_HEADER_SIZE_BYTES
|
|
|
269
300
|
PROCESSOR_ABI_VERSION
|
|
270
301
|
PROCESSOR_ARTIFACT_FORMAT
|
|
271
302
|
PROCESSOR_ARTIFACT_FORMAT_VERSION
|
|
303
|
+
PROCESSOR_BEGIN_BLOCK
|
|
304
|
+
PROCESSOR_END_BLOCK
|
|
272
305
|
PROCESSOR_EXECUTION_OK
|
|
273
306
|
PROCESSOR_EXECUTION_RUNTIME_SAFETY_FAILURE
|
|
307
|
+
PROCESSOR_FULL_BLOCK
|
|
274
308
|
PROCESSOR_INIT_FULL
|
|
275
309
|
PROCESSOR_INIT_PRESERVE_PINNED
|
|
276
310
|
PROCESSOR_SNAPSHOT_FORMAT_VERSION
|
|
@@ -279,6 +313,7 @@ createParamControl
|
|
|
279
313
|
paramElementMetadata
|
|
280
314
|
createParamDomain
|
|
281
315
|
createProcessorArtifactFiles
|
|
316
|
+
decodeDelegateBatch
|
|
282
317
|
decodeDelegateRecords
|
|
283
318
|
decodePrintRecords
|
|
284
319
|
formatPrintBatch
|
|
@@ -303,6 +338,7 @@ OndaPayloadSchema
|
|
|
303
338
|
OndaPayloadDefault
|
|
304
339
|
OndaPayloadValue
|
|
305
340
|
OndaPayloadSizes
|
|
341
|
+
OndaPayloadTensorMetadata
|
|
306
342
|
PayloadPlan
|
|
307
343
|
canonicalF32Number
|
|
308
344
|
EVENT_INPUT_SIZE_BYTES
|
|
@@ -317,12 +353,19 @@ OndaArtifactError
|
|
|
317
353
|
OndaBinaryenError
|
|
318
354
|
OndaBinaryenOptions
|
|
319
355
|
OndaProcessorArtifact
|
|
356
|
+
OndaProcessorInitMode
|
|
320
357
|
OndaProcessorMetadata
|
|
321
358
|
PROCESSOR_ABI_VERSION
|
|
322
359
|
PROCESSOR_ARTIFACT_FORMAT
|
|
323
360
|
PROCESSOR_ARTIFACT_FORMAT_VERSION
|
|
361
|
+
PROCESSOR_BEGIN_BLOCK
|
|
362
|
+
PROCESSOR_END_BLOCK
|
|
363
|
+
PROCESSOR_EXECUTION_INPUT_REJECTED
|
|
324
364
|
PROCESSOR_EXECUTION_OK
|
|
325
365
|
PROCESSOR_EXECUTION_RUNTIME_SAFETY_FAILURE
|
|
366
|
+
PROCESSOR_FULL_BLOCK
|
|
367
|
+
PROCESSOR_INIT_FULL
|
|
368
|
+
PROCESSOR_INIT_PRESERVE_PINNED
|
|
326
369
|
PROCESSOR_SNAPSHOT_FORMAT_VERSION
|
|
327
370
|
SUPPORTED_MIR_SCHEMA_VERSION
|
|
328
371
|
compileTrustedMir
|
|
@@ -363,6 +406,7 @@ OndaLspAnalysisOptions
|
|
|
363
406
|
OndaLspMessage
|
|
364
407
|
OndaMaterializedProjectFile
|
|
365
408
|
OndaProcessorArtifact
|
|
409
|
+
OndaProcessorInitMode
|
|
366
410
|
OndaProcessorMetadata
|
|
367
411
|
OndaProjectBufferInfo
|
|
368
412
|
OndaProjectCapabilities
|
|
@@ -380,8 +424,14 @@ OndaWorkerLike
|
|
|
380
424
|
PROCESSOR_ABI_VERSION
|
|
381
425
|
PROCESSOR_ARTIFACT_FORMAT
|
|
382
426
|
PROCESSOR_ARTIFACT_FORMAT_VERSION
|
|
427
|
+
PROCESSOR_BEGIN_BLOCK
|
|
428
|
+
PROCESSOR_END_BLOCK
|
|
429
|
+
PROCESSOR_EXECUTION_INPUT_REJECTED
|
|
383
430
|
PROCESSOR_EXECUTION_OK
|
|
384
431
|
PROCESSOR_EXECUTION_RUNTIME_SAFETY_FAILURE
|
|
432
|
+
PROCESSOR_FULL_BLOCK
|
|
433
|
+
PROCESSOR_INIT_FULL
|
|
434
|
+
PROCESSOR_INIT_PRESERVE_PINNED
|
|
385
435
|
PROCESSOR_SNAPSHOT_FORMAT_VERSION
|
|
386
436
|
WorkerCompilerOptions
|
|
387
437
|
createCompiler
|
|
@@ -405,11 +455,16 @@ OndaAudioProcessor
|
|
|
405
455
|
OndaAudioProcessorOptions
|
|
406
456
|
OndaAudioPrintBatch
|
|
407
457
|
OndaAudioPrintListener
|
|
458
|
+
OndaExecutionError
|
|
459
|
+
OndaExecutionErrorListener
|
|
408
460
|
OndaInitMode
|
|
409
461
|
OndaParamDomain
|
|
410
462
|
OndaPreparedParamControl
|
|
411
463
|
OndaProcessorArtifact
|
|
412
464
|
OndaProcessorMetadata
|
|
465
|
+
PROCESSOR_EXECUTION_INPUT_REJECTED
|
|
466
|
+
PROCESSOR_EXECUTION_OK
|
|
467
|
+
PROCESSOR_EXECUTION_RUNTIME_SAFETY_FAILURE
|
|
413
468
|
compileOndaProcessorModule
|
|
414
469
|
constrainParamPlain
|
|
415
470
|
createOndaAudioProcessor
|
|
@@ -432,11 +487,21 @@ are rejected. Missing event arguments use declared constant defaults.
|
|
|
432
487
|
Supply `i64` as `bigint`, an exact safe integer, or a decimal string. `decode(bytes)` returns named
|
|
433
488
|
nested values with `bigint` for `i64`. Plans own immutable schema snapshots.
|
|
434
489
|
|
|
490
|
+
`tensorMetadata` exposes the schema's flattened SoA contract without reparsing JSON. Each immutable
|
|
491
|
+
record contains `path`, `encoding`, fixed `shape`, `parameterIndex`, `isSlice`, and
|
|
492
|
+
`fixedElementCount`. Tuple path components use `__0`, `__1`, and so on. A slice's runtime tensor
|
|
493
|
+
length is its logical length times `fixedElementCount`; the dynamic outer axis is therefore not
|
|
494
|
+
repeated in `shape`.
|
|
495
|
+
|
|
435
496
|
`requiredWorkspace(bytes)` preflights packed little-endian input. `sizes(lengths)` reports wire
|
|
436
497
|
and aligned workspace sizes without allocating payload storage. Low-level wasm hosts provision
|
|
437
498
|
both regions and a 16-byte descriptor, then call `writeEventInput` before invoking the event.
|
|
438
499
|
Rejected input returns `PROCESSOR_EXECUTION_INPUT_REJECTED` (2) and leaves processor state usable.
|
|
439
500
|
`OndaAudioProcessor.trigger` performs logical encoding before transferring bytes to the worklet.
|
|
501
|
+
Web hosts intentionally have no unchecked tensor-view event entry: JavaScript values must cross the
|
|
502
|
+
main-thread/worklet and Wasm linear-memory boundaries, so native borrowed addresses cannot be
|
|
503
|
+
preserved end to end. Web event dispatch remains the packed, checked `onda_event_N` path and uses
|
|
504
|
+
its preallocated workspace.
|
|
440
505
|
Decoded `f32` leaves use `canonicalF32Number(value)`: the returned JavaScript number has the
|
|
441
506
|
shortest decimal representation that round-trips to the same `f32`, so JSON and controls do not
|
|
442
507
|
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.7",
|
|
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.7",
|
|
50
50
|
"binaryen": "130.0.0"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
package/src/artifact.d.ts
CHANGED
|
@@ -1,20 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
OndaArtifactError,
|
|
3
|
-
PROCESSOR_ABI_VERSION,
|
|
4
|
-
PROCESSOR_ARTIFACT_FORMAT,
|
|
5
|
-
PROCESSOR_ARTIFACT_FORMAT_VERSION,
|
|
6
|
-
PROCESSOR_EXECUTION_OK,
|
|
7
|
-
PROCESSOR_EXECUTION_RUNTIME_SAFETY_FAILURE,
|
|
8
|
-
PROCESSOR_SNAPSHOT_FORMAT_VERSION,
|
|
9
|
-
createProcessorArtifactFiles,
|
|
10
|
-
loadProcessorArtifactFiles,
|
|
11
|
-
parseProcessorMetadata,
|
|
12
|
-
serializeProcessorMetadata,
|
|
13
|
-
validateProcessorArtifact,
|
|
14
|
-
validateProcessorMetadata,
|
|
15
|
-
validateProcessorModule,
|
|
16
|
-
} from "@onda-lang/processor-abi";
|
|
17
|
-
export type {
|
|
18
|
-
OndaProcessorArtifact,
|
|
19
|
-
OndaProcessorMetadata,
|
|
20
|
-
} from "@onda-lang/processor-abi";
|
|
1
|
+
export * from "@onda-lang/processor-abi";
|
package/src/compiler/core.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
MATH_KERNEL_STACK_GLOBAL,
|
|
16
16
|
MAX_MEMORY_PAGES,
|
|
17
17
|
DEFAULT_OPTIMIZE_LEVEL,
|
|
18
|
-
|
|
18
|
+
PROCESSOR_FULL_BLOCK,
|
|
19
19
|
DELEGATE_BATCH_USED_OFFSET,
|
|
20
20
|
DELEGATE_BATCH_RECORD_COUNT_OFFSET,
|
|
21
21
|
DELEGATE_BATCH_OVERFLOW_OFFSET,
|
|
@@ -2443,7 +2443,7 @@ export class MirCompilerCore {
|
|
|
2443
2443
|
this.module.i32.ne(
|
|
2444
2444
|
this.module.i32.and(
|
|
2445
2445
|
flags(),
|
|
2446
|
-
this.module.i32.const(~
|
|
2446
|
+
this.module.i32.const(~PROCESSOR_FULL_BLOCK),
|
|
2447
2447
|
),
|
|
2448
2448
|
this.module.i32.const(0),
|
|
2449
2449
|
),
|
|
@@ -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) {
|
package/src/compiler/shared.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
PROCESSOR_ARTIFACT_FORMAT_VERSION,
|
|
10
10
|
PROCESSOR_EXECUTION_OK,
|
|
11
11
|
PROCESSOR_EXECUTION_RUNTIME_SAFETY_FAILURE,
|
|
12
|
+
PROCESSOR_FULL_BLOCK,
|
|
12
13
|
PROCESSOR_SNAPSHOT_FORMAT_VERSION,
|
|
13
14
|
validateProcessorMetadata,
|
|
14
15
|
} from "../artifact.js";
|
|
@@ -23,6 +24,7 @@ export {
|
|
|
23
24
|
PROCESSOR_ARTIFACT_FORMAT_VERSION,
|
|
24
25
|
PROCESSOR_EXECUTION_OK,
|
|
25
26
|
PROCESSOR_EXECUTION_RUNTIME_SAFETY_FAILURE,
|
|
27
|
+
PROCESSOR_FULL_BLOCK,
|
|
26
28
|
PROCESSOR_SNAPSHOT_FORMAT_VERSION,
|
|
27
29
|
validateProcessorMetadata,
|
|
28
30
|
};
|
|
@@ -35,7 +37,6 @@ export const MATH_KERNEL_STACK_GLOBAL = "__stack_pointer";
|
|
|
35
37
|
export const MAX_MEMORY_PAGES = 65_536;
|
|
36
38
|
export const WASM32_ADDRESS_SPACE_BYTES = MAX_MEMORY_PAGES * PAGE_BYTES;
|
|
37
39
|
export const DEFAULT_OPTIMIZE_LEVEL = 4;
|
|
38
|
-
export const ONDA_PROCESS_FULL_BLOCK = (1 << 0) | (1 << 1);
|
|
39
40
|
export const DELEGATE_RECORD_HEADER_SIZE = 12;
|
|
40
41
|
export const DELEGATE_BATCH_STORAGE_OFFSET = 0;
|
|
41
42
|
export const DELEGATE_BATCH_CAPACITY_OFFSET = 4;
|
package/src/index.d.ts
CHANGED
|
@@ -4,8 +4,14 @@ export {
|
|
|
4
4
|
PROCESSOR_ABI_VERSION,
|
|
5
5
|
PROCESSOR_ARTIFACT_FORMAT,
|
|
6
6
|
PROCESSOR_ARTIFACT_FORMAT_VERSION,
|
|
7
|
+
PROCESSOR_BEGIN_BLOCK,
|
|
8
|
+
PROCESSOR_END_BLOCK,
|
|
9
|
+
PROCESSOR_EXECUTION_INPUT_REJECTED,
|
|
7
10
|
PROCESSOR_EXECUTION_OK,
|
|
8
11
|
PROCESSOR_EXECUTION_RUNTIME_SAFETY_FAILURE,
|
|
12
|
+
PROCESSOR_FULL_BLOCK,
|
|
13
|
+
PROCESSOR_INIT_FULL,
|
|
14
|
+
PROCESSOR_INIT_PRESERVE_PINNED,
|
|
9
15
|
PROCESSOR_SNAPSHOT_FORMAT_VERSION,
|
|
10
16
|
createProcessorArtifactFiles,
|
|
11
17
|
loadProcessorArtifactFiles,
|
|
@@ -17,6 +23,7 @@ export {
|
|
|
17
23
|
} from "@onda-lang/processor-abi";
|
|
18
24
|
export type {
|
|
19
25
|
OndaProcessorArtifact,
|
|
26
|
+
OndaProcessorInitMode,
|
|
20
27
|
OndaProcessorMetadata,
|
|
21
28
|
} from "@onda-lang/processor-abi";
|
|
22
29
|
import type { OndaProcessorArtifact } from "@onda-lang/processor-abi";
|
package/src/index.js
CHANGED
|
@@ -6,8 +6,14 @@ export {
|
|
|
6
6
|
PROCESSOR_ABI_VERSION,
|
|
7
7
|
PROCESSOR_ARTIFACT_FORMAT,
|
|
8
8
|
PROCESSOR_ARTIFACT_FORMAT_VERSION,
|
|
9
|
+
PROCESSOR_BEGIN_BLOCK,
|
|
10
|
+
PROCESSOR_END_BLOCK,
|
|
11
|
+
PROCESSOR_EXECUTION_INPUT_REJECTED,
|
|
9
12
|
PROCESSOR_EXECUTION_OK,
|
|
10
13
|
PROCESSOR_EXECUTION_RUNTIME_SAFETY_FAILURE,
|
|
14
|
+
PROCESSOR_FULL_BLOCK,
|
|
15
|
+
PROCESSOR_INIT_FULL,
|
|
16
|
+
PROCESSOR_INIT_PRESERVE_PINNED,
|
|
11
17
|
PROCESSOR_SNAPSHOT_FORMAT_VERSION,
|
|
12
18
|
createProcessorArtifactFiles,
|
|
13
19
|
loadProcessorArtifactFiles,
|