Skip to content

Commit 9cedb47

Browse files
committed
Rebaseline audio test size (compressed is smaller, uncompressed larger)
1 parent efa0f21 commit 9cedb47

File tree

2 files changed

+114
-113
lines changed

2 files changed

+114
-113
lines changed

test/code_size/audio_worklet_wasm.js

Lines changed: 110 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,81 @@
1-
var k = globalThis.Module || "undefined" != typeof Module ? Module : {}, p = "em-ww" == globalThis.name, q = "undefined" !== typeof AudioWorkletGlobalScope, r, v, L, M, G, I, C, X, J, E, D, Y, Z;
1+
var l = globalThis.Module || "undefined" != typeof Module ? Module : {}, n = "em-ww" == globalThis.name, q = "undefined" !== typeof AudioWorkletGlobalScope, r, v, L, M, G, I, C, X, J, E, D, Y, Z;
22

3-
q && (p = !0);
3+
q && (n = !0);
44

55
function u(a) {
66
r = a;
77
v = a.I;
88
x();
9-
k ||= {};
10-
k.wasm = a.C;
9+
l ||= {};
10+
l.wasm = a.C;
1111
y();
1212
a.C = a.J = 0;
1313
}
1414

15-
p && !q && (onmessage = a => {
15+
n && !q && (onmessage = a => {
1616
onmessage = null;
1717
u(a.data);
1818
});
1919

2020
if (q) {
2121
function a(c) {
22-
class d extends AudioWorkletProcessor {
23-
constructor(e) {
22+
class e extends AudioWorkletProcessor {
23+
constructor(d) {
2424
super();
25-
e = e.processorOptions;
26-
this.u = C.get(e.u);
27-
this.v = e.v;
28-
this.s = e.s;
25+
d = d.processorOptions;
26+
this.u = C.get(d.u);
27+
this.v = d.v;
28+
this.s = d.s;
2929
}
3030
static get parameterDescriptors() {
3131
return c;
3232
}
33-
process(e, h, f) {
34-
let m = e.length, w = h.length, F = 0, l, z, n, t = 4 * this.s, g = 12 * (m + w), W = D(), A, H, B;
35-
for (l of e) g += l.length * t;
36-
for (l of h) g += l.length * t;
37-
for (l in f) g += f[l].byteLength + 8, ++F;
38-
A = E(g);
39-
g = A >> 2;
40-
n = A + 12 * m;
41-
for (l of e) {
42-
G[g] = l.length;
43-
G[g + 1] = this.s;
44-
G[g + 2] = n;
45-
g += 3;
46-
for (z of l) I.set(z, n >> 2), n += t;
33+
process(d, g, h) {
34+
let p = d.length, w = g.length, F = 0, k, z, m, t = 4 * this.s, f = 12 * (p + w), W = D(), A, H, B;
35+
for (k of d) f += k.length * t;
36+
for (k of g) f += k.length * t;
37+
for (k in h) f += h[k].byteLength + 8, ++F;
38+
A = E(f);
39+
f = A >> 2;
40+
m = A + 12 * p;
41+
for (k of d) {
42+
G[f] = k.length;
43+
G[f + 1] = this.s;
44+
G[f + 2] = m;
45+
f += 3;
46+
for (z of k) I.set(z, m >> 2), m += t;
47+
}
48+
H = m;
49+
f = H >> 2;
50+
d = m += 12 * w;
51+
for (k of g) G[f] = k.length, G[f + 1] = this.s, G[f + 2] = m, f += 3, m += t * k.length;
52+
t = m;
53+
f = t >> 2;
54+
m += 8 * F;
55+
for (k = 0; B = h[k++]; ) G[f] = B.length, G[f + 1] = m, f += 2, I.set(B, m >> 2),
56+
m += 4 * B.length;
57+
if (h = this.u(p, A, w, H, F, t, this.v)) {
58+
d >>= 2;
59+
for (k of g) for (z of k) for (f = 0; f < this.s; ++f) z[f] = I[d++];
4760
}
48-
H = n;
49-
g = H >> 2;
50-
e = (n += 12 * w) >> 2;
51-
for (l of h) G[g] = l.length, G[g + 1] = this.s, G[g + 2] = n, g += 3, n += t * l.length;
52-
t = n;
53-
g = t >> 2;
54-
n += 8 * F;
55-
for (l = 0; B = f[l++]; ) G[g] = B.length, G[g + 1] = n, g += 2, I.set(B, n >> 2),
56-
n += 4 * B.length;
57-
if (f = this.u(m, A, w, H, F, t, this.v)) for (l of h) for (z of l) for (g = 0; g < this.s; ++g) z[g] = I[e++];
5861
J(W);
59-
return !!f;
62+
return !!h;
6063
}
6164
}
62-
return d;
65+
return e;
6366
}
6467
var K;
6568
class b extends AudioWorkletProcessor {
6669
constructor(c) {
6770
super();
6871
u(c.processorOptions);
6972
K = this.port;
70-
K.onmessage = async d => {
71-
d = d.data;
72-
d._wpn ? (registerProcessor(d._wpn, a(d.D)), K.postMessage({
73-
_wsc: d.u,
74-
A: [ d.F, 1, d.v ]
75-
})) : d._wsc && C.get(d._wsc)(...d.A);
73+
K.onmessage = async e => {
74+
e = e.data;
75+
e._wpn ? (registerProcessor(e._wpn, a(e.D)), K.postMessage({
76+
_wsc: e.u,
77+
A: [ e.F, 1, e.v ]
78+
})) : e._wsc && C.get(e._wsc)(...e.A);
7679
};
7780
}
7881
process() {}
@@ -88,7 +91,7 @@ function x() {
8891
I = new Float32Array(a);
8992
}
9093

91-
p || (v = k.mem || new WebAssembly.Memory({
94+
n || (v = l.mem || new WebAssembly.Memory({
9295
initial: 256,
9396
maximum: 256,
9497
shared: !0
@@ -100,24 +103,24 @@ var N = [], O = a => {
100103
b && C.get(b)(...a.x);
101104
}, P = a => {
102105
N.push(a);
103-
}, Q = a => J(a), R = () => D(), aa = (a, b, c, d) => {
106+
}, Q = a => J(a), R = () => D(), aa = (a, b, c, e) => {
104107
b = S[b];
105-
S[a].connect(b.destination || b, c, d);
108+
S[a].connect(b.destination || b, c, e);
106109
}, S = {}, T = 0, U = "undefined" != typeof TextDecoder ? new TextDecoder : void 0, V = (a = 0) => {
107-
for (var b = L, c = a, d = c + void 0; b[c] && !(c >= d); ) ++c;
110+
for (var b = L, c = a, e = c + void 0; b[c] && !(c >= e); ) ++c;
108111
if (16 < c - a && b.buffer && U) return U.decode(b.slice(a, c));
109-
for (d = ""; a < c; ) {
110-
var e = b[a++];
111-
if (e & 128) {
112-
var h = b[a++] & 63;
113-
if (192 == (e & 224)) d += String.fromCharCode((e & 31) << 6 | h); else {
114-
var f = b[a++] & 63;
115-
e = 224 == (e & 240) ? (e & 15) << 12 | h << 6 | f : (e & 7) << 18 | h << 12 | f << 6 | b[a++] & 63;
116-
65536 > e ? d += String.fromCharCode(e) : (e -= 65536, d += String.fromCharCode(55296 | e >> 10, 56320 | e & 1023));
112+
for (e = ""; a < c; ) {
113+
var d = b[a++];
114+
if (d & 128) {
115+
var g = b[a++] & 63;
116+
if (192 == (d & 224)) e += String.fromCharCode((d & 31) << 6 | g); else {
117+
var h = b[a++] & 63;
118+
d = 224 == (d & 240) ? (d & 15) << 12 | g << 6 | h : (d & 7) << 18 | g << 12 | h << 6 | b[a++] & 63;
119+
65536 > d ? e += String.fromCharCode(d) : (d -= 65536, e += String.fromCharCode(55296 | d >> 10, 56320 | d & 1023));
117120
}
118-
} else d += String.fromCharCode(e);
121+
} else e += String.fromCharCode(d);
119122
}
120-
return d;
123+
return e;
121124
}, ba = a => {
122125
var b = window.AudioContext || window.webkitAudioContext;
123126
if (a >>= 2) {
@@ -129,72 +132,70 @@ var N = [], O = a => {
129132
} else a = void 0;
130133
if (c = b) b = new b(a), S[++T] = b, c = T;
131134
return c;
132-
}, ca = (a, b, c, d, e) => {
133-
if (c >>= 2) {
134-
var h = M[c], f = M[c + 1];
135-
if (G[c + 2]) {
136-
var m = G[c + 2] >> 2;
137-
c = M[c + 1];
138-
let w = [];
139-
for (;c--; ) w.push(G[m++]);
140-
m = w;
141-
} else m = void 0;
142-
d = {
135+
}, ca = (a, b, c, e, d) => {
136+
let g = c ? M[c + 4 >> 2] : 0;
137+
if (c) {
138+
var h = M[c >> 2];
139+
c = G[c + 8 >> 2];
140+
var p = g;
141+
if (c) {
142+
c >>= 2;
143+
for (var w = []; p--; ) w.push(G[c++]);
144+
c = w;
145+
} else c = void 0;
146+
e = {
143147
numberOfInputs: h,
144-
numberOfOutputs: f,
145-
outputChannelCount: m,
148+
numberOfOutputs: g,
149+
outputChannelCount: c,
146150
processorOptions: {
147-
u: d,
148-
v: e,
151+
u: e,
152+
v: d,
149153
s: 128
150154
}
151155
};
152-
} else d = void 0;
153-
a = new AudioWorkletNode(S[a], b ? V(b) : "", d);
156+
} else e = void 0;
157+
a = new AudioWorkletNode(S[a], b ? V(b) : "", e);
154158
S[++T] = a;
155159
return T;
156-
}, da = (a, b, c, d) => {
157-
b >>= 2;
158-
let e = [], h = G[b + 1], f = G[b + 2] >> 2, m = 0;
159-
for (;h--; ) e.push({
160-
name: m++,
161-
defaultValue: I[f++],
162-
minValue: I[f++],
163-
maxValue: I[f++],
164-
automationRate: [ "a", "k" ][G[f++]] + "-rate"
165-
});
166-
h = S[a].audioWorklet.B.port;
167-
f = h.postMessage;
168-
b = (b = G[b]) ? V(b) : "";
169-
f.call(h, {
170-
_wpn: b,
171-
D: e,
160+
}, da = (a, b, c, e) => {
161+
var d = [], g = (g = G[b >> 2]) ? V(g) : "", h = M[b + 4 >> 2];
162+
b = G[b + 8 >> 2];
163+
for (var p = 0; h--; ) d.push({
164+
name: p++,
165+
defaultValue: I[b >> 2],
166+
minValue: I[b + 4 >> 2],
167+
maxValue: I[b + 8 >> 2],
168+
automationRate: (M[b + 12 >> 2] ? "k" : "a") + "-rate"
169+
}), b += 16;
170+
S[a].audioWorklet.B.port.postMessage({
171+
_wpn: g,
172+
D: d,
172173
F: a,
173174
u: c,
174-
v: d
175+
v: e
175176
});
176177
}, ea = () => !1, fa = 1, ha = a => {
177178
a = a.data;
178179
let b = a._wsc;
179180
b && C.get(b)(...a.A);
180-
}, ia = a => E(a), ja = (a, b, c, d, e) => {
181-
let h = S[a], f = h.audioWorklet, m = () => {
182-
C.get(d)(a, 0, e);
181+
}, ia = a => E(a), ja = (a, b, c, e, d) => {
182+
let g = S[a], h = g.audioWorklet, p = () => {
183+
C.get(e)(a, 0, d);
183184
};
184-
if (!f) return m();
185-
f.addModule(k.js).then((() => {
186-
f.B = new AudioWorkletNode(h, "em-bootstrap", {
185+
if (!h) return p();
186+
h.addModule(l.js).then((() => {
187+
h.B = new AudioWorkletNode(g, "em-bootstrap", {
187188
processorOptions: {
188189
K: fa++,
189-
C: k.wasm,
190+
C: l.wasm,
190191
I: v,
191192
G: b,
192193
H: c
193194
}
194195
});
195-
f.B.port.onmessage = ha;
196-
C.get(d)(a, 1, e);
197-
})).catch(m);
196+
h.B.port.onmessage = ha;
197+
C.get(e)(a, 1, d);
198+
})).catch(p);
198199
};
199200

200201
function ka(a) {
@@ -218,7 +219,7 @@ function y() {
218219
c: ja,
219220
a: v
220221
};
221-
WebAssembly.instantiate(k.wasm, {
222+
WebAssembly.instantiate(l.wasm, {
222223
a: Z
223224
}).then((a => {
224225
a = a.instance.exports;
@@ -228,14 +229,14 @@ function y() {
228229
D = a.n;
229230
Y = a.o;
230231
C = a.k;
231-
k.stackSave = R;
232-
k.stackAlloc = ia;
233-
k.stackRestore = Q;
234-
k.wasmTable = C;
235-
p ? (Y(r.G, r.H), "undefined" === typeof AudioWorkletGlobalScope && (removeEventListener("message", P),
232+
l.stackSave = R;
233+
l.stackAlloc = ia;
234+
l.stackRestore = Q;
235+
l.wasmTable = C;
236+
n ? (Y(r.G, r.H), "undefined" === typeof AudioWorkletGlobalScope && (removeEventListener("message", P),
236237
N = N.forEach(O), addEventListener("message", O))) : a.i();
237-
p || X();
238+
n || X();
238239
}));
239240
}
240241

241-
p || y();
242+
n || y();
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.html": 519,
33
"a.html.gz": 357,
4-
"a.js": 3853,
5-
"a.js.gz": 2045,
4+
"a.js": 3864,
5+
"a.js.gz": 2041,
66
"a.wasm": 1288,
77
"a.wasm.gz": 860,
8-
"total": 5660,
9-
"total_gz": 3262
8+
"total": 5671,
9+
"total_gz": 3258
1010
}

0 commit comments

Comments
 (0)