MCPcopy Create free account
hub / github.com/GamerHack/GamerHack.github.io / constructor

Method constructor

g2all/900/module/mem.js:433–464  ·  view source on GitHub ↗
(main, worker, obj, addr_addr)

Source from the content-addressed store, hash-verified

431
432export class Memory {
433 constructor(main, worker, obj, addr_addr) {
434 this._main = main;
435 this._worker = worker;
436 this._obj = obj;
437 this._addr_low = addr_addr.lo;
438 this._addr_high = addr_addr.hi;
439
440 main[view_m_length / 4] = 0xffffffff;
441
442 init_module(this);
443
444 const off_mvec = view_m_vector;
445 // use this to create WastefulTypedArrays to avoid a GC crash
446 const buf = new ArrayBuffer(0);
447
448 const src = new Uint8Array(buf);
449 const sset = new Uint32Array(buf);
450 const sset_p = this.addrof(sset);
451 sset_p.write64(off_mvec, this.addrof(src).add(off_mvec));
452 sset_p.write32(view_m_length, 3);
453 this._cpysrc = src;
454 this._src_setter = sset;
455
456 const dst = new Uint8Array(buf);
457 const dset = new Uint32Array(buf);
458 const dset_p = this.addrof(dset);
459 dset_p.write64(off_mvec, this.addrof(dst).add(off_mvec));
460 dset_p.write32(view_m_length, 3);
461 dset[2] = 0xffffffff;
462 this._cpydst = dst;
463 this._dst_setter = dset;
464 }
465
466 // dst and src may overlap
467 cpy(dst, src, len) {

Callers

nothing calls this directly

Calls 5

addrofMethod · 0.95
init_moduleFunction · 0.70
write64Method · 0.45
addMethod · 0.45
write32Method · 0.45

Tested by

no test coverage detected