@daneren2005/shared-memory-objects 0.0.21 → 1.0.0
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 +167 -167
- package/dist/shared-memory-objects.js +479 -575
- 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/memory-heap.d.ts +0 -1
- package/dist/src/utils/atomic-math.d.ts +4 -4
- package/dist/src/utils/typedarray.d.ts +278 -278
- package/package.json +70 -72
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
const
|
|
2
|
-
function c(
|
|
3
|
-
return
|
|
1
|
+
const Qt = 20, te = 12, tt = Math.pow(2, 20), et = Math.pow(2, 12);
|
|
2
|
+
function c(s, t = 0) {
|
|
3
|
+
return y(Atomics.load(s, t));
|
|
4
4
|
}
|
|
5
|
-
function O(
|
|
6
|
-
return Atomics.load(
|
|
5
|
+
function O(s, t = 0) {
|
|
6
|
+
return Atomics.load(s, t);
|
|
7
7
|
}
|
|
8
|
-
function k(
|
|
9
|
-
Atomics.store(
|
|
8
|
+
function k(s, t = 0, e, r) {
|
|
9
|
+
Atomics.store(s, t, L(e, r));
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
Atomics.store(
|
|
11
|
+
function U(s, t = 0, e) {
|
|
12
|
+
Atomics.store(s, t, e);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
let a = L(
|
|
16
|
-
return Atomics.compareExchange(
|
|
14
|
+
function ee(s, t, e, r, i, o) {
|
|
15
|
+
let a = L(i, o);
|
|
16
|
+
return Atomics.compareExchange(s, t, a, L(e, r)) === a;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return Atomics.compareExchange(
|
|
18
|
+
function H(s, t, e, r) {
|
|
19
|
+
return Atomics.compareExchange(s, t, r, e) === r;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function y(s) {
|
|
22
22
|
return {
|
|
23
|
-
bufferPosition:
|
|
24
|
-
bufferByteOffset:
|
|
23
|
+
bufferPosition: s & 4095,
|
|
24
|
+
bufferByteOffset: s >>> 12
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
function L(
|
|
28
|
-
return
|
|
27
|
+
function L(s, t) {
|
|
28
|
+
return s + (t << 12);
|
|
29
29
|
}
|
|
30
|
-
class
|
|
30
|
+
class f {
|
|
31
31
|
memory;
|
|
32
32
|
bufferPosition;
|
|
33
33
|
get bufferByteOffset() {
|
|
@@ -60,15 +60,15 @@ class h {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
const
|
|
64
|
-
function
|
|
65
|
-
for (; Atomics.compareExchange(
|
|
66
|
-
"WorkerGlobalScope" in self && Atomics.wait(
|
|
63
|
+
const W = 0, D = 1;
|
|
64
|
+
function x(s, t = 0) {
|
|
65
|
+
for (; Atomics.compareExchange(s, t, W, D) !== W; )
|
|
66
|
+
"WorkerGlobalScope" in self && Atomics.wait(s, t, D);
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
Atomics.compareExchange(
|
|
68
|
+
function b(s, t = 0) {
|
|
69
|
+
Atomics.compareExchange(s, t, D, W) !== D && console.warn("We are unlocking when it was not locked!"), Atomics.notify(s, t);
|
|
70
70
|
}
|
|
71
|
-
const
|
|
71
|
+
const re = 1, Rt = {
|
|
72
72
|
5120: "i8",
|
|
73
73
|
5121: "u8",
|
|
74
74
|
5122: "i16",
|
|
@@ -76,35 +76,35 @@ const de = 1, Vt = {
|
|
|
76
76
|
5124: "i32",
|
|
77
77
|
5125: "u32",
|
|
78
78
|
5126: "f32"
|
|
79
|
-
},
|
|
79
|
+
}, $t = {
|
|
80
80
|
f32: Float32Array,
|
|
81
81
|
f64: Float64Array
|
|
82
|
-
},
|
|
82
|
+
}, Ht = {
|
|
83
83
|
i8: Int8Array,
|
|
84
84
|
i16: Int16Array,
|
|
85
85
|
i32: Int32Array
|
|
86
|
-
},
|
|
86
|
+
}, Yt = {
|
|
87
87
|
u8: Uint8Array,
|
|
88
88
|
u8c: Uint8ClampedArray,
|
|
89
89
|
u16: Uint16Array,
|
|
90
90
|
u32: Uint32Array
|
|
91
|
-
},
|
|
91
|
+
}, Vt = {
|
|
92
92
|
i64: BigInt64Array,
|
|
93
93
|
u64: BigUint64Array
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
...
|
|
97
|
-
...
|
|
98
|
-
},
|
|
99
|
-
const t =
|
|
100
|
-
return t !== void 0 ? t :
|
|
94
|
+
}, Kt = {
|
|
95
|
+
...$t,
|
|
96
|
+
...Ht,
|
|
97
|
+
...Yt
|
|
98
|
+
}, Xt = (s) => {
|
|
99
|
+
const t = Rt[s];
|
|
100
|
+
return t !== void 0 ? t : s;
|
|
101
101
|
};
|
|
102
|
-
function
|
|
103
|
-
const e =
|
|
104
|
-
return new (e ||
|
|
102
|
+
function Gt(s, ...t) {
|
|
103
|
+
const e = Vt[s];
|
|
104
|
+
return new (e || Kt[Xt(s)])(...t);
|
|
105
105
|
}
|
|
106
|
-
const
|
|
107
|
-
class
|
|
106
|
+
const rt = 0, it = 1, st = 2, ot = 3, at = 4, g = 5, nt = 6, Y = 1, V = 2, lt = 32, K = 0, X = 1, d = 8;
|
|
107
|
+
class G {
|
|
108
108
|
buf;
|
|
109
109
|
start;
|
|
110
110
|
u8;
|
|
@@ -112,29 +112,29 @@ class W {
|
|
|
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, 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`);
|
|
119
|
-
const r = this.initialTop(e),
|
|
120
|
-
if (r >=
|
|
119
|
+
const r = this.initialTop(e), i = t.end != null ? Math.min(t.end, this.buf.byteLength) : this.buf.byteLength;
|
|
120
|
+
if (r >= i)
|
|
121
121
|
throw new Error(
|
|
122
122
|
`insufficient address range (0x${this.start.toString(
|
|
123
123
|
16
|
|
124
|
-
)} - 0x${
|
|
124
|
+
)} - 0x${i.toString(16)})`
|
|
125
125
|
);
|
|
126
|
-
this.align = e, this.doCompact = t.compact !== !1, this.doSplit = t.split !== !1, this.minSplit = t.minSplit || 16, this.end =
|
|
126
|
+
this.align = e, this.doCompact = t.compact !== !1, this.doSplit = t.split !== !1, this.minSplit = t.minSplit || 16, this.end = i, this.top = r, this._free = 0, this._used = 0;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
stats() {
|
|
130
130
|
const t = (r) => {
|
|
131
|
-
let
|
|
131
|
+
let i = 0, o = 0;
|
|
132
132
|
for (; r; )
|
|
133
|
-
if (
|
|
133
|
+
if (i++, o += this.blockSize(r), r = this.blockNext(r), r > this.end) {
|
|
134
134
|
console.error(`Trying to get stats for block past end of buffer: ${r} > ${this.end}`);
|
|
135
135
|
break;
|
|
136
136
|
}
|
|
137
|
-
return { count:
|
|
137
|
+
return { count: i, size: o };
|
|
138
138
|
}, e = t(this._free);
|
|
139
139
|
return {
|
|
140
140
|
free: e,
|
|
@@ -145,12 +145,12 @@ class W {
|
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
147
|
callocAs(t, e, r = 0) {
|
|
148
|
-
const
|
|
149
|
-
return
|
|
148
|
+
const i = this.mallocAs(t, e);
|
|
149
|
+
return i && i.fill(r), i;
|
|
150
150
|
}
|
|
151
151
|
mallocAs(t, e) {
|
|
152
|
-
const r = this.malloc(e *
|
|
153
|
-
return r ?
|
|
152
|
+
const r = this.malloc(e * Zt[t]);
|
|
153
|
+
return r ? Gt(t, this.buf, r, e) : void 0;
|
|
154
154
|
}
|
|
155
155
|
calloc(t, e = 0) {
|
|
156
156
|
const r = this.malloc(t);
|
|
@@ -159,68 +159,68 @@ class W {
|
|
|
159
159
|
malloc(t) {
|
|
160
160
|
if (t <= 0)
|
|
161
161
|
return 0;
|
|
162
|
-
|
|
163
|
-
const e =
|
|
164
|
-
let
|
|
162
|
+
x(this.lock);
|
|
163
|
+
const e = C(t + d, this.align), r = this.end;
|
|
164
|
+
let i = this.top, o = this._free, a = 0;
|
|
165
165
|
for (; o; ) {
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
let
|
|
166
|
+
const n = this.blockSize(o), l = o + n >= i;
|
|
167
|
+
if (l || n >= e) {
|
|
168
|
+
let h = this.mallocTop(
|
|
169
169
|
o,
|
|
170
170
|
a,
|
|
171
|
-
|
|
171
|
+
n,
|
|
172
172
|
e,
|
|
173
|
-
|
|
173
|
+
l
|
|
174
174
|
);
|
|
175
|
-
return
|
|
175
|
+
return b(this.lock), h;
|
|
176
176
|
}
|
|
177
177
|
a = o, o = this.blockNext(o);
|
|
178
178
|
}
|
|
179
|
-
if (o =
|
|
180
|
-
this.initBlock(o, e, this._used), this._used = o, this.top =
|
|
181
|
-
let
|
|
182
|
-
return
|
|
179
|
+
if (o = i, i = o + e, i <= r) {
|
|
180
|
+
this.initBlock(o, e, this._used), this._used = o, this.top = i;
|
|
181
|
+
let n = T(o);
|
|
182
|
+
return b(this.lock), n;
|
|
183
183
|
}
|
|
184
|
-
return
|
|
184
|
+
return b(this.lock), 0;
|
|
185
185
|
}
|
|
186
|
-
mallocTop(t, e, r,
|
|
187
|
-
if (o && t +
|
|
186
|
+
mallocTop(t, e, r, i, o) {
|
|
187
|
+
if (o && t + i > this.end) return 0;
|
|
188
188
|
if (e ? this.unlinkBlock(e, t) : this._free = this.blockNext(t), this.setBlockNext(t, this._used), this._used = t, o)
|
|
189
|
-
this.top = t + this.setBlockSize(t,
|
|
189
|
+
this.top = t + this.setBlockSize(t, i);
|
|
190
190
|
else if (this.doSplit) {
|
|
191
|
-
const a = r -
|
|
192
|
-
a >= this.minSplit && this.splitBlock(t,
|
|
191
|
+
const a = r - i;
|
|
192
|
+
a >= this.minSplit && this.splitBlock(t, i, a);
|
|
193
193
|
}
|
|
194
|
-
return
|
|
194
|
+
return T(t);
|
|
195
195
|
}
|
|
196
196
|
realloc(t, e) {
|
|
197
197
|
if (e <= 0)
|
|
198
198
|
return 0;
|
|
199
|
-
const r =
|
|
200
|
-
let
|
|
199
|
+
const r = _(t);
|
|
200
|
+
let i = 0, o = this._used, a = 0;
|
|
201
201
|
for (; o; ) {
|
|
202
202
|
if (o === r) {
|
|
203
|
-
[
|
|
203
|
+
[i, a] = this.reallocBlock(o, e);
|
|
204
204
|
break;
|
|
205
205
|
}
|
|
206
206
|
o = this.blockNext(o);
|
|
207
207
|
}
|
|
208
|
-
return
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
return i && i !== r && this.u8.copyWithin(
|
|
209
|
+
T(i),
|
|
210
|
+
T(r),
|
|
211
211
|
a
|
|
212
|
-
),
|
|
212
|
+
), T(i);
|
|
213
213
|
}
|
|
214
214
|
reallocBlock(t, e) {
|
|
215
|
-
const r = this.blockSize(t),
|
|
215
|
+
const r = this.blockSize(t), i = t + r, o = i >= this.top, a = C(e + d, this.align);
|
|
216
216
|
if (a <= r) {
|
|
217
217
|
if (this.doSplit) {
|
|
218
|
-
const
|
|
219
|
-
|
|
218
|
+
const n = r - a;
|
|
219
|
+
n >= this.minSplit ? this.splitBlock(t, a, n) : o && (this.top = t + a);
|
|
220
220
|
} else o && (this.top = t + a);
|
|
221
|
-
return [t,
|
|
221
|
+
return [t, i];
|
|
222
222
|
}
|
|
223
|
-
return o && t + a < this.end ? (this.top = t + this.setBlockSize(t, a), [t,
|
|
223
|
+
return o && t + a < this.end ? (this.top = t + this.setBlockSize(t, a), [t, i]) : (this.free(t), [_(this.malloc(e)), i]);
|
|
224
224
|
}
|
|
225
225
|
reallocArray(t, e) {
|
|
226
226
|
if (t.buffer !== this.buf)
|
|
@@ -239,11 +239,11 @@ class W {
|
|
|
239
239
|
e = t.byteOffset;
|
|
240
240
|
} else
|
|
241
241
|
e = t;
|
|
242
|
-
e =
|
|
242
|
+
e = _(e);
|
|
243
243
|
let r = this._used;
|
|
244
244
|
for (; r; ) {
|
|
245
245
|
if (r === e)
|
|
246
|
-
return this.blockSize(e) -
|
|
246
|
+
return this.blockSize(e) - d;
|
|
247
247
|
r = this.blockNext(r);
|
|
248
248
|
}
|
|
249
249
|
}
|
|
@@ -260,14 +260,14 @@ class W {
|
|
|
260
260
|
e = t.byteOffset;
|
|
261
261
|
} else
|
|
262
262
|
e = t;
|
|
263
|
-
|
|
264
|
-
let r = this._used,
|
|
263
|
+
x(this.lock), e = _(e);
|
|
264
|
+
let r = this._used, i = 0;
|
|
265
265
|
for (; r; ) {
|
|
266
266
|
if (r === e)
|
|
267
|
-
return
|
|
268
|
-
|
|
267
|
+
return i ? this.unlinkBlock(i, r) : this._used = this.blockNext(r), this.insert(r), this.doCompact && this.compact(), b(this.lock), !0;
|
|
268
|
+
i = r, r = this.blockNext(r);
|
|
269
269
|
}
|
|
270
|
-
return
|
|
270
|
+
return b(this.lock), !1;
|
|
271
271
|
}
|
|
272
272
|
freeAll() {
|
|
273
273
|
this._free = 0, this._used = 0, this.top = this.initialTop();
|
|
@@ -276,57 +276,57 @@ class W {
|
|
|
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
|
-
return this.state[
|
|
285
|
+
return this.state[ot];
|
|
286
286
|
}
|
|
287
287
|
set end(t) {
|
|
288
|
-
this.state[
|
|
288
|
+
this.state[ot] = t;
|
|
289
289
|
}
|
|
290
290
|
get top() {
|
|
291
|
-
return Atomics.load(this.state,
|
|
291
|
+
return Atomics.load(this.state, st);
|
|
292
292
|
}
|
|
293
293
|
set top(t) {
|
|
294
|
-
Atomics.store(this.state,
|
|
294
|
+
Atomics.store(this.state, st, t);
|
|
295
295
|
}
|
|
296
296
|
get _free() {
|
|
297
|
-
return Atomics.load(this.state,
|
|
297
|
+
return Atomics.load(this.state, rt);
|
|
298
298
|
}
|
|
299
299
|
set _free(t) {
|
|
300
|
-
Atomics.store(this.state,
|
|
300
|
+
Atomics.store(this.state, rt, t);
|
|
301
301
|
}
|
|
302
302
|
get _used() {
|
|
303
|
-
return Atomics.load(this.state,
|
|
303
|
+
return Atomics.load(this.state, it);
|
|
304
304
|
}
|
|
305
305
|
set _used(t) {
|
|
306
|
-
Atomics.store(this.state,
|
|
306
|
+
Atomics.store(this.state, it, t);
|
|
307
307
|
}
|
|
308
308
|
get doCompact() {
|
|
309
|
-
return !!(this.state[
|
|
309
|
+
return !!(this.state[g] & Y);
|
|
310
310
|
}
|
|
311
311
|
set doCompact(t) {
|
|
312
|
-
t ? this.state[
|
|
312
|
+
t ? this.state[g] |= 1 << Y - 1 : this.state[g] &= ~Y;
|
|
313
313
|
}
|
|
314
314
|
get doSplit() {
|
|
315
|
-
return !!(this.state[
|
|
315
|
+
return !!(this.state[g] & V);
|
|
316
316
|
}
|
|
317
317
|
set doSplit(t) {
|
|
318
|
-
t ? this.state[
|
|
318
|
+
t ? this.state[g] |= 1 << V - 1 : this.state[g] &= ~V;
|
|
319
319
|
}
|
|
320
320
|
get minSplit() {
|
|
321
|
-
return this.state[
|
|
321
|
+
return this.state[nt];
|
|
322
322
|
}
|
|
323
323
|
set minSplit(t) {
|
|
324
|
-
if (t <=
|
|
325
|
-
throw new Error(`illegal min split threshold: ${t}, require at least ${
|
|
326
|
-
this.state[
|
|
324
|
+
if (t <= d)
|
|
325
|
+
throw new Error(`illegal min split threshold: ${t}, require at least ${d + 1}`);
|
|
326
|
+
this.state[nt] = t;
|
|
327
327
|
}
|
|
328
328
|
blockSize(t) {
|
|
329
|
-
return Atomics.load(this.u32, (t >> 2) +
|
|
329
|
+
return Atomics.load(this.u32, (t >> 2) + K);
|
|
330
330
|
}
|
|
331
331
|
/**
|
|
332
332
|
* Sets & returns given block size.
|
|
@@ -335,10 +335,10 @@ class W {
|
|
|
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) + K, e), e;
|
|
339
339
|
}
|
|
340
340
|
blockNext(t) {
|
|
341
|
-
return Atomics.load(this.u32, (t >> 2) +
|
|
341
|
+
return Atomics.load(this.u32, (t >> 2) + X);
|
|
342
342
|
}
|
|
343
343
|
/**
|
|
344
344
|
* Sets block next pointer to `next`. Use zero to indicate list end.
|
|
@@ -346,7 +346,7 @@ class W {
|
|
|
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) + X, e);
|
|
350
350
|
}
|
|
351
351
|
/**
|
|
352
352
|
* Initializes block header with given `size` and `next` pointer. Returns `block`.
|
|
@@ -356,8 +356,8 @@ class W {
|
|
|
356
356
|
* @param next -
|
|
357
357
|
*/
|
|
358
358
|
initBlock(t, e, r) {
|
|
359
|
-
const
|
|
360
|
-
return Atomics.store(this.u32,
|
|
359
|
+
const i = t >>> 2;
|
|
360
|
+
return Atomics.store(this.u32, i + K, e), Atomics.store(this.u32, i + X, r), t;
|
|
361
361
|
}
|
|
362
362
|
unlinkBlock(t, e) {
|
|
363
363
|
this.setBlockNext(t, this.blockNext(e));
|
|
@@ -372,7 +372,7 @@ class W {
|
|
|
372
372
|
), this.doCompact && this.compact();
|
|
373
373
|
}
|
|
374
374
|
initialTop(t = this.align) {
|
|
375
|
-
return
|
|
375
|
+
return C(this.start + lt + d, t) - d;
|
|
376
376
|
}
|
|
377
377
|
/**
|
|
378
378
|
* Traverses free list and attempts to recursively merge blocks
|
|
@@ -380,20 +380,20 @@ class W {
|
|
|
380
380
|
* have been merged. Only called if `compact` option is enabled.
|
|
381
381
|
*/
|
|
382
382
|
compact() {
|
|
383
|
-
let t = this._free, e = 0, r = 0,
|
|
383
|
+
let t = this._free, e = 0, r = 0, i, o = !1;
|
|
384
384
|
for (; t; ) {
|
|
385
|
-
for (
|
|
386
|
-
|
|
387
|
-
if (
|
|
388
|
-
const a =
|
|
385
|
+
for (i = t, r = this.blockNext(t); r && i + this.blockSize(i) === r; )
|
|
386
|
+
i = r, r = this.blockNext(r);
|
|
387
|
+
if (i !== t) {
|
|
388
|
+
const a = i - t + this.blockSize(i);
|
|
389
389
|
this.setBlockSize(t, a);
|
|
390
|
-
const
|
|
391
|
-
let
|
|
392
|
-
for (;
|
|
393
|
-
const
|
|
394
|
-
this.setBlockNext(
|
|
390
|
+
const n = this.blockNext(i);
|
|
391
|
+
let l = this.blockNext(t);
|
|
392
|
+
for (; l && l !== n; ) {
|
|
393
|
+
const h = this.blockNext(l);
|
|
394
|
+
this.setBlockNext(l, 0), l = h;
|
|
395
395
|
}
|
|
396
|
-
this.setBlockNext(t,
|
|
396
|
+
this.setBlockNext(t, n), 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 W {
|
|
|
411
411
|
r ? this.setBlockNext(r, t) : this._free = t, this.setBlockNext(t, e);
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
const
|
|
414
|
+
const T = (s) => s > 0 ? s + d : 0, _ = (s) => s > 0 ? s - d : 0, C = (s, t) => (t--, s + t & ~t), Zt = {
|
|
415
415
|
u8: 1,
|
|
416
416
|
u8c: 1,
|
|
417
417
|
i8: 1,
|
|
@@ -423,156 +423,55 @@ const _ = (i) => i > 0 ? i + y : 0, C = (i) => i > 0 ? i - y : 0, I = (i, t) =>
|
|
|
423
423
|
u64: 8,
|
|
424
424
|
f32: 4,
|
|
425
425
|
f64: 8
|
|
426
|
-
},
|
|
427
|
-
|
|
428
|
-
"kB",
|
|
429
|
-
"MB",
|
|
430
|
-
"GB",
|
|
431
|
-
"TB",
|
|
432
|
-
"PB",
|
|
433
|
-
"EB",
|
|
434
|
-
"ZB",
|
|
435
|
-
"YB"
|
|
436
|
-
], Qt = [
|
|
437
|
-
"B",
|
|
438
|
-
"KiB",
|
|
439
|
-
"MiB",
|
|
440
|
-
"GiB",
|
|
441
|
-
"TiB",
|
|
442
|
-
"PiB",
|
|
443
|
-
"EiB",
|
|
444
|
-
"ZiB",
|
|
445
|
-
"YiB"
|
|
446
|
-
], te = [
|
|
447
|
-
"b",
|
|
448
|
-
"kbit",
|
|
449
|
-
"Mbit",
|
|
450
|
-
"Gbit",
|
|
451
|
-
"Tbit",
|
|
452
|
-
"Pbit",
|
|
453
|
-
"Ebit",
|
|
454
|
-
"Zbit",
|
|
455
|
-
"Ybit"
|
|
456
|
-
], ee = [
|
|
457
|
-
"b",
|
|
458
|
-
"kibit",
|
|
459
|
-
"Mibit",
|
|
460
|
-
"Gibit",
|
|
461
|
-
"Tibit",
|
|
462
|
-
"Pibit",
|
|
463
|
-
"Eibit",
|
|
464
|
-
"Zibit",
|
|
465
|
-
"Yibit"
|
|
466
|
-
], ht = (i, t, e) => {
|
|
467
|
-
let r = i;
|
|
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
|
-
}, _t = (i) => {
|
|
470
|
-
if (typeof i == "number")
|
|
471
|
-
return Math.log10(i);
|
|
472
|
-
const t = i.toString(10);
|
|
473
|
-
return t.length + Math.log10(`0.${t.slice(0, 15)}`);
|
|
474
|
-
}, re = (i) => typeof i == "number" ? Math.log(i) : _t(i) * Math.log(10), ie = (i, t) => {
|
|
475
|
-
if (typeof i == "number")
|
|
476
|
-
return i / t;
|
|
477
|
-
const e = i / BigInt(t), r = i % BigInt(t);
|
|
478
|
-
return Number(e) + Number(r) / t;
|
|
479
|
-
}, ct = (i, t) => {
|
|
480
|
-
if (t === void 0)
|
|
481
|
-
return i;
|
|
482
|
-
if (typeof t != "number" || !Number.isSafeInteger(t) || t < 0)
|
|
483
|
-
throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof t}: ${t}`);
|
|
484
|
-
return t === 0 ? i : i.length < t ? i.padStart(t, " ") : i;
|
|
485
|
-
}, se = (i) => {
|
|
486
|
-
const { minimumFractionDigits: t, maximumFractionDigits: e } = i;
|
|
487
|
-
if (!(t === void 0 && e === void 0))
|
|
488
|
-
return {
|
|
489
|
-
...t !== void 0 && { minimumFractionDigits: t },
|
|
490
|
-
...e !== void 0 && { maximumFractionDigits: e },
|
|
491
|
-
roundingMode: "trunc"
|
|
492
|
-
};
|
|
493
|
-
};
|
|
494
|
-
function oe(i, t) {
|
|
495
|
-
if (typeof i != "bigint" && !Number.isFinite(i))
|
|
496
|
-
throw new TypeError(`Expected a finite number, got ${typeof i}: ${i}`);
|
|
497
|
-
t = {
|
|
498
|
-
bits: !1,
|
|
499
|
-
binary: !1,
|
|
500
|
-
space: !0,
|
|
501
|
-
nonBreakingSpace: !1,
|
|
502
|
-
...t
|
|
503
|
-
};
|
|
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
|
-
if (t.signed && s) {
|
|
506
|
-
const f = ` 0${r}${e[0]}`;
|
|
507
|
-
return ct(f, t.fixedWidth);
|
|
508
|
-
}
|
|
509
|
-
const o = i < 0, a = o ? "-" : t.signed ? "+" : "";
|
|
510
|
-
o && (i = -i);
|
|
511
|
-
const l = se(t);
|
|
512
|
-
let n;
|
|
513
|
-
if (i < 1) {
|
|
514
|
-
const f = ht(i, t.locale, l);
|
|
515
|
-
n = a + f + r + e[0];
|
|
516
|
-
} else {
|
|
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
|
-
const M = Math.max(3, Math.floor(i).toString().length);
|
|
520
|
-
i = i.toPrecision(M);
|
|
521
|
-
}
|
|
522
|
-
const T = ht(Number(i), t.locale, l), H = e[f];
|
|
523
|
-
n = a + T + r + H;
|
|
524
|
-
}
|
|
525
|
-
return ct(n, t.fixedWidth);
|
|
526
|
-
}
|
|
527
|
-
const ae = 8192, ut = 0, v = 1, N = 2;
|
|
528
|
-
class ye {
|
|
426
|
+
}, Wt = 8192, ft = 0, Z = 1, I = 2;
|
|
427
|
+
class ie {
|
|
529
428
|
buffers;
|
|
530
429
|
onGrowBufferHandlers = [];
|
|
531
430
|
isClone;
|
|
532
431
|
memory;
|
|
533
432
|
get bufferSize() {
|
|
534
|
-
return this.memory.data[
|
|
433
|
+
return this.memory.data[ft];
|
|
535
434
|
}
|
|
536
435
|
constructor(t) {
|
|
537
436
|
if (t && "buffers" in t)
|
|
538
|
-
this.buffers = t.buffers.map((e) => new
|
|
437
|
+
this.buffers = t.buffers.map((e) => new G({
|
|
539
438
|
buf: e,
|
|
540
439
|
skipInitialization: !0
|
|
541
|
-
})), this.memory = new
|
|
440
|
+
})), this.memory = new f(this, {
|
|
542
441
|
bufferPosition: 0,
|
|
543
442
|
bufferByteOffset: 40
|
|
544
443
|
}), this.isClone = !0;
|
|
545
444
|
else {
|
|
546
445
|
"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 ${
|
|
446
|
+
const e = t?.bufferSize ?? Wt;
|
|
447
|
+
if (e > tt)
|
|
448
|
+
throw new Error(`Buffer size ${e} is greater than max ${tt} that we can reference with pointers`);
|
|
550
449
|
let r = this.createBuffer(e);
|
|
551
450
|
this.buffers = [
|
|
552
451
|
r
|
|
553
452
|
];
|
|
554
|
-
const
|
|
555
|
-
if (
|
|
556
|
-
this.memory = new
|
|
453
|
+
const i = r.callocAs("u32", 3);
|
|
454
|
+
if (i)
|
|
455
|
+
this.memory = new f(this, {
|
|
557
456
|
bufferPosition: 0,
|
|
558
|
-
bufferByteOffset:
|
|
457
|
+
bufferByteOffset: i.byteOffset
|
|
559
458
|
});
|
|
560
459
|
else
|
|
561
460
|
throw new Error("Failed to initialize first byte from buffer");
|
|
562
|
-
this.memory.data[
|
|
461
|
+
this.memory.data[ft] = e, this.memory.data[Z] = 1, this.memory.data[I] = t?.autoGrowSize ?? 100, this.isClone = !1;
|
|
563
462
|
for (let o = 1; o < (t?.initialBuffers ?? 1); o++)
|
|
564
463
|
this.buffers.push(this.createBuffer(e));
|
|
565
464
|
}
|
|
566
465
|
}
|
|
567
466
|
addSharedBuffer(t) {
|
|
568
|
-
this.buffers[t.bufferPosition] = new
|
|
467
|
+
this.buffers[t.bufferPosition] = new G({
|
|
569
468
|
buf: t.buffer,
|
|
570
469
|
skipInitialization: !0
|
|
571
470
|
});
|
|
572
471
|
}
|
|
573
472
|
growBuffer() {
|
|
574
473
|
const t = this.createBuffer();
|
|
575
|
-
let e = Atomics.add(this.memory.data,
|
|
474
|
+
let e = Atomics.add(this.memory.data, Z, 1);
|
|
576
475
|
return this.buffers[e] = t, this.onGrowBufferHandlers.forEach((r) => r({
|
|
577
476
|
bufferPosition: e,
|
|
578
477
|
buffer: t.buf
|
|
@@ -581,7 +480,7 @@ class ye {
|
|
|
581
480
|
createBuffer(t) {
|
|
582
481
|
const e = t ?? this.bufferSize;
|
|
583
482
|
let r;
|
|
584
|
-
return "SharedArrayBuffer" in globalThis ? r = new SharedArrayBuffer(e) : r = new ArrayBuffer(e), new
|
|
483
|
+
return "SharedArrayBuffer" in globalThis ? r = new SharedArrayBuffer(e) : r = new ArrayBuffer(e), new G({
|
|
585
484
|
buf: r,
|
|
586
485
|
// We can't use this unless we can 100% guarantee that every thread will stop using memory the instant it is freed
|
|
587
486
|
// 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
|
|
@@ -595,23 +494,23 @@ class ye {
|
|
|
595
494
|
}
|
|
596
495
|
allocUI32(t) {
|
|
597
496
|
t = Math.ceil(t);
|
|
598
|
-
for (let
|
|
599
|
-
const o = this.buffers[
|
|
497
|
+
for (let i = 0; i < this.buffers.length; i++) {
|
|
498
|
+
const o = this.buffers[i];
|
|
600
499
|
if (!o)
|
|
601
500
|
continue;
|
|
602
501
|
const a = o.callocAs("u32", t);
|
|
603
502
|
if (a)
|
|
604
|
-
return
|
|
503
|
+
return i === this.buffers.length - 1 && Atomics.load(this.memory.data, Z) === this.buffers.length && this.memory.data[I] < 100 && this.memory.data[I] > 0 && o.top / o.end > this.memory.data[I] / 100 && this.growBuffer(), new f(this, {
|
|
605
504
|
data: a,
|
|
606
505
|
buffer: o
|
|
607
506
|
});
|
|
608
507
|
}
|
|
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 ${
|
|
508
|
+
if (this.buffers.length >= et)
|
|
509
|
+
throw new Error(`Can't initialize a new buffer since it would have a position greater than the max of ${et}`);
|
|
611
510
|
let e = this.growBuffer();
|
|
612
511
|
const r = e.callocAs("u32", t);
|
|
613
512
|
if (r)
|
|
614
|
-
return new
|
|
513
|
+
return new f(this, {
|
|
615
514
|
data: r,
|
|
616
515
|
buffer: e
|
|
617
516
|
});
|
|
@@ -619,7 +518,7 @@ class ye {
|
|
|
619
518
|
}
|
|
620
519
|
getSharedAlloc(t) {
|
|
621
520
|
if (this.buffers[t.bufferPosition] !== void 0)
|
|
622
|
-
return new
|
|
521
|
+
return new f(this, t);
|
|
623
522
|
}
|
|
624
523
|
get currentUsed() {
|
|
625
524
|
return this.totalAllocated - this.buffers.reduce((t, e) => t + e.stats().available, 0);
|
|
@@ -627,25 +526,15 @@ class ye {
|
|
|
627
526
|
get totalAllocated() {
|
|
628
527
|
return this.buffers[0].buf.byteLength * this.buffers.length;
|
|
629
528
|
}
|
|
630
|
-
prettyMemory() {
|
|
631
|
-
return `${dt(this.currentUsed)} / ${dt(this.totalAllocated)}`;
|
|
632
|
-
}
|
|
633
529
|
getSharedMemory() {
|
|
634
530
|
return {
|
|
635
531
|
buffers: this.buffers.map((t) => t.buf)
|
|
636
532
|
};
|
|
637
533
|
}
|
|
638
534
|
}
|
|
639
|
-
|
|
640
|
-
return oe(i, {
|
|
641
|
-
binary: !0,
|
|
642
|
-
minimumFractionDigits: 1,
|
|
643
|
-
maximumFractionDigits: 1
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
const yt = 4, Bt = 1, p = 2;
|
|
535
|
+
const ht = 4, ct = 1, A = 2;
|
|
647
536
|
class u {
|
|
648
|
-
static ALLOCATE_COUNT =
|
|
537
|
+
static ALLOCATE_COUNT = ht;
|
|
649
538
|
memory;
|
|
650
539
|
/* First block
|
|
651
540
|
32 index 0
|
|
@@ -670,7 +559,7 @@ class u {
|
|
|
670
559
|
uint16Array;
|
|
671
560
|
onDelete;
|
|
672
561
|
get length() {
|
|
673
|
-
return Atomics.load(this.firstBlock.data,
|
|
562
|
+
return Atomics.load(this.firstBlock.data, A);
|
|
674
563
|
}
|
|
675
564
|
get type() {
|
|
676
565
|
return Atomics.load(this.uint16Array, 0);
|
|
@@ -686,9 +575,9 @@ class u {
|
|
|
686
575
|
}
|
|
687
576
|
constructor(t, e) {
|
|
688
577
|
if (this.memory = t, e && "firstBlock" in e)
|
|
689
|
-
this.firstBlock = new
|
|
578
|
+
this.firstBlock = new f(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + (A + 1) * Uint32Array.BYTES_PER_ELEMENT, 2);
|
|
690
579
|
else {
|
|
691
|
-
e && e.initWithBlock ? this.firstBlock = new
|
|
580
|
+
e && e.initWithBlock ? this.firstBlock = new f(t, e.initWithBlock) : this.firstBlock = t.allocUI32(ht), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + (A + 1) * Uint32Array.BYTES_PER_ELEMENT, 2);
|
|
692
581
|
const r = e?.type ?? Uint32Array;
|
|
693
582
|
r === Uint32Array ? this.type = 0 : r === Int32Array ? this.type = 1 : r === Float32Array && (this.type = 2), this.dataLength = e?.dataLength ?? 1;
|
|
694
583
|
}
|
|
@@ -698,23 +587,23 @@ class u {
|
|
|
698
587
|
let e = this.dataLength;
|
|
699
588
|
if (t.length > e)
|
|
700
589
|
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
|
-
|
|
704
|
-
let a,
|
|
705
|
-
for (; !
|
|
706
|
-
a = O(this.firstBlock.data, 1),
|
|
590
|
+
let r = this.memory.allocUI32(ct + e), i = this.getDataBlock(r.data), o = r.pointer;
|
|
591
|
+
for (let l = 0; l < t.length; l++)
|
|
592
|
+
i instanceof Int32Array || i instanceof Uint32Array ? Atomics.store(i, l, t[l]) : i[l] = t[l];
|
|
593
|
+
let a, n = !1;
|
|
594
|
+
for (; !n; )
|
|
595
|
+
a = O(this.firstBlock.data, 1), n = H(this.firstBlock.data, 1, o, a);
|
|
707
596
|
if (a) {
|
|
708
|
-
let { bufferPosition:
|
|
709
|
-
|
|
597
|
+
let { bufferPosition: l, bufferByteOffset: h } = y(a), $ = new Uint32Array(this.memory.buffers[l].buf, h, 1);
|
|
598
|
+
U($, 0, o);
|
|
710
599
|
} else
|
|
711
|
-
|
|
712
|
-
Atomics.add(this.firstBlock.data,
|
|
600
|
+
U(this.firstBlock.data, 0, o);
|
|
601
|
+
Atomics.add(this.firstBlock.data, A, 1);
|
|
713
602
|
}
|
|
714
603
|
deleteMatch(t) {
|
|
715
|
-
for (let { data: e, index: r, deleteCurrent:
|
|
604
|
+
for (let { data: e, index: r, deleteCurrent: i } of this)
|
|
716
605
|
if (t(e, r))
|
|
717
|
-
return
|
|
606
|
+
return i(), !0;
|
|
718
607
|
return !1;
|
|
719
608
|
}
|
|
720
609
|
deleteIndex(t) {
|
|
@@ -735,37 +624,37 @@ class u {
|
|
|
735
624
|
for (; !r; ) {
|
|
736
625
|
if (t = O(this.firstBlock.data, 0), e = O(this.firstBlock.data, 1), !e)
|
|
737
626
|
return;
|
|
738
|
-
r =
|
|
627
|
+
r = H(this.firstBlock.data, 1, 0, e);
|
|
739
628
|
}
|
|
740
629
|
if (!t)
|
|
741
630
|
return;
|
|
742
|
-
|
|
743
|
-
let
|
|
631
|
+
H(this.firstBlock.data, 0, 0, t);
|
|
632
|
+
let i = 0, o = t;
|
|
744
633
|
for (; o; ) {
|
|
745
|
-
let { bufferPosition: a, bufferByteOffset:
|
|
746
|
-
if (!
|
|
634
|
+
let { bufferPosition: a, bufferByteOffset: n } = y(o), l = this.memory.buffers[a];
|
|
635
|
+
if (!l)
|
|
747
636
|
break;
|
|
748
|
-
let
|
|
749
|
-
o = O(
|
|
637
|
+
let h = new Uint32Array(l.buf, n, 2);
|
|
638
|
+
o = O(h, 0), i++, this.onDelete && this.onDelete(this.getDataBlock(h)), l.free(h.byteOffset);
|
|
750
639
|
}
|
|
751
|
-
Atomics.sub(this.firstBlock.data,
|
|
640
|
+
Atomics.sub(this.firstBlock.data, A, i);
|
|
752
641
|
}
|
|
753
642
|
*[Symbol.iterator]() {
|
|
754
|
-
let t = 0, { bufferPosition: e, bufferByteOffset: r } = c(this.firstBlock.data, 0),
|
|
643
|
+
let t = 0, { bufferPosition: e, bufferByteOffset: r } = c(this.firstBlock.data, 0), i = this.firstBlock.data, o = 0, a = 0;
|
|
755
644
|
for (; r; ) {
|
|
756
|
-
let
|
|
757
|
-
if (!
|
|
645
|
+
let n = this.memory.buffers[e];
|
|
646
|
+
if (!n)
|
|
758
647
|
return;
|
|
759
|
-
let
|
|
760
|
-
({ bufferPosition: e, bufferByteOffset: r } = c(
|
|
761
|
-
let
|
|
648
|
+
let l = new Uint32Array(n.buf, r, 2), h = this.getDataBlock(l), $ = e, zt = r;
|
|
649
|
+
({ bufferPosition: e, bufferByteOffset: r } = c(l, 0));
|
|
650
|
+
let Q = !0;
|
|
762
651
|
yield {
|
|
763
|
-
data:
|
|
652
|
+
data: h,
|
|
764
653
|
index: t,
|
|
765
654
|
deleteCurrent: () => {
|
|
766
|
-
k(
|
|
655
|
+
k(i, 0, e, r), r || k(this.firstBlock.data, 1, o, a), this.onDelete && this.onDelete(this.getDataBlock(l)), n.free(l.byteOffset), Atomics.sub(this.firstBlock.data, A, 1), Q = !1;
|
|
767
656
|
}
|
|
768
|
-
},
|
|
657
|
+
}, Q && (i = l, o = $, a = zt, t++);
|
|
769
658
|
}
|
|
770
659
|
}
|
|
771
660
|
forEach(t) {
|
|
@@ -778,7 +667,7 @@ class u {
|
|
|
778
667
|
};
|
|
779
668
|
}
|
|
780
669
|
getDataBlock(t) {
|
|
781
|
-
const e = t.byteOffset +
|
|
670
|
+
const e = t.byteOffset + ct * t.BYTES_PER_ELEMENT;
|
|
782
671
|
switch (this.type) {
|
|
783
672
|
case 1:
|
|
784
673
|
return new Int32Array(t.buffer, e, this.dataLength);
|
|
@@ -793,7 +682,7 @@ class u {
|
|
|
793
682
|
free() {
|
|
794
683
|
let { bufferPosition: t, bufferByteOffset: e } = c(this.firstBlock.data, 0);
|
|
795
684
|
for (; e; ) {
|
|
796
|
-
let r = new
|
|
685
|
+
let r = new f(this.memory, {
|
|
797
686
|
bufferPosition: t,
|
|
798
687
|
bufferByteOffset: e
|
|
799
688
|
});
|
|
@@ -802,15 +691,15 @@ class u {
|
|
|
802
691
|
this.firstBlock.free();
|
|
803
692
|
}
|
|
804
693
|
}
|
|
805
|
-
const
|
|
806
|
-
class
|
|
694
|
+
const ut = 10;
|
|
695
|
+
class wt {
|
|
807
696
|
static ALLOCATE_COUNT = 4;
|
|
808
697
|
memory;
|
|
809
698
|
// Memory order: Pointer, Lock, Length, MaxHash
|
|
810
699
|
pointerMemory;
|
|
811
700
|
lock;
|
|
812
701
|
get hashMemory() {
|
|
813
|
-
return new
|
|
702
|
+
return new f(this.memory, c(this.pointerMemory.data, 0));
|
|
814
703
|
}
|
|
815
704
|
get length() {
|
|
816
705
|
return Atomics.load(this.pointerMemory.data, 2);
|
|
@@ -820,51 +709,51 @@ class Ot {
|
|
|
820
709
|
}
|
|
821
710
|
constructor(t, e) {
|
|
822
711
|
if (this.memory = t, e)
|
|
823
|
-
this.pointerMemory = new
|
|
712
|
+
this.pointerMemory = new f(t, e.firstBlock);
|
|
824
713
|
else {
|
|
825
|
-
this.pointerMemory = t.allocUI32(
|
|
826
|
-
let r = t.allocUI32(
|
|
827
|
-
k(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3,
|
|
714
|
+
this.pointerMemory = t.allocUI32(wt.ALLOCATE_COUNT);
|
|
715
|
+
let r = t.allocUI32(ut);
|
|
716
|
+
k(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, ut);
|
|
828
717
|
}
|
|
829
718
|
this.lock = new Int32Array(this.pointerMemory.data.buffer, this.pointerMemory.bufferByteOffset + Uint32Array.BYTES_PER_ELEMENT, 1);
|
|
830
719
|
}
|
|
831
720
|
set(t, e) {
|
|
832
721
|
this.length >= this.maxHash * 2 && this.growHashTable();
|
|
833
|
-
let r =
|
|
722
|
+
let r = M(t);
|
|
834
723
|
this.setHashKey(this.hashMemory, this.maxHash, r, e) && Atomics.add(this.pointerMemory.data, 2, 1);
|
|
835
724
|
}
|
|
836
|
-
setHashKey(t, e, r,
|
|
837
|
-
let o = this.hash(r, e), a,
|
|
838
|
-
if (
|
|
725
|
+
setHashKey(t, e, r, i) {
|
|
726
|
+
let o = this.hash(r, e), a, n = c(t.data, o);
|
|
727
|
+
if (n.bufferByteOffset === 0) {
|
|
839
728
|
a = new u(this.memory, {
|
|
840
729
|
dataLength: 2
|
|
841
730
|
});
|
|
842
|
-
let
|
|
843
|
-
k(t.data, o,
|
|
731
|
+
let h = a.getSharedMemory();
|
|
732
|
+
k(t.data, o, h.firstBlock.bufferPosition, h.firstBlock.bufferByteOffset);
|
|
844
733
|
} else
|
|
845
734
|
a = new u(this.memory, {
|
|
846
|
-
firstBlock:
|
|
735
|
+
firstBlock: n
|
|
847
736
|
});
|
|
848
|
-
let
|
|
849
|
-
return a.deleteValue(r) && (
|
|
737
|
+
let l = !0;
|
|
738
|
+
return a.deleteValue(r) && (l = !1), a.insert([r, i]), l;
|
|
850
739
|
}
|
|
851
740
|
get(t) {
|
|
852
|
-
let e =
|
|
853
|
-
if (
|
|
741
|
+
let e = M(t), r = this.hash(e, this.maxHash), i = c(this.hashMemory.data, r);
|
|
742
|
+
if (i.bufferByteOffset === 0)
|
|
854
743
|
return;
|
|
855
744
|
let o = new u(this.memory, {
|
|
856
|
-
firstBlock:
|
|
745
|
+
firstBlock: i
|
|
857
746
|
});
|
|
858
747
|
for (let { data: a } of o)
|
|
859
748
|
if (a[0] === e)
|
|
860
749
|
return a[1];
|
|
861
750
|
}
|
|
862
751
|
has(t) {
|
|
863
|
-
let e =
|
|
864
|
-
if (
|
|
752
|
+
let e = M(t), r = this.hash(e, this.maxHash), i = c(this.hashMemory.data, r);
|
|
753
|
+
if (i.bufferByteOffset === 0)
|
|
865
754
|
return !1;
|
|
866
755
|
let o = new u(this.memory, {
|
|
867
|
-
firstBlock:
|
|
756
|
+
firstBlock: i
|
|
868
757
|
});
|
|
869
758
|
for (let { data: a } of o)
|
|
870
759
|
if (a[0] === e)
|
|
@@ -872,30 +761,31 @@ class Ot {
|
|
|
872
761
|
return !1;
|
|
873
762
|
}
|
|
874
763
|
delete(t) {
|
|
875
|
-
let e =
|
|
876
|
-
if (
|
|
764
|
+
let e = M(t), r = this.hash(e, this.maxHash), i = c(this.hashMemory.data, r);
|
|
765
|
+
if (i.bufferByteOffset === 0)
|
|
877
766
|
return !1;
|
|
878
767
|
let o = new u(this.memory, {
|
|
879
|
-
firstBlock:
|
|
768
|
+
firstBlock: i
|
|
880
769
|
});
|
|
881
|
-
for (let { data: a, deleteCurrent:
|
|
770
|
+
for (let { data: a, deleteCurrent: n } of o)
|
|
882
771
|
if (a[0] === e)
|
|
883
|
-
return
|
|
772
|
+
return n(), Atomics.sub(this.pointerMemory.data, 2, 1), !0;
|
|
884
773
|
return !1;
|
|
885
774
|
}
|
|
886
775
|
growHashTable() {
|
|
887
|
-
let t = this.maxHash, e = t * 2, r = this.memory.allocUI32(e),
|
|
776
|
+
let t = this.maxHash, e = t * 2, r = this.memory.allocUI32(e), i = this.hashMemory;
|
|
888
777
|
for (let o = 0; o < t; o++) {
|
|
889
|
-
let a = c(
|
|
778
|
+
let a = c(i.data, o);
|
|
890
779
|
if (a.bufferByteOffset === 0)
|
|
891
780
|
continue;
|
|
892
|
-
let
|
|
781
|
+
let n = new u(this.memory, {
|
|
893
782
|
firstBlock: a
|
|
894
783
|
});
|
|
895
|
-
for (let { data:
|
|
896
|
-
this.setHashKey(r, e,
|
|
784
|
+
for (let { data: l } of n)
|
|
785
|
+
this.setHashKey(r, e, l[0], l[1]);
|
|
786
|
+
n.free();
|
|
897
787
|
}
|
|
898
|
-
k(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, e);
|
|
788
|
+
k(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, e), i.free();
|
|
899
789
|
}
|
|
900
790
|
hash(t, e) {
|
|
901
791
|
return t % e;
|
|
@@ -917,24 +807,24 @@ class Ot {
|
|
|
917
807
|
};
|
|
918
808
|
}
|
|
919
809
|
}
|
|
920
|
-
function
|
|
921
|
-
return typeof
|
|
810
|
+
function M(s) {
|
|
811
|
+
return typeof s == "number" ? s : typeof s == "string" ? vt(s) : s;
|
|
922
812
|
}
|
|
923
|
-
function
|
|
924
|
-
let t =
|
|
813
|
+
function vt(s) {
|
|
814
|
+
let t = s.length, e = 17 ^ t, r = 0, i;
|
|
925
815
|
for (; t >= 4; )
|
|
926
|
-
|
|
816
|
+
i = s.charCodeAt(r) & 255 | (s.charCodeAt(++r) & 255) << 8 | (s.charCodeAt(++r) & 255) << 16 | (s.charCodeAt(++r) & 255) << 14, i = (i & 65535) * 1540483477 + (((i >>> 16) * 1540483477 & 65535) << 16), i ^= i >>> 14, i = (i & 65535) * 1540483477 + (((i >>> 16) * 1540483477 & 65535) << 16), e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16) ^ i, t -= 4, ++r;
|
|
927
817
|
switch (t) {
|
|
928
818
|
case 3:
|
|
929
|
-
e ^= (
|
|
819
|
+
e ^= (s.charCodeAt(r + 2) & 255) << 16;
|
|
930
820
|
case 2:
|
|
931
|
-
e ^= (
|
|
821
|
+
e ^= (s.charCodeAt(r + 1) & 255) << 8;
|
|
932
822
|
case 1:
|
|
933
|
-
e ^=
|
|
823
|
+
e ^= s.charCodeAt(r) & 255, e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16);
|
|
934
824
|
}
|
|
935
825
|
return e ^= e >>> 13, e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16), e ^= e >>> 15, e = e >>> 0, e;
|
|
936
826
|
}
|
|
937
|
-
class
|
|
827
|
+
class se {
|
|
938
828
|
memory;
|
|
939
829
|
list;
|
|
940
830
|
constructor(t, e) {
|
|
@@ -952,9 +842,9 @@ class Be {
|
|
|
952
842
|
*[Symbol.iterator]() {
|
|
953
843
|
let t = this.list[Symbol.iterator]();
|
|
954
844
|
for (let { data: e } of t) {
|
|
955
|
-
let { bufferPosition: r, bufferByteOffset:
|
|
845
|
+
let { bufferPosition: r, bufferByteOffset: i } = c(e, 0), o = new f(this.memory, {
|
|
956
846
|
bufferPosition: r,
|
|
957
|
-
bufferByteOffset:
|
|
847
|
+
bufferByteOffset: i
|
|
958
848
|
});
|
|
959
849
|
yield this.createItem(o);
|
|
960
850
|
}
|
|
@@ -977,11 +867,11 @@ class Be {
|
|
|
977
867
|
this.list.free();
|
|
978
868
|
}
|
|
979
869
|
}
|
|
980
|
-
const
|
|
870
|
+
const dt = {
|
|
981
871
|
1: Uint8Array,
|
|
982
872
|
2: Uint16Array
|
|
983
|
-
},
|
|
984
|
-
class
|
|
873
|
+
}, N = 0, yt = 1, mt = 2, Bt = 3;
|
|
874
|
+
class Lt {
|
|
985
875
|
static ALLOCATE_COUNT = 4;
|
|
986
876
|
memory;
|
|
987
877
|
allocatedMemory;
|
|
@@ -989,11 +879,11 @@ class Mt {
|
|
|
989
879
|
cachedPointer;
|
|
990
880
|
cachedString;
|
|
991
881
|
constructor(t, e) {
|
|
992
|
-
this.memory = t, typeof e == "string" ? (this.allocatedMemory = this.memory.allocUI32(
|
|
882
|
+
this.memory = t, typeof e == "string" ? (this.allocatedMemory = this.memory.allocUI32(Lt.ALLOCATE_COUNT), this.lock = new Int32Array(this.allocatedMemory.data.buffer, this.allocatedMemory.bufferByteOffset + Bt * this.allocatedMemory.data.BYTES_PER_ELEMENT), this.updateString(e)) : (this.allocatedMemory = new f(t, e), this.lock = new Int32Array(this.allocatedMemory.data.buffer, this.allocatedMemory.bufferByteOffset + Bt * this.allocatedMemory.data.BYTES_PER_ELEMENT), "value" in e && this.updateString(e.value));
|
|
993
883
|
}
|
|
994
884
|
updateString(t) {
|
|
995
885
|
let e = this.createString(t);
|
|
996
|
-
|
|
886
|
+
x(this.lock), U(this.allocatedMemory.data, N, e.pointer), Atomics.store(this.allocatedMemory.data, yt, t.length), Atomics.store(this.allocatedMemory.data, mt, e.charType), b(this.lock), this.cachedPointer = e.pointer, this.cachedString = t;
|
|
997
887
|
}
|
|
998
888
|
createString(t) {
|
|
999
889
|
if (t === "")
|
|
@@ -1002,30 +892,32 @@ class Mt {
|
|
|
1002
892
|
charType: 1
|
|
1003
893
|
/* ASCII */
|
|
1004
894
|
};
|
|
1005
|
-
let e =
|
|
1006
|
-
for (let n = 0; n < t.length; n++)
|
|
1007
|
-
|
|
1008
|
-
|
|
895
|
+
let e = 0;
|
|
896
|
+
for (let n = 0; n < t.length; n++) {
|
|
897
|
+
let l = t.charCodeAt(n);
|
|
898
|
+
l > e && (e = l);
|
|
899
|
+
}
|
|
900
|
+
let r = e > 255 ? 2 : 1, i = dt[r], o = this.memory.allocUI32(Math.ceil(t.length / (4 / i.BYTES_PER_ELEMENT))), a = new i(o.data.buffer, o.data.byteOffset, t.length);
|
|
1009
901
|
for (let n = 0; n < t.length; n++)
|
|
1010
|
-
|
|
902
|
+
a[n] = t.charCodeAt(n);
|
|
1011
903
|
return {
|
|
1012
|
-
pointer:
|
|
1013
|
-
charType:
|
|
904
|
+
pointer: o.pointer,
|
|
905
|
+
charType: r
|
|
1014
906
|
};
|
|
1015
907
|
}
|
|
1016
908
|
get value() {
|
|
1017
|
-
let t = O(this.allocatedMemory.data,
|
|
909
|
+
let t = O(this.allocatedMemory.data, N);
|
|
1018
910
|
if (this.cachedPointer === t && this.cachedString !== void 0)
|
|
1019
911
|
return this.cachedString;
|
|
1020
912
|
if (t === 0)
|
|
1021
913
|
return "";
|
|
1022
|
-
let { bufferPosition: e, bufferByteOffset: r } =
|
|
1023
|
-
|
|
1024
|
-
let
|
|
1025
|
-
return
|
|
914
|
+
let { bufferPosition: e, bufferByteOffset: r } = y(t);
|
|
915
|
+
x(this.lock);
|
|
916
|
+
let i = Atomics.load(this.allocatedMemory.data, mt), o = dt[i], a = Atomics.load(this.allocatedMemory.data, yt), n = new o(this.memory.buffers[e].buf, r, a), l = jt(n);
|
|
917
|
+
return b(this.lock), this.cachedPointer = t, this.cachedString = l, l;
|
|
1026
918
|
}
|
|
1027
919
|
set value(t) {
|
|
1028
|
-
let { bufferPosition: e, bufferByteOffset: r } = c(this.allocatedMemory.data,
|
|
920
|
+
let { bufferPosition: e, bufferByteOffset: r } = c(this.allocatedMemory.data, N);
|
|
1029
921
|
this.updateString(t), r && this.memory.buffers[e].free(r);
|
|
1030
922
|
}
|
|
1031
923
|
getSharedMemory() {
|
|
@@ -1035,11 +927,19 @@ class Mt {
|
|
|
1035
927
|
return this.allocatedMemory.pointer;
|
|
1036
928
|
}
|
|
1037
929
|
free() {
|
|
1038
|
-
let { bufferPosition: t, bufferByteOffset: e } = c(this.allocatedMemory.data,
|
|
930
|
+
let { bufferPosition: t, bufferByteOffset: e } = c(this.allocatedMemory.data, N);
|
|
1039
931
|
e && this.memory.buffers[t].free(e), this.allocatedMemory.free();
|
|
1040
932
|
}
|
|
1041
933
|
}
|
|
1042
|
-
|
|
934
|
+
function jt(s) {
|
|
935
|
+
if (s.length <= 8192)
|
|
936
|
+
return String.fromCharCode.apply(null, s);
|
|
937
|
+
let e = "";
|
|
938
|
+
for (let r = 0; r < s.length; r += 8192)
|
|
939
|
+
e += String.fromCharCode.apply(null, s.subarray(r, r + 8192));
|
|
940
|
+
return e;
|
|
941
|
+
}
|
|
942
|
+
const p = 0, E = 1, bt = 2, kt = 3, gt = 4;
|
|
1043
943
|
class m {
|
|
1044
944
|
static ALLOCATE_COUNT = 4;
|
|
1045
945
|
memory;
|
|
@@ -1047,7 +947,7 @@ class m {
|
|
|
1047
947
|
firstBlock;
|
|
1048
948
|
uint16Array;
|
|
1049
949
|
get length() {
|
|
1050
|
-
return Atomics.load(this.firstBlock.data,
|
|
950
|
+
return Atomics.load(this.firstBlock.data, E);
|
|
1051
951
|
}
|
|
1052
952
|
get type() {
|
|
1053
953
|
return this.uint16Array[0];
|
|
@@ -1062,10 +962,10 @@ class m {
|
|
|
1062
962
|
Atomics.store(this.uint16Array, 1, t);
|
|
1063
963
|
}
|
|
1064
964
|
get bufferLength() {
|
|
1065
|
-
return Atomics.load(this.firstBlock.data,
|
|
965
|
+
return Atomics.load(this.firstBlock.data, bt);
|
|
1066
966
|
}
|
|
1067
967
|
set bufferLength(t) {
|
|
1068
|
-
Atomics.store(this.firstBlock.data,
|
|
968
|
+
Atomics.store(this.firstBlock.data, bt, t);
|
|
1069
969
|
}
|
|
1070
970
|
get pointer() {
|
|
1071
971
|
return this.firstBlock.pointer;
|
|
@@ -1074,19 +974,19 @@ class m {
|
|
|
1074
974
|
cachedPointer;
|
|
1075
975
|
constructor(t, e) {
|
|
1076
976
|
if (this.memory = t, e && "firstBlock" in e) {
|
|
1077
|
-
if (this.firstBlock = new
|
|
1078
|
-
const r = e.bufferLength ??
|
|
1079
|
-
let
|
|
1080
|
-
k(this.firstBlock.data,
|
|
977
|
+
if (this.firstBlock = new f(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + kt * Uint32Array.BYTES_PER_ELEMENT, 2), "type" in e || "dataLength" in e) {
|
|
978
|
+
const r = e.bufferLength ?? gt;
|
|
979
|
+
let i = t.allocUI32(r * (e.dataLength ?? 1));
|
|
980
|
+
k(this.firstBlock.data, p, i.bufferPosition, i.bufferByteOffset), this.bufferLength = r, this.dataLength = e.dataLength ?? 1;
|
|
1081
981
|
}
|
|
1082
982
|
if ("type" in e) {
|
|
1083
983
|
const r = e?.type ?? Uint32Array;
|
|
1084
984
|
r === Uint32Array ? this.type = 0 : r === Int32Array ? this.type = 1 : r === Float32Array && (this.type = 2);
|
|
1085
985
|
}
|
|
1086
986
|
} else {
|
|
1087
|
-
this.firstBlock = t.allocUI32(m.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset +
|
|
1088
|
-
let r = e?.dataLength ?? 1,
|
|
1089
|
-
k(this.firstBlock.data,
|
|
987
|
+
this.firstBlock = t.allocUI32(m.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + kt * Uint32Array.BYTES_PER_ELEMENT, 2);
|
|
988
|
+
let r = e?.dataLength ?? 1, i = e?.bufferLength ?? gt, o = t.allocUI32(i * r);
|
|
989
|
+
k(this.firstBlock.data, p, o.bufferPosition, o.bufferByteOffset), this.bufferLength = i;
|
|
1090
990
|
const a = e?.type ?? Uint32Array;
|
|
1091
991
|
a === Uint32Array ? this.type = 0 : a === Int32Array ? this.type = 1 : a === Float32Array && (this.type = 2), this.dataLength = r;
|
|
1092
992
|
}
|
|
@@ -1111,86 +1011,86 @@ class m {
|
|
|
1111
1011
|
const r = typeof t == "number";
|
|
1112
1012
|
if (!r && t.length > e)
|
|
1113
1013
|
throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
|
|
1114
|
-
let
|
|
1115
|
-
return r ?
|
|
1014
|
+
let i = this.getFullDataBlock(), o = this.length, a = e * o;
|
|
1015
|
+
return r ? i[a] = t : i.set(t, a), Atomics.add(this.firstBlock.data, E, 1) + 1 >= this.bufferLength && this.growBuffer(), o;
|
|
1116
1016
|
}
|
|
1117
1017
|
pop() {
|
|
1118
|
-
let t = Atomics.sub(this.firstBlock.data,
|
|
1018
|
+
let t = Atomics.sub(this.firstBlock.data, E, 1), e = this.getFullDataBlock();
|
|
1119
1019
|
return this.getDataBlock(e, t - 1);
|
|
1120
1020
|
}
|
|
1121
1021
|
// Returns the first number irregardless of dataLength - faster way to pop if you don't care about the rest of the data block
|
|
1122
1022
|
popNumber() {
|
|
1123
|
-
const t = Atomics.sub(this.firstBlock.data,
|
|
1023
|
+
const t = Atomics.sub(this.firstBlock.data, E, 1);
|
|
1124
1024
|
return this.getFullDataBlock()[(t - 1) * this.dataLength];
|
|
1125
1025
|
}
|
|
1126
1026
|
deleteIndex(t) {
|
|
1127
1027
|
let e = this.length;
|
|
1128
1028
|
if (t >= e || t < 0)
|
|
1129
1029
|
throw new Error(`${t} is out of bounds ${e}`);
|
|
1130
|
-
let r = this.dataLength,
|
|
1030
|
+
let r = this.dataLength, i = this.getFullDataBlock();
|
|
1131
1031
|
for (let o = t; o < e; o++)
|
|
1132
1032
|
for (let a = 0; a < r; a++)
|
|
1133
|
-
|
|
1134
|
-
Atomics.sub(this.firstBlock.data,
|
|
1033
|
+
i[o * r + a] = i[(o + 1) * r + a];
|
|
1034
|
+
Atomics.sub(this.firstBlock.data, E, 1);
|
|
1135
1035
|
}
|
|
1136
1036
|
clear() {
|
|
1137
|
-
this.firstBlock.data[
|
|
1037
|
+
this.firstBlock.data[E] = 0;
|
|
1138
1038
|
}
|
|
1139
1039
|
*[Symbol.iterator]() {
|
|
1140
1040
|
let t = this.getFullDataBlock(), e = this.dataLength, r = this.length * e;
|
|
1141
|
-
for (let
|
|
1142
|
-
yield t.subarray(
|
|
1041
|
+
for (let i = 0; i < r; i += e)
|
|
1042
|
+
yield t.subarray(i, i + e);
|
|
1143
1043
|
}
|
|
1144
1044
|
// Significantly faster but won't be thread safe if anything is removing/adding to it during iteration
|
|
1145
1045
|
getCurrentArray() {
|
|
1146
1046
|
return this.getFullDataBlock().subarray(0, this.length * this.dataLength);
|
|
1147
1047
|
}
|
|
1148
1048
|
getFullDataBlock() {
|
|
1149
|
-
let t = Atomics.load(this.firstBlock.data,
|
|
1049
|
+
let t = Atomics.load(this.firstBlock.data, p);
|
|
1150
1050
|
if (this.cachedPointer === t && this.cachedFullDataBlock)
|
|
1151
1051
|
return this.cachedFullDataBlock;
|
|
1152
|
-
let e =
|
|
1052
|
+
let e = y(t), r = new f(this.memory, e), i;
|
|
1153
1053
|
switch (this.type) {
|
|
1154
1054
|
case 1:
|
|
1155
|
-
|
|
1055
|
+
i = new Int32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
|
|
1156
1056
|
break;
|
|
1157
1057
|
case 0:
|
|
1158
|
-
|
|
1058
|
+
i = new Uint32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
|
|
1159
1059
|
break;
|
|
1160
1060
|
case 2:
|
|
1161
|
-
|
|
1061
|
+
i = new Float32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
|
|
1162
1062
|
break;
|
|
1163
1063
|
default:
|
|
1164
1064
|
throw new Error(`Unknown data block type ${this.type}`);
|
|
1165
1065
|
}
|
|
1166
|
-
return this.cachedPointer = t, this.cachedFullDataBlock =
|
|
1066
|
+
return this.cachedPointer = t, this.cachedFullDataBlock = i, i;
|
|
1167
1067
|
}
|
|
1168
1068
|
getDataBlock(t, e) {
|
|
1169
1069
|
const r = e * this.dataLength;
|
|
1170
1070
|
return t.subarray(r, r + this.dataLength);
|
|
1171
1071
|
}
|
|
1172
1072
|
growBuffer() {
|
|
1173
|
-
let e = this.bufferLength * 2, r = this.dataLength,
|
|
1073
|
+
let e = this.bufferLength * 2, r = this.dataLength, i = c(this.firstBlock.data, p), o = new f(this.memory, i), a = this.getFullDataBlock(), n = this.memory.allocUI32(e * r), l;
|
|
1174
1074
|
switch (this.type) {
|
|
1175
1075
|
case 1:
|
|
1176
|
-
|
|
1076
|
+
l = new Int32Array(n.data.buffer, n.bufferByteOffset, r * e);
|
|
1177
1077
|
break;
|
|
1178
1078
|
case 0:
|
|
1179
|
-
|
|
1079
|
+
l = new Uint32Array(n.data.buffer, n.bufferByteOffset, r * e);
|
|
1180
1080
|
break;
|
|
1181
1081
|
case 2:
|
|
1182
|
-
|
|
1082
|
+
l = new Float32Array(n.data.buffer, n.bufferByteOffset, r * e);
|
|
1183
1083
|
break;
|
|
1184
1084
|
default:
|
|
1185
1085
|
throw new Error(`Unknown data block type ${this.type}`);
|
|
1186
1086
|
}
|
|
1187
|
-
|
|
1188
|
-
const
|
|
1189
|
-
|
|
1087
|
+
l.set(a);
|
|
1088
|
+
const h = n.pointer;
|
|
1089
|
+
U(this.firstBlock.data, p, h), this.bufferLength = e, o.free(), this.cachedPointer = h, this.cachedFullDataBlock = l;
|
|
1190
1090
|
}
|
|
1191
1091
|
free() {
|
|
1192
|
-
let t = c(this.firstBlock.data,
|
|
1193
|
-
new
|
|
1092
|
+
let t = c(this.firstBlock.data, p);
|
|
1093
|
+
new f(this.memory, t).free(), this.firstBlock.free();
|
|
1194
1094
|
}
|
|
1195
1095
|
getSharedMemory() {
|
|
1196
1096
|
return {
|
|
@@ -1198,17 +1098,17 @@ class m {
|
|
|
1198
1098
|
};
|
|
1199
1099
|
}
|
|
1200
1100
|
}
|
|
1201
|
-
class
|
|
1101
|
+
class oe {
|
|
1202
1102
|
static ALLOCATE_COUNT = u.ALLOCATE_COUNT;
|
|
1203
1103
|
heap;
|
|
1204
1104
|
list;
|
|
1205
1105
|
cache = /* @__PURE__ */ new Map();
|
|
1206
1106
|
constructor(t, e) {
|
|
1207
1107
|
e ? this.list = new u(t, e) : this.list = new u(t), this.heap = t, this.list.onDelete = (r) => {
|
|
1208
|
-
let
|
|
1209
|
-
if (
|
|
1210
|
-
let o = this.cache.get(
|
|
1211
|
-
o || (o = this.initItem(
|
|
1108
|
+
let i = Atomics.load(r, 0);
|
|
1109
|
+
if (i) {
|
|
1110
|
+
let o = this.cache.get(i);
|
|
1111
|
+
o || (o = this.initItem(i)), o && (o.free(), this.cache.delete(i));
|
|
1212
1112
|
}
|
|
1213
1113
|
};
|
|
1214
1114
|
}
|
|
@@ -1231,11 +1131,11 @@ class me {
|
|
|
1231
1131
|
*[Symbol.iterator]() {
|
|
1232
1132
|
let t = this.list[Symbol.iterator]();
|
|
1233
1133
|
for (let { data: e, deleteCurrent: r } of t) {
|
|
1234
|
-
let
|
|
1235
|
-
if (!
|
|
1134
|
+
let i = Atomics.load(e, 0);
|
|
1135
|
+
if (!i)
|
|
1236
1136
|
continue;
|
|
1237
|
-
let o = this.cache.get(
|
|
1238
|
-
o || (o = this.initItem(
|
|
1137
|
+
let o = this.cache.get(i);
|
|
1138
|
+
o || (o = this.initItem(i), o && this.cache.set(i, o)), o && (yield {
|
|
1239
1139
|
item: o,
|
|
1240
1140
|
deleteCurrent: r
|
|
1241
1141
|
});
|
|
@@ -1269,8 +1169,8 @@ class me {
|
|
|
1269
1169
|
this.list.free(), this.cache.clear();
|
|
1270
1170
|
}
|
|
1271
1171
|
}
|
|
1272
|
-
const
|
|
1273
|
-
class
|
|
1172
|
+
const P = 0, At = 1, pt = 2, v = 3, Et = v + m.ALLOCATE_COUNT;
|
|
1173
|
+
class St {
|
|
1274
1174
|
static ALLOCATE_COUNT = 3 + m.ALLOCATE_COUNT * 2;
|
|
1275
1175
|
memory;
|
|
1276
1176
|
// Current Length, Type/DataLength, MaxChunkLength, Pointer vector, Recycle vector
|
|
@@ -1280,13 +1180,13 @@ class Ct {
|
|
|
1280
1180
|
recycleVector;
|
|
1281
1181
|
cachedFullDataBlock = {};
|
|
1282
1182
|
get length() {
|
|
1283
|
-
return Atomics.load(this.firstBlock.data,
|
|
1183
|
+
return Atomics.load(this.firstBlock.data, P) - this.recycleVector.length;
|
|
1284
1184
|
}
|
|
1285
1185
|
get maxChunkSize() {
|
|
1286
|
-
return this.firstBlock.data[
|
|
1186
|
+
return this.firstBlock.data[pt];
|
|
1287
1187
|
}
|
|
1288
1188
|
set maxChunkSize(t) {
|
|
1289
|
-
Atomics.store(this.firstBlock.data,
|
|
1189
|
+
Atomics.store(this.firstBlock.data, pt, t);
|
|
1290
1190
|
}
|
|
1291
1191
|
get type() {
|
|
1292
1192
|
return this.uint16Array[0];
|
|
@@ -1311,37 +1211,37 @@ class Ct {
|
|
|
1311
1211
|
}
|
|
1312
1212
|
constructor(t, e) {
|
|
1313
1213
|
if (this.memory = t, e && "firstBlock" in e)
|
|
1314
|
-
this.firstBlock = new
|
|
1214
|
+
this.firstBlock = new f(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + At * Uint32Array.BYTES_PER_ELEMENT, 2), this.pointerVector = new m(t, {
|
|
1315
1215
|
firstBlock: {
|
|
1316
1216
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1317
|
-
bufferByteOffset: this.firstBlock.bufferByteOffset +
|
|
1217
|
+
bufferByteOffset: this.firstBlock.bufferByteOffset + v * Uint32Array.BYTES_PER_ELEMENT
|
|
1318
1218
|
}
|
|
1319
1219
|
}), this.recycleVector = new m(t, {
|
|
1320
1220
|
firstBlock: {
|
|
1321
1221
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1322
|
-
bufferByteOffset: this.firstBlock.bufferByteOffset +
|
|
1222
|
+
bufferByteOffset: this.firstBlock.bufferByteOffset + Et * Uint32Array.BYTES_PER_ELEMENT
|
|
1323
1223
|
}
|
|
1324
1224
|
});
|
|
1325
1225
|
else {
|
|
1326
|
-
this.firstBlock = t.allocUI32(
|
|
1327
|
-
let r = e?.dataLength ?? 1,
|
|
1226
|
+
this.firstBlock = t.allocUI32(St.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + At * Uint32Array.BYTES_PER_ELEMENT, 2);
|
|
1227
|
+
let r = e?.dataLength ?? 1, i = e?.maxChunkSize ?? 100;
|
|
1328
1228
|
this.pointerVector = new m(t, {
|
|
1329
1229
|
type: Uint32Array,
|
|
1330
1230
|
firstBlock: {
|
|
1331
1231
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1332
|
-
bufferByteOffset: this.firstBlock.bufferByteOffset +
|
|
1232
|
+
bufferByteOffset: this.firstBlock.bufferByteOffset + v * Uint32Array.BYTES_PER_ELEMENT
|
|
1333
1233
|
}
|
|
1334
1234
|
}), this.recycleVector = new m(t, {
|
|
1335
1235
|
type: Uint32Array,
|
|
1336
1236
|
firstBlock: {
|
|
1337
1237
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1338
|
-
bufferByteOffset: this.firstBlock.bufferByteOffset +
|
|
1238
|
+
bufferByteOffset: this.firstBlock.bufferByteOffset + Et * Uint32Array.BYTES_PER_ELEMENT
|
|
1339
1239
|
},
|
|
1340
1240
|
bufferLength: e?.recycleBufferLength
|
|
1341
1241
|
});
|
|
1342
1242
|
const o = e?.type ?? Uint32Array;
|
|
1343
|
-
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 =
|
|
1344
|
-
let a = t.allocUI32(
|
|
1243
|
+
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 = i;
|
|
1244
|
+
let a = t.allocUI32(i * r * this.byteMultipler);
|
|
1345
1245
|
this.pointerVector.push(a.pointer);
|
|
1346
1246
|
}
|
|
1347
1247
|
}
|
|
@@ -1361,25 +1261,25 @@ class Ct {
|
|
|
1361
1261
|
if (t.length > e)
|
|
1362
1262
|
throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
|
|
1363
1263
|
let r;
|
|
1364
|
-
this.recycleVector.length ? r = this.recycleVector.popNumber() : r = Atomics.add(this.firstBlock.data,
|
|
1365
|
-
let
|
|
1366
|
-
return
|
|
1264
|
+
this.recycleVector.length ? r = this.recycleVector.popNumber() : r = Atomics.add(this.firstBlock.data, P, 1);
|
|
1265
|
+
let i = this.getFullDataBlock(r), o = r % this.maxChunkSize;
|
|
1266
|
+
return i.set(t, e * o), r;
|
|
1367
1267
|
}
|
|
1368
1268
|
deleteIndex(t) {
|
|
1369
1269
|
this.recycleVector.push(t);
|
|
1370
1270
|
}
|
|
1371
1271
|
clear() {
|
|
1372
|
-
this.firstBlock.data[
|
|
1272
|
+
this.firstBlock.data[P] = 0, this.recycleVector.clear();
|
|
1373
1273
|
}
|
|
1374
1274
|
*[Symbol.iterator]() {
|
|
1375
1275
|
const t = {};
|
|
1376
|
-
for (let
|
|
1377
|
-
t[
|
|
1276
|
+
for (let i of this.recycleVector)
|
|
1277
|
+
t[i[0]] = !0;
|
|
1378
1278
|
let e = this.getFullDataBlock(0), r = 0;
|
|
1379
|
-
for (let
|
|
1380
|
-
if (!t[
|
|
1381
|
-
let o = Math.floor(
|
|
1382
|
-
o !== r && (e = this.getFullDataBlock(
|
|
1279
|
+
for (let i = 0; i < Atomics.load(this.firstBlock.data, P); i++)
|
|
1280
|
+
if (!t[i]) {
|
|
1281
|
+
let o = Math.floor(i / this.maxChunkSize);
|
|
1282
|
+
o !== r && (e = this.getFullDataBlock(i), r = o), yield this.getDataBlock(e, i % this.maxChunkSize);
|
|
1383
1283
|
}
|
|
1384
1284
|
}
|
|
1385
1285
|
getFullDataBlock(t) {
|
|
@@ -1390,19 +1290,19 @@ class Ct {
|
|
|
1390
1290
|
let a = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
|
|
1391
1291
|
this.pointerVector.push(a.pointer);
|
|
1392
1292
|
}
|
|
1393
|
-
let
|
|
1293
|
+
let i = new f(this.memory, y(this.pointerVector.get(e))), o;
|
|
1394
1294
|
switch (this.type) {
|
|
1395
1295
|
case 1:
|
|
1396
|
-
o = new Int32Array(
|
|
1296
|
+
o = new Int32Array(i.data.buffer, i.bufferByteOffset, this.dataLength * this.maxChunkSize);
|
|
1397
1297
|
break;
|
|
1398
1298
|
case 0:
|
|
1399
|
-
o = new Uint32Array(
|
|
1299
|
+
o = new Uint32Array(i.data.buffer, i.bufferByteOffset, this.dataLength * this.maxChunkSize);
|
|
1400
1300
|
break;
|
|
1401
1301
|
case 2:
|
|
1402
|
-
o = new Float32Array(
|
|
1302
|
+
o = new Float32Array(i.data.buffer, i.bufferByteOffset, this.dataLength * this.maxChunkSize);
|
|
1403
1303
|
break;
|
|
1404
1304
|
case 3:
|
|
1405
|
-
o = new Float64Array(
|
|
1305
|
+
o = new Float64Array(i.data.buffer, i.bufferByteOffset, this.dataLength * this.maxChunkSize);
|
|
1406
1306
|
break;
|
|
1407
1307
|
default:
|
|
1408
1308
|
throw new Error(`Unknown data block type ${this.type}`);
|
|
@@ -1417,7 +1317,7 @@ class Ct {
|
|
|
1417
1317
|
this.recycleVector.free();
|
|
1418
1318
|
for (let t of this.pointerVector) {
|
|
1419
1319
|
let e = t[0];
|
|
1420
|
-
new
|
|
1320
|
+
new f(this.memory, y(e)).free();
|
|
1421
1321
|
}
|
|
1422
1322
|
this.pointerVector.free(), this.firstBlock.free();
|
|
1423
1323
|
}
|
|
@@ -1427,7 +1327,7 @@ class Ct {
|
|
|
1427
1327
|
};
|
|
1428
1328
|
}
|
|
1429
1329
|
}
|
|
1430
|
-
class
|
|
1330
|
+
class ae {
|
|
1431
1331
|
memory;
|
|
1432
1332
|
pointers = [];
|
|
1433
1333
|
recycledIndexes = [];
|
|
@@ -1445,9 +1345,9 @@ class be {
|
|
|
1445
1345
|
}
|
|
1446
1346
|
constructor(t, e) {
|
|
1447
1347
|
this.memory = t;
|
|
1448
|
-
const r = e?.dataLength ?? 1,
|
|
1449
|
-
this.dataLength = r, this.maxChunkSize =
|
|
1450
|
-
let o = t.allocUI32(
|
|
1348
|
+
const r = e?.dataLength ?? 1, i = e?.maxChunkSize ?? 100;
|
|
1349
|
+
this.dataLength = r, this.maxChunkSize = i, this.typeConstructor = e.type, this.typeConstructor === Float64Array && (this.byteMultipler = 2);
|
|
1350
|
+
let o = t.allocUI32(i * r * this.byteMultipler);
|
|
1451
1351
|
this.pointers.push(o.pointer);
|
|
1452
1352
|
let a = new this.typeConstructor(o.data.buffer, o.bufferByteOffset, this.dataLength * this.maxChunkSize);
|
|
1453
1353
|
this.fullDataBlocks[0] = a;
|
|
@@ -1468,15 +1368,15 @@ class be {
|
|
|
1468
1368
|
throw new Error(`Can't insert ${t.length} array into shared list of ${this.dataLength} dataLength`);
|
|
1469
1369
|
let r = this.recycledIndexes.pop();
|
|
1470
1370
|
r === void 0 && (r = this.totalLength++);
|
|
1471
|
-
let
|
|
1472
|
-
if (
|
|
1473
|
-
let
|
|
1474
|
-
this.pointers.push(
|
|
1475
|
-
let
|
|
1476
|
-
this.fullDataBlocks[
|
|
1371
|
+
let i = Math.floor(r / this.maxChunkSize);
|
|
1372
|
+
if (i >= this.pointers.length) {
|
|
1373
|
+
let l = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
|
|
1374
|
+
this.pointers.push(l.pointer);
|
|
1375
|
+
let h = new this.typeConstructor(l.data.buffer, l.bufferByteOffset, this.dataLength * this.maxChunkSize);
|
|
1376
|
+
this.fullDataBlocks[i] = h;
|
|
1477
1377
|
}
|
|
1478
|
-
let o = this.fullDataBlocks[
|
|
1479
|
-
return e ? o[
|
|
1378
|
+
let o = this.fullDataBlocks[i], a = r % this.maxChunkSize, n = this.dataLength * a;
|
|
1379
|
+
return e ? o[n] = t : o.set(t, n), r;
|
|
1480
1380
|
}
|
|
1481
1381
|
deleteIndex(t) {
|
|
1482
1382
|
this.recycledIndexes.push(t);
|
|
@@ -1486,13 +1386,13 @@ class be {
|
|
|
1486
1386
|
}
|
|
1487
1387
|
*[Symbol.iterator]() {
|
|
1488
1388
|
const t = {};
|
|
1489
|
-
for (let
|
|
1490
|
-
t[
|
|
1389
|
+
for (let i of this.recycledIndexes)
|
|
1390
|
+
t[i] = !0;
|
|
1491
1391
|
let e = this.getFullDataBlock(0), r = 0;
|
|
1492
|
-
for (let
|
|
1493
|
-
if (!t[
|
|
1494
|
-
let o = Math.floor(
|
|
1495
|
-
o !== r && (e = this.getFullDataBlock(
|
|
1392
|
+
for (let i = 0; i < this.totalLength; i++)
|
|
1393
|
+
if (!t[i]) {
|
|
1394
|
+
let o = Math.floor(i / this.maxChunkSize);
|
|
1395
|
+
o !== r && (e = this.getFullDataBlock(i), r = o), yield this.getDataBlock(e, i % this.maxChunkSize);
|
|
1496
1396
|
}
|
|
1497
1397
|
}
|
|
1498
1398
|
getFullDataBlock(t) {
|
|
@@ -1503,7 +1403,7 @@ class be {
|
|
|
1503
1403
|
let a = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
|
|
1504
1404
|
this.pointers.push(a.pointer);
|
|
1505
1405
|
}
|
|
1506
|
-
let
|
|
1406
|
+
let i = new f(this.memory, y(this.pointers[e])), o = new this.typeConstructor(i.data.buffer, i.bufferByteOffset, this.dataLength * this.maxChunkSize);
|
|
1507
1407
|
return this.fullDataBlocks[e] = o, o;
|
|
1508
1408
|
}
|
|
1509
1409
|
getDataBlock(t, e) {
|
|
@@ -1512,163 +1412,167 @@ class be {
|
|
|
1512
1412
|
}
|
|
1513
1413
|
free() {
|
|
1514
1414
|
for (let t of this.pointers)
|
|
1515
|
-
new
|
|
1415
|
+
new f(this.memory, y(t)).free();
|
|
1516
1416
|
this.pointers = [], this.recycledIndexes = [], this.totalLength = 0, this.fullDataBlocks = {};
|
|
1517
1417
|
}
|
|
1518
1418
|
}
|
|
1519
|
-
const
|
|
1520
|
-
function
|
|
1521
|
-
return
|
|
1419
|
+
const Tt = new ArrayBuffer(4), Ot = new Uint32Array(Tt), F = new Uint16Array(Tt);
|
|
1420
|
+
function ne(s, t) {
|
|
1421
|
+
return qt(Atomics.load(s, t));
|
|
1522
1422
|
}
|
|
1523
|
-
function
|
|
1524
|
-
Atomics.store(
|
|
1423
|
+
function le(s, t, e, r) {
|
|
1424
|
+
Atomics.store(s, t, Jt(e, r));
|
|
1525
1425
|
}
|
|
1526
|
-
function
|
|
1527
|
-
return
|
|
1426
|
+
function qt(s) {
|
|
1427
|
+
return Ot[0] = s, [F[0], F[1]];
|
|
1528
1428
|
}
|
|
1529
|
-
function
|
|
1530
|
-
return
|
|
1429
|
+
function Jt(s, t) {
|
|
1430
|
+
return F[0] = s, F[1] = t, Ot[0];
|
|
1531
1431
|
}
|
|
1532
|
-
const
|
|
1533
|
-
function
|
|
1534
|
-
return
|
|
1432
|
+
const _t = new ArrayBuffer(8), Ct = new BigUint64Array(_t), B = new Uint16Array(_t);
|
|
1433
|
+
function fe(s, t) {
|
|
1434
|
+
return Ct[0] = Atomics.load(s, t), [B[0], B[1], B[2], B[3]];
|
|
1535
1435
|
}
|
|
1536
|
-
function
|
|
1537
|
-
|
|
1436
|
+
function he(s, t, e, r, i, o = 0) {
|
|
1437
|
+
B[0] = e, B[1] = r, B[2] = i, B[3] = o, Atomics.store(s, t, Ct[0]);
|
|
1538
1438
|
}
|
|
1539
|
-
const
|
|
1540
|
-
function
|
|
1541
|
-
return
|
|
1439
|
+
const It = new ArrayBuffer(4), Mt = new Float32Array(It), Nt = new Int32Array(It);
|
|
1440
|
+
function Pt(s, t) {
|
|
1441
|
+
return s instanceof Float32Array && (s = new Int32Array(s.buffer, s.byteOffset, s.length)), q(Atomics.load(s, t));
|
|
1542
1442
|
}
|
|
1543
|
-
function
|
|
1544
|
-
|
|
1443
|
+
function ce(s, t, e) {
|
|
1444
|
+
s instanceof Float32Array && (s = new Int32Array(s.buffer, s.byteOffset, s.length)), Atomics.store(s, t, z(e));
|
|
1545
1445
|
}
|
|
1546
|
-
function
|
|
1547
|
-
return
|
|
1446
|
+
function q(s) {
|
|
1447
|
+
return Nt[0] = s, Mt[0];
|
|
1548
1448
|
}
|
|
1549
|
-
function
|
|
1550
|
-
return
|
|
1449
|
+
function z(s) {
|
|
1450
|
+
return Mt[0] = s, Nt[0];
|
|
1551
1451
|
}
|
|
1552
|
-
function
|
|
1553
|
-
return
|
|
1452
|
+
function ue(s, t, e) {
|
|
1453
|
+
return s instanceof Float32Array && (s = new Int32Array(s.buffer, s.byteOffset, s.length)), q(Atomics.exchange(s, t, z(e)));
|
|
1554
1454
|
}
|
|
1555
|
-
function
|
|
1556
|
-
return
|
|
1455
|
+
function Ut(s, t, e, r) {
|
|
1456
|
+
return s instanceof Float32Array && (s = new Int32Array(s.buffer, s.byteOffset, s.length)), q(Atomics.compareExchange(s, t, z(e), z(r)));
|
|
1557
1457
|
}
|
|
1558
|
-
function
|
|
1559
|
-
let
|
|
1458
|
+
function de(s, t, e, r) {
|
|
1459
|
+
let i, o;
|
|
1560
1460
|
do
|
|
1561
|
-
|
|
1562
|
-
while (Atomics.compareExchange(
|
|
1461
|
+
i = Atomics.load(s, t), o = Math.min(i + e, r);
|
|
1462
|
+
while (Atomics.compareExchange(s, t, i, o) !== i);
|
|
1463
|
+
return o;
|
|
1563
1464
|
}
|
|
1564
|
-
function
|
|
1565
|
-
let
|
|
1465
|
+
function ye(s, t, e, r) {
|
|
1466
|
+
let i, o;
|
|
1566
1467
|
do
|
|
1567
|
-
|
|
1568
|
-
while (Atomics.compareExchange(
|
|
1468
|
+
i = Atomics.load(s, t), o = Math.max(i - e, r);
|
|
1469
|
+
while (Atomics.compareExchange(s, t, i, o) !== i);
|
|
1470
|
+
return o;
|
|
1569
1471
|
}
|
|
1570
|
-
function
|
|
1571
|
-
let
|
|
1472
|
+
function me(s, t, e, r) {
|
|
1473
|
+
let i, o;
|
|
1572
1474
|
do
|
|
1573
|
-
|
|
1574
|
-
while (
|
|
1475
|
+
i = Pt(s, t), o = Math.min(i + e, r);
|
|
1476
|
+
while (Ut(s, t, i, o) !== i);
|
|
1477
|
+
return o;
|
|
1575
1478
|
}
|
|
1576
|
-
function
|
|
1577
|
-
let
|
|
1479
|
+
function Be(s, t, e, r) {
|
|
1480
|
+
let i, o;
|
|
1578
1481
|
do
|
|
1579
|
-
|
|
1580
|
-
while (
|
|
1482
|
+
i = Pt(s, t), o = Math.max(i - e, r);
|
|
1483
|
+
while (Ut(s, t, i, o) !== i);
|
|
1484
|
+
return o;
|
|
1581
1485
|
}
|
|
1582
|
-
const
|
|
1583
|
-
function
|
|
1584
|
-
return
|
|
1486
|
+
const Dt = new ArrayBuffer(8), xt = new Float64Array(Dt), Ft = new BigInt64Array(Dt);
|
|
1487
|
+
function be(s, t) {
|
|
1488
|
+
return s instanceof Float64Array && (s = new BigInt64Array(s.buffer, s.byteOffset, s.length)), J(Atomics.load(s, t));
|
|
1585
1489
|
}
|
|
1586
|
-
function
|
|
1587
|
-
|
|
1490
|
+
function ke(s, t, e) {
|
|
1491
|
+
s instanceof Float64Array && (s = new BigInt64Array(s.buffer, s.byteOffset, s.length)), Atomics.store(s, t, R(e));
|
|
1588
1492
|
}
|
|
1589
|
-
function
|
|
1590
|
-
return
|
|
1493
|
+
function J(s) {
|
|
1494
|
+
return Ft[0] = s, xt[0];
|
|
1591
1495
|
}
|
|
1592
|
-
function
|
|
1593
|
-
return
|
|
1496
|
+
function R(s) {
|
|
1497
|
+
return xt[0] = s, Ft[0];
|
|
1594
1498
|
}
|
|
1595
|
-
function
|
|
1596
|
-
return
|
|
1499
|
+
function ge(s, t, e) {
|
|
1500
|
+
return s instanceof Float64Array && (s = new BigInt64Array(s.buffer, s.byteOffset, s.length)), J(Atomics.exchange(s, t, R(e)));
|
|
1597
1501
|
}
|
|
1598
|
-
function
|
|
1599
|
-
return
|
|
1502
|
+
function Ae(s, t, e, r) {
|
|
1503
|
+
return s instanceof Float64Array && (s = new BigInt64Array(s.buffer, s.byteOffset, s.length)), J(Atomics.compareExchange(s, t, R(e), R(r)));
|
|
1600
1504
|
}
|
|
1601
|
-
const w = 0,
|
|
1602
|
-
function
|
|
1603
|
-
for (; Atomics.compareExchange(
|
|
1604
|
-
Atomics.wait(
|
|
1605
|
-
Atomics.add(
|
|
1505
|
+
const w = 0, j = 1, S = 2;
|
|
1506
|
+
function pe(s, t = 0) {
|
|
1507
|
+
for (; Atomics.compareExchange(s, t, w, j) === S; )
|
|
1508
|
+
Atomics.wait(s, t, S);
|
|
1509
|
+
Atomics.add(s, t + 1, 1);
|
|
1606
1510
|
}
|
|
1607
|
-
function
|
|
1608
|
-
let e = Atomics.compareExchange(
|
|
1511
|
+
function Ee(s, t = 0) {
|
|
1512
|
+
let e = Atomics.compareExchange(s, t, w, S);
|
|
1609
1513
|
for (; e !== w; )
|
|
1610
|
-
Atomics.wait(
|
|
1514
|
+
Atomics.wait(s, t, e), e = Atomics.compareExchange(s, t, w, S);
|
|
1611
1515
|
}
|
|
1612
|
-
function
|
|
1613
|
-
Atomics.sub(
|
|
1516
|
+
function we(s, t = 0) {
|
|
1517
|
+
Atomics.sub(s, t + 1, 1) - 1 <= 0 && (Atomics.compareExchange(s, t, j, w) !== j && console.warn("We are unlocking when it was not read locked!"), Atomics.notify(s, t));
|
|
1614
1518
|
}
|
|
1615
|
-
function
|
|
1616
|
-
Atomics.compareExchange(
|
|
1519
|
+
function Le(s, t = 0) {
|
|
1520
|
+
Atomics.compareExchange(s, t, S, w) !== S && console.warn("We are unlocking when it was not write locked!"), Atomics.notify(s, t);
|
|
1617
1521
|
}
|
|
1618
|
-
const
|
|
1522
|
+
const Se = 2;
|
|
1619
1523
|
export {
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1524
|
+
f as AllocatedMemory,
|
|
1525
|
+
Qt as BYTE_OFFSET_BIT_COUNT,
|
|
1526
|
+
oe as CachedItemList,
|
|
1527
|
+
ae as LocalPool,
|
|
1528
|
+
tt as MAX_BYTE_OFFSET_LENGTH,
|
|
1529
|
+
et as MAX_POSITION_LENGTH,
|
|
1530
|
+
G as MemoryBuffer,
|
|
1531
|
+
ie as MemoryHeap,
|
|
1532
|
+
te as POSITION_BIT_COUNT,
|
|
1533
|
+
Se as READ_WRITE_LOCK_ALLOCATE_COUNT,
|
|
1534
|
+
re as SIMPLE_LOCK_ALLOCATE_COUNT,
|
|
1631
1535
|
u as SharedList,
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1536
|
+
wt as SharedMap,
|
|
1537
|
+
se as SharedPointerList,
|
|
1538
|
+
St as SharedPool,
|
|
1539
|
+
Lt as SharedString,
|
|
1636
1540
|
m as SharedVector,
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1541
|
+
me as addAtomicFloat32,
|
|
1542
|
+
de as addAtomicInt,
|
|
1543
|
+
Ut as compareExchangeFloat32,
|
|
1544
|
+
Ae as compareExchangeFloat64,
|
|
1545
|
+
Jt as convert16To32,
|
|
1546
|
+
qt as convert32To16,
|
|
1547
|
+
z as convertFloat32ToInt32,
|
|
1548
|
+
R as convertFloat64ToInt64,
|
|
1549
|
+
q as convertInt32ToFloat32,
|
|
1550
|
+
J as convertInt64ToFloat64,
|
|
1647
1551
|
L as createPointer,
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1552
|
+
ue as exchangeFloat32,
|
|
1553
|
+
ge as exchangeFloat64,
|
|
1554
|
+
y as getPointer,
|
|
1555
|
+
ne as load16From32,
|
|
1556
|
+
fe as load16From64,
|
|
1557
|
+
Pt as loadFloat32,
|
|
1558
|
+
be as loadFloat64,
|
|
1655
1559
|
c as loadPointer,
|
|
1656
1560
|
O as loadRawPointer,
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1561
|
+
x as lock,
|
|
1562
|
+
pe as readLock,
|
|
1563
|
+
we as readUnlock,
|
|
1564
|
+
ee as replacePointer,
|
|
1565
|
+
H as replaceRawPointer,
|
|
1566
|
+
le as store16In32,
|
|
1567
|
+
he as store16In64,
|
|
1568
|
+
ce as storeFloat32,
|
|
1569
|
+
ke as storeFloat64,
|
|
1666
1570
|
k as storePointer,
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1571
|
+
U as storeRawPointer,
|
|
1572
|
+
Be as subtractAtomicFloat,
|
|
1573
|
+
ye as subtractAtomicInt,
|
|
1574
|
+
b as unlock,
|
|
1575
|
+
Ee as writeLock,
|
|
1576
|
+
Le as writeUnlock
|
|
1673
1577
|
};
|
|
1674
1578
|
//# sourceMappingURL=shared-memory-objects.js.map
|