@onda-lang/wasm-compiler 0.8.38 → 0.8.40
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 +4 -0
- package/api.md +9 -2
- package/dist/backend/compiler/lowering.js +3 -1
- package/dist/backend/compiler/simd.js +154 -0
- package/dist/build.json +3 -3
- package/dist/frontend/README.md +1 -1
- package/dist/frontend/onda_compiler_web.d.ts +6 -6
- package/dist/frontend/onda_compiler_web.js +24 -15
- package/dist/frontend/onda_compiler_web_bg.wasm +0 -0
- package/dist/frontend/onda_compiler_web_bg.wasm.d.ts +3 -3
- package/dist/frontend/package.json +1 -1
- package/dist/licenses/RUST-DEPENDENCIES.txt +8 -8
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/src/index.d.ts +5 -0
- package/src/index.js +6 -4
- package/src/worker.js +1 -0
package/README.md
CHANGED
|
@@ -92,6 +92,9 @@ const { artifact, sourceFiles } = await compiler.compileWorkspace({
|
|
|
92
92
|
console.log(sourceFiles);
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
+
An optional `workspace.constants` object carries project-manifest defaults: numbers, booleans,
|
|
96
|
+
decimal strings for `i64`, and primitive arrays. Explicit `options.constants` override them.
|
|
97
|
+
|
|
95
98
|
Compilation failures throw `OndaCompileError`. Its `diagnostics` property contains structured
|
|
96
99
|
parse, semantic, MIR, configuration, or code-generation diagnostics. Its `sourceFiles` property
|
|
97
100
|
contains every project source resolved before compilation stopped, allowing hosts to retain useful
|
|
@@ -117,6 +120,7 @@ const sample = await compiler.encodeBufferAsset({
|
|
|
117
120
|
const image = await compiler.createProjectImage(
|
|
118
121
|
compiled.sourceGraph,
|
|
119
122
|
new Map([["sample", sample]]),
|
|
123
|
+
workspace.constants,
|
|
120
124
|
);
|
|
121
125
|
|
|
122
126
|
const replayed = await compiler.compileProjectImage(image.bytes, options);
|
package/api.md
CHANGED
|
@@ -70,7 +70,7 @@ The returned instance provides:
|
|
|
70
70
|
- `compileSource(source, options?)` and `inspectSourceConstants(source, options?)`.
|
|
71
71
|
- `compileWorkspace(workspace, options?)` and `inspectWorkspaceConstants(workspace, options?)`.
|
|
72
72
|
- `compileProjectImage(bytes, options?)` and `inspectProjectImageConstants(bytes, options?)`.
|
|
73
|
-
- `createProjectImage(sourceGraph, buffers?)`, `inspectProjectImage(bytes)`,
|
|
73
|
+
- `createProjectImage(sourceGraph, buffers?, constants?)`, `inspectProjectImage(bytes)`,
|
|
74
74
|
`loadProjectFiles(files, projectFilePath?)`, and `materializeProjectImage(bytes, names?)`.
|
|
75
75
|
- `encodeBufferAsset(binding)`, `decodeBufferAsset(bytes)`, and `decodeBufferFile(bytes, path?)`.
|
|
76
76
|
- `projectCapabilities()` for supported image, buffer, and standard-library versions.
|
|
@@ -78,6 +78,9 @@ The returned instance provides:
|
|
|
78
78
|
- `dispose()`, an idempotent terminal release of compiler and worker resources.
|
|
79
79
|
|
|
80
80
|
Compile options accept `sampleRate`, `blockSize`, typed compile-constant overrides, and `codegen`.
|
|
81
|
+
Workspaces may carry `constants` in project-manifest form (numbers, booleans, decimal strings for
|
|
82
|
+
`i64`, and primitive arrays). These are project defaults; explicit `options.constants` take
|
|
83
|
+
precedence. Pass the same defaults to `createProjectImage` when exporting an edited workspace.
|
|
81
84
|
The sample rate defaults to 48000 Hz and the block size to 512 frames.
|
|
82
85
|
Code generation can select optimization level `0..4`, shrink level `0..2`, strict or fast math,
|
|
83
86
|
SIMD, loop-containing inlining, and optional WAT emission. A successful compilation returns an
|
|
@@ -136,6 +139,9 @@ endpoints, apply linear, logarithmic, or curved scale, and clamp and snap to the
|
|
|
136
139
|
|
|
137
140
|
### Delegates and print output
|
|
138
141
|
|
|
142
|
+
See the [host output guide](https://onda-lang.org/docs/host-output/#javascript-and-web-audio)
|
|
143
|
+
for batch sizing, decoding, formatting, and Web Audio listener examples.
|
|
144
|
+
|
|
139
145
|
Complete wasm32 processor exports receive an optional execution-output descriptor containing
|
|
140
146
|
independently nullable delegate and print batches. Allocate all descriptors and storage before
|
|
141
147
|
real-time execution. Their linear-memory regions must be mutually disjoint and must not overlap any
|
|
@@ -156,7 +162,7 @@ chronological output stream.
|
|
|
156
162
|
|
|
157
163
|
Batch capacity is host policy. `overflowCount` reports whole records that did not fit; it is not a
|
|
158
164
|
byte count. Consume the returned storage before reusing it for another init, process, or event call.
|
|
159
|
-
See the [language guide](https://onda-lang.org/docs/language/#delegates) for authored semantics and
|
|
165
|
+
See the [language guide](https://onda-lang.org/docs/language/#delegates-and-when) for authored semantics and
|
|
160
166
|
the [processor API](https://onda-lang.org/docs/processor-api/#call-scoped-execution-output) for
|
|
161
167
|
physical record layout.
|
|
162
168
|
|
|
@@ -425,6 +431,7 @@ OndaProcessorInitMode
|
|
|
425
431
|
OndaProcessorMetadata
|
|
426
432
|
OndaProjectBufferInfo
|
|
427
433
|
OndaProjectCapabilities
|
|
434
|
+
OndaProjectConstant
|
|
428
435
|
OndaProjectImageInfo
|
|
429
436
|
OndaProjectMaterialization
|
|
430
437
|
OndaResolvedCompileConstValue
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import binaryen from "binaryen";
|
|
2
|
+
import { vectorizeSampleLoop } from "./simd.js";
|
|
2
3
|
import { MirCompilerCore } from "./core.js";
|
|
3
4
|
import {
|
|
4
5
|
DELEGATE_RECORD_HEADER_SIZE,
|
|
@@ -94,12 +95,13 @@ export class MirCompilerLowering extends MirCompilerCore {
|
|
|
94
95
|
const body = this.compileBlock(data.body, context);
|
|
95
96
|
context.breakLabels.pop();
|
|
96
97
|
context.continueLabels.pop();
|
|
97
|
-
|
|
98
|
+
const scalarLoop = this.module.block(breakLabel, [
|
|
98
99
|
this.module.loop(
|
|
99
100
|
continueLabel,
|
|
100
101
|
this.module.block(null, [body, this.module.br(continueLabel)]),
|
|
101
102
|
),
|
|
102
103
|
]);
|
|
104
|
+
return vectorizeSampleLoop(this, statement, context, scalarLoop) ?? scalarLoop;
|
|
103
105
|
}
|
|
104
106
|
case "break":
|
|
105
107
|
return this.module.br(this.currentLabel(context.breakLabels, "break"));
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Vectorize independent sample iterations. The proof admits only straight-line
|
|
2
|
+
// float arithmetic, invariant reads, and contiguous audio I/O. Stateful loops,
|
|
3
|
+
// calls, gathers, and loop-carried values retain scalar lowering.
|
|
4
|
+
import binaryen from "binaryen";
|
|
5
|
+
import { POINTER_GLOBALS } from "./shared.js";
|
|
6
|
+
|
|
7
|
+
const local = (value) => value?.kind === "local" ? value.data : null;
|
|
8
|
+
const destination = (data) => data?.destination?.projections?.length === 0
|
|
9
|
+
? local(data.destination.base) : null;
|
|
10
|
+
const isOne = (value) => value?.kind === "constant"
|
|
11
|
+
&& value.data.type === "i32" && value.data.value === 1;
|
|
12
|
+
const same = (a, b) => local(a) !== null && local(a) === local(b);
|
|
13
|
+
|
|
14
|
+
export function vectorizeSampleLoop(compiler, statement, context, scalarLoop) {
|
|
15
|
+
if (!compiler.options.simd || context.function.kind.kind !== "process") return null;
|
|
16
|
+
const loop = statement.kind.data.body.statements;
|
|
17
|
+
if (loop.length !== 2 || loop[0].kind.kind !== "assign" || loop[1].kind.kind !== "if") return null;
|
|
18
|
+
const test = loop[0].kind.data;
|
|
19
|
+
const branch = loop[1].kind.data;
|
|
20
|
+
const comparison = test.value;
|
|
21
|
+
if (comparison.kind !== "compare" || comparison.data.op !== "less"
|
|
22
|
+
|| local(comparison.data.lhs) === null || destination(test) !== local(branch.condition)
|
|
23
|
+
|| branch.else_block.statements.length !== 1
|
|
24
|
+
|| branch.else_block.statements[0].kind.kind !== "break") return null;
|
|
25
|
+
const index = local(comparison.data.lhs);
|
|
26
|
+
const limit = comparison.data.rhs;
|
|
27
|
+
const body = branch.then_block.statements;
|
|
28
|
+
const step = body.at(-1)?.kind;
|
|
29
|
+
if (step?.kind !== "assign" || destination(step.data) !== index
|
|
30
|
+
|| step.data.value.kind !== "binary" || step.data.value.data.op !== "add"
|
|
31
|
+
|| local(step.data.value.data.lhs) !== index || !isOne(step.data.value.data.rhs)) return null;
|
|
32
|
+
// Require the actual segment length, not an arbitrary integer loop bound.
|
|
33
|
+
const limitDefinitions = context.function.body.statements.filter((item) =>
|
|
34
|
+
item.kind.kind === "assign" && destination(item.kind.data) === local(limit));
|
|
35
|
+
if (limitDefinitions.length !== 1) return null;
|
|
36
|
+
const limitLoad = limitDefinitions[0].kind.data.value;
|
|
37
|
+
if (limitLoad.kind !== "load" || limitLoad.data.base.kind !== "parameter"
|
|
38
|
+
|| limitLoad.data.base.data !== 1 || limitLoad.data.projections.length !== 0) return null;
|
|
39
|
+
const frameStatement = body[0]?.kind;
|
|
40
|
+
if (frameStatement?.kind !== "assign" || frameStatement.data.value.kind !== "process_frame"
|
|
41
|
+
|| local(frameStatement.data.value.data.offset) !== index) return null;
|
|
42
|
+
const frame = destination(frameStatement.data);
|
|
43
|
+
const operations = body.slice(1, -1);
|
|
44
|
+
const written = new Set();
|
|
45
|
+
let scalar;
|
|
46
|
+
const ports = new Map();
|
|
47
|
+
const addPort = (kind, data) => {
|
|
48
|
+
const layout = kind === "input" ? compiler.inputLayout[data.input] : compiler.outputLayout[data.output];
|
|
49
|
+
if (!layout || layout.scalar !== scalar || data.element !== null || local(data.frame) !== frame) return false;
|
|
50
|
+
ports.set(`${kind}:${kind === "input" ? data.input : data.output}`, { kind, data, layout });
|
|
51
|
+
return true;
|
|
52
|
+
};
|
|
53
|
+
for (const operation of operations) {
|
|
54
|
+
if (operation.kind.kind === "assign") {
|
|
55
|
+
const id = destination(operation.kind.data);
|
|
56
|
+
if (id === null || id === index || id === frame || compiler.localScalarRefLayout[context.functionId][id]) return null;
|
|
57
|
+
const type = context.localScalars[id];
|
|
58
|
+
if (!['f32', 'f64'].includes(type) || (scalar && scalar !== type)) return null;
|
|
59
|
+
scalar = type;
|
|
60
|
+
written.add(id);
|
|
61
|
+
} else if (operation.kind.kind !== "output_store") return null;
|
|
62
|
+
}
|
|
63
|
+
if (!scalar) return null;
|
|
64
|
+
const defined = new Set();
|
|
65
|
+
const validValue = (value) => value?.kind === "constant" ? value.data.type === scalar
|
|
66
|
+
: local(value) !== null && context.localScalars[value.data] === scalar
|
|
67
|
+
&& (!written.has(value.data) || defined.has(value.data));
|
|
68
|
+
let stores = 0;
|
|
69
|
+
for (const operation of operations) {
|
|
70
|
+
const { kind, data } = operation.kind;
|
|
71
|
+
if (kind === "output_store") {
|
|
72
|
+
if (!validValue(data.value) || !addPort("output", data)) return null;
|
|
73
|
+
stores += 1;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const value = data.value;
|
|
77
|
+
switch (value.kind) {
|
|
78
|
+
case "use": if (!validValue(value.data)) return null; break;
|
|
79
|
+
case "binary":
|
|
80
|
+
if (!['add', 'subtract', 'multiply', 'divide'].includes(value.data.op)
|
|
81
|
+
|| !validValue(value.data.lhs) || !validValue(value.data.rhs)) return null;
|
|
82
|
+
break;
|
|
83
|
+
case "input_load": if (!addPort("input", value.data)) return null; break;
|
|
84
|
+
// Parameters and state cannot change in the admitted loop. A projected
|
|
85
|
+
// load could depend on the induction variable, so leave it scalar.
|
|
86
|
+
case "load":
|
|
87
|
+
if (!['state', 'param', 'parameter'].includes(value.data.base.kind) || value.data.projections.length) return null;
|
|
88
|
+
break;
|
|
89
|
+
default: return null;
|
|
90
|
+
}
|
|
91
|
+
defined.add(destination(data));
|
|
92
|
+
}
|
|
93
|
+
if (!stores) return null;
|
|
94
|
+
|
|
95
|
+
const m = compiler.module;
|
|
96
|
+
const lanes = scalar === "f32" ? 4 : 2;
|
|
97
|
+
const vector = scalar === "f32" ? m.f32x4 : m.f64x2;
|
|
98
|
+
const locals = new Map([...written].map((id) => [id, compiler.allocateGeneratedLocal(context, "v128", "sample.vector")]));
|
|
99
|
+
const getVector = (value) => locals.has(local(value))
|
|
100
|
+
? m.local.get(locals.get(value.data), binaryen.v128)
|
|
101
|
+
: vector.splat(compiler.compileValue(value, context));
|
|
102
|
+
const pointers = new Map([...ports].map(([key, { kind, data, layout }]) => [key, () => compiler.audioChannelPointer(
|
|
103
|
+
kind === "input" ? POINTER_GLOBALS.inputs : POINTER_GLOBALS.outputs,
|
|
104
|
+
layout, data.element, data.bounds, context,
|
|
105
|
+
)]));
|
|
106
|
+
const address = (kind, data) => m.i32.add(
|
|
107
|
+
pointers.get(`${kind}:${kind === "input" ? data.input : data.output}`)(),
|
|
108
|
+
m.i32.mul(compiler.compileProcessFrame({ offset: comparison.data.lhs }, context), m.i32.const(compiler.scalarSize(scalar))),
|
|
109
|
+
);
|
|
110
|
+
const vectorBody = [];
|
|
111
|
+
const binary = { add: 'add', subtract: 'sub', multiply: 'mul', divide: 'div' };
|
|
112
|
+
for (const operation of operations) {
|
|
113
|
+
const { kind, data } = operation.kind;
|
|
114
|
+
if (kind === "output_store") {
|
|
115
|
+
vectorBody.push(m.v128.store(0, 1, address("output", data), getVector(data.value)));
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const value = data.value;
|
|
119
|
+
let expression;
|
|
120
|
+
if (value.kind === "use") expression = getVector(value.data);
|
|
121
|
+
else if (value.kind === "binary") expression = vector[binary[value.data.op]](getVector(value.data.lhs), getVector(value.data.rhs));
|
|
122
|
+
else if (value.kind === "input_load") expression = m.v128.load(0, 1, address("input", value.data));
|
|
123
|
+
else expression = vector.splat(compiler.compileRvalue(value, scalar, context));
|
|
124
|
+
vectorBody.push(m.local.set(locals.get(destination(data)), expression));
|
|
125
|
+
}
|
|
126
|
+
// Preserve locals observed by block-post code, including the last frame.
|
|
127
|
+
for (const [id, vectorLocal] of locals) {
|
|
128
|
+
vectorBody.push(compiler.storePlace({ base: { kind: "local", data: id }, projections: [] },
|
|
129
|
+
vector.extract_lane(m.local.get(vectorLocal, binaryen.v128), lanes - 1), scalar, context));
|
|
130
|
+
}
|
|
131
|
+
vectorBody.push(compiler.storePlace(frameStatement.data.destination,
|
|
132
|
+
m.i32.add(compiler.compileProcessFrame({ offset: comparison.data.lhs }, context), m.i32.const(lanes - 1)), "i32", context));
|
|
133
|
+
vectorBody.push(compiler.storePlace(step.data.destination,
|
|
134
|
+
m.i32.add(compiler.compileValue(comparison.data.lhs, context), m.i32.const(lanes)), "i32", context));
|
|
135
|
+
const label = `$onda.sample.vector.${compiler.nextLabel++}`;
|
|
136
|
+
const vectorLoop = m.loop(label, m.if(
|
|
137
|
+
m.i32.le_s(compiler.compileValue(comparison.data.lhs, context), m.i32.sub(compiler.compileValue(limit, context), m.i32.const(lanes))),
|
|
138
|
+
m.block(null, [...vectorBody, m.br(label)]),
|
|
139
|
+
));
|
|
140
|
+
// Exact in-place buffers preserve per-lane order. Partial overlap can carry
|
|
141
|
+
// data between iterations, so version the loop with a disjointness check.
|
|
142
|
+
const accessed = [...ports.keys()];
|
|
143
|
+
let safe = m.i32.const(1);
|
|
144
|
+
for (let i = 0; i < accessed.length; i += 1) {
|
|
145
|
+
for (let j = i + 1; j < accessed.length; j += 1) {
|
|
146
|
+
if (accessed[i].startsWith("input:") && accessed[j].startsWith("input:")) continue;
|
|
147
|
+
const a = pointers.get(accessed[i]);
|
|
148
|
+
const b = pointers.get(accessed[j]);
|
|
149
|
+
const distance = m.select(m.i32.lt_u(a(), b()), m.i32.sub(b(), a()), m.i32.sub(a(), b()), binaryen.i32);
|
|
150
|
+
safe = m.i32.and(safe, m.i32.or(m.i32.eq(a(), b()), m.i32.ge_u(distance, m.i32.const(compiler.mir.config.block_size * compiler.scalarSize(scalar)))));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return m.block(null, [m.if(safe, vectorLoop), scalarLoop]);
|
|
154
|
+
}
|
package/dist/build.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"ondaVersion": "0.8.
|
|
2
|
+
"ondaVersion": "0.8.40",
|
|
3
3
|
"binaryenVersion": "130.0.0",
|
|
4
4
|
"frontendPackage": "onda_compiler_web",
|
|
5
5
|
"frontendOptimization": {
|
|
6
6
|
"tool": "wasm-opt",
|
|
7
7
|
"binaryenVersion": "130.0.0",
|
|
8
8
|
"optimizeLevel": 4,
|
|
9
|
-
"inputBytes":
|
|
10
|
-
"outputBytes":
|
|
9
|
+
"inputBytes": 11446015,
|
|
10
|
+
"outputBytes": 8373471
|
|
11
11
|
}
|
|
12
12
|
}
|
package/dist/frontend/README.md
CHANGED
|
@@ -63,7 +63,7 @@ This crate deliberately stops at optimized validated MIR transport. DSP Wasm emi
|
|
|
63
63
|
Wasm math legalization, runtime layout metadata, and AudioWorklet hosting live in the Binaryen
|
|
64
64
|
package and browser example. Backend
|
|
65
65
|
compile/render measurements are documented in
|
|
66
|
-
[
|
|
66
|
+
[the benchmark guide](../../scripts/bench/README.md#compare-backend-compilation-and-runtime).
|
|
67
67
|
|
|
68
68
|
Application consumers should normally install
|
|
69
69
|
[`@onda-lang/wasm-compiler`](../../packages/onda_wasm_compiler/README.md), which packages this
|
|
@@ -58,7 +58,7 @@ export class WebProjectImageBuilder {
|
|
|
58
58
|
free(): void;
|
|
59
59
|
[Symbol.dispose](): void;
|
|
60
60
|
add_buffer(name: string, ondabuffer_bytes: Uint8Array): void;
|
|
61
|
-
constructor(source_image_json: string);
|
|
61
|
+
constructor(source_image_json: string, constants_json: string);
|
|
62
62
|
serialize(): Uint8Array;
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -78,7 +78,7 @@ export function compile_project_image_to_mir_messagepack(image_bytes: Uint8Array
|
|
|
78
78
|
|
|
79
79
|
export function compile_source_workspace_to_mir_json(entry_path: string, sources_json: string, sample_rate: number, block_size: number, constants_json: string): FrontendJsonCompilation;
|
|
80
80
|
|
|
81
|
-
export function compile_source_workspace_to_mir_messagepack(entry_path: string, sources_json: string, sample_rate: number, block_size: number, constants_json: string): FrontendMessagePackCompilation;
|
|
81
|
+
export function compile_source_workspace_to_mir_messagepack(entry_path: string, sources_json: string, sample_rate: number, block_size: number, constants_json: string, project_constants_json: string): FrontendMessagePackCompilation;
|
|
82
82
|
|
|
83
83
|
export function compile_to_mir_json(source: string, sample_rate: number, block_size: number, constants_json: string): FrontendJsonCompilation;
|
|
84
84
|
|
|
@@ -98,7 +98,7 @@ export function inspect_project_image_compile_constants(image_bytes: Uint8Array,
|
|
|
98
98
|
|
|
99
99
|
export function inspect_source_compile_constants(source: string, sample_rate: number, block_size: number, constants_json: string): string;
|
|
100
100
|
|
|
101
|
-
export function inspect_source_workspace_compile_constants(entry_path: string, sources_json: string, sample_rate: number, block_size: number, constants_json: string): string;
|
|
101
|
+
export function inspect_source_workspace_compile_constants(entry_path: string, sources_json: string, sample_rate: number, block_size: number, constants_json: string, project_constants_json: string): string;
|
|
102
102
|
|
|
103
103
|
export function materialize_project_image(image_bytes: Uint8Array, asset_file_names_json: string): WebProjectMaterializationPlan;
|
|
104
104
|
|
|
@@ -125,7 +125,7 @@ export interface InitOutput {
|
|
|
125
125
|
readonly buffer_asset_format_version: () => number;
|
|
126
126
|
readonly compile_project_image_to_mir_messagepack: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
127
127
|
readonly compile_source_workspace_to_mir_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
|
|
128
|
-
readonly compile_source_workspace_to_mir_messagepack: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
|
|
128
|
+
readonly compile_source_workspace_to_mir_messagepack: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number];
|
|
129
129
|
readonly compile_to_mir_json: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
130
130
|
readonly compile_to_mir_messagepack: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
131
131
|
readonly current_stdlib_digest: () => [number, number];
|
|
@@ -140,7 +140,7 @@ export interface InitOutput {
|
|
|
140
140
|
readonly inspect_project_image: (a: number, b: number) => [number, number, number, number];
|
|
141
141
|
readonly inspect_project_image_compile_constants: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
142
142
|
readonly inspect_source_compile_constants: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
143
|
-
readonly inspect_source_workspace_compile_constants: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
143
|
+
readonly inspect_source_workspace_compile_constants: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number, number];
|
|
144
144
|
readonly materialize_project_image: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
145
145
|
readonly mir_schema_version: () => number;
|
|
146
146
|
readonly onda_version: () => [number, number];
|
|
@@ -158,7 +158,7 @@ export interface InitOutput {
|
|
|
158
158
|
readonly webmaterializedprojectbuilder_select_project: (a: number, b: number, c: number) => [number, number];
|
|
159
159
|
readonly webmaterializedprojectbuilder_serialize: (a: number) => [number, number, number, number];
|
|
160
160
|
readonly webprojectimagebuilder_add_buffer: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
161
|
-
readonly webprojectimagebuilder_new: (a: number, b: number) => [number, number, number];
|
|
161
|
+
readonly webprojectimagebuilder_new: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
162
162
|
readonly webprojectimagebuilder_serialize: (a: number) => [number, number, number, number];
|
|
163
163
|
readonly webprojectmaterializationplan_directories_json: (a: number) => [number, number];
|
|
164
164
|
readonly webprojectmaterializationplan_file_bytes: (a: number, b: number) => [number, number];
|
|
@@ -335,11 +335,14 @@ export class WebProjectImageBuilder {
|
|
|
335
335
|
}
|
|
336
336
|
/**
|
|
337
337
|
* @param {string} source_image_json
|
|
338
|
+
* @param {string} constants_json
|
|
338
339
|
*/
|
|
339
|
-
constructor(source_image_json) {
|
|
340
|
+
constructor(source_image_json, constants_json) {
|
|
340
341
|
const ptr0 = passStringToWasm0(source_image_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
341
342
|
const len0 = WASM_VECTOR_LEN;
|
|
342
|
-
const
|
|
343
|
+
const ptr1 = passStringToWasm0(constants_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
344
|
+
const len1 = WASM_VECTOR_LEN;
|
|
345
|
+
const ret = wasm.webprojectimagebuilder_new(ptr0, len0, ptr1, len1);
|
|
343
346
|
if (ret[2]) {
|
|
344
347
|
throw takeFromExternrefTable0(ret[1]);
|
|
345
348
|
}
|
|
@@ -486,16 +489,19 @@ export function compile_source_workspace_to_mir_json(entry_path, sources_json, s
|
|
|
486
489
|
* @param {number} sample_rate
|
|
487
490
|
* @param {number} block_size
|
|
488
491
|
* @param {string} constants_json
|
|
492
|
+
* @param {string} project_constants_json
|
|
489
493
|
* @returns {FrontendMessagePackCompilation}
|
|
490
494
|
*/
|
|
491
|
-
export function compile_source_workspace_to_mir_messagepack(entry_path, sources_json, sample_rate, block_size, constants_json) {
|
|
495
|
+
export function compile_source_workspace_to_mir_messagepack(entry_path, sources_json, sample_rate, block_size, constants_json, project_constants_json) {
|
|
492
496
|
const ptr0 = passStringToWasm0(entry_path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
493
497
|
const len0 = WASM_VECTOR_LEN;
|
|
494
498
|
const ptr1 = passStringToWasm0(sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
495
499
|
const len1 = WASM_VECTOR_LEN;
|
|
496
500
|
const ptr2 = passStringToWasm0(constants_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
497
501
|
const len2 = WASM_VECTOR_LEN;
|
|
498
|
-
const
|
|
502
|
+
const ptr3 = passStringToWasm0(project_constants_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
503
|
+
const len3 = WASM_VECTOR_LEN;
|
|
504
|
+
const ret = wasm.compile_source_workspace_to_mir_messagepack(ptr0, len0, ptr1, len1, sample_rate, block_size, ptr2, len2, ptr3, len3);
|
|
499
505
|
if (ret[2]) {
|
|
500
506
|
throw takeFromExternrefTable0(ret[1]);
|
|
501
507
|
}
|
|
@@ -700,11 +706,12 @@ export function inspect_source_compile_constants(source, sample_rate, block_size
|
|
|
700
706
|
* @param {number} sample_rate
|
|
701
707
|
* @param {number} block_size
|
|
702
708
|
* @param {string} constants_json
|
|
709
|
+
* @param {string} project_constants_json
|
|
703
710
|
* @returns {string}
|
|
704
711
|
*/
|
|
705
|
-
export function inspect_source_workspace_compile_constants(entry_path, sources_json, sample_rate, block_size, constants_json) {
|
|
706
|
-
let
|
|
707
|
-
let
|
|
712
|
+
export function inspect_source_workspace_compile_constants(entry_path, sources_json, sample_rate, block_size, constants_json, project_constants_json) {
|
|
713
|
+
let deferred6_0;
|
|
714
|
+
let deferred6_1;
|
|
708
715
|
try {
|
|
709
716
|
const ptr0 = passStringToWasm0(entry_path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
710
717
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -712,18 +719,20 @@ export function inspect_source_workspace_compile_constants(entry_path, sources_j
|
|
|
712
719
|
const len1 = WASM_VECTOR_LEN;
|
|
713
720
|
const ptr2 = passStringToWasm0(constants_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
714
721
|
const len2 = WASM_VECTOR_LEN;
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
|
|
722
|
+
const ptr3 = passStringToWasm0(project_constants_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
723
|
+
const len3 = WASM_VECTOR_LEN;
|
|
724
|
+
const ret = wasm.inspect_source_workspace_compile_constants(ptr0, len0, ptr1, len1, sample_rate, block_size, ptr2, len2, ptr3, len3);
|
|
725
|
+
var ptr5 = ret[0];
|
|
726
|
+
var len5 = ret[1];
|
|
718
727
|
if (ret[3]) {
|
|
719
|
-
|
|
728
|
+
ptr5 = 0; len5 = 0;
|
|
720
729
|
throw takeFromExternrefTable0(ret[2]);
|
|
721
730
|
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
return getStringFromWasm0(
|
|
731
|
+
deferred6_0 = ptr5;
|
|
732
|
+
deferred6_1 = len5;
|
|
733
|
+
return getStringFromWasm0(ptr5, len5);
|
|
725
734
|
} finally {
|
|
726
|
-
wasm.__wbindgen_free(
|
|
735
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
727
736
|
}
|
|
728
737
|
}
|
|
729
738
|
|
|
Binary file
|
|
@@ -11,7 +11,7 @@ export const __wbg_webprojectmaterializationplan_free: (a: number, b: number) =>
|
|
|
11
11
|
export const buffer_asset_format_version: () => number;
|
|
12
12
|
export const compile_project_image_to_mir_messagepack: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
13
13
|
export const compile_source_workspace_to_mir_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
|
|
14
|
-
export const compile_source_workspace_to_mir_messagepack: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
|
|
14
|
+
export const compile_source_workspace_to_mir_messagepack: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number];
|
|
15
15
|
export const compile_to_mir_json: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
16
16
|
export const compile_to_mir_messagepack: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
17
17
|
export const current_stdlib_digest: () => [number, number];
|
|
@@ -26,7 +26,7 @@ export const frontendmessagepackcompilation_source_image_json: (a: number) => [n
|
|
|
26
26
|
export const inspect_project_image: (a: number, b: number) => [number, number, number, number];
|
|
27
27
|
export const inspect_project_image_compile_constants: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
28
28
|
export const inspect_source_compile_constants: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
29
|
-
export const inspect_source_workspace_compile_constants: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
29
|
+
export const inspect_source_workspace_compile_constants: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number, number];
|
|
30
30
|
export const materialize_project_image: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
31
31
|
export const mir_schema_version: () => number;
|
|
32
32
|
export const onda_version: () => [number, number];
|
|
@@ -44,7 +44,7 @@ export const webmaterializedprojectbuilder_new: () => number;
|
|
|
44
44
|
export const webmaterializedprojectbuilder_select_project: (a: number, b: number, c: number) => [number, number];
|
|
45
45
|
export const webmaterializedprojectbuilder_serialize: (a: number) => [number, number, number, number];
|
|
46
46
|
export const webprojectimagebuilder_add_buffer: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
47
|
-
export const webprojectimagebuilder_new: (a: number, b: number) => [number, number, number];
|
|
47
|
+
export const webprojectimagebuilder_new: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
48
48
|
export const webprojectimagebuilder_serialize: (a: number) => [number, number, number, number];
|
|
49
49
|
export const webprojectmaterializationplan_directories_json: (a: number) => [number, number];
|
|
50
50
|
export const webprojectmaterializationplan_file_bytes: (a: number, b: number) => [number, number];
|
|
@@ -675,7 +675,7 @@ SOFTWARE.
|
|
|
675
675
|
MIT License (MIT)
|
|
676
676
|
|
|
677
677
|
Used by:
|
|
678
|
-
- onda_compiler_web 0.8.
|
|
678
|
+
- onda_compiler_web 0.8.40 (https://github.com/onda-lang/onda)
|
|
679
679
|
|
|
680
680
|
MIT License
|
|
681
681
|
|
|
@@ -704,13 +704,13 @@ SOFTWARE.
|
|
|
704
704
|
MIT License (MIT)
|
|
705
705
|
|
|
706
706
|
Used by:
|
|
707
|
-
- onda_frontend 0.8.
|
|
708
|
-
- onda_host_protocol 0.8.
|
|
709
|
-
- onda_lsp 0.8.
|
|
710
|
-
- onda_mir 0.8.
|
|
711
|
-
- onda_processor_abi 0.8.
|
|
712
|
-
- onda_project 0.8.
|
|
713
|
-
- onda_semantics 0.8.
|
|
707
|
+
- onda_frontend 0.8.40
|
|
708
|
+
- onda_host_protocol 0.8.40
|
|
709
|
+
- onda_lsp 0.8.40
|
|
710
|
+
- onda_mir 0.8.40
|
|
711
|
+
- onda_processor_abi 0.8.40
|
|
712
|
+
- onda_project 0.8.40
|
|
713
|
+
- onda_semantics 0.8.40
|
|
714
714
|
|
|
715
715
|
MIT License
|
|
716
716
|
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const ONDA_VERSION = "0.8.
|
|
1
|
+
export const ONDA_VERSION = "0.8.40";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onda-lang/wasm-compiler",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.40",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Onda source-to-WebAssembly compiler for browsers and Node.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"prepack": "npm run build && node ../../scripts/stage-web-api-docs.mjs"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@onda-lang/processor-abi": "0.8.
|
|
63
|
+
"@onda-lang/processor-abi": "0.8.40",
|
|
64
64
|
"binaryen": "130.0.0"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
package/src/index.d.ts
CHANGED
|
@@ -104,7 +104,11 @@ export interface OndaCompileConstDescriptor {
|
|
|
104
104
|
value: OndaResolvedCompileConstValue;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
/** Project-manifest values; i64 values use decimal strings. */
|
|
108
|
+
export type OndaProjectConstant = boolean | number | string | (boolean | number | string)[];
|
|
109
|
+
|
|
107
110
|
export interface OndaSourceWorkspace {
|
|
111
|
+
constants?: Record<string, OndaProjectConstant>;
|
|
108
112
|
entry: string;
|
|
109
113
|
sources: Record<string, string>;
|
|
110
114
|
}
|
|
@@ -219,6 +223,7 @@ export interface OndaCompilerInstance {
|
|
|
219
223
|
sourceGraph: OndaSourceGraph,
|
|
220
224
|
buffers?: Map<string, ArrayBuffer | ArrayBufferView>
|
|
221
225
|
| Record<string, ArrayBuffer | ArrayBufferView>,
|
|
226
|
+
constants?: Record<string, OndaProjectConstant>,
|
|
222
227
|
): Promise<OndaSerializedProjectImage>;
|
|
223
228
|
inspectProjectImage(
|
|
224
229
|
imageBytes: ArrayBuffer | ArrayBufferView,
|
package/src/index.js
CHANGED
|
@@ -154,6 +154,7 @@ class OndaCompiler {
|
|
|
154
154
|
compile.sampleRate,
|
|
155
155
|
compile.blockSize,
|
|
156
156
|
compile.constantsJson,
|
|
157
|
+
JSON.stringify(workspace.constants ?? {}),
|
|
157
158
|
);
|
|
158
159
|
} catch (error) {
|
|
159
160
|
throw diagnosticsFromFrontend(error);
|
|
@@ -180,6 +181,7 @@ class OndaCompiler {
|
|
|
180
181
|
compile.sampleRate,
|
|
181
182
|
compile.blockSize,
|
|
182
183
|
compile.constantsJson,
|
|
184
|
+
JSON.stringify(workspace.constants ?? {}),
|
|
183
185
|
);
|
|
184
186
|
} catch (error) {
|
|
185
187
|
throw diagnosticsFromFrontend(error);
|
|
@@ -230,10 +232,10 @@ class OndaCompiler {
|
|
|
230
232
|
return decodeCompileConstDescriptors(encoded);
|
|
231
233
|
}
|
|
232
234
|
|
|
233
|
-
async createProjectImage(sourceGraph, buffers = new Map()) {
|
|
235
|
+
async createProjectImage(sourceGraph, buffers = new Map(), constants = {}) {
|
|
234
236
|
this.assertActive();
|
|
235
237
|
const graph = normalizeSourceGraph(sourceGraph);
|
|
236
|
-
const builder = new this.frontend.WebProjectImageBuilder(JSON.stringify(graph));
|
|
238
|
+
const builder = new this.frontend.WebProjectImageBuilder(JSON.stringify(graph), JSON.stringify(constants));
|
|
237
239
|
try {
|
|
238
240
|
for (const [name, bytes] of normalizeBufferAssetEntries(buffers)) {
|
|
239
241
|
builder.add_buffer(name, bytes);
|
|
@@ -447,8 +449,8 @@ class WorkerOndaCompiler {
|
|
|
447
449
|
return this.request("inspectProjectImageConstants", { imageBytes, options });
|
|
448
450
|
}
|
|
449
451
|
|
|
450
|
-
createProjectImage(sourceGraph, buffers = new Map()) {
|
|
451
|
-
return this.request("createProjectImage", { sourceGraph, buffers });
|
|
452
|
+
createProjectImage(sourceGraph, buffers = new Map(), constants = {}) {
|
|
453
|
+
return this.request("createProjectImage", { sourceGraph, buffers, constants });
|
|
452
454
|
}
|
|
453
455
|
|
|
454
456
|
inspectProjectImage(imageBytes) {
|
package/src/worker.js
CHANGED