@daneren2005/shared-memory-objects 0.0.17 → 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 +381 -280
- 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-pool.d.ts +1 -0
- package/dist/src/shared-vector.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,30 +1,30 @@
|
|
|
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
|
-
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 a =
|
|
16
|
-
return Atomics.compareExchange(i, t, a,
|
|
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
|
|
64
|
-
function
|
|
65
|
-
for (; Atomics.compareExchange(i, t,
|
|
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
|
|
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,29 +159,29 @@ class Z {
|
|
|
159
159
|
malloc(t) {
|
|
160
160
|
if (t <= 0)
|
|
161
161
|
return 0;
|
|
162
|
-
|
|
163
|
-
const e =
|
|
162
|
+
z(this.lock);
|
|
163
|
+
const e = C(t + y, this.align), r = this.end;
|
|
164
164
|
let s = this.top, o = this._free, a = 0;
|
|
165
165
|
for (; o; ) {
|
|
166
|
-
const
|
|
167
|
-
if (n ||
|
|
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
170
|
a,
|
|
171
|
-
|
|
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;
|
|
@@ -212,11 +212,11 @@ class Z {
|
|
|
212
212
|
), _(s);
|
|
213
213
|
}
|
|
214
214
|
reallocBlock(t, e) {
|
|
215
|
-
const r = this.blockSize(t), s = t + r, o = s >= this.top, a =
|
|
215
|
+
const r = this.blockSize(t), s = t + r, o = s >= this.top, a = C(e + y, this.align);
|
|
216
216
|
if (a <= r) {
|
|
217
217
|
if (this.doSplit) {
|
|
218
|
-
const
|
|
219
|
-
|
|
218
|
+
const l = r - a;
|
|
219
|
+
l >= this.minSplit ? this.splitBlock(t, a, l) : o && (this.top = t + a);
|
|
220
220
|
} else o && (this.top = t + a);
|
|
221
221
|
return [t, s];
|
|
222
222
|
}
|
|
@@ -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,46 +276,46 @@ 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
|
-
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
|
-
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
321
|
return this.state[lt];
|
|
@@ -326,7 +326,7 @@ class Z {
|
|
|
326
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
|
|
@@ -387,13 +387,13 @@ class Z {
|
|
|
387
387
|
if (s !== t) {
|
|
388
388
|
const a = s - t + this.blockSize(s);
|
|
389
389
|
this.setBlockSize(t, a);
|
|
390
|
-
const
|
|
390
|
+
const l = this.blockNext(s);
|
|
391
391
|
let n = this.blockNext(t);
|
|
392
|
-
for (; n && n !==
|
|
393
|
-
const
|
|
394
|
-
this.setBlockNext(n, 0), n =
|
|
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,
|
|
@@ -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)
|
|
@@ -503,39 +503,39 @@ 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
|
|
506
|
+
const f = ` 0${r}${e[0]}`;
|
|
507
|
+
return ct(f, t.fixedWidth);
|
|
508
508
|
}
|
|
509
509
|
const o = i < 0, a = o ? "-" : t.signed ? "+" : "";
|
|
510
510
|
o && (i = -i);
|
|
511
|
-
const
|
|
511
|
+
const l = se(t);
|
|
512
512
|
let n;
|
|
513
513
|
if (i < 1) {
|
|
514
|
-
const
|
|
515
|
-
n = a +
|
|
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
|
-
n = a +
|
|
522
|
+
const T = ht(Number(i), t.locale, l), H = e[f];
|
|
523
|
+
n = a + T + r + H;
|
|
524
524
|
}
|
|
525
|
-
return
|
|
525
|
+
return ct(n, t.fixedWidth);
|
|
526
526
|
}
|
|
527
|
-
const ae = 8192,
|
|
528
|
-
class
|
|
527
|
+
const ae = 8192, ut = 0, v = 1, N = 2;
|
|
528
|
+
class ye {
|
|
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)
|
|
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, {
|
|
@@ -545,8 +545,8 @@ class de {
|
|
|
545
545
|
else {
|
|
546
546
|
"SharedArrayBuffer" in globalThis || console.warn("SharedArrayBuffer is not working: falling back to ArrayBuffer");
|
|
547
547
|
const e = t?.bufferSize ?? ae;
|
|
548
|
-
if (e >
|
|
549
|
-
throw new Error(`Buffer size ${e} is greater than max ${
|
|
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,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[
|
|
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
|
|
@@ -601,13 +601,13 @@ class de {
|
|
|
601
601
|
continue;
|
|
602
602
|
const a = o.callocAs("u32", t);
|
|
603
603
|
if (a)
|
|
604
|
-
return s === this.buffers.length - 1 && Atomics.load(this.memory.data,
|
|
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
605
|
data: a,
|
|
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)
|
|
@@ -643,9 +643,9 @@ function dt(i) {
|
|
|
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
|
}
|
|
@@ -698,18 +698,18 @@ 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(
|
|
701
|
+
let r = this.memory.allocUI32(Bt + e), s = this.getDataBlock(r.data), o = r.pointer;
|
|
702
702
|
for (let n = 0; n < t.length; n++)
|
|
703
703
|
s instanceof Int32Array || s instanceof Uint32Array ? Atomics.store(s, n, t[n]) : s[n] = t[n];
|
|
704
|
-
let a,
|
|
705
|
-
for (; !
|
|
706
|
-
a = O(this.firstBlock.data, 1),
|
|
704
|
+
let a, l = !1;
|
|
705
|
+
for (; !l; )
|
|
706
|
+
a = O(this.firstBlock.data, 1), l = V(this.firstBlock.data, 1, o, a);
|
|
707
707
|
if (a) {
|
|
708
|
-
let { bufferPosition: n, bufferByteOffset:
|
|
709
|
-
|
|
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: a, bufferByteOffset:
|
|
745
|
+
let { bufferPosition: a, bufferByteOffset: l } = B(o), n = this.memory.buffers[a];
|
|
746
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
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 n = new Uint32Array(
|
|
759
|
+
let n = new Uint32Array(l.buf, r, 2), f = this.getDataBlock(n), T = e, H = r;
|
|
760
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 = n, o =
|
|
768
|
+
}, M && (s = n, o = T, a = H, 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,33 +823,33 @@ 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
|
-
|
|
826
|
+
let r = t.allocUI32(mt);
|
|
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), a,
|
|
838
|
-
if (
|
|
837
|
+
let o = this.hash(r, e), a, l = c(t.data, o);
|
|
838
|
+
if (l.bufferByteOffset === 0) {
|
|
839
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
845
|
a = new u(this.memory, {
|
|
846
|
-
firstBlock:
|
|
846
|
+
firstBlock: l
|
|
847
847
|
});
|
|
848
848
|
let n = !0;
|
|
849
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, {
|
|
@@ -860,7 +860,7 @@ class Ot {
|
|
|
860
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, {
|
|
@@ -872,15 +872,15 @@ class Ot {
|
|
|
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: a, deleteCurrent:
|
|
881
|
+
for (let { data: a, deleteCurrent: l } of o)
|
|
882
882
|
if (a[0] === e)
|
|
883
|
-
return
|
|
883
|
+
return l(), Atomics.sub(this.pointerMemory.data, 2, 1), !0;
|
|
884
884
|
return !1;
|
|
885
885
|
}
|
|
886
886
|
growHashTable() {
|
|
@@ -889,13 +889,13 @@ class Ot {
|
|
|
889
889
|
let a = c(s.data, o);
|
|
890
890
|
if (a.bufferByteOffset === 0)
|
|
891
891
|
continue;
|
|
892
|
-
let
|
|
892
|
+
let l = new u(this.memory, {
|
|
893
893
|
firstBlock: a
|
|
894
894
|
});
|
|
895
|
-
for (let { data: n } of
|
|
895
|
+
for (let { data: n } of l)
|
|
896
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,7 +917,7 @@ class Ot {
|
|
|
917
917
|
};
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
|
-
function
|
|
920
|
+
function P(i) {
|
|
921
921
|
return typeof i == "number" ? i : typeof i == "string" ? ne(i) : i;
|
|
922
922
|
}
|
|
923
923
|
function ne(i) {
|
|
@@ -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]();
|
|
@@ -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, gt = 1, kt = 2,
|
|
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 === "")
|
|
@@ -1005,9 +1005,9 @@ class Mt {
|
|
|
1005
1005
|
let e = [];
|
|
1006
1006
|
for (let n = 0; n < t.length; n++)
|
|
1007
1007
|
e.push(t.charCodeAt(n));
|
|
1008
|
-
let s = Math.max(...e) > 255 ? 2 : 1, o =
|
|
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
1009
|
for (let n = 0; n < t.length; n++)
|
|
1010
|
-
|
|
1010
|
+
l[n] = t.charCodeAt(n);
|
|
1011
1011
|
return {
|
|
1012
1012
|
pointer: a.pointer,
|
|
1013
1013
|
charType: s
|
|
@@ -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, kt), o =
|
|
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,18 +1074,19 @@ 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 + Et * Uint32Array.BYTES_PER_ELEMENT, 2), "type" in e || "dataLength" in e) {
|
|
1078
|
+
const r = e.bufferLength ?? wt;
|
|
1079
|
+
let s = t.allocUI32(r * (e.dataLength ?? 1));
|
|
1080
|
+
k(this.firstBlock.data, E, 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(
|
|
1087
|
-
let r = e?.dataLength ?? 1, s = e?.bufferLength ??
|
|
1088
|
-
|
|
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;
|
|
1089
1090
|
const a = e?.type ?? Uint32Array;
|
|
1090
1091
|
a === Uint32Array ? this.type = 0 : a === Int32Array ? this.type = 1 : a === Float32Array && (this.type = 2), this.dataLength = r;
|
|
1091
1092
|
}
|
|
@@ -1106,17 +1107,22 @@ class d {
|
|
|
1106
1107
|
return this.getFullDataBlock()[t * this.dataLength + e];
|
|
1107
1108
|
}
|
|
1108
1109
|
push(t) {
|
|
1109
|
-
typeof t == "number" && (t = [t]);
|
|
1110
1110
|
let e = this.dataLength;
|
|
1111
|
-
|
|
1111
|
+
const r = typeof t == "number";
|
|
1112
|
+
if (!r && t.length > e)
|
|
1112
1113
|
throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
|
|
1113
|
-
let
|
|
1114
|
-
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;
|
|
1115
1116
|
}
|
|
1116
1117
|
pop() {
|
|
1117
|
-
let t = Atomics.sub(this.firstBlock.data,
|
|
1118
|
+
let t = Atomics.sub(this.firstBlock.data, d, d), e = this.getFullDataBlock();
|
|
1118
1119
|
return this.getDataBlock(e, t - 1);
|
|
1119
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
|
+
}
|
|
1120
1126
|
deleteIndex(t) {
|
|
1121
1127
|
let e = this.length;
|
|
1122
1128
|
if (t >= e || t < 0)
|
|
@@ -1125,10 +1131,10 @@ class d {
|
|
|
1125
1131
|
for (let o = t; o < e; o++)
|
|
1126
1132
|
for (let a = 0; a < r; a++)
|
|
1127
1133
|
s[o * r + a] = s[(o + 1) * r + a];
|
|
1128
|
-
Atomics.sub(this.firstBlock.data,
|
|
1134
|
+
Atomics.sub(this.firstBlock.data, d, d);
|
|
1129
1135
|
}
|
|
1130
1136
|
clear() {
|
|
1131
|
-
this.firstBlock.data[
|
|
1137
|
+
this.firstBlock.data[d] = 0;
|
|
1132
1138
|
}
|
|
1133
1139
|
*[Symbol.iterator]() {
|
|
1134
1140
|
let t = this.getFullDataBlock();
|
|
@@ -1136,10 +1142,10 @@ class d {
|
|
|
1136
1142
|
yield this.getDataBlock(t, e);
|
|
1137
1143
|
}
|
|
1138
1144
|
getFullDataBlock() {
|
|
1139
|
-
let t = Atomics.load(this.firstBlock.data,
|
|
1145
|
+
let t = Atomics.load(this.firstBlock.data, E);
|
|
1140
1146
|
if (this.cachedPointer === t && this.cachedFullDataBlock)
|
|
1141
1147
|
return this.cachedFullDataBlock;
|
|
1142
|
-
let e =
|
|
1148
|
+
let e = B(t), r = new h(this.memory, e), s;
|
|
1143
1149
|
switch (this.type) {
|
|
1144
1150
|
case 1:
|
|
1145
1151
|
s = new Int32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
|
|
@@ -1160,24 +1166,26 @@ class d {
|
|
|
1160
1166
|
return t.subarray(r, r + this.dataLength);
|
|
1161
1167
|
}
|
|
1162
1168
|
growBuffer() {
|
|
1163
|
-
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;
|
|
1164
1170
|
switch (this.type) {
|
|
1165
1171
|
case 1:
|
|
1166
|
-
n = new Int32Array(
|
|
1172
|
+
n = new Int32Array(l.data.buffer, l.bufferByteOffset, r * e);
|
|
1167
1173
|
break;
|
|
1168
1174
|
case 0:
|
|
1169
|
-
n = new Uint32Array(
|
|
1175
|
+
n = new Uint32Array(l.data.buffer, l.bufferByteOffset, r * e);
|
|
1170
1176
|
break;
|
|
1171
1177
|
case 2:
|
|
1172
|
-
n = new Float32Array(
|
|
1178
|
+
n = new Float32Array(l.data.buffer, l.bufferByteOffset, r * e);
|
|
1173
1179
|
break;
|
|
1174
1180
|
default:
|
|
1175
1181
|
throw new Error(`Unknown data block type ${this.type}`);
|
|
1176
1182
|
}
|
|
1177
|
-
n.set(a)
|
|
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;
|
|
1178
1186
|
}
|
|
1179
1187
|
free() {
|
|
1180
|
-
let t = c(this.firstBlock.data,
|
|
1188
|
+
let t = c(this.firstBlock.data, E);
|
|
1181
1189
|
new h(this.memory, t).free(), this.firstBlock.free();
|
|
1182
1190
|
}
|
|
1183
1191
|
getSharedMemory() {
|
|
@@ -1257,9 +1265,9 @@ class me {
|
|
|
1257
1265
|
this.list.free(), this.cache.clear();
|
|
1258
1266
|
}
|
|
1259
1267
|
}
|
|
1260
|
-
const
|
|
1268
|
+
const D = 0, Lt = 1, St = 2, q = 3, Tt = q + m.ALLOCATE_COUNT;
|
|
1261
1269
|
class It {
|
|
1262
|
-
static ALLOCATE_COUNT = 3 +
|
|
1270
|
+
static ALLOCATE_COUNT = 3 + m.ALLOCATE_COUNT * 2;
|
|
1263
1271
|
memory;
|
|
1264
1272
|
// Current Length, Type/DataLength, MaxChunkLength, Pointer vector, Recycle vector
|
|
1265
1273
|
firstBlock;
|
|
@@ -1268,13 +1276,13 @@ class It {
|
|
|
1268
1276
|
recycleVector;
|
|
1269
1277
|
cachedFullDataBlock = {};
|
|
1270
1278
|
get length() {
|
|
1271
|
-
return Atomics.load(this.firstBlock.data,
|
|
1279
|
+
return Atomics.load(this.firstBlock.data, D) - this.recycleVector.length;
|
|
1272
1280
|
}
|
|
1273
1281
|
get maxChunkSize() {
|
|
1274
|
-
return this.firstBlock.data[
|
|
1282
|
+
return this.firstBlock.data[St];
|
|
1275
1283
|
}
|
|
1276
1284
|
set maxChunkSize(t) {
|
|
1277
|
-
Atomics.store(this.firstBlock.data,
|
|
1285
|
+
Atomics.store(this.firstBlock.data, St, t);
|
|
1278
1286
|
}
|
|
1279
1287
|
get type() {
|
|
1280
1288
|
return this.uint16Array[0];
|
|
@@ -1291,36 +1299,39 @@ class It {
|
|
|
1291
1299
|
get bufferLength() {
|
|
1292
1300
|
return this.maxChunkSize * this.pointerVector.length;
|
|
1293
1301
|
}
|
|
1302
|
+
get recycleBufferLength() {
|
|
1303
|
+
return this.recycleVector.bufferLength;
|
|
1304
|
+
}
|
|
1294
1305
|
get byteMultipler() {
|
|
1295
1306
|
return this.type === 3 ? 2 : 1;
|
|
1296
1307
|
}
|
|
1297
1308
|
constructor(t, e) {
|
|
1298
1309
|
if (this.memory = t, e && "firstBlock" in e)
|
|
1299
|
-
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, {
|
|
1300
1311
|
firstBlock: {
|
|
1301
1312
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1302
|
-
bufferByteOffset: this.firstBlock.bufferByteOffset +
|
|
1313
|
+
bufferByteOffset: this.firstBlock.bufferByteOffset + q * Uint32Array.BYTES_PER_ELEMENT
|
|
1303
1314
|
}
|
|
1304
|
-
}), this.recycleVector = new
|
|
1315
|
+
}), this.recycleVector = new m(t, {
|
|
1305
1316
|
firstBlock: {
|
|
1306
1317
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1307
|
-
bufferByteOffset: this.firstBlock.bufferByteOffset +
|
|
1318
|
+
bufferByteOffset: this.firstBlock.bufferByteOffset + Tt * Uint32Array.BYTES_PER_ELEMENT
|
|
1308
1319
|
}
|
|
1309
1320
|
});
|
|
1310
1321
|
else {
|
|
1311
|
-
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);
|
|
1312
1323
|
let r = e?.dataLength ?? 1, s = e?.maxChunkSize ?? 100;
|
|
1313
|
-
this.pointerVector = new
|
|
1324
|
+
this.pointerVector = new m(t, {
|
|
1314
1325
|
type: Uint32Array,
|
|
1315
1326
|
firstBlock: {
|
|
1316
1327
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1317
|
-
bufferByteOffset: this.firstBlock.bufferByteOffset +
|
|
1328
|
+
bufferByteOffset: this.firstBlock.bufferByteOffset + q * Uint32Array.BYTES_PER_ELEMENT
|
|
1318
1329
|
}
|
|
1319
|
-
}), this.recycleVector = new
|
|
1330
|
+
}), this.recycleVector = new m(t, {
|
|
1320
1331
|
type: Uint32Array,
|
|
1321
1332
|
firstBlock: {
|
|
1322
1333
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1323
|
-
bufferByteOffset: this.firstBlock.bufferByteOffset +
|
|
1334
|
+
bufferByteOffset: this.firstBlock.bufferByteOffset + Tt * Uint32Array.BYTES_PER_ELEMENT
|
|
1324
1335
|
},
|
|
1325
1336
|
bufferLength: e?.recycleBufferLength
|
|
1326
1337
|
});
|
|
@@ -1346,7 +1357,7 @@ class It {
|
|
|
1346
1357
|
if (t.length > e)
|
|
1347
1358
|
throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
|
|
1348
1359
|
let r;
|
|
1349
|
-
this.recycleVector.length ? r = this.recycleVector.
|
|
1360
|
+
this.recycleVector.length ? r = this.recycleVector.popNumber() : r = Atomics.add(this.firstBlock.data, D, 1);
|
|
1350
1361
|
let s = this.getFullDataBlock(r), o = r % this.maxChunkSize;
|
|
1351
1362
|
return s.set(t, e * o), r;
|
|
1352
1363
|
}
|
|
@@ -1354,14 +1365,14 @@ class It {
|
|
|
1354
1365
|
this.recycleVector.push(t);
|
|
1355
1366
|
}
|
|
1356
1367
|
clear() {
|
|
1357
|
-
this.firstBlock.data[
|
|
1368
|
+
this.firstBlock.data[D] = 0, this.recycleVector.clear();
|
|
1358
1369
|
}
|
|
1359
1370
|
*[Symbol.iterator]() {
|
|
1360
1371
|
const t = {};
|
|
1361
1372
|
for (let s of this.recycleVector)
|
|
1362
1373
|
t[s[0]] = !0;
|
|
1363
1374
|
let e = this.getFullDataBlock(0), r = 0;
|
|
1364
|
-
for (let s = 0; s < Atomics.load(this.firstBlock.data,
|
|
1375
|
+
for (let s = 0; s < Atomics.load(this.firstBlock.data, D); s++)
|
|
1365
1376
|
if (!t[s]) {
|
|
1366
1377
|
let o = Math.floor(s / this.maxChunkSize);
|
|
1367
1378
|
o !== r && (e = this.getFullDataBlock(s), r = o), yield this.getDataBlock(e, s % this.maxChunkSize);
|
|
@@ -1375,7 +1386,7 @@ class It {
|
|
|
1375
1386
|
let a = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
|
|
1376
1387
|
this.pointerVector.push(a.pointer);
|
|
1377
1388
|
}
|
|
1378
|
-
let s = new h(this.memory,
|
|
1389
|
+
let s = new h(this.memory, B(this.pointerVector.get(e))), o;
|
|
1379
1390
|
switch (this.type) {
|
|
1380
1391
|
case 1:
|
|
1381
1392
|
o = new Int32Array(s.data.buffer, s.bufferByteOffset, this.dataLength * this.maxChunkSize);
|
|
@@ -1402,7 +1413,7 @@ class It {
|
|
|
1402
1413
|
this.recycleVector.free();
|
|
1403
1414
|
for (let t of this.pointerVector) {
|
|
1404
1415
|
let e = t[0];
|
|
1405
|
-
new h(this.memory,
|
|
1416
|
+
new h(this.memory, B(e)).free();
|
|
1406
1417
|
}
|
|
1407
1418
|
this.pointerVector.free(), this.firstBlock.free();
|
|
1408
1419
|
}
|
|
@@ -1412,158 +1423,248 @@ class It {
|
|
|
1412
1423
|
};
|
|
1413
1424
|
}
|
|
1414
1425
|
}
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
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));
|
|
1418
1518
|
}
|
|
1419
|
-
function
|
|
1420
|
-
Atomics.store(i, t,
|
|
1519
|
+
function ke(i, t, e, r) {
|
|
1520
|
+
Atomics.store(i, t, fe(e, r));
|
|
1421
1521
|
}
|
|
1422
|
-
function
|
|
1522
|
+
function le(i) {
|
|
1423
1523
|
return Nt[0] = i, [R[0], R[1]];
|
|
1424
1524
|
}
|
|
1425
|
-
function
|
|
1525
|
+
function fe(i, t) {
|
|
1426
1526
|
return R[0] = i, R[1] = t, Nt[0];
|
|
1427
1527
|
}
|
|
1428
|
-
const
|
|
1429
|
-
function
|
|
1430
|
-
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]];
|
|
1431
1531
|
}
|
|
1432
|
-
function
|
|
1433
|
-
|
|
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]);
|
|
1434
1534
|
}
|
|
1435
|
-
const
|
|
1436
|
-
function
|
|
1437
|
-
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)),
|
|
1535
|
+
const Dt = new ArrayBuffer(4), xt = new Float32Array(Dt), Ft = new Int32Array(Dt);
|
|
1536
|
+
function zt(i, t) {
|
|
1537
|
+
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.load(i, t));
|
|
1438
1538
|
}
|
|
1439
1539
|
function Ee(i, t, e) {
|
|
1440
1540
|
i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Atomics.store(i, t, $(e));
|
|
1441
1541
|
}
|
|
1442
|
-
function
|
|
1443
|
-
return
|
|
1542
|
+
function Q(i) {
|
|
1543
|
+
return Ft[0] = i, xt[0];
|
|
1444
1544
|
}
|
|
1445
1545
|
function $(i) {
|
|
1446
|
-
return
|
|
1546
|
+
return xt[0] = i, Ft[0];
|
|
1447
1547
|
}
|
|
1448
1548
|
function we(i, t, e) {
|
|
1449
|
-
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)),
|
|
1549
|
+
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.exchange(i, t, $(e)));
|
|
1450
1550
|
}
|
|
1451
|
-
function
|
|
1452
|
-
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)),
|
|
1551
|
+
function Rt(i, t, e, r) {
|
|
1552
|
+
return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.compareExchange(i, t, $(e), $(r)));
|
|
1453
1553
|
}
|
|
1454
|
-
function
|
|
1554
|
+
function Le(i, t, e, r) {
|
|
1455
1555
|
let s, o;
|
|
1456
1556
|
do
|
|
1457
1557
|
s = Atomics.load(i, t), o = Math.min(s + e, r);
|
|
1458
1558
|
while (Atomics.compareExchange(i, t, s, o) !== s);
|
|
1459
1559
|
}
|
|
1460
|
-
function
|
|
1560
|
+
function Se(i, t, e, r) {
|
|
1461
1561
|
let s, o;
|
|
1462
1562
|
do
|
|
1463
1563
|
s = Atomics.load(i, t), o = Math.max(s - e, r);
|
|
1464
1564
|
while (Atomics.compareExchange(i, t, s, o) !== s);
|
|
1465
1565
|
}
|
|
1466
|
-
function
|
|
1566
|
+
function Te(i, t, e, r) {
|
|
1467
1567
|
let s, o;
|
|
1468
1568
|
do
|
|
1469
|
-
s =
|
|
1470
|
-
while (
|
|
1569
|
+
s = zt(i, t), o = Math.min(s + e, r);
|
|
1570
|
+
while (Rt(i, t, s, o) !== s);
|
|
1471
1571
|
}
|
|
1472
|
-
function
|
|
1572
|
+
function _e(i, t, e, r) {
|
|
1473
1573
|
let s, o;
|
|
1474
1574
|
do
|
|
1475
|
-
s =
|
|
1476
|
-
while (
|
|
1575
|
+
s = zt(i, t), o = Math.max(s - e, r);
|
|
1576
|
+
while (Rt(i, t, s, o) !== s);
|
|
1477
1577
|
}
|
|
1478
|
-
const
|
|
1479
|
-
function
|
|
1480
|
-
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)),
|
|
1578
|
+
const $t = new ArrayBuffer(8), Yt = new Float64Array($t), Ht = new BigInt64Array($t);
|
|
1579
|
+
function Oe(i, t) {
|
|
1580
|
+
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.load(i, t));
|
|
1481
1581
|
}
|
|
1482
|
-
function
|
|
1483
|
-
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));
|
|
1484
1584
|
}
|
|
1485
|
-
function
|
|
1585
|
+
function tt(i) {
|
|
1486
1586
|
return Ht[0] = i, Yt[0];
|
|
1487
1587
|
}
|
|
1488
|
-
function
|
|
1588
|
+
function Y(i) {
|
|
1489
1589
|
return Yt[0] = i, Ht[0];
|
|
1490
1590
|
}
|
|
1491
|
-
function
|
|
1492
|
-
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)),
|
|
1493
|
-
}
|
|
1494
|
-
function Ie(i, t, e, r) {
|
|
1495
|
-
return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), et(Atomics.compareExchange(i, t, z(e), z(r)));
|
|
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)));
|
|
1496
1593
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
for (; Atomics.compareExchange(i, t, p, Q) === L; )
|
|
1500
|
-
Atomics.wait(i, t, L);
|
|
1501
|
-
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)));
|
|
1502
1596
|
}
|
|
1597
|
+
const w = 0, J = 1, S = 2;
|
|
1503
1598
|
function Ne(i, t = 0) {
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1599
|
+
for (; Atomics.compareExchange(i, t, w, J) === S; )
|
|
1600
|
+
Atomics.wait(i, t, S);
|
|
1601
|
+
Atomics.add(i, t + 1, 1);
|
|
1507
1602
|
}
|
|
1508
|
-
function
|
|
1509
|
-
|
|
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);
|
|
1510
1607
|
}
|
|
1511
1608
|
function Ue(i, t = 0) {
|
|
1512
|
-
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);
|
|
1513
1613
|
}
|
|
1514
|
-
const
|
|
1614
|
+
const xe = 2;
|
|
1515
1615
|
export {
|
|
1516
1616
|
h as AllocatedMemory,
|
|
1517
1617
|
he as BYTE_OFFSET_BIT_COUNT,
|
|
1518
1618
|
me as CachedItemList,
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1619
|
+
be as LocalPool,
|
|
1620
|
+
et as MAX_BYTE_OFFSET_LENGTH,
|
|
1621
|
+
rt as MAX_POSITION_LENGTH,
|
|
1622
|
+
W as MemoryBuffer,
|
|
1623
|
+
ye as MemoryHeap,
|
|
1523
1624
|
ce as POSITION_BIT_COUNT,
|
|
1524
|
-
|
|
1525
|
-
|
|
1625
|
+
xe as READ_WRITE_LOCK_ALLOCATE_COUNT,
|
|
1626
|
+
de as SIMPLE_LOCK_ALLOCATE_COUNT,
|
|
1526
1627
|
u as SharedList,
|
|
1527
1628
|
Ot as SharedMap,
|
|
1528
1629
|
Be as SharedPointerList,
|
|
1529
1630
|
It as SharedPool,
|
|
1530
1631
|
Mt as SharedString,
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
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,
|
|
1538
1639
|
$ as convertFloat32ToInt32,
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1640
|
+
Y as convertFloat64ToInt64,
|
|
1641
|
+
Q as convertInt32ToFloat32,
|
|
1642
|
+
tt as convertInt64ToFloat64,
|
|
1643
|
+
L as createPointer,
|
|
1543
1644
|
we as exchangeFloat32,
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1645
|
+
Ie as exchangeFloat64,
|
|
1646
|
+
B as getPointer,
|
|
1647
|
+
ge as load16From32,
|
|
1648
|
+
Ae as load16From64,
|
|
1649
|
+
zt as loadFloat32,
|
|
1650
|
+
Oe as loadFloat64,
|
|
1550
1651
|
c as loadPointer,
|
|
1551
1652
|
O as loadRawPointer,
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1653
|
+
z as lock,
|
|
1654
|
+
Ne as readLock,
|
|
1655
|
+
Ue as readUnlock,
|
|
1555
1656
|
ue as replacePointer,
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1657
|
+
V as replaceRawPointer,
|
|
1658
|
+
ke as store16In32,
|
|
1659
|
+
pe as store16In64,
|
|
1559
1660
|
Ee as storeFloat32,
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
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
|
|
1568
1669
|
};
|
|
1569
1670
|
//# sourceMappingURL=shared-memory-objects.js.map
|