Skip to content

Commit 592aeca

Browse files
authored
Automatically generate __sig properties for JS library symbols (#18985)
This primary change here is the creation of `emscripten_internal.h` which is an internal-only header that contains that declaration of internal JS function that are not already declared in other files. The reason for this is to ensure that all JS library functions that are callable form native code have a valid declaration, at least internally, so that gen_sig_info.py can extract that signature from a compiled wasm file. This change add the scripte for generating `library_sigs.js` but doesn't actually start using it, or erase the correpsonding hand-created `__sig` entries. That is will be part of a followup
1 parent 468e2ab commit 592aeca

27 files changed

+1397
-88
lines changed

src/compiler.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ global.printErr = (x) => {
2121
};
2222

2323
function find(filename) {
24+
assert(filename);
2425
const prefixes = [__dirname, process.cwd()];
2526
for (let i = 0; i < prefixes.length; ++i) {
2627
const combined = nodePath.join(prefixes[i], filename);
@@ -32,6 +33,7 @@ function find(filename) {
3233
}
3334

3435
global.read = (filename) => {
36+
assert(filename);
3537
const absolute = find(filename);
3638
return fs.readFileSync(absolute).toString();
3739
};
@@ -43,22 +45,25 @@ function load(f) {
4345
// Basic utilities
4446
load('utility.js');
4547

48+
// Load default settings
49+
load('./settings.js');
50+
load('./settings_internal.js');
4651

4752
const argv = process.argv.slice(2);
4853
const symbolsOnlyArg = argv.indexOf('--symbols-only');
4954
if (symbolsOnlyArg != -1) {
5055
argv.splice(symbolsOnlyArg, 1);
5156
}
5257

53-
const symbolsOnly = symbolsOnlyArg != -1;
54-
5558
// Load settings from JSON passed on the command line
5659
const settingsFile = argv[0];
5760
assert(settingsFile);
5861

5962
const settings = JSON.parse(read(settingsFile));
6063
Object.assign(global, settings);
6164

65+
global.symbolsOnly = symbolsOnlyArg != -1;
66+
6267
EXPORTED_FUNCTIONS = new Set(EXPORTED_FUNCTIONS);
6368
WASM_EXPORTS = new Set(WASM_EXPORTS);
6469
SIDE_MODULE_EXPORTS = new Set(SIDE_MODULE_EXPORTS);
@@ -94,7 +99,7 @@ if (!STRICT) {
9499
B = new Benchmarker();
95100

96101
try {
97-
runJSify(symbolsOnly);
102+
runJSify();
98103

99104
B.print('glue');
100105
} catch (err) {

src/jsifier.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function isDefined(symName) {
6666
return false;
6767
}
6868

69-
function runJSify(symbolsOnly = false) {
69+
function runJSify() {
7070
const libraryItems = [];
7171
const symbolDeps = {};
7272
let postSets = [];

src/library.js

-5
Original file line numberDiff line numberDiff line change
@@ -3029,16 +3029,11 @@ mergeInto(LibraryManager.library, {
30293029
return runEmAsmFunction(code, sigPtr, argbuf);
30303030
},
30313031

3032-
#if MEMORY64
3033-
// We can't use the alias in wasm64 mode becuase the function signature differs
30343032
emscripten_asm_const_ptr__sig: 'pppp',
30353033
emscripten_asm_const_ptr__deps: ['$runEmAsmFunction'],
30363034
emscripten_asm_const_ptr: function(code, sigPtr, argbuf) {
30373035
return runEmAsmFunction(code, sigPtr, argbuf);
30383036
},
3039-
#else
3040-
emscripten_asm_const_ptr: 'emscripten_asm_const_int',
3041-
#endif
30423037

30433038
$runMainThreadEmAsm__deps: ['$readEmAsmArgs'],
30443039
$runMainThreadEmAsm__sig: 'iippi',

0 commit comments

Comments
 (0)