Skip to content

Commit 8b5c868

Browse files
authored
Simplify createExportWrapper. NFC (emscripten-core#19817)
This functions is only used in debug builds (when ASSERTIONS are enabled), so we can just keep it simple.
1 parent f2ac81a commit 8b5c868

6 files changed

Lines changed: 14 additions & 21 deletions

emscripten.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -763,10 +763,7 @@ def install_wrapper(sym):
763763
if settings.ASSERTIONS and install_wrapper(name):
764764
# With assertions enabled we create a wrapper that are calls get routed through, for
765765
# the lifetime of the program.
766-
if delay_assignment:
767-
wrapper += 'createExportWrapper("%s");' % name
768-
else:
769-
wrapper += 'createExportWrapper("%s", asm);' % name
766+
wrapper += "createExportWrapper('%s');" % name
770767
elif delay_assignment:
771768
# With assertions disabled the wrapper will replace the global var and Module var on
772769
# first use.

src/preamble.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ function preRun() {
215215
}
216216

217217
function initRuntime() {
218+
#if RUNTIME_DEBUG
219+
dbg('initRuntime');
220+
#endif
218221
#if ASSERTIONS
219222
assert(!runtimeInitialized);
220223
#endif
@@ -518,22 +521,15 @@ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
518521
#include "URIUtils.js"
519522

520523
#if ASSERTIONS
521-
/** @param {boolean=} fixedasm */
522-
function createExportWrapper(name, fixedasm) {
524+
function createExportWrapper(name) {
523525
return function() {
524-
var displayName = name;
525-
var asm = fixedasm;
526-
if (!fixedasm) {
527-
asm = Module['asm'];
528-
}
529-
assert(runtimeInitialized, 'native function `' + displayName + '` called before runtime initialization');
526+
assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
530527
#if EXIT_RUNTIME
531-
assert(!runtimeExited, 'native function `' + displayName + '` called after runtime exit (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
528+
assert(!runtimeExited, `native function \`${name}\` called after runtime exit (use NO_EXIT_RUNTIME to keep it alive after main() exits)`);
532529
#endif
533-
if (!asm[name]) {
534-
assert(asm[name], 'exported native function `' + displayName + '` not found');
535-
}
536-
return asm[name].apply(null, arguments);
530+
var f = Module['asm'][name];
531+
assert(f, `exported native function \`${name}\` not found`);
532+
return f.apply(null, arguments);
537533
};
538534
}
539535
#endif
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
23718
1+
23701
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20140
1+
20123
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
58948
1+
58765
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
57914
1+
57731

0 commit comments

Comments
 (0)