Skip to content

Commit 8282bd9

Browse files
committed
webassembly: Move MP_JS_EPOCH init to library postset.
This eliminates the need for wrapper.js to run to set up the time. Signed-off-by: Damien George <[email protected]>
1 parent ff15dfc commit 8282bd9

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

ports/webassembly/library.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ mergeInto(LibraryManager.library, {
3535
}
3636
},
3737

38-
mp_js_ticks_ms: function() {
39-
return Date.now() - MP_JS_EPOCH;
40-
},
38+
// This string will be emitted directly into the output file by Emscripten.
39+
mp_js_ticks_ms__postset: "var MP_JS_EPOCH = Date.now()",
40+
41+
mp_js_ticks_ms: () => Date.now() - MP_JS_EPOCH,
4142

4243
mp_js_hook: function() {
4344
if (ENVIRONMENT_IS_NODE) {

ports/webassembly/wrapper.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ var mainProgram = function()
3333
mp_js_init_repl = Module.cwrap('mp_js_init_repl', 'null', ['null']);
3434
mp_js_process_char = Module.cwrap('mp_js_process_char', 'number', ['number'], {async: true});
3535

36-
MP_JS_EPOCH = Date.now();
37-
3836
if (typeof window === 'undefined' && require.main === module) {
3937
var fs = require('fs');
4038
var heap_size = 128 * 1024;

0 commit comments

Comments
 (0)