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 <damien@micropython.org>
pull/13583/head
Damien George 2023-05-30 13:13:39 +10:00
rodzic ff15dfcaa8
commit 8282bd93a2
2 zmienionych plików z 4 dodań i 5 usunięć

Wyświetl plik

@ -35,9 +35,10 @@ mergeInto(LibraryManager.library, {
}
},
mp_js_ticks_ms: function() {
return Date.now() - MP_JS_EPOCH;
},
// This string will be emitted directly into the output file by Emscripten.
mp_js_ticks_ms__postset: "var MP_JS_EPOCH = Date.now()",
mp_js_ticks_ms: () => Date.now() - MP_JS_EPOCH,
mp_js_hook: function() {
if (ENVIRONMENT_IS_NODE) {

Wyświetl plik

@ -33,8 +33,6 @@ var mainProgram = function()
mp_js_init_repl = Module.cwrap('mp_js_init_repl', 'null', ['null']);
mp_js_process_char = Module.cwrap('mp_js_process_char', 'number', ['number'], {async: true});
MP_JS_EPOCH = Date.now();
if (typeof window === 'undefined' && require.main === module) {
var fs = require('fs');
var heap_size = 128 * 1024;