-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Part two of dynCall removal #12059
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
Part two of dynCall removal #12059
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3872,7 +3872,7 @@ LibraryManager.library = { | |
var trace = _emscripten_get_callstack_js(); | ||
var parts = trace.split('\n'); | ||
for (var i = 0; i < parts.length; i++) { | ||
var ret = {{{ makeDynCall('iii') }}}(func, 0, arg); | ||
var ret = {{{ makeDynCall('iii', 'func') }}}(0, arg); | ||
if (ret !== 0) return; | ||
} | ||
}, | ||
|
@@ -3921,7 +3921,7 @@ LibraryManager.library = { | |
emscripten_scan_stack: function(func) { | ||
var base = STACK_BASE; // TODO verify this is right on pthreads | ||
var end = stackSave(); | ||
{{{ makeDynCall('vii') }}}(func, Math.min(base, end), Math.max(base, end)); | ||
{{{ makeDynCall('vii', 'func') }}}(Math.min(base, end), Math.max(base, end)); | ||
}, | ||
|
||
// misc definitions to avoid unnecessary unresolved symbols being reported | ||
|
@@ -4004,6 +4004,60 @@ LibraryManager.library = { | |
}); | ||
}, | ||
|
||
#if USE_LEGACY_DYNCALLS || !WASM_BIGINT | ||
$dynCallLegacy: function(sig, ptr, args) { | ||
#if ASSERTIONS | ||
assert(('dynCall_' + sig) in Module, 'bad function pointer type - no table for sig \'' + sig + '\''); | ||
if (args && args.length) { | ||
// j (64-bit integer) must be passed in as two numbers [low 32, high 32]. | ||
assert(args.length === sig.substring(1).replace(/j/g, '--').length); | ||
} else { | ||
assert(sig.length == 1); | ||
} | ||
#endif | ||
if (args && args.length) { | ||
return Module['dynCall_' + sig].apply(null, [ptr].concat(args)); | ||
} | ||
return Module['dynCall_' + sig].call(null, ptr); | ||
}, | ||
$dynCall__deps: ['$dynCallLegacy'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's odd to have the deps not near the function - why is this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the dependency is conditional in the exact same way the this functions existence is conditions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I don't feel strongly but I believe this is the one place in the entire codebase not to have the two adjacent. Maybe it's worth the benefit though. |
||
|
||
// Used in library code to get JS function from wasm function pointer. | ||
// All callers should use direct table access where possible and only fall | ||
// back to this function if needed. | ||
$getDynCaller__deps: ['$dynCall'], | ||
$getDynCaller: function(sig, ptr) { | ||
#if !USE_LEGACY_DYNCALLS | ||
assert(sig.indexOf('j') >= 0, 'getDynCaller should only be called with i64 sigs') | ||
#endif | ||
var argCache = []; | ||
return function() { | ||
argCache.length = arguments.length; | ||
for (var i = 0; i < arguments.length; i++) { | ||
argCache[i] = arguments[i]; | ||
} | ||
return dynCall(sig, ptr, argCache); | ||
}; | ||
}, | ||
#endif | ||
|
||
$dynCall: function (sig, ptr, args) { | ||
#if USE_LEGACY_DYNCALLS | ||
return dynCallLegacy(sig, ptr, args); | ||
#else | ||
#if !WASM_BIGINT | ||
// Without WASM_BIGINT support we cannot directly call function with i64 as | ||
// part of thier signature, so we rely the dynCall functions generated by | ||
// wasm-emscripten-finalize | ||
if (sig.indexOf('j') != -1) { | ||
return dynCallLegacy(sig, ptr, args); | ||
} | ||
#endif | ||
|
||
return wasmTable.get(ptr).apply(null, args) | ||
#endif | ||
}, | ||
|
||
$callRuntimeCallbacks: function(callbacks) { | ||
while(callbacks.length > 0) { | ||
var callback = callbacks.shift(); | ||
|
@@ -4014,9 +4068,9 @@ LibraryManager.library = { | |
var func = callback.func; | ||
if (typeof func === 'number') { | ||
if (callback.arg === undefined) { | ||
dynCall_v(func); | ||
{{{ makeDynCall('v', 'func') }}}(); | ||
} else { | ||
dynCall_vi(func, callback.arg); | ||
{{{ makeDynCall('vi', 'func') }}}(callback.arg); | ||
} | ||
} else { | ||
func(callback.arg === undefined ? null : callback.arg); | ||
|
Uh oh!
There was an error while loading. Please reload this page.