From 0c36b799f6e0ddea22bbdd40ee99e3f9d53694a2 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 1 Aug 2018 10:30:31 -0400 Subject: [PATCH 1/2] emulated function pointer casts requires function calls for all exports (since we use an i64 return value, and cannot call through an export to JS) - emulated function pointers without casts does not need all the fp$ exports --- emscripten.py | 2 +- src/library.js | 4 ++-- src/support.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/emscripten.py b/emscripten.py index 22ba0775091ba..ee29d17514dfe 100755 --- a/emscripten.py +++ b/emscripten.py @@ -1289,7 +1289,7 @@ def create_exports(exported_implemented_functions, in_table, function_table_data exports.append(quote(str(k)) + ': ' + str(v)) # shared wasm emulated function pointer mode requires us to know the function pointer for # each function. export fp$func => function pointer for func - if shared.Settings.WASM and shared.Settings.RELOCATABLE and shared.Settings.EMULATED_FUNCTION_POINTERS: + if shared.Settings.WASM and shared.Settings.RELOCATABLE and shared.Settings.EMULATE_FUNCTION_POINTER_CASTS: for k, v in metadata['functionPointers'].items(): exports.append(quote('fp$' + str(k)) + ': ' + str(v)) return '{ ' + ', '.join(exports) + ' }' diff --git a/src/library.js b/src/library.js index 9e7582ee19410..087901f75198a 100644 --- a/src/library.js +++ b/src/library.js @@ -1865,7 +1865,7 @@ LibraryManager.library = { var result = lib.module[symbol]; if (typeof result === 'function') { #if WASM -#if EMULATED_FUNCTION_POINTERS +#if EMULATE_FUNCTION_POINTER_CASTS // for wasm with emulated function pointers, the i64 ABI is used for all // function calls, so we can't just call addFunction on something JS // can call (which does not use that ABI), as the function pointer would @@ -1881,7 +1881,7 @@ LibraryManager.library = { assert(typeof result === 'number', 'could not find function pointer for ' + symbol); #endif // ASSERTIONS return result; -#endif // EMULATED_FUNCTION_POINTERS +#endif // EMULATE_FUNCTION_POINTER_CASTS #endif // WASM // convert the exported function into a function pointer using our generic // JS mechanism. diff --git a/src/support.js b/src/support.js index 81cdec94c0767..a259b585f0cd7 100644 --- a/src/support.js +++ b/src/support.js @@ -229,14 +229,14 @@ function loadWebAssemblyModule(binary, loadAsync) { } if (typeof value === 'number') { // relocate it - modules export the absolute value, they can't relocate before they export -#if EMULATED_FUNCTION_POINTERS +#if EMULATE_FUNCTION_POINTER_CASTS // it may be a function pointer if (e.substr(0, 3) == 'fp$' && typeof instance.exports[e.substr(3)] === 'function') { value = value + env['tableBase']; } else { #endif value = value + env['memoryBase']; -#if EMULATED_FUNCTION_POINTERS +#if EMULATE_FUNCTION_POINTER_CASTS } #endif } From 1b510c6314b44ded3eb36a4b5b3ed08454c02b4a Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 2 Aug 2018 11:36:27 -0700 Subject: [PATCH 2/2] update other.test_metadce --- tests/test_other.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_other.py b/tests/test_other.py index ae48a551d9275..f02cffb1279ba 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -8091,7 +8091,7 @@ def test(filename, expectations): 0, [], ['tempDoublePtr', 'waka'], 8, 0, 0), # totally empty! # but we don't metadce with linkable code! other modules may want it (['-O3', '-s', 'MAIN_MODULE=1'], - 1534, ['invoke_i'], ['waka'], 496958, 163, 2560), + 1534, ['invoke_i'], ['waka'], 469663, 163, 1449), ]) print('test on a minimal pure computational thing')