Skip to content

Commit fe41ac4

Browse files
committed
Use micro task instead of setTimeout and use Uint8Array
1 parent b37a342 commit fe41ac4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

javascript/emscripten.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ def garbage_collector(args):
620620
if globals.pendingAsync is None or not len(globals.pendingAsync):
621621
if globals.snapshot is None:
622622
globals.snapshot = Object(snapshot).keep()
623-
globals.setTimeout(globals.snapshot.toRef(), JSON.fromInteger(0))
623+
globals.setTimeout(globals.snapshot.toRef()) #, JSON.fromInteger(0))
624624
globals.collector_id = None
625625

626626

@@ -631,9 +631,9 @@ def run_garbage_collector():
631631
#if globals.collector_function is None:
632632
globals.collector_function = json.fromFunction(garbage_collector)
633633
if globals.setTimeout is None:
634-
globals.setTimeout = Object('setTimeout').keep().toFunction()
634+
globals.setTimeout = Object('Promise.resolve()')['then'].keep().toFunction()
635635
setTimeout = globals.setTimeout
636-
timeout = setTimeout(globals.collector_function, json.fromInteger(0))
636+
timeout = setTimeout(globals.collector_function) #, json.fromInteger(0))
637637
globals.collector_id = timeout.toString()
638638

639639
method_template = '''

javascript/utils/snapshot_memory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(function () {
22
var copy;
33
return function () {
4-
if (!copy) copy = new Uint32Array(global.Module.wasmMemory.buffer.slice());
5-
var view = new Uint32Array(global.Module.wasmMemory.buffer);
4+
if (!copy) copy = new Uint8Array(global.Module.wasmMemory.buffer.slice());
5+
var view = new Uint8Array(global.Module.wasmMemory.buffer);
66
view.fill(0);
77
view.set(copy);
88
}

0 commit comments

Comments
 (0)