@daneren2005/shared-memory-objects 0.0.17 → 0.0.18
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const he = 20, ce = 12,
|
|
1
|
+
const he = 20, ce = 12, et = Math.pow(2, 20), rt = Math.pow(2, 12);
|
|
2
2
|
function c(i, t = 0) {
|
|
3
3
|
return g(Atomics.load(i, t));
|
|
4
4
|
}
|
|
@@ -8,12 +8,12 @@ function O(i, t = 0) {
|
|
|
8
8
|
function m(i, t = 0, e, r) {
|
|
9
9
|
Atomics.store(i, t, T(e, r));
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function v(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 n = T(s, o);
|
|
16
|
+
return Atomics.compareExchange(i, t, n, T(e, r)) === n;
|
|
17
17
|
}
|
|
18
18
|
function H(i, t, e, r) {
|
|
19
19
|
return Atomics.compareExchange(i, t, r, e) === r;
|
|
@@ -60,13 +60,13 @@ class h {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
const
|
|
63
|
+
const j = 0, D = 1;
|
|
64
64
|
function x(i, t = 0) {
|
|
65
|
-
for (; Atomics.compareExchange(i, t,
|
|
65
|
+
for (; Atomics.compareExchange(i, t, j, D) !== j; )
|
|
66
66
|
"WorkerGlobalScope" in self && Atomics.wait(i, t, D);
|
|
67
67
|
}
|
|
68
68
|
function A(i, t = 0) {
|
|
69
|
-
Atomics.compareExchange(i, t, D,
|
|
69
|
+
Atomics.compareExchange(i, t, D, j) !== D && console.warn("We are unlocking when it was not locked!"), Atomics.notify(i, t);
|
|
70
70
|
}
|
|
71
71
|
const ye = 1, Vt = {
|
|
72
72
|
5120: "i8",
|
|
@@ -103,7 +103,7 @@ function jt(i, ...t) {
|
|
|
103
103
|
const e = Zt[i];
|
|
104
104
|
return new (e || Wt[vt(i)])(...t);
|
|
105
105
|
}
|
|
106
|
-
const
|
|
106
|
+
const it = 0, st = 1, ot = 2, nt = 3, at = 4, k = 5, ft = 6, V = 1, K = 2, lt = 32, G = 0, X = 1, y = 8;
|
|
107
107
|
class Z {
|
|
108
108
|
buf;
|
|
109
109
|
start;
|
|
@@ -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 ? P(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,
|
|
115
|
+
if (this.buf = t.buf ? t.buf : new ArrayBuffer(t.size || 4096), this.start = t.start != null ? P(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, lt / 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`);
|
|
@@ -161,20 +161,20 @@ class Z {
|
|
|
161
161
|
return 0;
|
|
162
162
|
x(this.lock);
|
|
163
163
|
const e = P(t + y, this.align), r = this.end;
|
|
164
|
-
let s = this.top, o = this._free,
|
|
164
|
+
let s = this.top, o = this._free, n = 0;
|
|
165
165
|
for (; o; ) {
|
|
166
|
-
const f = this.blockSize(o),
|
|
167
|
-
if (
|
|
166
|
+
const f = this.blockSize(o), a = o + f >= s;
|
|
167
|
+
if (a || f >= e) {
|
|
168
168
|
let l = this.mallocTop(
|
|
169
169
|
o,
|
|
170
|
-
|
|
170
|
+
n,
|
|
171
171
|
f,
|
|
172
172
|
e,
|
|
173
|
-
|
|
173
|
+
a
|
|
174
174
|
);
|
|
175
175
|
return A(this.lock), l;
|
|
176
176
|
}
|
|
177
|
-
|
|
177
|
+
n = 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;
|
|
@@ -188,8 +188,8 @@ class Z {
|
|
|
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 n = r - s;
|
|
192
|
+
n >= this.minSplit && this.splitBlock(t, s, n);
|
|
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, n = 0;
|
|
201
201
|
for (; o; ) {
|
|
202
202
|
if (o === r) {
|
|
203
|
-
[s,
|
|
203
|
+
[s, n] = 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
|
+
n
|
|
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, n = P(e + y, this.align);
|
|
216
|
+
if (n <= r) {
|
|
217
217
|
if (this.doSplit) {
|
|
218
|
-
const f = r -
|
|
219
|
-
f >= this.minSplit ? this.splitBlock(t,
|
|
220
|
-
} else o && (this.top = t +
|
|
218
|
+
const f = r - n;
|
|
219
|
+
f >= this.minSplit ? this.splitBlock(t, n, f) : o && (this.top = t + n);
|
|
220
|
+
} else o && (this.top = t + n);
|
|
221
221
|
return [t, s];
|
|
222
222
|
}
|
|
223
|
-
return o && t +
|
|
223
|
+
return o && t + n < this.end ? (this.top = t + this.setBlockSize(t, n), [t, s]) : (this.free(t), [I(this.malloc(e)), s]);
|
|
224
224
|
}
|
|
225
225
|
reallocArray(t, e) {
|
|
226
226
|
if (t.buffer !== this.buf)
|
|
@@ -276,10 +276,10 @@ 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[at];
|
|
280
280
|
}
|
|
281
281
|
set align(t) {
|
|
282
|
-
this.state[
|
|
282
|
+
this.state[at] = t;
|
|
283
283
|
}
|
|
284
284
|
get end() {
|
|
285
285
|
return this.state[nt];
|
|
@@ -288,22 +288,22 @@ class Z {
|
|
|
288
288
|
this.state[nt] = t;
|
|
289
289
|
}
|
|
290
290
|
get top() {
|
|
291
|
-
return Atomics.load(this.state,
|
|
291
|
+
return Atomics.load(this.state, ot);
|
|
292
292
|
}
|
|
293
293
|
set top(t) {
|
|
294
|
-
Atomics.store(this.state,
|
|
294
|
+
Atomics.store(this.state, ot, t);
|
|
295
295
|
}
|
|
296
296
|
get _free() {
|
|
297
|
-
return Atomics.load(this.state,
|
|
297
|
+
return Atomics.load(this.state, it);
|
|
298
298
|
}
|
|
299
299
|
set _free(t) {
|
|
300
|
-
Atomics.store(this.state,
|
|
300
|
+
Atomics.store(this.state, it, t);
|
|
301
301
|
}
|
|
302
302
|
get _used() {
|
|
303
|
-
return Atomics.load(this.state,
|
|
303
|
+
return Atomics.load(this.state, st);
|
|
304
304
|
}
|
|
305
305
|
set _used(t) {
|
|
306
|
-
Atomics.store(this.state,
|
|
306
|
+
Atomics.store(this.state, st, t);
|
|
307
307
|
}
|
|
308
308
|
get doCompact() {
|
|
309
309
|
return !!(this.state[k] & V);
|
|
@@ -318,12 +318,12 @@ class Z {
|
|
|
318
318
|
t ? this.state[k] |= 1 << K - 1 : this.state[k] &= ~K;
|
|
319
319
|
}
|
|
320
320
|
get minSplit() {
|
|
321
|
-
return this.state[
|
|
321
|
+
return this.state[ft];
|
|
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[ft] = t;
|
|
327
327
|
}
|
|
328
328
|
blockSize(t) {
|
|
329
329
|
return Atomics.load(this.u32, (t >> 2) + G);
|
|
@@ -372,7 +372,7 @@ class Z {
|
|
|
372
372
|
), this.doCompact && this.compact();
|
|
373
373
|
}
|
|
374
374
|
initialTop(t = this.align) {
|
|
375
|
-
return P(this.start +
|
|
375
|
+
return P(this.start + lt + y, t) - y;
|
|
376
376
|
}
|
|
377
377
|
/**
|
|
378
378
|
* Traverses free list and attempts to recursively merge blocks
|
|
@@ -385,13 +385,13 @@ 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,
|
|
388
|
+
const n = s - t + this.blockSize(s);
|
|
389
|
+
this.setBlockSize(t, n);
|
|
390
390
|
const f = this.blockNext(s);
|
|
391
|
-
let
|
|
392
|
-
for (;
|
|
393
|
-
const l = this.blockNext(
|
|
394
|
-
this.setBlockNext(
|
|
391
|
+
let a = this.blockNext(t);
|
|
392
|
+
for (; a && a !== f; ) {
|
|
393
|
+
const l = this.blockNext(a);
|
|
394
|
+
this.setBlockNext(a, 0), a = l;
|
|
395
395
|
}
|
|
396
396
|
this.setBlockNext(t, f), o = !0;
|
|
397
397
|
}
|
|
@@ -463,7 +463,7 @@ const _ = (i) => i > 0 ? i + y : 0, I = (i) => i > 0 ? i - y : 0, P = (i, t) =>
|
|
|
463
463
|
"Eibit",
|
|
464
464
|
"Zibit",
|
|
465
465
|
"Yibit"
|
|
466
|
-
],
|
|
466
|
+
], ht = (i, t, e) => {
|
|
467
467
|
let r = i;
|
|
468
468
|
return typeof t == "string" || Array.isArray(t) ? r = i.toLocaleString(t, e) : (t === !0 || e !== void 0) && (r = i.toLocaleString(void 0, e)), r;
|
|
469
469
|
}, _t = (i) => {
|
|
@@ -476,7 +476,7 @@ const _ = (i) => i > 0 ? i + y : 0, I = (i) => i > 0 ? i - y : 0, P = (i, t) =>
|
|
|
476
476
|
return i / t;
|
|
477
477
|
const e = i / BigInt(t), r = i % BigInt(t);
|
|
478
478
|
return Number(e) + Number(r) / t;
|
|
479
|
-
},
|
|
479
|
+
}, ct = (i, t) => {
|
|
480
480
|
if (t === void 0)
|
|
481
481
|
return i;
|
|
482
482
|
if (typeof t != "number" || !Number.isSafeInteger(t) || t < 0)
|
|
@@ -504,34 +504,34 @@ function oe(i, t) {
|
|
|
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
506
|
const l = ` 0${r}${e[0]}`;
|
|
507
|
-
return
|
|
507
|
+
return ct(l, t.fixedWidth);
|
|
508
508
|
}
|
|
509
|
-
const o = i < 0,
|
|
509
|
+
const o = i < 0, n = o ? "-" : t.signed ? "+" : "";
|
|
510
510
|
o && (i = -i);
|
|
511
511
|
const f = se(t);
|
|
512
|
-
let
|
|
512
|
+
let a;
|
|
513
513
|
if (i < 1) {
|
|
514
|
-
const l =
|
|
515
|
-
|
|
514
|
+
const l = ht(i, t.locale, f);
|
|
515
|
+
a = n + l + r + e[0];
|
|
516
516
|
} else {
|
|
517
517
|
const l = Math.min(Math.floor(t.binary ? re(i) / Math.log(1024) : _t(i) / 3), e.length - 1);
|
|
518
518
|
if (i = ie(i, (t.binary ? 1024 : 1e3) ** l), !f) {
|
|
519
519
|
const M = Math.max(3, Math.floor(i).toString().length);
|
|
520
520
|
i = i.toPrecision(M);
|
|
521
521
|
}
|
|
522
|
-
const S =
|
|
523
|
-
|
|
522
|
+
const S = ht(Number(i), t.locale, f), Y = e[l];
|
|
523
|
+
a = n + S + r + Y;
|
|
524
524
|
}
|
|
525
|
-
return
|
|
525
|
+
return ct(a, t.fixedWidth);
|
|
526
526
|
}
|
|
527
|
-
const
|
|
527
|
+
const ne = 8192, ut = 0, W = 1, N = 2;
|
|
528
528
|
class de {
|
|
529
529
|
buffers;
|
|
530
530
|
onGrowBufferHandlers = [];
|
|
531
531
|
isClone;
|
|
532
532
|
memory;
|
|
533
533
|
get bufferSize() {
|
|
534
|
-
return this.memory.data[
|
|
534
|
+
return this.memory.data[ut];
|
|
535
535
|
}
|
|
536
536
|
constructor(t) {
|
|
537
537
|
if (t && "buffers" in t)
|
|
@@ -544,9 +544,9 @@ 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 ??
|
|
548
|
-
if (e >
|
|
549
|
-
throw new Error(`Buffer size ${e} is greater than max ${
|
|
547
|
+
const e = t?.bufferSize ?? ne;
|
|
548
|
+
if (e > et)
|
|
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);
|
|
551
551
|
this.buffers = [
|
|
552
552
|
r
|
|
@@ -559,7 +559,7 @@ class de {
|
|
|
559
559
|
});
|
|
560
560
|
else
|
|
561
561
|
throw new Error("Failed to initialize first byte from buffer");
|
|
562
|
-
this.memory.data[
|
|
562
|
+
this.memory.data[ut] = e, this.memory.data[W] = 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
|
}
|
|
@@ -599,15 +599,15 @@ class de {
|
|
|
599
599
|
const o = this.buffers[s];
|
|
600
600
|
if (!o)
|
|
601
601
|
continue;
|
|
602
|
-
const
|
|
603
|
-
if (
|
|
602
|
+
const n = o.callocAs("u32", t);
|
|
603
|
+
if (n)
|
|
604
604
|
return s === this.buffers.length - 1 && Atomics.load(this.memory.data, W) === 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:
|
|
605
|
+
data: n,
|
|
606
606
|
buffer: o
|
|
607
607
|
});
|
|
608
608
|
}
|
|
609
|
-
if (this.buffers.length >=
|
|
610
|
-
throw new Error(`Can't initialize a new buffer since it would have a position greater than the max of ${
|
|
609
|
+
if (this.buffers.length >= rt)
|
|
610
|
+
throw new Error(`Can't initialize a new buffer since it would have a position greater than the max of ${rt}`);
|
|
611
611
|
let e = this.growBuffer();
|
|
612
612
|
const r = e.callocAs("u32", t);
|
|
613
613
|
if (r)
|
|
@@ -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 `${yt(this.currentUsed)} / ${yt(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 yt(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 dt = 4, Bt = 1, E = 2;
|
|
647
647
|
class u {
|
|
648
|
-
static ALLOCATE_COUNT =
|
|
648
|
+
static ALLOCATE_COUNT = dt;
|
|
649
649
|
memory;
|
|
650
650
|
/* First block
|
|
651
651
|
32 index 0
|
|
@@ -688,7 +688,7 @@ class u {
|
|
|
688
688
|
if (this.memory = t, e && "firstBlock" in e)
|
|
689
689
|
this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + (E + 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(dt), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + (E + 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
|
}
|
|
@@ -698,17 +698,17 @@ class u {
|
|
|
698
698
|
let e = this.dataLength;
|
|
699
699
|
if (t.length > e)
|
|
700
700
|
throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
|
|
701
|
-
let r = this.memory.allocUI32(
|
|
702
|
-
for (let
|
|
703
|
-
s instanceof Int32Array || s instanceof Uint32Array ? Atomics.store(s,
|
|
704
|
-
let
|
|
701
|
+
let r = this.memory.allocUI32(Bt + e), s = this.getDataBlock(r.data), o = r.pointer;
|
|
702
|
+
for (let a = 0; a < t.length; a++)
|
|
703
|
+
s instanceof Int32Array || s instanceof Uint32Array ? Atomics.store(s, a, t[a]) : s[a] = t[a];
|
|
704
|
+
let n, f = !1;
|
|
705
705
|
for (; !f; )
|
|
706
|
-
|
|
707
|
-
if (
|
|
708
|
-
let { bufferPosition:
|
|
709
|
-
|
|
706
|
+
n = O(this.firstBlock.data, 1), f = H(this.firstBlock.data, 1, o, n);
|
|
707
|
+
if (n) {
|
|
708
|
+
let { bufferPosition: a, bufferByteOffset: l } = g(n), S = new Uint32Array(this.memory.buffers[a].buf, l, 1);
|
|
709
|
+
v(S, 0, o);
|
|
710
710
|
} else
|
|
711
|
-
|
|
711
|
+
v(this.firstBlock.data, 0, o);
|
|
712
712
|
Atomics.add(this.firstBlock.data, E, 1);
|
|
713
713
|
}
|
|
714
714
|
deleteMatch(t) {
|
|
@@ -742,30 +742,30 @@ class u {
|
|
|
742
742
|
H(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: n, bufferByteOffset: f } = g(o), a = this.memory.buffers[n];
|
|
746
|
+
if (!a)
|
|
747
747
|
break;
|
|
748
|
-
let l = new Uint32Array(
|
|
749
|
-
o = O(l, 0), s++, this.onDelete && this.onDelete(this.getDataBlock(l)),
|
|
748
|
+
let l = new Uint32Array(a.buf, f, 2);
|
|
749
|
+
o = O(l, 0), s++, this.onDelete && this.onDelete(this.getDataBlock(l)), a.free(l.byteOffset);
|
|
750
750
|
}
|
|
751
751
|
Atomics.sub(this.firstBlock.data, E, 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, n = 0;
|
|
755
755
|
for (; r; ) {
|
|
756
756
|
let f = this.memory.buffers[e];
|
|
757
757
|
if (!f)
|
|
758
758
|
return;
|
|
759
|
-
let
|
|
760
|
-
({ bufferPosition: e, bufferByteOffset: r } = c(
|
|
759
|
+
let a = new Uint32Array(f.buf, r, 2), l = this.getDataBlock(a), S = e, Y = r;
|
|
760
|
+
({ bufferPosition: e, bufferByteOffset: r } = c(a, 0));
|
|
761
761
|
let M = !0;
|
|
762
762
|
yield {
|
|
763
763
|
data: l,
|
|
764
764
|
index: t,
|
|
765
765
|
deleteCurrent: () => {
|
|
766
|
-
m(s, 0, e, r), r || m(this.firstBlock.data, 1, o,
|
|
766
|
+
m(s, 0, e, r), r || m(this.firstBlock.data, 1, o, n), this.onDelete && this.onDelete(this.getDataBlock(a)), f.free(a.byteOffset), Atomics.sub(this.firstBlock.data, E, 1), M = !1;
|
|
767
767
|
}
|
|
768
|
-
}, M && (s =
|
|
768
|
+
}, M && (s = a, o = S, n = Y, t++);
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
771
|
forEach(t) {
|
|
@@ -778,7 +778,7 @@ class u {
|
|
|
778
778
|
};
|
|
779
779
|
}
|
|
780
780
|
getDataBlock(t) {
|
|
781
|
-
const e = t.byteOffset +
|
|
781
|
+
const e = t.byteOffset + Bt * t.BYTES_PER_ELEMENT;
|
|
782
782
|
switch (this.type) {
|
|
783
783
|
case 1:
|
|
784
784
|
return new Int32Array(t.buffer, e, this.dataLength);
|
|
@@ -802,7 +802,7 @@ class u {
|
|
|
802
802
|
this.firstBlock.free();
|
|
803
803
|
}
|
|
804
804
|
}
|
|
805
|
-
const
|
|
805
|
+
const mt = 10;
|
|
806
806
|
class Ot {
|
|
807
807
|
static ALLOCATE_COUNT = 4;
|
|
808
808
|
memory;
|
|
@@ -823,8 +823,8 @@ class Ot {
|
|
|
823
823
|
this.pointerMemory = new h(t, e.firstBlock);
|
|
824
824
|
else {
|
|
825
825
|
this.pointerMemory = t.allocUI32(Ot.ALLOCATE_COUNT);
|
|
826
|
-
let r = t.allocUI32(
|
|
827
|
-
m(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3,
|
|
826
|
+
let r = t.allocUI32(mt);
|
|
827
|
+
m(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
|
}
|
|
@@ -834,19 +834,19 @@ class Ot {
|
|
|
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),
|
|
837
|
+
let o = this.hash(r, e), n, f = c(t.data, o);
|
|
838
838
|
if (f.bufferByteOffset === 0) {
|
|
839
|
-
|
|
839
|
+
n = new u(this.memory, {
|
|
840
840
|
dataLength: 2
|
|
841
841
|
});
|
|
842
|
-
let l =
|
|
842
|
+
let l = n.getSharedMemory();
|
|
843
843
|
m(t.data, o, l.firstBlock.bufferPosition, l.firstBlock.bufferByteOffset);
|
|
844
844
|
} else
|
|
845
|
-
|
|
845
|
+
n = new u(this.memory, {
|
|
846
846
|
firstBlock: f
|
|
847
847
|
});
|
|
848
|
-
let
|
|
849
|
-
return
|
|
848
|
+
let a = !0;
|
|
849
|
+
return n.deleteValue(r) && (a = !1), n.insert([r, s]), a;
|
|
850
850
|
}
|
|
851
851
|
get(t) {
|
|
852
852
|
let e = C(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
|
|
@@ -855,9 +855,9 @@ class Ot {
|
|
|
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: n } of o)
|
|
859
|
+
if (n[0] === e)
|
|
860
|
+
return n[1];
|
|
861
861
|
}
|
|
862
862
|
has(t) {
|
|
863
863
|
let e = C(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
|
|
@@ -866,8 +866,8 @@ class Ot {
|
|
|
866
866
|
let o = new u(this.memory, {
|
|
867
867
|
firstBlock: s
|
|
868
868
|
});
|
|
869
|
-
for (let { data:
|
|
870
|
-
if (
|
|
869
|
+
for (let { data: n } of o)
|
|
870
|
+
if (n[0] === e)
|
|
871
871
|
return !0;
|
|
872
872
|
return !1;
|
|
873
873
|
}
|
|
@@ -878,22 +878,22 @@ class Ot {
|
|
|
878
878
|
let o = new u(this.memory, {
|
|
879
879
|
firstBlock: s
|
|
880
880
|
});
|
|
881
|
-
for (let { data:
|
|
882
|
-
if (
|
|
881
|
+
for (let { data: n, deleteCurrent: f } of o)
|
|
882
|
+
if (n[0] === e)
|
|
883
883
|
return f(), 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 n = c(s.data, o);
|
|
890
|
+
if (n.bufferByteOffset === 0)
|
|
891
891
|
continue;
|
|
892
892
|
let f = new u(this.memory, {
|
|
893
|
-
firstBlock:
|
|
893
|
+
firstBlock: n
|
|
894
894
|
});
|
|
895
|
-
for (let { data:
|
|
896
|
-
this.setHashKey(r, e,
|
|
895
|
+
for (let { data: a } of f)
|
|
896
|
+
this.setHashKey(r, e, a[0], a[1]);
|
|
897
897
|
}
|
|
898
898
|
m(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, e);
|
|
899
899
|
}
|
|
@@ -918,9 +918,9 @@ class Ot {
|
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
920
|
function C(i) {
|
|
921
|
-
return typeof i == "number" ? i : typeof i == "string" ?
|
|
921
|
+
return typeof i == "number" ? i : typeof i == "string" ? ae(i) : i;
|
|
922
922
|
}
|
|
923
|
-
function
|
|
923
|
+
function ae(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;
|
|
@@ -977,10 +977,10 @@ class Be {
|
|
|
977
977
|
this.list.free();
|
|
978
978
|
}
|
|
979
979
|
}
|
|
980
|
-
const
|
|
980
|
+
const bt = {
|
|
981
981
|
1: Uint8Array,
|
|
982
982
|
2: Uint16Array
|
|
983
|
-
}, U = 0,
|
|
983
|
+
}, U = 0, At = 1, gt = 2, kt = 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 + kt * 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 + kt * 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
|
-
x(this.lock),
|
|
996
|
+
x(this.lock), v(this.allocatedMemory.data, U, e.pointer), Atomics.store(this.allocatedMemory.data, At, t.length), Atomics.store(this.allocatedMemory.data, gt, e.charType), A(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 =
|
|
1009
|
-
for (let
|
|
1010
|
-
f[
|
|
1006
|
+
for (let a = 0; a < t.length; a++)
|
|
1007
|
+
e.push(t.charCodeAt(a));
|
|
1008
|
+
let s = Math.max(...e) > 255 ? 2 : 1, o = bt[s], n = this.memory.allocUI32(Math.ceil(t.length / (4 / o.BYTES_PER_ELEMENT))), f = new o(n.data.buffer, n.data.byteOffset, t.length);
|
|
1009
|
+
for (let a = 0; a < t.length; a++)
|
|
1010
|
+
f[a] = t.charCodeAt(a);
|
|
1011
1011
|
return {
|
|
1012
|
-
pointer:
|
|
1012
|
+
pointer: n.pointer,
|
|
1013
1013
|
charType: s
|
|
1014
1014
|
};
|
|
1015
1015
|
}
|
|
@@ -1021,8 +1021,8 @@ class Mt {
|
|
|
1021
1021
|
return "";
|
|
1022
1022
|
let { bufferPosition: e, bufferByteOffset: r } = g(t);
|
|
1023
1023
|
x(this.lock);
|
|
1024
|
-
let s = Atomics.load(this.allocatedMemory.data,
|
|
1025
|
-
return A(this.lock), this.cachedPointer = t, this.cachedString =
|
|
1024
|
+
let s = Atomics.load(this.allocatedMemory.data, gt), o = bt[s], n = Atomics.load(this.allocatedMemory.data, At), f = new o(this.memory.buffers[e].buf, r, n), a = String.fromCharCode.apply(null, f);
|
|
1025
|
+
return A(this.lock), this.cachedPointer = t, this.cachedString = a, a;
|
|
1026
1026
|
}
|
|
1027
1027
|
set value(t) {
|
|
1028
1028
|
let { bufferPosition: e, bufferByteOffset: r } = c(this.allocatedMemory.data, U);
|
|
@@ -1039,7 +1039,7 @@ class Mt {
|
|
|
1039
1039
|
e && this.memory.buffers[t].free(e), this.allocatedMemory.free();
|
|
1040
1040
|
}
|
|
1041
1041
|
}
|
|
1042
|
-
const w = 0, b = 1,
|
|
1042
|
+
const w = 0, b = 1, Et = 2, wt = 3, pt = 4;
|
|
1043
1043
|
class d {
|
|
1044
1044
|
static ALLOCATE_COUNT = 4;
|
|
1045
1045
|
memory;
|
|
@@ -1062,10 +1062,10 @@ class d {
|
|
|
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, Et);
|
|
1066
1066
|
}
|
|
1067
1067
|
set bufferLength(t) {
|
|
1068
|
-
Atomics.store(this.firstBlock.data,
|
|
1068
|
+
Atomics.store(this.firstBlock.data, Et, t);
|
|
1069
1069
|
}
|
|
1070
1070
|
get pointer() {
|
|
1071
1071
|
return this.firstBlock.pointer;
|
|
@@ -1074,20 +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
|
-
|
|
1079
|
-
|
|
1077
|
+
if (this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + wt * Uint32Array.BYTES_PER_ELEMENT, 2), "type" in e || "dataLength" in e) {
|
|
1078
|
+
const r = e.bufferLength ?? pt;
|
|
1079
|
+
let s = t.allocUI32(r * (e.dataLength ?? 1));
|
|
1080
|
+
m(this.firstBlock.data, w, s.bufferPosition, s.bufferByteOffset), this.bufferLength = r, this.dataLength = e.dataLength ?? 1;
|
|
1080
1081
|
}
|
|
1081
1082
|
if ("type" in e) {
|
|
1082
1083
|
const r = e?.type ?? Uint32Array;
|
|
1083
1084
|
r === Uint32Array ? this.type = 0 : r === Int32Array ? this.type = 1 : r === Float32Array && (this.type = 2);
|
|
1084
1085
|
}
|
|
1085
1086
|
} else {
|
|
1086
|
-
this.firstBlock = t.allocUI32(d.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset +
|
|
1087
|
-
let r = e?.dataLength ?? 1, s = e?.bufferLength ??
|
|
1087
|
+
this.firstBlock = t.allocUI32(d.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + wt * Uint32Array.BYTES_PER_ELEMENT, 2);
|
|
1088
|
+
let r = e?.dataLength ?? 1, s = e?.bufferLength ?? pt, o = t.allocUI32(s * r);
|
|
1088
1089
|
m(this.firstBlock.data, w, o.bufferPosition, o.bufferByteOffset), this.bufferLength = s;
|
|
1089
|
-
const
|
|
1090
|
-
|
|
1090
|
+
const n = e?.type ?? Uint32Array;
|
|
1091
|
+
n === Uint32Array ? this.type = 0 : n === Int32Array ? this.type = 1 : n === Float32Array && (this.type = 2), this.dataLength = r;
|
|
1091
1092
|
}
|
|
1092
1093
|
this.cachedPointer = this.firstBlock.data[0], this.cachedFullDataBlock = this.getFullDataBlock();
|
|
1093
1094
|
}
|
|
@@ -1123,8 +1124,8 @@ class d {
|
|
|
1123
1124
|
throw new Error(`${t} is out of bounds ${e}`);
|
|
1124
1125
|
let r = this.dataLength, s = this.getFullDataBlock();
|
|
1125
1126
|
for (let o = t; o < e; o++)
|
|
1126
|
-
for (let
|
|
1127
|
-
s[o * r +
|
|
1127
|
+
for (let n = 0; n < r; n++)
|
|
1128
|
+
s[o * r + n] = s[(o + 1) * r + n];
|
|
1128
1129
|
Atomics.sub(this.firstBlock.data, b, b);
|
|
1129
1130
|
}
|
|
1130
1131
|
clear() {
|
|
@@ -1160,21 +1161,21 @@ class d {
|
|
|
1160
1161
|
return t.subarray(r, r + this.dataLength);
|
|
1161
1162
|
}
|
|
1162
1163
|
growBuffer() {
|
|
1163
|
-
let e = this.bufferLength * 2, r = this.dataLength, s = c(this.firstBlock.data, w), o = new h(this.memory, s),
|
|
1164
|
+
let e = this.bufferLength * 2, r = this.dataLength, s = c(this.firstBlock.data, w), o = new h(this.memory, s), n = this.getFullDataBlock(), f = this.memory.allocUI32(e * r), a;
|
|
1164
1165
|
switch (this.type) {
|
|
1165
1166
|
case 1:
|
|
1166
|
-
|
|
1167
|
+
a = new Int32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
|
|
1167
1168
|
break;
|
|
1168
1169
|
case 0:
|
|
1169
|
-
|
|
1170
|
+
a = new Uint32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
|
|
1170
1171
|
break;
|
|
1171
1172
|
case 2:
|
|
1172
|
-
|
|
1173
|
+
a = new Float32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
|
|
1173
1174
|
break;
|
|
1174
1175
|
default:
|
|
1175
1176
|
throw new Error(`Unknown data block type ${this.type}`);
|
|
1176
1177
|
}
|
|
1177
|
-
|
|
1178
|
+
a.set(n), m(this.firstBlock.data, w, f.bufferPosition, f.bufferByteOffset), this.bufferLength = e, o.free();
|
|
1178
1179
|
}
|
|
1179
1180
|
free() {
|
|
1180
1181
|
let t = c(this.firstBlock.data, w);
|
|
@@ -1257,7 +1258,7 @@ class me {
|
|
|
1257
1258
|
this.list.free(), this.cache.clear();
|
|
1258
1259
|
}
|
|
1259
1260
|
}
|
|
1260
|
-
const F = 0, Tt = 1, Lt = 2,
|
|
1261
|
+
const F = 0, Tt = 1, Lt = 2, q = 3, St = q + d.ALLOCATE_COUNT;
|
|
1261
1262
|
class It {
|
|
1262
1263
|
static ALLOCATE_COUNT = 3 + d.ALLOCATE_COUNT * 2;
|
|
1263
1264
|
memory;
|
|
@@ -1291,6 +1292,9 @@ class It {
|
|
|
1291
1292
|
get bufferLength() {
|
|
1292
1293
|
return this.maxChunkSize * this.pointerVector.length;
|
|
1293
1294
|
}
|
|
1295
|
+
get recycleBufferLength() {
|
|
1296
|
+
return this.recycleVector.bufferLength;
|
|
1297
|
+
}
|
|
1294
1298
|
get byteMultipler() {
|
|
1295
1299
|
return this.type === 3 ? 2 : 1;
|
|
1296
1300
|
}
|
|
@@ -1299,7 +1303,7 @@ class It {
|
|
|
1299
1303
|
this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Tt * Uint32Array.BYTES_PER_ELEMENT, 2), this.pointerVector = new d(t, {
|
|
1300
1304
|
firstBlock: {
|
|
1301
1305
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1302
|
-
bufferByteOffset: this.firstBlock.bufferByteOffset +
|
|
1306
|
+
bufferByteOffset: this.firstBlock.bufferByteOffset + q * Uint32Array.BYTES_PER_ELEMENT
|
|
1303
1307
|
}
|
|
1304
1308
|
}), this.recycleVector = new d(t, {
|
|
1305
1309
|
firstBlock: {
|
|
@@ -1314,7 +1318,7 @@ class It {
|
|
|
1314
1318
|
type: Uint32Array,
|
|
1315
1319
|
firstBlock: {
|
|
1316
1320
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1317
|
-
bufferByteOffset: this.firstBlock.bufferByteOffset +
|
|
1321
|
+
bufferByteOffset: this.firstBlock.bufferByteOffset + q * Uint32Array.BYTES_PER_ELEMENT
|
|
1318
1322
|
}
|
|
1319
1323
|
}), this.recycleVector = new d(t, {
|
|
1320
1324
|
type: Uint32Array,
|
|
@@ -1326,8 +1330,8 @@ class It {
|
|
|
1326
1330
|
});
|
|
1327
1331
|
const o = e?.type ?? Uint32Array;
|
|
1328
1332
|
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;
|
|
1329
|
-
let
|
|
1330
|
-
this.pointerVector.push(
|
|
1333
|
+
let n = t.allocUI32(s * r * this.byteMultipler);
|
|
1334
|
+
this.pointerVector.push(n.pointer);
|
|
1331
1335
|
}
|
|
1332
1336
|
}
|
|
1333
1337
|
at(t) {
|
|
@@ -1372,8 +1376,8 @@ class It {
|
|
|
1372
1376
|
if (r)
|
|
1373
1377
|
return r;
|
|
1374
1378
|
if (e >= this.pointerVector.length) {
|
|
1375
|
-
let
|
|
1376
|
-
this.pointerVector.push(
|
|
1379
|
+
let n = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
|
|
1380
|
+
this.pointerVector.push(n.pointer);
|
|
1377
1381
|
}
|
|
1378
1382
|
let s = new h(this.memory, g(this.pointerVector.get(e))), o;
|
|
1379
1383
|
switch (this.type) {
|
|
@@ -1434,22 +1438,22 @@ function ke(i, t, e, r, s, o = 0) {
|
|
|
1434
1438
|
}
|
|
1435
1439
|
const Ft = new ArrayBuffer(4), Dt = new Float32Array(Ft), xt = new Int32Array(Ft);
|
|
1436
1440
|
function Rt(i, t) {
|
|
1437
|
-
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)),
|
|
1441
|
+
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.load(i, t));
|
|
1438
1442
|
}
|
|
1439
1443
|
function Ee(i, t, e) {
|
|
1440
1444
|
i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Atomics.store(i, t, $(e));
|
|
1441
1445
|
}
|
|
1442
|
-
function
|
|
1446
|
+
function Q(i) {
|
|
1443
1447
|
return xt[0] = i, Dt[0];
|
|
1444
1448
|
}
|
|
1445
1449
|
function $(i) {
|
|
1446
1450
|
return Dt[0] = i, xt[0];
|
|
1447
1451
|
}
|
|
1448
1452
|
function we(i, t, e) {
|
|
1449
|
-
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)),
|
|
1453
|
+
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.exchange(i, t, $(e)));
|
|
1450
1454
|
}
|
|
1451
1455
|
function $t(i, t, e, r) {
|
|
1452
|
-
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)),
|
|
1456
|
+
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.compareExchange(i, t, $(e), $(r)));
|
|
1453
1457
|
}
|
|
1454
1458
|
function pe(i, t, e, r) {
|
|
1455
1459
|
let s, o;
|
|
@@ -1477,26 +1481,26 @@ function Se(i, t, e, r) {
|
|
|
1477
1481
|
}
|
|
1478
1482
|
const zt = new ArrayBuffer(8), Yt = new Float64Array(zt), Ht = new BigInt64Array(zt);
|
|
1479
1483
|
function _e(i, t) {
|
|
1480
|
-
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)),
|
|
1484
|
+
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.load(i, t));
|
|
1481
1485
|
}
|
|
1482
1486
|
function Oe(i, t, e) {
|
|
1483
1487
|
i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), Atomics.store(i, t, z(e));
|
|
1484
1488
|
}
|
|
1485
|
-
function
|
|
1489
|
+
function tt(i) {
|
|
1486
1490
|
return Ht[0] = i, Yt[0];
|
|
1487
1491
|
}
|
|
1488
1492
|
function z(i) {
|
|
1489
1493
|
return Yt[0] = i, Ht[0];
|
|
1490
1494
|
}
|
|
1491
1495
|
function Me(i, t, e) {
|
|
1492
|
-
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)),
|
|
1496
|
+
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.exchange(i, t, z(e)));
|
|
1493
1497
|
}
|
|
1494
1498
|
function Ie(i, t, e, r) {
|
|
1495
|
-
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)),
|
|
1499
|
+
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.compareExchange(i, t, z(e), z(r)));
|
|
1496
1500
|
}
|
|
1497
|
-
const p = 0,
|
|
1501
|
+
const p = 0, J = 1, L = 2;
|
|
1498
1502
|
function Pe(i, t = 0) {
|
|
1499
|
-
for (; Atomics.compareExchange(i, t, p,
|
|
1503
|
+
for (; Atomics.compareExchange(i, t, p, J) === L; )
|
|
1500
1504
|
Atomics.wait(i, t, L);
|
|
1501
1505
|
Atomics.add(i, t + 1, 1);
|
|
1502
1506
|
}
|
|
@@ -1506,7 +1510,7 @@ function Ne(i, t = 0) {
|
|
|
1506
1510
|
Atomics.wait(i, t, e), e = Atomics.compareExchange(i, t, p, L);
|
|
1507
1511
|
}
|
|
1508
1512
|
function Ce(i, t = 0) {
|
|
1509
|
-
Atomics.sub(i, t + 1, 1) - 1 <= 0 && (Atomics.compareExchange(i, t,
|
|
1513
|
+
Atomics.sub(i, t + 1, 1) - 1 <= 0 && (Atomics.compareExchange(i, t, J, p) !== J && console.warn("We are unlocking when it was not read locked!"), Atomics.notify(i, t));
|
|
1510
1514
|
}
|
|
1511
1515
|
function Ue(i, t = 0) {
|
|
1512
1516
|
Atomics.compareExchange(i, t, L, p) !== L && console.warn("We are unlocking when it was not write locked!"), Atomics.notify(i, t);
|
|
@@ -1516,8 +1520,8 @@ export {
|
|
|
1516
1520
|
h as AllocatedMemory,
|
|
1517
1521
|
he as BYTE_OFFSET_BIT_COUNT,
|
|
1518
1522
|
me as CachedItemList,
|
|
1519
|
-
|
|
1520
|
-
|
|
1523
|
+
et as MAX_BYTE_OFFSET_LENGTH,
|
|
1524
|
+
rt as MAX_POSITION_LENGTH,
|
|
1521
1525
|
Z as MemoryBuffer,
|
|
1522
1526
|
de as MemoryHeap,
|
|
1523
1527
|
ce as POSITION_BIT_COUNT,
|
|
@@ -1537,8 +1541,8 @@ export {
|
|
|
1537
1541
|
fe as convert32To16,
|
|
1538
1542
|
$ as convertFloat32ToInt32,
|
|
1539
1543
|
z as convertFloat64ToInt64,
|
|
1540
|
-
|
|
1541
|
-
|
|
1544
|
+
Q as convertInt32ToFloat32,
|
|
1545
|
+
tt as convertInt64ToFloat64,
|
|
1542
1546
|
T as createPointer,
|
|
1543
1547
|
we as exchangeFloat32,
|
|
1544
1548
|
Me as exchangeFloat64,
|
|
@@ -1559,7 +1563,7 @@ export {
|
|
|
1559
1563
|
Ee as storeFloat32,
|
|
1560
1564
|
Oe as storeFloat64,
|
|
1561
1565
|
m as storePointer,
|
|
1562
|
-
|
|
1566
|
+
v as storeRawPointer,
|
|
1563
1567
|
Se as subtractAtomicFloat,
|
|
1564
1568
|
Te as subtractAtomicInt,
|
|
1565
1569
|
A as unlock,
|