@daneren2005/shared-memory-objects 0.0.15 → 0.0.17
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.
|
@@ -12,8 +12,8 @@ function j(i, t = 0, e) {
|
|
|
12
12
|
Atomics.store(i, t, e);
|
|
13
13
|
}
|
|
14
14
|
function ue(i, t, e, r, s, o) {
|
|
15
|
-
let
|
|
16
|
-
return Atomics.compareExchange(i, t,
|
|
15
|
+
let a = T(s, o);
|
|
16
|
+
return Atomics.compareExchange(i, t, a, T(e, r)) === a;
|
|
17
17
|
}
|
|
18
18
|
function H(i, t, e, r) {
|
|
19
19
|
return Atomics.compareExchange(i, t, r, e) === r;
|
|
@@ -103,7 +103,7 @@ function jt(i, ...t) {
|
|
|
103
103
|
const e = Zt[i];
|
|
104
104
|
return new (e || Wt[vt(i)])(...t);
|
|
105
105
|
}
|
|
106
|
-
const st = 0, ot = 1,
|
|
106
|
+
const st = 0, ot = 1, at = 2, nt = 3, ft = 4, k = 5, lt = 6, V = 1, K = 2, ht = 32, G = 0, X = 1, y = 8;
|
|
107
107
|
class Z {
|
|
108
108
|
buf;
|
|
109
109
|
start;
|
|
@@ -161,20 +161,20 @@ class Z {
|
|
|
161
161
|
return 0;
|
|
162
162
|
x(this.lock);
|
|
163
163
|
const e = P(t + y, this.align), r = this.end;
|
|
164
|
-
let s = this.top, o = this._free,
|
|
164
|
+
let s = this.top, o = this._free, a = 0;
|
|
165
165
|
for (; o; ) {
|
|
166
|
-
const f = this.blockSize(o),
|
|
167
|
-
if (
|
|
166
|
+
const f = this.blockSize(o), n = o + f >= s;
|
|
167
|
+
if (n || f >= e) {
|
|
168
168
|
let l = this.mallocTop(
|
|
169
169
|
o,
|
|
170
|
-
|
|
170
|
+
a,
|
|
171
171
|
f,
|
|
172
172
|
e,
|
|
173
|
-
|
|
173
|
+
n
|
|
174
174
|
);
|
|
175
175
|
return A(this.lock), l;
|
|
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;
|
|
@@ -188,8 +188,8 @@ class Z {
|
|
|
188
188
|
if (e ? this.unlinkBlock(e, t) : this._free = this.blockNext(t), this.setBlockNext(t, this._used), this._used = t, o)
|
|
189
189
|
this.top = t + this.setBlockSize(t, s);
|
|
190
190
|
else if (this.doSplit) {
|
|
191
|
-
const
|
|
192
|
-
|
|
191
|
+
const a = r - s;
|
|
192
|
+
a >= this.minSplit && this.splitBlock(t, s, a);
|
|
193
193
|
}
|
|
194
194
|
return _(t);
|
|
195
195
|
}
|
|
@@ -197,10 +197,10 @@ class Z {
|
|
|
197
197
|
if (e <= 0)
|
|
198
198
|
return 0;
|
|
199
199
|
const r = I(t);
|
|
200
|
-
let s = 0, o = this._used,
|
|
200
|
+
let s = 0, o = this._used, a = 0;
|
|
201
201
|
for (; o; ) {
|
|
202
202
|
if (o === r) {
|
|
203
|
-
[s,
|
|
203
|
+
[s, a] = this.reallocBlock(o, e);
|
|
204
204
|
break;
|
|
205
205
|
}
|
|
206
206
|
o = this.blockNext(o);
|
|
@@ -208,19 +208,19 @@ class Z {
|
|
|
208
208
|
return s && s !== r && this.u8.copyWithin(
|
|
209
209
|
_(s),
|
|
210
210
|
_(r),
|
|
211
|
-
|
|
211
|
+
a
|
|
212
212
|
), _(s);
|
|
213
213
|
}
|
|
214
214
|
reallocBlock(t, e) {
|
|
215
|
-
const r = this.blockSize(t), s = t + r, o = s >= this.top,
|
|
216
|
-
if (
|
|
215
|
+
const r = this.blockSize(t), s = t + r, o = s >= this.top, a = P(e + y, this.align);
|
|
216
|
+
if (a <= r) {
|
|
217
217
|
if (this.doSplit) {
|
|
218
|
-
const f = r -
|
|
219
|
-
f >= this.minSplit ? this.splitBlock(t,
|
|
220
|
-
} else o && (this.top = t +
|
|
218
|
+
const f = r - a;
|
|
219
|
+
f >= this.minSplit ? this.splitBlock(t, a, f) : o && (this.top = t + a);
|
|
220
|
+
} else o && (this.top = t + a);
|
|
221
221
|
return [t, s];
|
|
222
222
|
}
|
|
223
|
-
return o && t +
|
|
223
|
+
return o && t + a < this.end ? (this.top = t + this.setBlockSize(t, a), [t, s]) : (this.free(t), [I(this.malloc(e)), s]);
|
|
224
224
|
}
|
|
225
225
|
reallocArray(t, e) {
|
|
226
226
|
if (t.buffer !== this.buf)
|
|
@@ -282,16 +282,16 @@ class Z {
|
|
|
282
282
|
this.state[ft] = t;
|
|
283
283
|
}
|
|
284
284
|
get end() {
|
|
285
|
-
return this.state[
|
|
285
|
+
return this.state[nt];
|
|
286
286
|
}
|
|
287
287
|
set end(t) {
|
|
288
|
-
this.state[
|
|
288
|
+
this.state[nt] = t;
|
|
289
289
|
}
|
|
290
290
|
get top() {
|
|
291
|
-
return Atomics.load(this.state,
|
|
291
|
+
return Atomics.load(this.state, at);
|
|
292
292
|
}
|
|
293
293
|
set top(t) {
|
|
294
|
-
Atomics.store(this.state,
|
|
294
|
+
Atomics.store(this.state, at, t);
|
|
295
295
|
}
|
|
296
296
|
get _free() {
|
|
297
297
|
return Atomics.load(this.state, st);
|
|
@@ -385,13 +385,13 @@ class Z {
|
|
|
385
385
|
for (s = t, r = this.blockNext(t); r && s + this.blockSize(s) === r; )
|
|
386
386
|
s = r, r = this.blockNext(r);
|
|
387
387
|
if (s !== t) {
|
|
388
|
-
const
|
|
389
|
-
this.setBlockSize(t,
|
|
388
|
+
const a = s - t + this.blockSize(s);
|
|
389
|
+
this.setBlockSize(t, a);
|
|
390
390
|
const f = this.blockNext(s);
|
|
391
|
-
let
|
|
392
|
-
for (;
|
|
393
|
-
const l = this.blockNext(
|
|
394
|
-
this.setBlockNext(
|
|
391
|
+
let n = this.blockNext(t);
|
|
392
|
+
for (; n && n !== f; ) {
|
|
393
|
+
const l = this.blockNext(n);
|
|
394
|
+
this.setBlockNext(n, 0), n = l;
|
|
395
395
|
}
|
|
396
396
|
this.setBlockNext(t, f), o = !0;
|
|
397
397
|
}
|
|
@@ -506,13 +506,13 @@ function oe(i, t) {
|
|
|
506
506
|
const l = ` 0${r}${e[0]}`;
|
|
507
507
|
return ut(l, t.fixedWidth);
|
|
508
508
|
}
|
|
509
|
-
const o = i < 0,
|
|
509
|
+
const o = i < 0, a = o ? "-" : t.signed ? "+" : "";
|
|
510
510
|
o && (i = -i);
|
|
511
511
|
const f = se(t);
|
|
512
|
-
let
|
|
512
|
+
let n;
|
|
513
513
|
if (i < 1) {
|
|
514
514
|
const l = ct(i, t.locale, f);
|
|
515
|
-
|
|
515
|
+
n = a + l + r + e[0];
|
|
516
516
|
} else {
|
|
517
517
|
const l = Math.min(Math.floor(t.binary ? re(i) / Math.log(1024) : _t(i) / 3), e.length - 1);
|
|
518
518
|
if (i = ie(i, (t.binary ? 1024 : 1e3) ** l), !f) {
|
|
@@ -520,11 +520,11 @@ function oe(i, t) {
|
|
|
520
520
|
i = i.toPrecision(M);
|
|
521
521
|
}
|
|
522
522
|
const S = ct(Number(i), t.locale, f), Y = e[l];
|
|
523
|
-
|
|
523
|
+
n = a + S + r + Y;
|
|
524
524
|
}
|
|
525
|
-
return ut(
|
|
525
|
+
return ut(n, t.fixedWidth);
|
|
526
526
|
}
|
|
527
|
-
const
|
|
527
|
+
const ae = 8192, yt = 0, W = 1, N = 2;
|
|
528
528
|
class de {
|
|
529
529
|
buffers;
|
|
530
530
|
onGrowBufferHandlers = [];
|
|
@@ -544,7 +544,7 @@ class de {
|
|
|
544
544
|
}), this.isClone = !0;
|
|
545
545
|
else {
|
|
546
546
|
"SharedArrayBuffer" in globalThis || console.warn("SharedArrayBuffer is not working: falling back to ArrayBuffer");
|
|
547
|
-
const e = t?.bufferSize ??
|
|
547
|
+
const e = t?.bufferSize ?? ae;
|
|
548
548
|
if (e > rt)
|
|
549
549
|
throw new Error(`Buffer size ${e} is greater than max ${rt} that we can reference with pointers`);
|
|
550
550
|
let r = this.createBuffer(e);
|
|
@@ -599,10 +599,10 @@ class de {
|
|
|
599
599
|
const o = this.buffers[s];
|
|
600
600
|
if (!o)
|
|
601
601
|
continue;
|
|
602
|
-
const
|
|
603
|
-
if (
|
|
602
|
+
const a = o.callocAs("u32", t);
|
|
603
|
+
if (a)
|
|
604
604
|
return s === this.buffers.length - 1 && Atomics.load(this.memory.data, W) === this.buffers.length && this.memory.data[N] < 100 && this.memory.data[N] > 0 && o.top / o.end > this.memory.data[N] / 100 && this.growBuffer(), new h(this, {
|
|
605
|
-
data:
|
|
605
|
+
data: a,
|
|
606
606
|
buffer: o
|
|
607
607
|
});
|
|
608
608
|
}
|
|
@@ -699,13 +699,13 @@ class u {
|
|
|
699
699
|
if (t.length > e)
|
|
700
700
|
throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
|
|
701
701
|
let r = this.memory.allocUI32(mt + e), s = this.getDataBlock(r.data), o = r.pointer;
|
|
702
|
-
for (let
|
|
703
|
-
s instanceof Int32Array || s instanceof Uint32Array ? Atomics.store(s,
|
|
704
|
-
let
|
|
702
|
+
for (let n = 0; n < t.length; n++)
|
|
703
|
+
s instanceof Int32Array || s instanceof Uint32Array ? Atomics.store(s, n, t[n]) : s[n] = t[n];
|
|
704
|
+
let a, f = !1;
|
|
705
705
|
for (; !f; )
|
|
706
|
-
|
|
707
|
-
if (
|
|
708
|
-
let { bufferPosition:
|
|
706
|
+
a = O(this.firstBlock.data, 1), f = H(this.firstBlock.data, 1, o, a);
|
|
707
|
+
if (a) {
|
|
708
|
+
let { bufferPosition: n, bufferByteOffset: l } = g(a), S = new Uint32Array(this.memory.buffers[n].buf, l, 1);
|
|
709
709
|
j(S, 0, o);
|
|
710
710
|
} else
|
|
711
711
|
j(this.firstBlock.data, 0, o);
|
|
@@ -742,30 +742,30 @@ class u {
|
|
|
742
742
|
H(this.firstBlock.data, 0, 0, t);
|
|
743
743
|
let s = 0, o = t;
|
|
744
744
|
for (; o; ) {
|
|
745
|
-
let { bufferPosition:
|
|
746
|
-
if (!
|
|
745
|
+
let { bufferPosition: a, bufferByteOffset: f } = g(o), n = this.memory.buffers[a];
|
|
746
|
+
if (!n)
|
|
747
747
|
break;
|
|
748
|
-
let l = new Uint32Array(
|
|
749
|
-
o = O(l, 0), s++, this.onDelete && this.onDelete(this.getDataBlock(l)),
|
|
748
|
+
let l = new Uint32Array(n.buf, f, 2);
|
|
749
|
+
o = O(l, 0), s++, this.onDelete && this.onDelete(this.getDataBlock(l)), n.free(l.byteOffset);
|
|
750
750
|
}
|
|
751
751
|
Atomics.sub(this.firstBlock.data, E, s);
|
|
752
752
|
}
|
|
753
753
|
*[Symbol.iterator]() {
|
|
754
|
-
let t = 0, { bufferPosition: e, bufferByteOffset: r } = c(this.firstBlock.data, 0), s = this.firstBlock.data, o = 0,
|
|
754
|
+
let t = 0, { bufferPosition: e, bufferByteOffset: r } = c(this.firstBlock.data, 0), s = this.firstBlock.data, o = 0, a = 0;
|
|
755
755
|
for (; r; ) {
|
|
756
756
|
let f = this.memory.buffers[e];
|
|
757
757
|
if (!f)
|
|
758
758
|
return;
|
|
759
|
-
let
|
|
760
|
-
({ bufferPosition: e, bufferByteOffset: r } = c(
|
|
759
|
+
let n = new Uint32Array(f.buf, r, 2), l = this.getDataBlock(n), S = e, Y = r;
|
|
760
|
+
({ bufferPosition: e, bufferByteOffset: r } = c(n, 0));
|
|
761
761
|
let M = !0;
|
|
762
762
|
yield {
|
|
763
763
|
data: l,
|
|
764
764
|
index: t,
|
|
765
765
|
deleteCurrent: () => {
|
|
766
|
-
m(s, 0, e, r), r || m(this.firstBlock.data, 1, o,
|
|
766
|
+
m(s, 0, e, r), r || m(this.firstBlock.data, 1, o, a), this.onDelete && this.onDelete(this.getDataBlock(n)), f.free(n.byteOffset), Atomics.sub(this.firstBlock.data, E, 1), M = !1;
|
|
767
767
|
}
|
|
768
|
-
}, M && (s =
|
|
768
|
+
}, M && (s = n, o = S, a = Y, t++);
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
771
|
forEach(t) {
|
|
@@ -834,19 +834,19 @@ class Ot {
|
|
|
834
834
|
this.setHashKey(this.hashMemory, this.maxHash, r, e) && Atomics.add(this.pointerMemory.data, 2, 1);
|
|
835
835
|
}
|
|
836
836
|
setHashKey(t, e, r, s) {
|
|
837
|
-
let o = this.hash(r, e),
|
|
837
|
+
let o = this.hash(r, e), a, f = c(t.data, o);
|
|
838
838
|
if (f.bufferByteOffset === 0) {
|
|
839
|
-
|
|
839
|
+
a = new u(this.memory, {
|
|
840
840
|
dataLength: 2
|
|
841
841
|
});
|
|
842
|
-
let l =
|
|
842
|
+
let l = a.getSharedMemory();
|
|
843
843
|
m(t.data, o, l.firstBlock.bufferPosition, l.firstBlock.bufferByteOffset);
|
|
844
844
|
} else
|
|
845
|
-
|
|
845
|
+
a = new u(this.memory, {
|
|
846
846
|
firstBlock: f
|
|
847
847
|
});
|
|
848
|
-
let
|
|
849
|
-
return
|
|
848
|
+
let n = !0;
|
|
849
|
+
return a.deleteValue(r) && (n = !1), a.insert([r, s]), n;
|
|
850
850
|
}
|
|
851
851
|
get(t) {
|
|
852
852
|
let e = C(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
|
|
@@ -855,9 +855,9 @@ class Ot {
|
|
|
855
855
|
let o = new u(this.memory, {
|
|
856
856
|
firstBlock: s
|
|
857
857
|
});
|
|
858
|
-
for (let { data:
|
|
859
|
-
if (
|
|
860
|
-
return
|
|
858
|
+
for (let { data: a } of o)
|
|
859
|
+
if (a[0] === e)
|
|
860
|
+
return a[1];
|
|
861
861
|
}
|
|
862
862
|
has(t) {
|
|
863
863
|
let e = C(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
|
|
@@ -866,8 +866,8 @@ class Ot {
|
|
|
866
866
|
let o = new u(this.memory, {
|
|
867
867
|
firstBlock: s
|
|
868
868
|
});
|
|
869
|
-
for (let { data:
|
|
870
|
-
if (
|
|
869
|
+
for (let { data: a } of o)
|
|
870
|
+
if (a[0] === e)
|
|
871
871
|
return !0;
|
|
872
872
|
return !1;
|
|
873
873
|
}
|
|
@@ -878,22 +878,22 @@ class Ot {
|
|
|
878
878
|
let o = new u(this.memory, {
|
|
879
879
|
firstBlock: s
|
|
880
880
|
});
|
|
881
|
-
for (let { data:
|
|
882
|
-
if (
|
|
881
|
+
for (let { data: a, deleteCurrent: f } of o)
|
|
882
|
+
if (a[0] === e)
|
|
883
883
|
return f(), Atomics.sub(this.pointerMemory.data, 2, 1), !0;
|
|
884
884
|
return !1;
|
|
885
885
|
}
|
|
886
886
|
growHashTable() {
|
|
887
887
|
let t = this.maxHash, e = t * 2, r = this.memory.allocUI32(e), s = this.hashMemory;
|
|
888
888
|
for (let o = 0; o < t; o++) {
|
|
889
|
-
let
|
|
890
|
-
if (
|
|
889
|
+
let a = c(s.data, o);
|
|
890
|
+
if (a.bufferByteOffset === 0)
|
|
891
891
|
continue;
|
|
892
892
|
let f = new u(this.memory, {
|
|
893
|
-
firstBlock:
|
|
893
|
+
firstBlock: a
|
|
894
894
|
});
|
|
895
|
-
for (let { data:
|
|
896
|
-
this.setHashKey(r, e,
|
|
895
|
+
for (let { data: n } of f)
|
|
896
|
+
this.setHashKey(r, e, n[0], n[1]);
|
|
897
897
|
}
|
|
898
898
|
m(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, e);
|
|
899
899
|
}
|
|
@@ -918,9 +918,9 @@ class Ot {
|
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
920
|
function C(i) {
|
|
921
|
-
return typeof i == "number" ? i : typeof i == "string" ?
|
|
921
|
+
return typeof i == "number" ? i : typeof i == "string" ? ne(i) : i;
|
|
922
922
|
}
|
|
923
|
-
function
|
|
923
|
+
function ne(i) {
|
|
924
924
|
let t = i.length, e = 17 ^ t, r = 0, s;
|
|
925
925
|
for (; t >= 4; )
|
|
926
926
|
s = i.charCodeAt(r) & 255 | (i.charCodeAt(++r) & 255) << 8 | (i.charCodeAt(++r) & 255) << 16 | (i.charCodeAt(++r) & 255) << 14, s = (s & 65535) * 1540483477 + (((s >>> 16) * 1540483477 & 65535) << 16), s ^= s >>> 14, s = (s & 65535) * 1540483477 + (((s >>> 16) * 1540483477 & 65535) << 16), e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16) ^ s, t -= 4, ++r;
|
|
@@ -1003,13 +1003,13 @@ class Mt {
|
|
|
1003
1003
|
/* ASCII */
|
|
1004
1004
|
};
|
|
1005
1005
|
let e = [];
|
|
1006
|
-
for (let
|
|
1007
|
-
e.push(t.charCodeAt(
|
|
1008
|
-
let s = Math.max(...e) > 255 ? 2 : 1, o = At[s],
|
|
1009
|
-
for (let
|
|
1010
|
-
f[
|
|
1006
|
+
for (let n = 0; n < t.length; n++)
|
|
1007
|
+
e.push(t.charCodeAt(n));
|
|
1008
|
+
let s = Math.max(...e) > 255 ? 2 : 1, o = At[s], a = this.memory.allocUI32(Math.ceil(t.length / (4 / o.BYTES_PER_ELEMENT))), f = new o(a.data.buffer, a.data.byteOffset, t.length);
|
|
1009
|
+
for (let n = 0; n < t.length; n++)
|
|
1010
|
+
f[n] = t.charCodeAt(n);
|
|
1011
1011
|
return {
|
|
1012
|
-
pointer:
|
|
1012
|
+
pointer: a.pointer,
|
|
1013
1013
|
charType: s
|
|
1014
1014
|
};
|
|
1015
1015
|
}
|
|
@@ -1021,8 +1021,8 @@ class Mt {
|
|
|
1021
1021
|
return "";
|
|
1022
1022
|
let { bufferPosition: e, bufferByteOffset: r } = g(t);
|
|
1023
1023
|
x(this.lock);
|
|
1024
|
-
let s = Atomics.load(this.allocatedMemory.data, kt), o = At[s],
|
|
1025
|
-
return A(this.lock), this.cachedPointer = t, this.cachedString =
|
|
1024
|
+
let s = Atomics.load(this.allocatedMemory.data, kt), o = At[s], a = Atomics.load(this.allocatedMemory.data, gt), f = new o(this.memory.buffers[e].buf, r, a), n = String.fromCharCode.apply(null, f);
|
|
1025
|
+
return A(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);
|
|
@@ -1086,8 +1086,8 @@ class d {
|
|
|
1086
1086
|
this.firstBlock = t.allocUI32(d.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + pt * Uint32Array.BYTES_PER_ELEMENT, 2);
|
|
1087
1087
|
let r = e?.dataLength ?? 1, s = e?.bufferLength ?? v, o = t.allocUI32(s * r);
|
|
1088
1088
|
m(this.firstBlock.data, w, o.bufferPosition, o.bufferByteOffset), this.bufferLength = s;
|
|
1089
|
-
const
|
|
1090
|
-
|
|
1089
|
+
const a = e?.type ?? Uint32Array;
|
|
1090
|
+
a === Uint32Array ? this.type = 0 : a === Int32Array ? this.type = 1 : a === Float32Array && (this.type = 2), this.dataLength = r;
|
|
1091
1091
|
}
|
|
1092
1092
|
this.cachedPointer = this.firstBlock.data[0], this.cachedFullDataBlock = this.getFullDataBlock();
|
|
1093
1093
|
}
|
|
@@ -1123,8 +1123,8 @@ class d {
|
|
|
1123
1123
|
throw new Error(`${t} is out of bounds ${e}`);
|
|
1124
1124
|
let r = this.dataLength, s = this.getFullDataBlock();
|
|
1125
1125
|
for (let o = t; o < e; o++)
|
|
1126
|
-
for (let
|
|
1127
|
-
s[o * r +
|
|
1126
|
+
for (let a = 0; a < r; a++)
|
|
1127
|
+
s[o * r + a] = s[(o + 1) * r + a];
|
|
1128
1128
|
Atomics.sub(this.firstBlock.data, b, b);
|
|
1129
1129
|
}
|
|
1130
1130
|
clear() {
|
|
@@ -1160,21 +1160,21 @@ class d {
|
|
|
1160
1160
|
return t.subarray(r, r + this.dataLength);
|
|
1161
1161
|
}
|
|
1162
1162
|
growBuffer() {
|
|
1163
|
-
let e = this.bufferLength * 2, r = this.dataLength, s = c(this.firstBlock.data, w), o = new h(this.memory, s),
|
|
1163
|
+
let e = this.bufferLength * 2, r = this.dataLength, s = c(this.firstBlock.data, w), o = new h(this.memory, s), a = this.getFullDataBlock(), f = this.memory.allocUI32(e * r), n;
|
|
1164
1164
|
switch (this.type) {
|
|
1165
1165
|
case 1:
|
|
1166
|
-
|
|
1166
|
+
n = new Int32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
|
|
1167
1167
|
break;
|
|
1168
1168
|
case 0:
|
|
1169
|
-
|
|
1169
|
+
n = new Uint32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
|
|
1170
1170
|
break;
|
|
1171
1171
|
case 2:
|
|
1172
|
-
|
|
1172
|
+
n = new Float32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
|
|
1173
1173
|
break;
|
|
1174
1174
|
default:
|
|
1175
1175
|
throw new Error(`Unknown data block type ${this.type}`);
|
|
1176
1176
|
}
|
|
1177
|
-
|
|
1177
|
+
n.set(a), m(this.firstBlock.data, w, f.bufferPosition, f.bufferByteOffset), this.bufferLength = e, o.free();
|
|
1178
1178
|
}
|
|
1179
1179
|
free() {
|
|
1180
1180
|
let t = c(this.firstBlock.data, w);
|
|
@@ -1321,12 +1321,13 @@ class It {
|
|
|
1321
1321
|
firstBlock: {
|
|
1322
1322
|
bufferPosition: this.firstBlock.bufferPosition,
|
|
1323
1323
|
bufferByteOffset: this.firstBlock.bufferByteOffset + St * Uint32Array.BYTES_PER_ELEMENT
|
|
1324
|
-
}
|
|
1324
|
+
},
|
|
1325
|
+
bufferLength: e?.recycleBufferLength
|
|
1325
1326
|
});
|
|
1326
1327
|
const o = e?.type ?? Uint32Array;
|
|
1327
1328
|
o === Uint32Array ? this.type = 0 : o === Int32Array ? this.type = 1 : o === Float32Array ? this.type = 2 : o === Float64Array && (this.type = 3), this.dataLength = r, this.maxChunkSize = s;
|
|
1328
|
-
let
|
|
1329
|
-
this.pointerVector.push(
|
|
1329
|
+
let a = t.allocUI32(s * r * this.byteMultipler);
|
|
1330
|
+
this.pointerVector.push(a.pointer);
|
|
1330
1331
|
}
|
|
1331
1332
|
}
|
|
1332
1333
|
at(t) {
|
|
@@ -1353,12 +1354,15 @@ class It {
|
|
|
1353
1354
|
this.recycleVector.push(t);
|
|
1354
1355
|
}
|
|
1355
1356
|
clear() {
|
|
1356
|
-
this.firstBlock.data[F] = 0;
|
|
1357
|
+
this.firstBlock.data[F] = 0, this.recycleVector.clear();
|
|
1357
1358
|
}
|
|
1358
1359
|
*[Symbol.iterator]() {
|
|
1359
|
-
|
|
1360
|
+
const t = {};
|
|
1361
|
+
for (let s of this.recycleVector)
|
|
1362
|
+
t[s[0]] = !0;
|
|
1363
|
+
let e = this.getFullDataBlock(0), r = 0;
|
|
1360
1364
|
for (let s = 0; s < Atomics.load(this.firstBlock.data, F); s++)
|
|
1361
|
-
if (!t
|
|
1365
|
+
if (!t[s]) {
|
|
1362
1366
|
let o = Math.floor(s / this.maxChunkSize);
|
|
1363
1367
|
o !== r && (e = this.getFullDataBlock(s), r = o), yield this.getDataBlock(e, s % this.maxChunkSize);
|
|
1364
1368
|
}
|
|
@@ -1368,8 +1372,8 @@ class It {
|
|
|
1368
1372
|
if (r)
|
|
1369
1373
|
return r;
|
|
1370
1374
|
if (e >= this.pointerVector.length) {
|
|
1371
|
-
let
|
|
1372
|
-
this.pointerVector.push(
|
|
1375
|
+
let a = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
|
|
1376
|
+
this.pointerVector.push(a.pointer);
|
|
1373
1377
|
}
|
|
1374
1378
|
let s = new h(this.memory, g(this.pointerVector.get(e))), o;
|
|
1375
1379
|
switch (this.type) {
|