Skip to content

Commit 4c5982b

Browse files
authored
Move resetPrototype into runtime_pthread.js. NFC (#23817)
This is the only place its ever used.
1 parent fd6a66b commit 4c5982b

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/preamble.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -701,18 +701,6 @@ function instantiateSync(file, info) {
701701
}
702702
#endif
703703

704-
#if (PTHREADS || WASM_WORKERS) && (LOAD_SOURCE_MAP || USE_OFFSET_CONVERTER)
705-
// When using postMessage to send an object, it is processed by the structured
706-
// clone algorithm. The prototype, and hence methods, on that object is then
707-
// lost. This function adds back the lost prototype. This does not work with
708-
// nested objects that has prototypes, but it suffices for WasmSourceMap and
709-
// WasmOffsetConverter.
710-
function resetPrototype(constructor, attrs) {
711-
var object = Object.create(constructor.prototype);
712-
return Object.assign(object, attrs);
713-
}
714-
#endif
715-
716704
#if WASM_ASYNC_COMPILATION
717705
async function instantiateArrayBuffer(binaryFile, imports) {
718706
try {

src/runtime_pthread.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ if (ENVIRONMENT_IS_PTHREAD) {
4949
console.error(text);
5050
}
5151

52+
#if LOAD_SOURCE_MAP || USE_OFFSET_CONVERTER
53+
// When using postMessage to send an object, it is processed by the structured
54+
// clone algorithm. The prototype, and hence methods, on that object is then
55+
// lost. This function adds back the lost prototype. This does not work with
56+
// nested objects that has prototypes, but it suffices for WasmSourceMap and
57+
// WasmOffsetConverter.
58+
function resetPrototype(constructor, attrs) {
59+
var object = Object.create(constructor.prototype);
60+
return Object.assign(object, attrs);
61+
}
62+
#endif
63+
5264
#if expectToReceiveOnModule('printErr')
5365
if (!Module['printErr'])
5466
#endif

0 commit comments

Comments
 (0)