Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix emulated function pointer cast exporting #6939

Merged
merged 3 commits into from
Aug 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) + ' }'
Expand Down
4 changes: 2 additions & 2 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down