Skip to content

Commit bc452a1

Browse files
authored
Simplify unexported runtime symbol checks (#17378)
`unexportedRuntimeSymbol` can be used for both function and numbers that are not exported so `unexportedRuntimeFunction` is redundant.
1 parent 6c85448 commit bc452a1

File tree

5 files changed

+8
-26
lines changed

5 files changed

+8
-26
lines changed

src/modules.js

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ function exportRuntime() {
380380
// in ASSERTIONS mode we show a useful error if it is used without
381381
// being exported. how we show the message depends on whether it's
382382
// a function (almost all of them) or a number.
383-
function maybeExport(name, isNumber) {
383+
function maybeExport(name) {
384384
// if requested to be exported, export it
385385
if (EXPORTED_RUNTIME_METHODS_SET.has(name)) {
386386
let exported = name;
@@ -401,20 +401,14 @@ function exportRuntime() {
401401
if (ASSERTIONS) {
402402
// check if it already exists, to support EXPORT_ALL and other cases
403403
const fssymbol = isExportedByForceFilesystem(name);
404-
if (isNumber) {
405-
return `unexportedRuntimeSymbol('${name}', ${fssymbol});`;
406-
} else {
407-
return `unexportedRuntimeFunction('${name}', ${fssymbol});`;
408-
}
404+
return `unexportedRuntimeSymbol('${name}', ${fssymbol});`;
409405
}
410406
}
411407

412-
function maybeExportNumber(name) {
413-
return maybeExport(name, true);
414-
}
415-
416408
// All possible runtime elements that can be exported
417409
let runtimeElements = [
410+
'ALLOC_NORMAL',
411+
'ALLOC_STACK',
418412
'ccall',
419413
'cwrap',
420414
'allocate',
@@ -532,22 +526,16 @@ function exportRuntime() {
532526
}
533527
}
534528

535-
const runtimeNumbers = [
536-
'ALLOC_NORMAL',
537-
'ALLOC_STACK',
538-
];
539529
if (ASSERTIONS) {
540530
// check all exported things exist, warn about typos
541531
const runtimeElementsSet = new Set(runtimeElements);
542-
const runtimeNumbersSet = new Set(runtimeNumbers);
543532
for (const name of EXPORTED_RUNTIME_METHODS_SET) {
544-
if (!runtimeElementsSet.has(name) && !runtimeNumbersSet.has(name)) {
533+
if (!runtimeElementsSet.has(name)) {
545534
printErr(`warning: invalid item in EXPORTED_RUNTIME_METHODS: ${name}`);
546535
}
547536
}
548537
}
549538
let exports = runtimeElements.map((name) => maybeExport(name));
550-
exports = exports.concat(runtimeNumbers.map((name) => maybeExportNumber(name)));
551539
exports = exports.filter((name) => name);
552540
return exports.join('\n') + '\n' + addMissingLibraryStubs();
553541
}

src/runtime_debug.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ function unexportedRuntimeSymbol(sym, isFSSybol) {
4444
});
4545
}
4646
}
47-
48-
function unexportedRuntimeFunction(sym, isFSSybol) {
49-
if (!Object.getOwnPropertyDescriptor(Module, sym)) {
50-
Module[sym] = () => abort(unexportedMessage(sym, isFSSybol));
51-
}
52-
}
5347
#endif
5448

5549
#if RUNTIME_DEBUG
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
26811
1+
26693
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
21502
1+
21384
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
93804
1+
93171

0 commit comments

Comments
 (0)