Skip to content

Commit 54fd105

Browse files
committed
.
1 parent cb19b59 commit 54fd105

7 files changed

+41
-54
lines changed

src/library_sdl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ var LibrarySDL = {
873873
if (!SDL.eventHandler) return;
874874

875875
while (SDL.pollEvent(SDL.eventHandlerTemp)) {
876-
tableCall(SDL.eventHandler, SDL.eventHandlerContext, SDL.eventHandlerTemp);
876+
Module['dynCall_iii'](SDL.eventHandler, SDL.eventHandlerContext, SDL.eventHandlerTemp);
877877
}
878878
},
879879

src/preamble.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ if (typeof WebAssembly !== 'object') {
4444

4545
var wasmMemory;
4646

47-
#include "runtime_table.js"
47+
// In fastcomp asm.js, we don't need a wasm Table at all.
48+
// In the wasm backend, we polyfill the WebAssembly object,
49+
// so this creates a (non-native-wasm) table for us.
50+
#include "runtime_init_table.js"
4851

4952
#if USE_PTHREADS
5053
// For sending to workers.
@@ -425,7 +428,11 @@ function callRuntimeCallbacks(callbacks) {
425428
}
426429
var func = callback.func;
427430
if (typeof func === 'number') {
428-
tableCall(func, callback.arg);
431+
if (callback.arg === undefined) {
432+
Module['dynCall_v'](func);
433+
} else {
434+
Module['dynCall_vi'](func, callback.arg);
435+
}
429436
} else {
430437
func(callback.arg === undefined ? null : callback.arg);
431438
}

src/preamble_minimal.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ assert(buffer instanceof SharedArrayBuffer, 'requested a shared WebAssembly.Memo
102102
#endif
103103
#endif
104104

105-
#include "runtime_table.js"
105+
#include "runtime_init_table.js"
106106

107107
#else
108108

@@ -211,7 +211,11 @@ function callRuntimeCallbacks(callbacks) {
211211
}
212212
var func = callback.func;
213213
if (typeof func === 'number') {
214-
tableCall(func, callback.arg);
214+
if (callback.arg === undefined) {
215+
dynCall_v(func);
216+
} else {
217+
dynCall_vi(func, callback.arg);
218+
}
215219
} else {
216220
func(callback.arg === undefined ? null : callback.arg);
217221
}

src/runtime_init_table.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#if !STANDALONE_WASM // standalone wasm creates the table in the wasm
2+
var wasmTable = new WebAssembly.Table({
3+
'initial': {{{ getQuoted('WASM_TABLE_SIZE') }}},
4+
#if !ALLOW_TABLE_GROWTH
5+
'maximum': {{{ getQuoted('WASM_TABLE_SIZE') }}},
6+
#endif
7+
'element': 'anyfunc'
8+
});
9+
#endif

src/runtime_table.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/support.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,10 +621,7 @@ function dynCall(sig, ptr, args) {
621621
}
622622
#endif
623623

624-
// TODO(sbc): Use ...args once ES6 is allowed:
625-
// tableCall(ptr, ...args);
626-
// https://github.com/emscripten-core/emscripten/issues/11984
627-
return tableCall.apply(null, [ptr].concat(args));
624+
return wasmTable.get(ptr).apply(null, args)
628625
}
629626

630627
var tempRet0 = 0;

tools/shared.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,25 +1208,26 @@ def make_jscall(sig):
12081208
return ret
12091209

12101210
@staticmethod
1211-
def make_dynCall(sig):
1212-
# Optimize dynCall accesses in the case when not building with dynamic
1213-
# linking enabled.
1214-
if not Settings.MAIN_MODULE and not Settings.SIDE_MODULE:
1215-
return 'dynCall_' + sig
1211+
def make_dynCall(sig, args):
1212+
# wasm2c and asyncify are yet compatible with direct wasm table calls
1213+
if Settings.ASYNCIFY or Settings.WASM2C or not JS.is_legal_sig(sig):
1214+
args = ','.join(args)
1215+
if not Settings.MAIN_MODULE and not Settings.SIDE_MODULE:
1216+
# Optimize dynCall accesses in the case when not building with dynamic
1217+
# linking enabled.
1218+
return 'dynCall_%s(%s)' % (sig, join)
1219+
else:
1220+
return 'Module["dynCall_%s"](%s)' % (sig, args)
12161221
else:
1217-
return 'Module["dynCall_' + sig + '"]'
1222+
return 'wasmTable.get(%s)(%s)' % (args[0], ','.join(args[1:]))
1223+
12181224

12191225
@staticmethod
12201226
def make_invoke(sig, named=True):
12211227
legal_sig = JS.legalize_sig(sig) # TODO: do this in extcall, jscall?
1222-
args = ','.join(['a' + str(i) for i in range(1, len(legal_sig))])
1228+
args = ['index'] + ['a' + str(i) for i in range(1, len(legal_sig))]
12231229
ret = 'return ' if sig[0] != 'v' else ''
1224-
args = 'index' + (',' if args else '') + args
1225-
# wasm2c doesn't yet support for the new `tableCall`
1226-
if Settings.WASM2C or not JS.is_legal_sig(sig):
1227-
body = '%s%s(%s);' % (ret, JS.make_dynCall(sig), args)
1228-
else:
1229-
body = '%stableCall(%s);' % (ret, args)
1230+
body = '%s%s;' % (ret, JS.make_dynCall(sig, args))
12301231
# C++ exceptions are numbers, and longjmp is a string 'longjmp'
12311232
if Settings.SUPPORT_LONGJMP:
12321233
rethrow = "if (e !== e+0 && e !== 'longjmp') throw e;"
@@ -1244,7 +1245,7 @@ def make_invoke(sig, named=True):
12441245
%s
12451246
_setThrew(1, 0);
12461247
}
1247-
}''' % (name, args, body, rethrow)
1248+
}''' % (name, ','.join(args), body, rethrow)
12481249

12491250
return ret
12501251

0 commit comments

Comments
 (0)