@daneren2005/shared-memory-objects 0.0.18 → 0.0.19
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 +57 -43
- package/dist/shared-memory-objects.js +405 -308
- package/dist/shared-memory-objects.js.map +1 -1
- package/dist/shared-memory-objects.umd.cjs +1 -1
- package/dist/shared-memory-objects.umd.cjs.map +1 -1
- package/dist/src/local-pool.d.ts +31 -0
- package/dist/src/main.d.ts +2 -1
- package/dist/src/shared-vector.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
const he = 20, ce = 12, et = Math.pow(2, 20), rt = Math.pow(2, 12);
|
|
2
2
|
function c(i, t = 0) {
|
|
3
|
-
return
|
|
3
|
+
return B(Atomics.load(i, t));
|
|
4
4
|
}
|
|
5
5
|
function O(i, t = 0) {
|
|
6
6
|
return Atomics.load(i, t);
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
Atomics.store(i, t,
|
|
8
|
+
function k(i, t = 0, e, r) {
|
|
9
|
+
Atomics.store(i, t, L(e, r));
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function x(i, t = 0, e) {
|
|
12
12
|
Atomics.store(i, t, e);
|
|
13
13
|
}
|
|
14
14
|
function ue(i, t, e, r, s, o) {
|
|
15
|
-
let
|
|
16
|
-
return Atomics.compareExchange(i, t,
|
|
15
|
+
let a = L(s, o);
|
|
16
|
+
return Atomics.compareExchange(i, t, a, L(e, r)) === a;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function V(i, t, e, r) {
|
|
19
19
|
return Atomics.compareExchange(i, t, r, e) === r;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function B(i) {
|
|
22
22
|
return {
|
|
23
23
|
bufferPosition: i & 4095,
|
|
24
24
|
bufferByteOffset: i >>> 12
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function L(i, t) {
|
|
28
28
|
return i + (t << 12);
|
|
29
29
|
}
|
|
30
30
|
class h {
|
|
@@ -34,7 +34,7 @@ class h {
|
|
|
34
34
|
return this.data.byteOffset;
|
|
35
35
|
}
|
|
36
36
|
get pointer() {
|
|
37
|
-
return
|
|
37
|
+
return L(this.bufferPosition, this.bufferByteOffset);
|
|
38
38
|
}
|
|
39
39
|
buffer;
|
|
40
40
|
data;
|
|
@@ -60,15 +60,15 @@ class h {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
const j = 0,
|
|
64
|
-
function
|
|
65
|
-
for (; Atomics.compareExchange(i, t, j,
|
|
66
|
-
"WorkerGlobalScope" in self && Atomics.wait(i, t,
|
|
63
|
+
const j = 0, F = 1;
|
|
64
|
+
function z(i, t = 0) {
|
|
65
|
+
for (; Atomics.compareExchange(i, t, j, F) !== j; )
|
|
66
|
+
"WorkerGlobalScope" in self && Atomics.wait(i, t, F);
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
Atomics.compareExchange(i, t,
|
|
68
|
+
function g(i, t = 0) {
|
|
69
|
+
Atomics.compareExchange(i, t, F, j) !== F && console.warn("We are unlocking when it was not locked!"), Atomics.notify(i, t);
|
|
70
70
|
}
|
|
71
|
-
const
|
|
71
|
+
const de = 1, Vt = {
|
|
72
72
|
5120: "i8",
|
|
73
73
|
5121: "u8",
|
|
74
74
|
5122: "i16",
|
|
@@ -103,8 +103,8 @@ function jt(i, ...t) {
|
|
|
103
103
|
const e = Zt[i];
|
|
104
104
|
return new (e || Wt[vt(i)])(...t);
|
|
105
105
|
}
|
|
106
|
-
const it = 0, st = 1, ot = 2,
|
|
107
|
-
class
|
|
106
|
+
const it = 0, st = 1, ot = 2, at = 3, nt = 4, A = 5, lt = 6, K = 1, G = 2, ft = 32, X = 0, Z = 1, y = 8;
|
|
107
|
+
class W {
|
|
108
108
|
buf;
|
|
109
109
|
start;
|
|
110
110
|
u8;
|
|
@@ -112,7 +112,7 @@ class Z {
|
|
|
112
112
|
state;
|
|
113
113
|
lock;
|
|
114
114
|
constructor(t = {}) {
|
|
115
|
-
if (this.buf = t.buf ? t.buf : new ArrayBuffer(t.size || 4096), this.start = t.start != null ?
|
|
115
|
+
if (this.buf = t.buf ? t.buf : new ArrayBuffer(t.size || 4096), this.start = t.start != null ? C(Math.max(t.start, 0), 4) : 0, this.u8 = new Uint8Array(this.buf), this.u32 = new Uint32Array(this.buf), this.state = new Uint32Array(this.buf, this.start, ft / 4), this.lock = new Int32Array(this.buf, this.start + this.state.byteLength - 4, 1), !t.skipInitialization) {
|
|
116
116
|
const e = t.align || 8;
|
|
117
117
|
if (e < 8)
|
|
118
118
|
throw new Error(`invalid alignment: ${e}, must be a pow2 and >= 8`);
|
|
@@ -159,37 +159,37 @@ class Z {
|
|
|
159
159
|
malloc(t) {
|
|
160
160
|
if (t <= 0)
|
|
161
161
|
return 0;
|
|
162
|
-
|
|
163
|
-
const e =
|
|
164
|
-
let s = this.top, o = this._free,
|
|
162
|
+
z(this.lock);
|
|
163
|
+
const e = C(t + y, this.align), r = this.end;
|
|
164
|
+
let s = this.top, o = this._free, a = 0;
|
|
165
165
|
for (; o; ) {
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
let
|
|
166
|
+
const l = this.blockSize(o), n = o + l >= s;
|
|
167
|
+
if (n || l >= e) {
|
|
168
|
+
let f = this.mallocTop(
|
|
169
169
|
o,
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
a,
|
|
171
|
+
l,
|
|
172
172
|
e,
|
|
173
|
-
|
|
173
|
+
n
|
|
174
174
|
);
|
|
175
|
-
return
|
|
175
|
+
return g(this.lock), f;
|
|
176
176
|
}
|
|
177
|
-
|
|
177
|
+
a = o, o = this.blockNext(o);
|
|
178
178
|
}
|
|
179
179
|
if (o = s, s = o + e, s <= r) {
|
|
180
180
|
this.initBlock(o, e, this._used), this._used = o, this.top = s;
|
|
181
|
-
let
|
|
182
|
-
return
|
|
181
|
+
let l = _(o);
|
|
182
|
+
return g(this.lock), l;
|
|
183
183
|
}
|
|
184
|
-
return
|
|
184
|
+
return g(this.lock), 0;
|
|
185
185
|
}
|
|
186
186
|
mallocTop(t, e, r, s, o) {
|
|
187
187
|
if (o && t + s > this.end) return 0;
|
|
188
188
|
if (e ? this.unlinkBlock(e, t) : this._free = this.blockNext(t), this.setBlockNext(t, this._used), this._used = t, o)
|
|
189
189
|
this.top = t + this.setBlockSize(t, s);
|
|
190
190
|
else if (this.doSplit) {
|
|
191
|
-
const
|
|
192
|
-
|
|
191
|
+
const a = r - s;
|
|
192
|
+
a >= this.minSplit && this.splitBlock(t, s, a);
|
|
193
193
|
}
|
|
194
194
|
return _(t);
|
|
195
195
|
}
|
|
@@ -197,10 +197,10 @@ class Z {
|
|
|
197
197
|
if (e <= 0)
|
|
198
198
|
return 0;
|
|
199
199
|
const r = I(t);
|
|
200
|
-
let s = 0, o = this._used,
|
|
200
|
+
let s = 0, o = this._used, a = 0;
|
|
201
201
|
for (; o; ) {
|
|
202
202
|
if (o === r) {
|
|
203
|
-
[s,
|
|
203
|
+
[s, a] = this.reallocBlock(o, e);
|
|
204
204
|
break;
|
|
205
205
|
}
|
|
206
206
|
o = this.blockNext(o);
|
|
@@ -208,19 +208,19 @@ class Z {
|
|
|
208
208
|
return s && s !== r && this.u8.copyWithin(
|
|
209
209
|
_(s),
|
|
210
210
|
_(r),
|
|
211
|
-
|
|
211
|
+
a
|
|
212
212
|
), _(s);
|
|
213
213
|
}
|
|
214
214
|
reallocBlock(t, e) {
|
|
215
|
-
const r = this.blockSize(t), s = t + r, o = s >= this.top,
|
|
216
|
-
if (
|
|
215
|
+
const r = this.blockSize(t), s = t + r, o = s >= this.top, a = C(e + y, this.align);
|
|
216
|
+
if (a <= r) {
|
|
217
217
|
if (this.doSplit) {
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
} else o && (this.top = t +
|
|
218
|
+
const l = r - a;
|
|
219
|
+
l >= this.minSplit ? this.splitBlock(t, a, l) : o && (this.top = t + a);
|
|
220
|
+
} else o && (this.top = t + a);
|
|
221
221
|
return [t, s];
|
|
222
222
|
}
|
|
223
|
-
return o && t +
|
|
223
|
+
return o && t + a < this.end ? (this.top = t + this.setBlockSize(t, a), [t, s]) : (this.free(t), [I(this.malloc(e)), s]);
|
|
224
224
|
}
|
|
225
225
|
reallocArray(t, e) {
|
|
226
226
|
if (t.buffer !== this.buf)
|
|
@@ -260,14 +260,14 @@ class Z {
|
|
|
260
260
|
e = t.byteOffset;
|
|
261
261
|
} else
|
|
262
262
|
e = t;
|
|
263
|
-
|
|
263
|
+
z(this.lock), e = I(e);
|
|
264
264
|
let r = this._used, s = 0;
|
|
265
265
|
for (; r; ) {
|
|
266
266
|
if (r === e)
|
|
267
|
-
return s ? this.unlinkBlock(s, r) : this._used = this.blockNext(r), this.insert(r), this.doCompact && this.compact(),
|
|
267
|
+
return s ? this.unlinkBlock(s, r) : this._used = this.blockNext(r), this.insert(r), this.doCompact && this.compact(), g(this.lock), !0;
|
|
268
268
|
s = r, r = this.blockNext(r);
|
|
269
269
|
}
|
|
270
|
-
return
|
|
270
|
+
return g(this.lock), !1;
|
|
271
271
|
}
|
|
272
272
|
freeAll() {
|
|
273
273
|
this._free = 0, this._used = 0, this.top = this.initialTop();
|
|
@@ -276,16 +276,16 @@ class Z {
|
|
|
276
276
|
return delete this.u8, delete this.u32, delete this.state, delete this.buf, !0;
|
|
277
277
|
}
|
|
278
278
|
get align() {
|
|
279
|
-
return this.state[
|
|
279
|
+
return this.state[nt];
|
|
280
280
|
}
|
|
281
281
|
set align(t) {
|
|
282
|
-
this.state[
|
|
282
|
+
this.state[nt] = t;
|
|
283
283
|
}
|
|
284
284
|
get end() {
|
|
285
|
-
return this.state[
|
|
285
|
+
return this.state[at];
|
|
286
286
|
}
|
|
287
287
|
set end(t) {
|
|
288
|
-
this.state[
|
|
288
|
+
this.state[at] = t;
|
|
289
289
|
}
|
|
290
290
|
get top() {
|
|
291
291
|
return Atomics.load(this.state, ot);
|
|
@@ -306,27 +306,27 @@ class Z {
|
|
|
306
306
|
Atomics.store(this.state, st, t);
|
|
307
307
|
}
|
|
308
308
|
get doCompact() {
|
|
309
|
-
return !!(this.state[
|
|
309
|
+
return !!(this.state[A] & K);
|
|
310
310
|
}
|
|
311
311
|
set doCompact(t) {
|
|
312
|
-
t ? this.state[
|
|
312
|
+
t ? this.state[A] |= 1 << K - 1 : this.state[A] &= ~K;
|
|
313
313
|
}
|
|
314
314
|
get doSplit() {
|
|
315
|
-
return !!(this.state[
|
|
315
|
+
return !!(this.state[A] & G);
|
|
316
316
|
}
|
|
317
317
|
set doSplit(t) {
|
|
318
|
-
t ? this.state[
|
|
318
|
+
t ? this.state[A] |= 1 << G - 1 : this.state[A] &= ~G;
|
|
319
319
|
}
|
|
320
320
|
get minSplit() {
|
|
321
|
-
return this.state[
|
|
321
|
+
return this.state[lt];
|
|
322
322
|
}
|
|
323
323
|
set minSplit(t) {
|
|
324
324
|
if (t <= y)
|
|
325
325
|
throw new Error(`illegal min split threshold: ${t}, require at least ${y + 1}`);
|
|
326
|
-
this.state[
|
|
326
|
+
this.state[lt] = t;
|
|
327
327
|
}
|
|
328
328
|
blockSize(t) {
|
|
329
|
-
return Atomics.load(this.u32, (t >> 2) +
|
|
329
|
+
return Atomics.load(this.u32, (t >> 2) + X);
|
|
330
330
|
}
|
|
331
331
|
/**
|
|
332
332
|
* Sets & returns given block size.
|
|
@@ -335,10 +335,10 @@ class Z {
|
|
|
335
335
|
* @param size -
|
|
336
336
|
*/
|
|
337
337
|
setBlockSize(t, e) {
|
|
338
|
-
return Atomics.store(this.u32, (t >> 2) +
|
|
338
|
+
return Atomics.store(this.u32, (t >> 2) + X, e), e;
|
|
339
339
|
}
|
|
340
340
|
blockNext(t) {
|
|
341
|
-
return Atomics.load(this.u32, (t >> 2) +
|
|
341
|
+
return Atomics.load(this.u32, (t >> 2) + Z);
|
|
342
342
|
}
|
|
343
343
|
/**
|
|
344
344
|
* Sets block next pointer to `next`. Use zero to indicate list end.
|
|
@@ -346,7 +346,7 @@ class Z {
|
|
|
346
346
|
* @param block -
|
|
347
347
|
*/
|
|
348
348
|
setBlockNext(t, e) {
|
|
349
|
-
Atomics.store(this.u32, (t >> 2) +
|
|
349
|
+
Atomics.store(this.u32, (t >> 2) + Z, e);
|
|
350
350
|
}
|
|
351
351
|
/**
|
|
352
352
|
* Initializes block header with given `size` and `next` pointer. Returns `block`.
|
|
@@ -357,7 +357,7 @@ class Z {
|
|
|
357
357
|
*/
|
|
358
358
|
initBlock(t, e, r) {
|
|
359
359
|
const s = t >>> 2;
|
|
360
|
-
return Atomics.store(this.u32, s +
|
|
360
|
+
return Atomics.store(this.u32, s + X, e), Atomics.store(this.u32, s + Z, r), t;
|
|
361
361
|
}
|
|
362
362
|
unlinkBlock(t, e) {
|
|
363
363
|
this.setBlockNext(t, this.blockNext(e));
|
|
@@ -372,7 +372,7 @@ class Z {
|
|
|
372
372
|
), this.doCompact && this.compact();
|
|
373
373
|
}
|
|
374
374
|
initialTop(t = this.align) {
|
|
375
|
-
return
|
|
375
|
+
return C(this.start + ft + y, t) - y;
|
|
376
376
|
}
|
|
377
377
|
/**
|
|
378
378
|
* Traverses free list and attempts to recursively merge blocks
|
|
@@ -385,15 +385,15 @@ class Z {
|
|
|
385
385
|
for (s = t, r = this.blockNext(t); r && s + this.blockSize(s) === r; )
|
|
386
386
|
s = r, r = this.blockNext(r);
|
|
387
387
|
if (s !== t) {
|
|
388
|
-
const
|
|
389
|
-
this.setBlockSize(t,
|
|
390
|
-
const
|
|
391
|
-
let
|
|
392
|
-
for (;
|
|
393
|
-
const
|
|
394
|
-
this.setBlockNext(
|
|
388
|
+
const a = s - t + this.blockSize(s);
|
|
389
|
+
this.setBlockSize(t, a);
|
|
390
|
+
const l = this.blockNext(s);
|
|
391
|
+
let n = this.blockNext(t);
|
|
392
|
+
for (; n && n !== l; ) {
|
|
393
|
+
const f = this.blockNext(n);
|
|
394
|
+
this.setBlockNext(n, 0), n = f;
|
|
395
395
|
}
|
|
396
|
-
this.setBlockNext(t,
|
|
396
|
+
this.setBlockNext(t, l), o = !0;
|
|
397
397
|
}
|
|
398
398
|
t + this.blockSize(t) >= this.top && (this.top = t, e ? this.unlinkBlock(e, t) : this._free = this.blockNext(t)), e = t, t = this.blockNext(t);
|
|
399
399
|
}
|
|
@@ -411,7 +411,7 @@ class Z {
|
|
|
411
411
|
r ? this.setBlockNext(r, t) : this._free = t, this.setBlockNext(t, e);
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
const _ = (i) => i > 0 ? i + y : 0, I = (i) => i > 0 ? i - y : 0,
|
|
414
|
+
const _ = (i) => i > 0 ? i + y : 0, I = (i) => i > 0 ? i - y : 0, C = (i, t) => (t--, i + t & ~t), qt = {
|
|
415
415
|
u8: 1,
|
|
416
416
|
u8c: 1,
|
|
417
417
|
i8: 1,
|
|
@@ -503,29 +503,29 @@ function oe(i, t) {
|
|
|
503
503
|
};
|
|
504
504
|
const e = t.bits ? t.binary ? ee : te : t.binary ? Qt : Jt, r = t.space ? t.nonBreakingSpace ? " " : " " : "", s = typeof i == "number" ? i === 0 : i === 0n;
|
|
505
505
|
if (t.signed && s) {
|
|
506
|
-
const
|
|
507
|
-
return ct(
|
|
506
|
+
const f = ` 0${r}${e[0]}`;
|
|
507
|
+
return ct(f, t.fixedWidth);
|
|
508
508
|
}
|
|
509
|
-
const o = i < 0,
|
|
509
|
+
const o = i < 0, a = o ? "-" : t.signed ? "+" : "";
|
|
510
510
|
o && (i = -i);
|
|
511
|
-
const
|
|
512
|
-
let
|
|
511
|
+
const l = se(t);
|
|
512
|
+
let n;
|
|
513
513
|
if (i < 1) {
|
|
514
|
-
const
|
|
515
|
-
|
|
514
|
+
const f = ht(i, t.locale, l);
|
|
515
|
+
n = a + f + r + e[0];
|
|
516
516
|
} else {
|
|
517
|
-
const
|
|
518
|
-
if (i = ie(i, (t.binary ? 1024 : 1e3) **
|
|
517
|
+
const f = Math.min(Math.floor(t.binary ? re(i) / Math.log(1024) : _t(i) / 3), e.length - 1);
|
|
518
|
+
if (i = ie(i, (t.binary ? 1024 : 1e3) ** f), !l) {
|
|
519
519
|
const M = Math.max(3, Math.floor(i).toString().length);
|
|
520
520
|
i = i.toPrecision(M);
|
|
521
521
|
}
|
|
522
|
-
const
|
|
523
|
-
|
|
522
|
+
const T = ht(Number(i), t.locale, l), H = e[f];
|
|
523
|
+
n = a + T + r + H;
|
|
524
524
|
}
|
|
525
|
-
return ct(
|
|
525
|
+
return ct(n, t.fixedWidth);
|
|
526
526
|
}
|
|
527
|
-
const
|
|
528
|
-
class
|
|
527
|
+
const ae = 8192, ut = 0, v = 1, N = 2;
|
|
528
|
+
class ye {
|
|
529
529
|
buffers;
|
|
530
530
|
onGrowBufferHandlers = [];
|
|
531
531
|
isClone;
|
|
@@ -535,7 +535,7 @@ class de {
|
|
|
535
535
|
}
|
|
536
536
|
constructor(t) {
|
|
537
537
|
if (t && "buffers" in t)
|
|
538
|
-
this.buffers = t.buffers.map((e) => new
|
|
538
|
+
this.buffers = t.buffers.map((e) => new W({
|
|
539
539
|
buf: e,
|
|
540
540
|
skipInitialization: !0
|
|
541
541
|
})), this.memory = new h(this, {
|
|
@@ -544,7 +544,7 @@ class de {
|
|
|
544
544
|
}), this.isClone = !0;
|
|
545
545
|
else {
|
|
546
546
|
"SharedArrayBuffer" in globalThis || console.warn("SharedArrayBuffer is not working: falling back to ArrayBuffer");
|
|
547
|
-
const e = t?.bufferSize ??
|
|
547
|
+
const e = t?.bufferSize ?? ae;
|
|
548
548
|
if (e > et)
|
|
549
549
|
throw new Error(`Buffer size ${e} is greater than max ${et} that we can reference with pointers`);
|
|
550
550
|
let r = this.createBuffer(e);
|
|
@@ -559,20 +559,20 @@ class de {
|
|
|
559
559
|
});
|
|
560
560
|
else
|
|
561
561
|
throw new Error("Failed to initialize first byte from buffer");
|
|
562
|
-
this.memory.data[ut] = e, this.memory.data[
|
|
562
|
+
this.memory.data[ut] = e, this.memory.data[v] = 1, this.memory.data[N] = t?.autoGrowSize ?? 100, this.isClone = !1;
|
|
563
563
|
for (let o = 1; o < (t?.initialBuffers ?? 1); o++)
|
|
564
564
|
this.buffers.push(this.createBuffer(e));
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
567
|
addSharedBuffer(t) {
|
|
568
|
-
this.buffers[t.bufferPosition] = new
|
|
568
|
+
this.buffers[t.bufferPosition] = new W({
|
|
569
569
|
buf: t.buffer,
|
|
570
570
|
skipInitialization: !0
|
|
571
571
|
});
|
|
572
572
|
}
|
|
573
573
|
growBuffer() {
|
|
574
574
|
const t = this.createBuffer();
|
|
575
|
-
let e = Atomics.add(this.memory.data,
|
|
575
|
+
let e = Atomics.add(this.memory.data, v, 1);
|
|
576
576
|
return this.buffers[e] = t, this.onGrowBufferHandlers.forEach((r) => r({
|
|
577
577
|
bufferPosition: e,
|
|
578
578
|
buffer: t.buf
|
|
@@ -581,7 +581,7 @@ class de {
|
|
|
581
581
|
createBuffer(t) {
|
|
582
582
|
const e = t ?? this.bufferSize;
|
|
583
583
|
let r;
|
|
584
|
-
return "SharedArrayBuffer" in globalThis ? r = new SharedArrayBuffer(e) : r = new ArrayBuffer(e), new
|
|
584
|
+
return "SharedArrayBuffer" in globalThis ? r = new SharedArrayBuffer(e) : r = new ArrayBuffer(e), new W({
|
|
585
585
|
buf: r,
|
|
586
586
|
// We can't use this unless we can 100% guarantee that every thread will stop using memory the instant it is freed
|
|
587
587
|
// ex: Allocate 16 bytes. Thread A frees that allocation and then allocates 12 bytes and 4 bytes, but Thread B is mid-execution on the old allocation can changes the internal state of the 4-byte allocation breaking everything
|
|
@@ -599,10 +599,10 @@ class de {
|
|
|
599
599
|
const o = this.buffers[s];
|
|
600
600
|
if (!o)
|
|
601
601
|
continue;
|
|
602
|
-
const
|
|
603
|
-
if (
|
|
604
|
-
return s === this.buffers.length - 1 && Atomics.load(this.memory.data,
|
|
605
|
-
data:
|
|
602
|
+
const a = o.callocAs("u32", t);
|
|
603
|
+
if (a)
|
|
604
|
+
return s === this.buffers.length - 1 && Atomics.load(this.memory.data, v) === this.buffers.length && this.memory.data[N] < 100 && this.memory.data[N] > 0 && o.top / o.end > this.memory.data[N] / 100 && this.growBuffer(), new h(this, {
|
|
605
|
+
data: a,
|
|
606
606
|
buffer: o
|
|
607
607
|
});
|
|
608
608
|
}
|
|
@@ -628,7 +628,7 @@ class de {
|
|
|
628
628
|
return this.buffers[0].buf.byteLength * this.buffers.length;
|
|
629
629
|
}
|
|
630
630
|
prettyMemory() {
|
|
631
|
-
return `${
|
|
631
|
+
return `${dt(this.currentUsed)} / ${dt(this.totalAllocated)}`;
|
|
632
632
|
}
|
|
633
633
|
getSharedMemory() {
|
|
634
634
|
return {
|
|
@@ -636,16 +636,16 @@ class de {
|
|
|
636
636
|
};
|
|
637
637
|
}
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function dt(i) {
|
|
640
640
|
return oe(i, {
|
|
641
641
|
binary: !0,
|
|
642
642
|
minimumFractionDigits: 1,
|
|
643
643
|
maximumFractionDigits: 1
|
|
644
644
|
});
|
|
645
645
|
}
|
|
646
|
-
const
|
|
646
|
+
const yt = 4, Bt = 1, p = 2;
|
|
647
647
|
class u {
|
|
648
|
-
static ALLOCATE_COUNT =
|
|
648
|
+
static ALLOCATE_COUNT = yt;
|
|
649
649
|
memory;
|
|
650
650
|
/* First block
|
|
651
651
|
32 index 0
|
|
@@ -670,7 +670,7 @@ class u {
|
|
|
670
670
|
uint16Array;
|
|
671
671
|
onDelete;
|
|
672
672
|
get length() {
|
|
673
|
-
return Atomics.load(this.firstBlock.data,
|
|
673
|
+
return Atomics.load(this.firstBlock.data, p);
|
|
674
674
|
}
|
|
675
675
|
get type() {
|
|
676
676
|
return Atomics.load(this.uint16Array, 0);
|
|
@@ -686,9 +686,9 @@ class u {
|
|
|
686
686
|
}
|
|
687
687
|
constructor(t, e) {
|
|
688
688
|
if (this.memory = t, e && "firstBlock" in e)
|
|
689
|
-
this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + (
|
|
689
|
+
this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + (p + 1) * Uint32Array.BYTES_PER_ELEMENT, 2);
|
|
690
690
|
else {
|
|
691
|
-
e && e.initWithBlock ? this.firstBlock = new h(t, e.initWithBlock) : this.firstBlock = t.allocUI32(
|
|
691
|
+
e && e.initWithBlock ? this.firstBlock = new h(t, e.initWithBlock) : this.firstBlock = t.allocUI32(yt), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + (p + 1) * Uint32Array.BYTES_PER_ELEMENT, 2);
|
|
692
692
|
const r = e?.type ?? Uint32Array;
|
|
693
693
|
r === Uint32Array ? this.type = 0 : r === Int32Array ? this.type = 1 : r === Float32Array && (this.type = 2), this.dataLength = e?.dataLength ?? 1;
|
|
694
694
|
}
|
|
@@ -699,17 +699,17 @@ class u {
|
|
|
699
699
|
if (t.length > e)
|
|
700
700
|
throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
|
|
701
701
|
let r = this.memory.allocUI32(Bt + e), s = this.getDataBlock(r.data), o = r.pointer;
|
|
702
|
-
for (let
|
|
703
|
-
s instanceof Int32Array || s instanceof Uint32Array ? Atomics.store(s,
|
|
704
|
-
let
|
|
705
|
-
for (; !
|
|
706
|
-
|
|
707
|
-
if (
|
|
708
|
-
let { bufferPosition:
|
|
709
|
-
|
|
702
|
+
for (let n = 0; n < t.length; n++)
|
|
703
|
+
s instanceof Int32Array || s instanceof Uint32Array ? Atomics.store(s, n, t[n]) : s[n] = t[n];
|
|
704
|
+
let a, l = !1;
|
|
705
|
+
for (; !l; )
|
|
706
|
+
a = O(this.firstBlock.data, 1), l = V(this.firstBlock.data, 1, o, a);
|
|
707
|
+
if (a) {
|
|
708
|
+
let { bufferPosition: n, bufferByteOffset: f } = B(a), T = new Uint32Array(this.memory.buffers[n].buf, f, 1);
|
|
709
|
+
x(T, 0, o);
|
|
710
710
|
} else
|
|
711
|
-
|
|
712
|
-
Atomics.add(this.firstBlock.data,
|
|
711
|
+
x(this.firstBlock.data, 0, o);
|
|
712
|
+
Atomics.add(this.firstBlock.data, p, 1);
|
|
713
713
|
}
|
|
714
714
|
deleteMatch(t) {
|
|
715
715
|
for (let { data: e, index: r, deleteCurrent: s } of this)
|
|
@@ -735,37 +735,37 @@ class u {
|
|
|
735
735
|
for (; !r; ) {
|
|
736
736
|
if (t = O(this.firstBlock.data, 0), e = O(this.firstBlock.data, 1), !e)
|
|
737
737
|
return;
|
|
738
|
-
r =
|
|
738
|
+
r = V(this.firstBlock.data, 1, 0, e);
|
|
739
739
|
}
|
|
740
740
|
if (!t)
|
|
741
741
|
return;
|
|
742
|
-
|
|
742
|
+
V(this.firstBlock.data, 0, 0, t);
|
|
743
743
|
let s = 0, o = t;
|
|
744
744
|
for (; o; ) {
|
|
745
|
-
let { bufferPosition:
|
|
746
|
-
if (!
|
|
745
|
+
let { bufferPosition: a, bufferByteOffset: l } = B(o), n = this.memory.buffers[a];
|
|
746
|
+
if (!n)
|
|
747
747
|
break;
|
|
748
|
-
let
|
|
749
|
-
o = O(
|
|
748
|
+
let f = new Uint32Array(n.buf, l, 2);
|
|
749
|
+
o = O(f, 0), s++, this.onDelete && this.onDelete(this.getDataBlock(f)), n.free(f.byteOffset);
|
|
750
750
|
}
|
|
751
|
-
Atomics.sub(this.firstBlock.data,
|
|
751
|
+
Atomics.sub(this.firstBlock.data, p, s);
|
|
752
752
|
}
|
|
753
753
|
*[Symbol.iterator]() {
|
|
754
|
-
let t = 0, { bufferPosition: e, bufferByteOffset: r } = c(this.firstBlock.data, 0), s = this.firstBlock.data, o = 0,
|
|
754
|
+
let t = 0, { bufferPosition: e, bufferByteOffset: r } = c(this.firstBlock.data, 0), s = this.firstBlock.data, o = 0, a = 0;
|
|
755
755
|
for (; r; ) {
|
|
756
|
-
let
|
|
757
|
-
if (!
|
|
756
|
+
let l = this.memory.buffers[e];
|
|
757
|
+
if (!l)
|
|
758
758
|
return;
|
|
759
|
-
let
|
|
760
|
-
({ bufferPosition: e, bufferByteOffset: r } = c(
|
|
759
|
+
let n = new Uint32Array(l.buf, r, 2), f = this.getDataBlock(n), T = e, H = r;
|
|
760
|
+
({ bufferPosition: e, bufferByteOffset: r } = c(n, 0));
|
|
761
761
|
let M = !0;
|
|
762
762
|
yield {
|
|
763
|
-
data:
|
|
763
|
+
data: f,
|
|
764
764
|
index: t,
|
|
765
765
|
deleteCurrent: () => {
|
|
766
|
-
|
|
766
|
+
k(s, 0, e, r), r || k(this.firstBlock.data, 1, o, a), this.onDelete && this.onDelete(this.getDataBlock(n)), l.free(n.byteOffset), Atomics.sub(this.firstBlock.data, p, 1), M = !1;
|
|
767
767
|
}
|
|
768
|
-
}, M && (s =
|
|
768
|
+
}, M && (s = n, o = T, a = H, t++);
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
771
|
forEach(t) {
|
|
@@ -824,78 +824,78 @@ class Ot {
|
|
|
824
824
|
else {
|
|
825
825
|
this.pointerMemory = t.allocUI32(Ot.ALLOCATE_COUNT);
|
|
826
826
|
let r = t.allocUI32(mt);
|
|
827
|
-
|
|
827
|
+
k(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, mt);
|
|
828
828
|
}
|
|
829
829
|
this.lock = new Int32Array(this.pointerMemory.data.buffer, this.pointerMemory.bufferByteOffset + Uint32Array.BYTES_PER_ELEMENT, 1);
|
|
830
830
|
}
|
|
831
831
|
set(t, e) {
|
|
832
832
|
this.length >= this.maxHash * 2 && this.growHashTable();
|
|
833
|
-
let r =
|
|
833
|
+
let r = P(t);
|
|
834
834
|
this.setHashKey(this.hashMemory, this.maxHash, r, e) && Atomics.add(this.pointerMemory.data, 2, 1);
|
|
835
835
|
}
|
|
836
836
|
setHashKey(t, e, r, s) {
|
|
837
|
-
let o = this.hash(r, e),
|
|
838
|
-
if (
|
|
839
|
-
|
|
837
|
+
let o = this.hash(r, e), a, l = c(t.data, o);
|
|
838
|
+
if (l.bufferByteOffset === 0) {
|
|
839
|
+
a = new u(this.memory, {
|
|
840
840
|
dataLength: 2
|
|
841
841
|
});
|
|
842
|
-
let
|
|
843
|
-
|
|
842
|
+
let f = a.getSharedMemory();
|
|
843
|
+
k(t.data, o, f.firstBlock.bufferPosition, f.firstBlock.bufferByteOffset);
|
|
844
844
|
} else
|
|
845
|
-
|
|
846
|
-
firstBlock:
|
|
845
|
+
a = new u(this.memory, {
|
|
846
|
+
firstBlock: l
|
|
847
847
|
});
|
|
848
|
-
let
|
|
849
|
-
return
|
|
848
|
+
let n = !0;
|
|
849
|
+
return a.deleteValue(r) && (n = !1), a.insert([r, s]), n;
|
|
850
850
|
}
|
|
851
851
|
get(t) {
|
|
852
|
-
let e =
|
|
852
|
+
let e = P(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
|
|
853
853
|
if (s.bufferByteOffset === 0)
|
|
854
854
|
return;
|
|
855
855
|
let o = new u(this.memory, {
|
|
856
856
|
firstBlock: s
|
|
857
857
|
});
|
|
858
|
-
for (let { data:
|
|
859
|
-
if (
|
|
860
|
-
return
|
|
858
|
+
for (let { data: a } of o)
|
|
859
|
+
if (a[0] === e)
|
|
860
|
+
return a[1];
|
|
861
861
|
}
|
|
862
862
|
has(t) {
|
|
863
|
-
let e =
|
|
863
|
+
let e = P(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
|
|
864
864
|
if (s.bufferByteOffset === 0)
|
|
865
865
|
return !1;
|
|
866
866
|
let o = new u(this.memory, {
|
|
867
867
|
firstBlock: s
|
|
868
868
|
});
|
|
869
|
-
for (let { data:
|
|
870
|
-
if (
|
|
869
|
+
for (let { data: a } of o)
|
|
870
|
+
if (a[0] === e)
|
|
871
871
|
return !0;
|
|
872
872
|
return !1;
|
|
873
873
|
}
|
|
874
874
|
delete(t) {
|
|
875
|
-
let e =
|
|
875
|
+
let e = P(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
|
|
876
876
|
if (s.bufferByteOffset === 0)
|
|
877
877
|
return !1;
|
|
878
878
|
let o = new u(this.memory, {
|
|
879
879
|
firstBlock: s
|
|
880
880
|
});
|
|
881
|
-
for (let { data:
|
|
882
|
-
if (
|
|
883
|
-
return
|
|
881
|
+
for (let { data: a, deleteCurrent: l } of o)
|
|
882
|
+
if (a[0] === e)
|
|
883
|
+
return l(), Atomics.sub(this.pointerMemory.data, 2, 1), !0;
|
|
884
884
|
return !1;
|
|
885
885
|
}
|
|
886
886
|
growHashTable() {
|
|
887
887
|
let t = this.maxHash, e = t * 2, r = this.memory.allocUI32(e), s = this.hashMemory;
|
|
888
888
|
for (let o = 0; o < t; o++) {
|
|
889
|
-
let
|
|
890
|
-
if (
|
|
889
|
+
let a = c(s.data, o);
|
|
890
|
+
if (a.bufferByteOffset === 0)
|
|
891
891
|
continue;
|
|
892
|
-
let
|
|
893
|
-
firstBlock:
|
|
892
|
+
let l = new u(this.memory, {
|
|
893
|
+
firstBlock: a
|
|
894
894
|
});
|
|
895
|
-
for (let { data:
|
|
896
|
-
this.setHashKey(r, e,
|
|
895
|
+
for (let { data: n } of l)
|
|
896
|
+
this.setHashKey(r, e, n[0], n[1]);
|
|
897
897
|
}
|
|
898
|
-
|
|
898
|
+
k(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, e);
|
|
899
899
|
}
|
|
900
900
|
hash(t, e) {
|
|
901
901
|
return t % e;
|
|
@@ -917,10 +917,10 @@ class Ot {
|
|
|
917
917
|
};
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
|
-
function
|
|
921
|
-
return typeof i == "number" ? i : typeof i == "string" ?
|
|
920
|
+
function P(i) {
|
|
921
|
+
return typeof i == "number" ? i : typeof i == "string" ? ne(i) : i;
|
|
922
922
|
}
|
|
923
|
-
function
|
|
923
|
+
function ne(i) {
|
|
924
924
|
let t = i.length, e = 17 ^ t, r = 0, s;
|
|
925
925
|
for (; t >= 4; )
|
|
926
926
|
s = i.charCodeAt(r) & 255 | (i.charCodeAt(++r) & 255) << 8 | (i.charCodeAt(++r) & 255) << 16 | (i.charCodeAt(++r) & 255) << 14, s = (s & 65535) * 1540483477 + (((s >>> 16) * 1540483477 & 65535) << 16), s ^= s >>> 14, s = (s & 65535) * 1540483477 + (((s >>> 16) * 1540483477 & 65535) << 16), e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16) ^ s, t -= 4, ++r;
|
|
@@ -944,10 +944,10 @@ class Be {
|
|
|
944
944
|
return this.list.length;
|
|
945
945
|
}
|
|
946
946
|
insert(t) {
|
|
947
|
-
this.list.insert(
|
|
947
|
+
this.list.insert(L(t.memory.bufferPosition, t.memory.bufferByteOffset));
|
|
948
948
|
}
|
|
949
949
|
delete(t) {
|
|
950
|
-
return this.list.deleteValue(
|
|
950
|
+
return this.list.deleteValue(L(t.memory.bufferPosition, t.memory.bufferByteOffset));
|
|
951
951
|
}
|
|
952
952
|
*[Symbol.iterator]() {
|
|
953
953
|
let t = this.list[Symbol.iterator]();
|
|
@@ -980,7 +980,7 @@ class Be {
|
|
|
980
980
|
const bt = {
|
|
981
981
|
1: Uint8Array,
|
|
982
982
|
2: Uint16Array
|
|
983
|
-
}, U = 0,
|
|
983
|
+
}, U = 0, gt = 1, kt = 2, At = 3;
|
|
984
984
|
class Mt {
|
|
985
985
|
static ALLOCATE_COUNT = 4;
|
|
986
986
|
memory;
|
|
@@ -989,11 +989,11 @@ class Mt {
|
|
|
989
989
|
cachedPointer;
|
|
990
990
|
cachedString;
|
|
991
991
|
constructor(t, e) {
|
|
992
|
-
this.memory = t, typeof e == "string" ? (this.allocatedMemory = this.memory.allocUI32(Mt.ALLOCATE_COUNT), this.lock = new Int32Array(this.allocatedMemory.data.buffer, this.allocatedMemory.bufferByteOffset +
|
|
992
|
+
this.memory = t, typeof e == "string" ? (this.allocatedMemory = this.memory.allocUI32(Mt.ALLOCATE_COUNT), this.lock = new Int32Array(this.allocatedMemory.data.buffer, this.allocatedMemory.bufferByteOffset + At * this.allocatedMemory.data.BYTES_PER_ELEMENT), this.updateString(e)) : (this.allocatedMemory = new h(t, e), this.lock = new Int32Array(this.allocatedMemory.data.buffer, this.allocatedMemory.bufferByteOffset + At * this.allocatedMemory.data.BYTES_PER_ELEMENT), "value" in e && this.updateString(e.value));
|
|
993
993
|
}
|
|
994
994
|
updateString(t) {
|
|
995
995
|
let e = this.createString(t);
|
|
996
|
-
|
|
996
|
+
z(this.lock), x(this.allocatedMemory.data, U, e.pointer), Atomics.store(this.allocatedMemory.data, gt, t.length), Atomics.store(this.allocatedMemory.data, kt, e.charType), g(this.lock), this.cachedPointer = e.pointer, this.cachedString = t;
|
|
997
997
|
}
|
|
998
998
|
createString(t) {
|
|
999
999
|
if (t === "")
|
|
@@ -1003,13 +1003,13 @@ class Mt {
|
|
|
1003
1003
|
/* ASCII */
|
|
1004
1004
|
};
|
|
1005
1005
|
let e = [];
|
|
1006
|
-
for (let
|
|
1007
|
-
e.push(t.charCodeAt(
|
|
1008
|
-
let s = Math.max(...e) > 255 ? 2 : 1, o = bt[s],
|
|
1009
|
-
for (let
|
|
1010
|
-
|
|
1006
|
+
for (let n = 0; n < t.length; n++)
|
|
1007
|
+
e.push(t.charCodeAt(n));
|
|
1008
|
+
let s = Math.max(...e) > 255 ? 2 : 1, o = bt[s], a = this.memory.allocUI32(Math.ceil(t.length / (4 / o.BYTES_PER_ELEMENT))), l = new o(a.data.buffer, a.data.byteOffset, t.length);
|
|
1009
|
+
for (let n = 0; n < t.length; n++)
|
|
1010
|
+
l[n] = t.charCodeAt(n);
|
|
1011
1011
|
return {
|
|
1012
|
-
pointer:
|
|
1012
|
+
pointer: a.pointer,
|
|
1013
1013
|
charType: s
|
|
1014
1014
|
};
|
|
1015
1015
|
}
|
|
@@ -1019,10 +1019,10 @@ class Mt {
|
|
|
1019
1019
|
return this.cachedString;
|
|
1020
1020
|
if (t === 0)
|
|
1021
1021
|
return "";
|
|
1022
|
-
let { bufferPosition: e, bufferByteOffset: r } =
|
|
1023
|
-
|
|
1024
|
-
let s = Atomics.load(this.allocatedMemory.data,
|
|
1025
|
-
return
|
|
1022
|
+
let { bufferPosition: e, bufferByteOffset: r } = B(t);
|
|
1023
|
+
z(this.lock);
|
|
1024
|
+
let s = Atomics.load(this.allocatedMemory.data, kt), o = bt[s], a = Atomics.load(this.allocatedMemory.data, gt), l = new o(this.memory.buffers[e].buf, r, a), n = String.fromCharCode.apply(null, l);
|
|
1025
|
+
return g(this.lock), this.cachedPointer = t, this.cachedString = n, n;
|
|
1026
1026
|
}
|
|
1027
1027
|
set value(t) {
|
|
1028
1028
|
let { bufferPosition: e, bufferByteOffset: r } = c(this.allocatedMemory.data, U);
|
|
@@ -1039,15 +1039,15 @@ class Mt {
|
|
|
1039
1039
|
e && this.memory.buffers[t].free(e), this.allocatedMemory.free();
|
|
1040
1040
|
}
|
|
1041
1041
|
}
|
|
1042
|
-
const
|
|
1043
|
-
class
|
|
1042
|
+
const E = 0, d = 1, pt = 2, Et = 3, wt = 4;
|
|
1043
|
+
class m {
|
|
1044
1044
|
static ALLOCATE_COUNT = 4;
|
|
1045
1045
|
memory;
|
|
1046
1046
|
// Pointer, List Length, Buffer Length, Type/DataLength
|
|
1047
1047
|
firstBlock;
|
|
1048
1048
|
uint16Array;
|
|
1049
1049
|
get length() {
|
|
1050
|
-
return Atomics.load(this.firstBlock.data,
|
|
1050
|
+
return Atomics.load(this.firstBlock.data, d);
|
|
1051
1051
|
}
|
|
1052
1052
|
get type() {
|
|
1053
1053
|
return this.uint16Array[0];
|
|
@@ -1056,16 +1056,16 @@ class d {
|
|
|
1056
1056
|
Atomics.store(this.uint16Array, 0, t);
|
|
1057
1057
|
}
|
|
1058
1058
|
get dataLength() {
|
|
1059
|
-
return
|
|
1059
|
+
return this.uint16Array[1] || 1;
|
|
1060
1060
|
}
|
|
1061
1061
|
set dataLength(t) {
|
|
1062
1062
|
Atomics.store(this.uint16Array, 1, t);
|
|
1063
1063
|
}
|
|
1064
1064
|
get bufferLength() {
|
|
1065
|
-
return Atomics.load(this.firstBlock.data,
|
|
1065
|
+
return Atomics.load(this.firstBlock.data, pt);
|
|
1066
1066
|
}
|
|
1067
1067
|
set bufferLength(t) {
|
|
1068
|
-
Atomics.store(this.firstBlock.data,
|
|
1068
|
+
Atomics.store(this.firstBlock.data, pt, t);
|
|
1069
1069
|
}
|
|
1070
1070
|
get pointer() {
|
|
1071
1071
|
return this.firstBlock.pointer;
|
|
@@ -1074,21 +1074,21 @@ class d {
|
|
|
1074
1074
|
cachedPointer;
|
|
1075
1075
|
constructor(t, e) {
|
|
1076
1076
|
if (this.memory = t, e && "firstBlock" in e) {
|
|
1077
|
-
if (this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset +
|
|
1078
|
-
const r = e.bufferLength ??
|
|
1077
|
+
if (this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Et * Uint32Array.BYTES_PER_ELEMENT, 2), "type" in e || "dataLength" in e) {
|
|
1078
|
+
const r = e.bufferLength ?? wt;
|
|
1079
1079
|
let s = t.allocUI32(r * (e.dataLength ?? 1));
|
|
1080
|
-
|
|
1080
|
+
k(this.firstBlock.data, E, s.bufferPosition, s.bufferByteOffset), this.bufferLength = r, this.dataLength = e.dataLength ?? 1;
|
|
1081
1081
|
}
|
|
1082
1082
|
if ("type" in e) {
|
|
1083
1083
|
const r = e?.type ?? Uint32Array;
|
|
1084
1084
|
r === Uint32Array ? this.type = 0 : r === Int32Array ? this.type = 1 : r === Float32Array && (this.type = 2);
|
|
1085
1085
|
}
|
|
1086
1086
|
} else {
|
|
1087
|
-
this.firstBlock = t.allocUI32(
|
|
1088
|
-
let r = e?.dataLength ?? 1, s = e?.bufferLength ??
|
|
1089
|
-
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1087
|
+
this.firstBlock = t.allocUI32(m.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Et * Uint32Array.BYTES_PER_ELEMENT, 2);
|
|
1088
|
+
let r = e?.dataLength ?? 1, s = e?.bufferLength ?? wt, o = t.allocUI32(s * r);
|
|
1089
|
+
k(this.firstBlock.data, E, o.bufferPosition, o.bufferByteOffset), this.bufferLength = s;
|
|
1090
|
+
const a = e?.type ?? Uint32Array;
|
|
1091
|
+
a === Uint32Array ? this.type = 0 : a === Int32Array ? this.type = 1 : a === Float32Array && (this.type = 2), this.dataLength = r;
|
|
1092
1092
|
}
|
|
1093
1093
|
this.cachedPointer = this.firstBlock.data[0], this.cachedFullDataBlock = this.getFullDataBlock();
|
|
1094
1094
|
}
|
|
@@ -1107,29 +1107,34 @@ class d {
|
|
|
1107
1107
|
return this.getFullDataBlock()[t * this.dataLength + e];
|
|
1108
1108
|
}
|
|
1109
1109
|
push(t) {
|
|
1110
|
-
typeof t == "number" && (t = [t]);
|
|
1111
1110
|
let e = this.dataLength;
|
|
1112
|
-
|
|
1111
|
+
const r = typeof t == "number";
|
|
1112
|
+
if (!r && t.length > e)
|
|
1113
1113
|
throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
|
|
1114
|
-
let
|
|
1115
|
-
return r.set(t,
|
|
1114
|
+
let s = this.getFullDataBlock(), o = this.length, a = e * o;
|
|
1115
|
+
return r ? s[a] = t : s.set(t, a), Atomics.add(this.firstBlock.data, d, 1) + 1 >= this.bufferLength && this.growBuffer(), o;
|
|
1116
1116
|
}
|
|
1117
1117
|
pop() {
|
|
1118
|
-
let t = Atomics.sub(this.firstBlock.data,
|
|
1118
|
+
let t = Atomics.sub(this.firstBlock.data, d, d), e = this.getFullDataBlock();
|
|
1119
1119
|
return this.getDataBlock(e, t - 1);
|
|
1120
1120
|
}
|
|
1121
|
+
// Returns the first number irregardless of dataLength - faster way to pop if you don't care about the rest of the data block
|
|
1122
|
+
popNumber() {
|
|
1123
|
+
const t = Atomics.sub(this.firstBlock.data, d, d);
|
|
1124
|
+
return this.getFullDataBlock()[(t - 1) * this.dataLength];
|
|
1125
|
+
}
|
|
1121
1126
|
deleteIndex(t) {
|
|
1122
1127
|
let e = this.length;
|
|
1123
1128
|
if (t >= e || t < 0)
|
|
1124
1129
|
throw new Error(`${t} is out of bounds ${e}`);
|
|
1125
1130
|
let r = this.dataLength, s = this.getFullDataBlock();
|
|
1126
1131
|
for (let o = t; o < e; o++)
|
|
1127
|
-
for (let
|
|
1128
|
-
s[o * r +
|
|
1129
|
-
Atomics.sub(this.firstBlock.data,
|
|
1132
|
+
for (let a = 0; a < r; a++)
|
|
1133
|
+
s[o * r + a] = s[(o + 1) * r + a];
|
|
1134
|
+
Atomics.sub(this.firstBlock.data, d, d);
|
|
1130
1135
|
}
|
|
1131
1136
|
clear() {
|
|
1132
|
-
this.firstBlock.data[
|
|
1137
|
+
this.firstBlock.data[d] = 0;
|
|
1133
1138
|
}
|
|
1134
1139
|
*[Symbol.iterator]() {
|
|
1135
1140
|
let t = this.getFullDataBlock();
|
|
@@ -1137,10 +1142,10 @@ class d {
|
|
|
1137
1142
|
yield this.getDataBlock(t, e);
|
|
1138
1143
|
}
|
|
1139
1144
|
getFullDataBlock() {
|
|
1140
|
-
let t = Atomics.load(this.firstBlock.data,
|
|
1145
|
+
let t = Atomics.load(this.firstBlock.data, E);
|
|
1141
1146
|
if (this.cachedPointer === t && this.cachedFullDataBlock)
|
|
1142
1147
|
return this.cachedFullDataBlock;
|
|
1143
|
-
let e =
|
|
1148
|
+
let e = B(t), r = new h(this.memory, e), s;
|
|
1144
1149
|
switch (this.type) {
|
|
1145
1150
|
case 1:
|
|
1146
1151
|
s = new Int32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
|
|
@@ -1161,24 +1166,26 @@ class d {
|
|
|
1161
1166
|
return t.subarray(r, r + this.dataLength);
|
|
1162
1167
|
}
|
|
1163
1168
|
growBuffer() {
|
|
1164
|
-
let e = this.bufferLength * 2, r = this.dataLength, s = c(this.firstBlock.data,
|
|
1169
|
+
let e = this.bufferLength * 2, r = this.dataLength, s = c(this.firstBlock.data, E), o = new h(this.memory, s), a = this.getFullDataBlock(), l = this.memory.allocUI32(e * r), n;
|
|
1165
1170
|
switch (this.type) {
|
|
1166
1171
|
case 1:
|
|
1167
|
-
|
|
1172
|
+
n = new Int32Array(l.data.buffer, l.bufferByteOffset, r * e);
|
|
1168
1173
|
break;
|
|
1169
1174
|
case 0:
|
|
1170
|
-
|
|
1175
|
+
n = new Uint32Array(l.data.buffer, l.bufferByteOffset, r * e);
|
|
1171
1176
|
break;
|
|
1172
1177
|
case 2:
|
|
1173
|
-
|
|
1178
|
+
n = new Float32Array(l.data.buffer, l.bufferByteOffset, r * e);
|
|
1174
1179
|
break;
|
|
1175
1180
|
default:
|
|
1176
1181
|
throw new Error(`Unknown data block type ${this.type}`);
|
|
1177
1182
|
}
|
|
1178
|
-
|
|
1183
|
+
n.set(a);
|
|
1184
|
+
const f = l.pointer;
|
|
1185
|
+
x(this.firstBlock.data, E, f), this.bufferLength = e, o.free(), this.cachedPointer = f, this.cachedFullDataBlock = n;
|
|
1179
1186
|
}
|
|
1180
1187
|
free() {
|
|
1181
|
-
let t = c(this.firstBlock.data,
|
|
1188
|
+
let t = c(this.firstBlock.data, E);
|
|
1182
1189
|
new h(this.memory, t).free(), this.firstBlock.free();
|
|
1183
1190
|
}
|
|
1184
1191
|
getSharedMemory() {
|
|
@@ -1258,9 +1265,9 @@ class me {
|
|
|
1258
1265
|
this.list.free(), this.cache.clear();
|
|
1259
1266
|
}
|
|
1260
1267
|
}
|
|
1261
|
-
const
|
|
1268
|
+
const D = 0, Lt = 1, St = 2, q = 3, Tt = q + m.ALLOCATE_COUNT;
|
|
1262
1269
|
class It {
|
|
1263
|
-
static ALLOCATE_COUNT = 3 +
|
|
1270
|
+
static ALLOCATE_COUNT = 3 + m.ALLOCATE_COUNT * 2;
|
|
1264
1271
|
memory;
|
|
1265
1272
|
// Current Length, Type/DataLength, MaxChunkLength, Pointer vector, Recycle vector
|
|
1266
1273
|
firstBlock;
|
|
@@ -1269,13 +1276,13 @@ class It {
|
|
|
1269
1276
|
recycleVector;
|
|
1270
1277
|
cachedFullDataBlock = {};
|
|
1271
1278
|
get length() {
|
|
1272
|
-
return Atomics.load(this.firstBlock.data,
|
|
1279
|
+
return Atomics.load(this.firstBlock.data, D) - this.recycleVector.length;
|
|
1273
1280
|
}
|
|
1274
1281
|
get maxChunkSize() {
|
|
1275
|
-
return this.firstBlock.data[
|
|
1282
|
+
return this.firstBlock.data[St];
|
|
1276
1283
|
}
|
|
1277
1284
|
set maxChunkSize(t) {
|
|
1278
|
-
Atomics.store(this.firstBlock.data,
|
|
1285
|
+
Atomics.store(this.firstBlock.data, St, t);
|
|
1279
1286
|
}
|
|
1280
1287
|
get type() {
|
|
1281
1288
|
return this.uint16Array[0];
|
|
@@ -1300,38 +1307,38 @@ class It {
|
|
|
1300
1307
|
}
|
|
1301
1308
|
constructor(t, e) {
|
|
1302
1309
|
if (this.memory = t, e && "firstBlock" in e)
|
|
1303
|
-
this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset +
|
|
1310
|
+
this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Lt * Uint32Array.BYTES_PER_ELEMENT, 2), this.pointerVector = new m(t, {
|
|
1304
1311
|
firstBlock: {
|
|
1305
1312
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1306
1313
|
bufferByteOffset: this.firstBlock.bufferByteOffset + q * Uint32Array.BYTES_PER_ELEMENT
|
|
1307
1314
|
}
|
|
1308
|
-
}), this.recycleVector = new
|
|
1315
|
+
}), this.recycleVector = new m(t, {
|
|
1309
1316
|
firstBlock: {
|
|
1310
1317
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1311
|
-
bufferByteOffset: this.firstBlock.bufferByteOffset +
|
|
1318
|
+
bufferByteOffset: this.firstBlock.bufferByteOffset + Tt * Uint32Array.BYTES_PER_ELEMENT
|
|
1312
1319
|
}
|
|
1313
1320
|
});
|
|
1314
1321
|
else {
|
|
1315
|
-
this.firstBlock = t.allocUI32(It.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset +
|
|
1322
|
+
this.firstBlock = t.allocUI32(It.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Lt * Uint32Array.BYTES_PER_ELEMENT, 2);
|
|
1316
1323
|
let r = e?.dataLength ?? 1, s = e?.maxChunkSize ?? 100;
|
|
1317
|
-
this.pointerVector = new
|
|
1324
|
+
this.pointerVector = new m(t, {
|
|
1318
1325
|
type: Uint32Array,
|
|
1319
1326
|
firstBlock: {
|
|
1320
1327
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1321
1328
|
bufferByteOffset: this.firstBlock.bufferByteOffset + q * Uint32Array.BYTES_PER_ELEMENT
|
|
1322
1329
|
}
|
|
1323
|
-
}), this.recycleVector = new
|
|
1330
|
+
}), this.recycleVector = new m(t, {
|
|
1324
1331
|
type: Uint32Array,
|
|
1325
1332
|
firstBlock: {
|
|
1326
1333
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1327
|
-
bufferByteOffset: this.firstBlock.bufferByteOffset +
|
|
1334
|
+
bufferByteOffset: this.firstBlock.bufferByteOffset + Tt * Uint32Array.BYTES_PER_ELEMENT
|
|
1328
1335
|
},
|
|
1329
1336
|
bufferLength: e?.recycleBufferLength
|
|
1330
1337
|
});
|
|
1331
1338
|
const o = e?.type ?? Uint32Array;
|
|
1332
1339
|
o === Uint32Array ? this.type = 0 : o === Int32Array ? this.type = 1 : o === Float32Array ? this.type = 2 : o === Float64Array && (this.type = 3), this.dataLength = r, this.maxChunkSize = s;
|
|
1333
|
-
let
|
|
1334
|
-
this.pointerVector.push(
|
|
1340
|
+
let a = t.allocUI32(s * r * this.byteMultipler);
|
|
1341
|
+
this.pointerVector.push(a.pointer);
|
|
1335
1342
|
}
|
|
1336
1343
|
}
|
|
1337
1344
|
at(t) {
|
|
@@ -1350,7 +1357,7 @@ class It {
|
|
|
1350
1357
|
if (t.length > e)
|
|
1351
1358
|
throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
|
|
1352
1359
|
let r;
|
|
1353
|
-
this.recycleVector.length ? r = this.recycleVector.
|
|
1360
|
+
this.recycleVector.length ? r = this.recycleVector.popNumber() : r = Atomics.add(this.firstBlock.data, D, 1);
|
|
1354
1361
|
let s = this.getFullDataBlock(r), o = r % this.maxChunkSize;
|
|
1355
1362
|
return s.set(t, e * o), r;
|
|
1356
1363
|
}
|
|
@@ -1358,14 +1365,14 @@ class It {
|
|
|
1358
1365
|
this.recycleVector.push(t);
|
|
1359
1366
|
}
|
|
1360
1367
|
clear() {
|
|
1361
|
-
this.firstBlock.data[
|
|
1368
|
+
this.firstBlock.data[D] = 0, this.recycleVector.clear();
|
|
1362
1369
|
}
|
|
1363
1370
|
*[Symbol.iterator]() {
|
|
1364
1371
|
const t = {};
|
|
1365
1372
|
for (let s of this.recycleVector)
|
|
1366
1373
|
t[s[0]] = !0;
|
|
1367
1374
|
let e = this.getFullDataBlock(0), r = 0;
|
|
1368
|
-
for (let s = 0; s < Atomics.load(this.firstBlock.data,
|
|
1375
|
+
for (let s = 0; s < Atomics.load(this.firstBlock.data, D); s++)
|
|
1369
1376
|
if (!t[s]) {
|
|
1370
1377
|
let o = Math.floor(s / this.maxChunkSize);
|
|
1371
1378
|
o !== r && (e = this.getFullDataBlock(s), r = o), yield this.getDataBlock(e, s % this.maxChunkSize);
|
|
@@ -1376,10 +1383,10 @@ class It {
|
|
|
1376
1383
|
if (r)
|
|
1377
1384
|
return r;
|
|
1378
1385
|
if (e >= this.pointerVector.length) {
|
|
1379
|
-
let
|
|
1380
|
-
this.pointerVector.push(
|
|
1386
|
+
let a = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
|
|
1387
|
+
this.pointerVector.push(a.pointer);
|
|
1381
1388
|
}
|
|
1382
|
-
let s = new h(this.memory,
|
|
1389
|
+
let s = new h(this.memory, B(this.pointerVector.get(e))), o;
|
|
1383
1390
|
switch (this.type) {
|
|
1384
1391
|
case 1:
|
|
1385
1392
|
o = new Int32Array(s.data.buffer, s.bufferByteOffset, this.dataLength * this.maxChunkSize);
|
|
@@ -1406,7 +1413,7 @@ class It {
|
|
|
1406
1413
|
this.recycleVector.free();
|
|
1407
1414
|
for (let t of this.pointerVector) {
|
|
1408
1415
|
let e = t[0];
|
|
1409
|
-
new h(this.memory,
|
|
1416
|
+
new h(this.memory, B(e)).free();
|
|
1410
1417
|
}
|
|
1411
1418
|
this.pointerVector.free(), this.firstBlock.free();
|
|
1412
1419
|
}
|
|
@@ -1416,158 +1423,248 @@ class It {
|
|
|
1416
1423
|
};
|
|
1417
1424
|
}
|
|
1418
1425
|
}
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1426
|
+
class be {
|
|
1427
|
+
memory;
|
|
1428
|
+
pointers = [];
|
|
1429
|
+
recycledIndexes = [];
|
|
1430
|
+
totalLength = 0;
|
|
1431
|
+
maxChunkSize = 100;
|
|
1432
|
+
dataLength = 1;
|
|
1433
|
+
byteMultipler = 1;
|
|
1434
|
+
typeConstructor;
|
|
1435
|
+
fullDataBlocks = {};
|
|
1436
|
+
get length() {
|
|
1437
|
+
return this.totalLength - this.recycledIndexes.length;
|
|
1438
|
+
}
|
|
1439
|
+
get bufferLength() {
|
|
1440
|
+
return this.maxChunkSize * this.pointers.length;
|
|
1441
|
+
}
|
|
1442
|
+
constructor(t, e) {
|
|
1443
|
+
this.memory = t;
|
|
1444
|
+
const r = e?.dataLength ?? 1, s = e?.maxChunkSize ?? 100;
|
|
1445
|
+
this.dataLength = r, this.maxChunkSize = s, this.typeConstructor = e.type, this.typeConstructor === Float64Array && (this.byteMultipler = 2);
|
|
1446
|
+
let o = t.allocUI32(s * r * this.byteMultipler);
|
|
1447
|
+
this.pointers.push(o.pointer);
|
|
1448
|
+
let a = new this.typeConstructor(o.data.buffer, o.bufferByteOffset, this.dataLength * this.maxChunkSize);
|
|
1449
|
+
this.fullDataBlocks[0] = a;
|
|
1450
|
+
}
|
|
1451
|
+
at(t) {
|
|
1452
|
+
let e = this.fullDataBlocks[Math.floor(t / this.maxChunkSize)];
|
|
1453
|
+
return this.getDataBlock(e, t % this.maxChunkSize);
|
|
1454
|
+
}
|
|
1455
|
+
get(t, e = 0) {
|
|
1456
|
+
const r = this.dataLength;
|
|
1457
|
+
if (e >= r)
|
|
1458
|
+
throw new Error(`${e} is out of dataLength bounds ${r}`);
|
|
1459
|
+
return this.fullDataBlocks[Math.floor(t / this.maxChunkSize)][t % this.maxChunkSize * r + e];
|
|
1460
|
+
}
|
|
1461
|
+
push(t) {
|
|
1462
|
+
const e = typeof t == "number";
|
|
1463
|
+
if (!e && t.length > this.dataLength)
|
|
1464
|
+
throw new Error(`Can't insert ${t.length} array into shared list of ${this.dataLength} dataLength`);
|
|
1465
|
+
let r = this.recycledIndexes.pop();
|
|
1466
|
+
r === void 0 && (r = this.totalLength++);
|
|
1467
|
+
let s = Math.floor(r / this.maxChunkSize);
|
|
1468
|
+
if (s >= this.pointers.length) {
|
|
1469
|
+
let n = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
|
|
1470
|
+
this.pointers.push(n.pointer);
|
|
1471
|
+
let f = new this.typeConstructor(n.data.buffer, n.bufferByteOffset, this.dataLength * this.maxChunkSize);
|
|
1472
|
+
this.fullDataBlocks[s] = f;
|
|
1473
|
+
}
|
|
1474
|
+
let o = this.fullDataBlocks[s], a = r % this.maxChunkSize, l = this.dataLength * a;
|
|
1475
|
+
return e ? o[l] = t : o.set(t, l), r;
|
|
1476
|
+
}
|
|
1477
|
+
deleteIndex(t) {
|
|
1478
|
+
this.recycledIndexes.push(t);
|
|
1479
|
+
}
|
|
1480
|
+
clear() {
|
|
1481
|
+
this.totalLength = 0, this.recycledIndexes = [];
|
|
1482
|
+
}
|
|
1483
|
+
*[Symbol.iterator]() {
|
|
1484
|
+
const t = {};
|
|
1485
|
+
for (let s of this.recycledIndexes)
|
|
1486
|
+
t[s] = !0;
|
|
1487
|
+
let e = this.getFullDataBlock(0), r = 0;
|
|
1488
|
+
for (let s = 0; s < this.totalLength; s++)
|
|
1489
|
+
if (!t[s]) {
|
|
1490
|
+
let o = Math.floor(s / this.maxChunkSize);
|
|
1491
|
+
o !== r && (e = this.getFullDataBlock(s), r = o), yield this.getDataBlock(e, s % this.maxChunkSize);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
getFullDataBlock(t) {
|
|
1495
|
+
let e = Math.floor(t / this.maxChunkSize), r = this.fullDataBlocks[e];
|
|
1496
|
+
if (r)
|
|
1497
|
+
return r;
|
|
1498
|
+
if (e >= this.pointers.length) {
|
|
1499
|
+
let a = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
|
|
1500
|
+
this.pointers.push(a.pointer);
|
|
1501
|
+
}
|
|
1502
|
+
let s = new h(this.memory, B(this.pointers[e])), o = new this.typeConstructor(s.data.buffer, s.bufferByteOffset, this.dataLength * this.maxChunkSize);
|
|
1503
|
+
return this.fullDataBlocks[e] = o, o;
|
|
1504
|
+
}
|
|
1505
|
+
getDataBlock(t, e) {
|
|
1506
|
+
const r = e * this.dataLength;
|
|
1507
|
+
return t.subarray(r, r + this.dataLength);
|
|
1508
|
+
}
|
|
1509
|
+
free() {
|
|
1510
|
+
for (let t of this.pointers)
|
|
1511
|
+
new h(this.memory, B(t)).free();
|
|
1512
|
+
this.pointers = [], this.recycledIndexes = [], this.totalLength = 0, this.fullDataBlocks = {};
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
const Ct = new ArrayBuffer(4), Nt = new Uint32Array(Ct), R = new Uint16Array(Ct);
|
|
1516
|
+
function ge(i, t) {
|
|
1517
|
+
return le(Atomics.load(i, t));
|
|
1422
1518
|
}
|
|
1423
|
-
function
|
|
1424
|
-
Atomics.store(i, t,
|
|
1519
|
+
function ke(i, t, e, r) {
|
|
1520
|
+
Atomics.store(i, t, fe(e, r));
|
|
1425
1521
|
}
|
|
1426
|
-
function
|
|
1522
|
+
function le(i) {
|
|
1427
1523
|
return Nt[0] = i, [R[0], R[1]];
|
|
1428
1524
|
}
|
|
1429
|
-
function
|
|
1525
|
+
function fe(i, t) {
|
|
1430
1526
|
return R[0] = i, R[1] = t, Nt[0];
|
|
1431
1527
|
}
|
|
1432
|
-
const
|
|
1433
|
-
function
|
|
1434
|
-
return Ut[0] = Atomics.load(i, t), [
|
|
1528
|
+
const Pt = new ArrayBuffer(8), Ut = new BigUint64Array(Pt), b = new Uint16Array(Pt);
|
|
1529
|
+
function Ae(i, t) {
|
|
1530
|
+
return Ut[0] = Atomics.load(i, t), [b[0], b[1], b[2], b[3]];
|
|
1435
1531
|
}
|
|
1436
|
-
function
|
|
1437
|
-
|
|
1532
|
+
function pe(i, t, e, r, s, o = 0) {
|
|
1533
|
+
b[0] = e, b[1] = r, b[2] = s, b[3] = o, Atomics.store(i, t, Ut[0]);
|
|
1438
1534
|
}
|
|
1439
|
-
const
|
|
1440
|
-
function
|
|
1535
|
+
const Dt = new ArrayBuffer(4), xt = new Float32Array(Dt), Ft = new Int32Array(Dt);
|
|
1536
|
+
function zt(i, t) {
|
|
1441
1537
|
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.load(i, t));
|
|
1442
1538
|
}
|
|
1443
1539
|
function Ee(i, t, e) {
|
|
1444
1540
|
i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Atomics.store(i, t, $(e));
|
|
1445
1541
|
}
|
|
1446
1542
|
function Q(i) {
|
|
1447
|
-
return
|
|
1543
|
+
return Ft[0] = i, xt[0];
|
|
1448
1544
|
}
|
|
1449
1545
|
function $(i) {
|
|
1450
|
-
return
|
|
1546
|
+
return xt[0] = i, Ft[0];
|
|
1451
1547
|
}
|
|
1452
1548
|
function we(i, t, e) {
|
|
1453
1549
|
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.exchange(i, t, $(e)));
|
|
1454
1550
|
}
|
|
1455
|
-
function
|
|
1551
|
+
function Rt(i, t, e, r) {
|
|
1456
1552
|
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.compareExchange(i, t, $(e), $(r)));
|
|
1457
1553
|
}
|
|
1458
|
-
function
|
|
1554
|
+
function Le(i, t, e, r) {
|
|
1459
1555
|
let s, o;
|
|
1460
1556
|
do
|
|
1461
1557
|
s = Atomics.load(i, t), o = Math.min(s + e, r);
|
|
1462
1558
|
while (Atomics.compareExchange(i, t, s, o) !== s);
|
|
1463
1559
|
}
|
|
1464
|
-
function
|
|
1560
|
+
function Se(i, t, e, r) {
|
|
1465
1561
|
let s, o;
|
|
1466
1562
|
do
|
|
1467
1563
|
s = Atomics.load(i, t), o = Math.max(s - e, r);
|
|
1468
1564
|
while (Atomics.compareExchange(i, t, s, o) !== s);
|
|
1469
1565
|
}
|
|
1470
|
-
function
|
|
1566
|
+
function Te(i, t, e, r) {
|
|
1471
1567
|
let s, o;
|
|
1472
1568
|
do
|
|
1473
|
-
s =
|
|
1474
|
-
while (
|
|
1569
|
+
s = zt(i, t), o = Math.min(s + e, r);
|
|
1570
|
+
while (Rt(i, t, s, o) !== s);
|
|
1475
1571
|
}
|
|
1476
|
-
function
|
|
1572
|
+
function _e(i, t, e, r) {
|
|
1477
1573
|
let s, o;
|
|
1478
1574
|
do
|
|
1479
|
-
s =
|
|
1480
|
-
while (
|
|
1575
|
+
s = zt(i, t), o = Math.max(s - e, r);
|
|
1576
|
+
while (Rt(i, t, s, o) !== s);
|
|
1481
1577
|
}
|
|
1482
|
-
const
|
|
1483
|
-
function
|
|
1578
|
+
const $t = new ArrayBuffer(8), Yt = new Float64Array($t), Ht = new BigInt64Array($t);
|
|
1579
|
+
function Oe(i, t) {
|
|
1484
1580
|
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.load(i, t));
|
|
1485
1581
|
}
|
|
1486
|
-
function
|
|
1487
|
-
i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), Atomics.store(i, t,
|
|
1582
|
+
function Me(i, t, e) {
|
|
1583
|
+
i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), Atomics.store(i, t, Y(e));
|
|
1488
1584
|
}
|
|
1489
1585
|
function tt(i) {
|
|
1490
1586
|
return Ht[0] = i, Yt[0];
|
|
1491
1587
|
}
|
|
1492
|
-
function
|
|
1588
|
+
function Y(i) {
|
|
1493
1589
|
return Yt[0] = i, Ht[0];
|
|
1494
1590
|
}
|
|
1495
|
-
function
|
|
1496
|
-
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.exchange(i, t,
|
|
1591
|
+
function Ie(i, t, e) {
|
|
1592
|
+
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.exchange(i, t, Y(e)));
|
|
1497
1593
|
}
|
|
1498
|
-
function
|
|
1499
|
-
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.compareExchange(i, t,
|
|
1500
|
-
}
|
|
1501
|
-
const p = 0, J = 1, L = 2;
|
|
1502
|
-
function Pe(i, t = 0) {
|
|
1503
|
-
for (; Atomics.compareExchange(i, t, p, J) === L; )
|
|
1504
|
-
Atomics.wait(i, t, L);
|
|
1505
|
-
Atomics.add(i, t + 1, 1);
|
|
1594
|
+
function Ce(i, t, e, r) {
|
|
1595
|
+
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.compareExchange(i, t, Y(e), Y(r)));
|
|
1506
1596
|
}
|
|
1597
|
+
const w = 0, J = 1, S = 2;
|
|
1507
1598
|
function Ne(i, t = 0) {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1599
|
+
for (; Atomics.compareExchange(i, t, w, J) === S; )
|
|
1600
|
+
Atomics.wait(i, t, S);
|
|
1601
|
+
Atomics.add(i, t + 1, 1);
|
|
1511
1602
|
}
|
|
1512
|
-
function
|
|
1513
|
-
|
|
1603
|
+
function Pe(i, t = 0) {
|
|
1604
|
+
let e = Atomics.compareExchange(i, t, w, S);
|
|
1605
|
+
for (; e !== w; )
|
|
1606
|
+
Atomics.wait(i, t, e), e = Atomics.compareExchange(i, t, w, S);
|
|
1514
1607
|
}
|
|
1515
1608
|
function Ue(i, t = 0) {
|
|
1516
|
-
Atomics.compareExchange(i, t,
|
|
1609
|
+
Atomics.sub(i, t + 1, 1) - 1 <= 0 && (Atomics.compareExchange(i, t, J, w) !== J && console.warn("We are unlocking when it was not read locked!"), Atomics.notify(i, t));
|
|
1610
|
+
}
|
|
1611
|
+
function De(i, t = 0) {
|
|
1612
|
+
Atomics.compareExchange(i, t, S, w) !== S && console.warn("We are unlocking when it was not write locked!"), Atomics.notify(i, t);
|
|
1517
1613
|
}
|
|
1518
|
-
const
|
|
1614
|
+
const xe = 2;
|
|
1519
1615
|
export {
|
|
1520
1616
|
h as AllocatedMemory,
|
|
1521
1617
|
he as BYTE_OFFSET_BIT_COUNT,
|
|
1522
1618
|
me as CachedItemList,
|
|
1619
|
+
be as LocalPool,
|
|
1523
1620
|
et as MAX_BYTE_OFFSET_LENGTH,
|
|
1524
1621
|
rt as MAX_POSITION_LENGTH,
|
|
1525
|
-
|
|
1526
|
-
|
|
1622
|
+
W as MemoryBuffer,
|
|
1623
|
+
ye as MemoryHeap,
|
|
1527
1624
|
ce as POSITION_BIT_COUNT,
|
|
1528
|
-
|
|
1529
|
-
|
|
1625
|
+
xe as READ_WRITE_LOCK_ALLOCATE_COUNT,
|
|
1626
|
+
de as SIMPLE_LOCK_ALLOCATE_COUNT,
|
|
1530
1627
|
u as SharedList,
|
|
1531
1628
|
Ot as SharedMap,
|
|
1532
1629
|
Be as SharedPointerList,
|
|
1533
1630
|
It as SharedPool,
|
|
1534
1631
|
Mt as SharedString,
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1632
|
+
m as SharedVector,
|
|
1633
|
+
Te as addAtomicFloat32,
|
|
1634
|
+
Le as addAtomicInt,
|
|
1635
|
+
Rt as compareExchangeFloat32,
|
|
1636
|
+
Ce as compareExchangeFloat64,
|
|
1637
|
+
fe as convert16To32,
|
|
1638
|
+
le as convert32To16,
|
|
1542
1639
|
$ as convertFloat32ToInt32,
|
|
1543
|
-
|
|
1640
|
+
Y as convertFloat64ToInt64,
|
|
1544
1641
|
Q as convertInt32ToFloat32,
|
|
1545
1642
|
tt as convertInt64ToFloat64,
|
|
1546
|
-
|
|
1643
|
+
L as createPointer,
|
|
1547
1644
|
we as exchangeFloat32,
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1645
|
+
Ie as exchangeFloat64,
|
|
1646
|
+
B as getPointer,
|
|
1647
|
+
ge as load16From32,
|
|
1648
|
+
Ae as load16From64,
|
|
1649
|
+
zt as loadFloat32,
|
|
1650
|
+
Oe as loadFloat64,
|
|
1554
1651
|
c as loadPointer,
|
|
1555
1652
|
O as loadRawPointer,
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1653
|
+
z as lock,
|
|
1654
|
+
Ne as readLock,
|
|
1655
|
+
Ue as readUnlock,
|
|
1559
1656
|
ue as replacePointer,
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1657
|
+
V as replaceRawPointer,
|
|
1658
|
+
ke as store16In32,
|
|
1659
|
+
pe as store16In64,
|
|
1563
1660
|
Ee as storeFloat32,
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1661
|
+
Me as storeFloat64,
|
|
1662
|
+
k as storePointer,
|
|
1663
|
+
x as storeRawPointer,
|
|
1664
|
+
_e as subtractAtomicFloat,
|
|
1665
|
+
Se as subtractAtomicInt,
|
|
1666
|
+
g as unlock,
|
|
1667
|
+
Pe as writeLock,
|
|
1668
|
+
De as writeUnlock
|
|
1572
1669
|
};
|
|
1573
1670
|
//# sourceMappingURL=shared-memory-objects.js.map
|