Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -1429,13 +1429,6 @@ addToLibrary({
emscripten_random: () => Math.random(),

emscripten_get_now: `;
#if ENVIRONMENT_MAY_BE_NODE && MIN_NODE_VERSION < 160000
// The performance global was added to node in v16.0.0:
// https://nodejs.org/api/globals.html#performance
if (ENVIRONMENT_IS_NODE) {
global.performance = require('perf_hooks').performance;
}
#endif
#if PTHREADS && !AUDIO_WORKLET
// Pthreads need their clocks synchronized to the execution of the main
// thread, so, when using them, make sure to adjust all timings to the
Expand Down
8 changes: 4 additions & 4 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
// An online HTML version (which may be of a different version of Emscripten)
// is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html

#if PTHREADS
#include "runtime_pthread.js"
#endif

#if RELOCATABLE
{{{ makeModuleReceiveWithVar('dynamicLibraries', undefined, '[]', true) }}}
#endif
Expand Down Expand Up @@ -152,6 +148,10 @@ var HEAP_DATA_VIEW;

#include "runtime_shared.js"

#if PTHREADS
#include "runtime_pthread.js"
#endif

#if ASSERTIONS
assert(!Module['STACK_SIZE'], 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time')
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/preamble_minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
#include "runtime_asan.js"
#endif

#if PTHREADS
#include "runtime_pthread.js"
#endif

#if ASSERTIONS
/** @type {function(*, string=)} */
function assert(condition, text) {
Expand Down Expand Up @@ -60,6 +56,10 @@ var HEAP8, HEAP16, HEAP32, HEAPU8, HEAPU16, HEAPU32, HEAPF32, HEAPF64,

#include "runtime_shared.js"

#if PTHREADS
#include "runtime_pthread.js"
#endif

#if IMPORTED_MEMORY
#if PTHREADS
if (!ENVIRONMENT_IS_PTHREAD) {
Expand Down
1 change: 0 additions & 1 deletion src/runtime_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ if (ENVIRONMENT_IS_PTHREAD) {
#endif
},
postMessage: (msg) => parentPort.postMessage(msg),
performance: global.performance || { now: Date.now },
});
}
#endif // ENVIRONMENT_MAY_BE_NODE
Expand Down
12 changes: 12 additions & 0 deletions src/runtime_shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,15 @@ var toIndexType = (function() {
return (i) => bigintMemoryBounds ? BigInt(i) : i;
})();
#endif

#if ENVIRONMENT_MAY_BE_NODE && MIN_NODE_VERSION < 160000
// The performance global was added to node in v16.0.0:
// https://nodejs.org/api/globals.html#performance
if (ENVIRONMENT_IS_NODE) {
// This is needed for emscripten_get_now and for pthreads support which
// depends on it for accurate timing.
// Use `global` rather than `globalThis` here since older versions of node
// don't have `globalThis`.
global.performance ??= require('perf_hooks').performance;
}
#endif
8 changes: 0 additions & 8 deletions src/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,14 +428,6 @@ if (!ENVIRONMENT_IS_AUDIO_WORKLET)
}

#if ENVIRONMENT_MAY_BE_NODE && PTHREADS
if (ENVIRONMENT_IS_NODE) {
// Polyfill the performance object, which emscripten pthreads support
// depends on for good timing.
if (typeof performance == 'undefined') {
global.performance = require('perf_hooks').performance;
}
}

// Set up the out() and err() hooks, which are how we can print to stdout or
// stderr, respectively.
// Normally just binding console.log/console.error here works fine, but
Expand Down
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_pthreads.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4959
4916
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_pthreads.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10602
10465
Loading