@@ -414,14 +414,6 @@ def define_asmjs_import_names(imports):
414
414
415
415
function_tables_impls = make_function_tables_impls (function_table_data )
416
416
final_function_tables = '\n ' .join (function_tables_impls ) + '\n ' + function_tables_defs
417
- if shared .Settings .EMULATED_FUNCTION_POINTERS :
418
- final_function_tables = (
419
- final_function_tables
420
- .replace ("asm['" , '' )
421
- .replace ("']" , '' )
422
- .replace ('var SIDE_FUNCTION_TABLE_' , 'var FUNCTION_TABLE_' )
423
- .replace ('var dynCall_' , '//' )
424
- )
425
417
426
418
if DEBUG :
427
419
logger .debug ('asm text sizes' + str ([
@@ -580,8 +572,6 @@ def create_backend_cmd(infile, temp_js):
580
572
args += ['-emscripten-assertions=%d' % shared .Settings .ASSERTIONS ]
581
573
if shared .Settings .ALIASING_FUNCTION_POINTERS == 0 :
582
574
args += ['-emscripten-no-aliasing-function-pointers' ]
583
- if shared .Settings .EMULATED_FUNCTION_POINTERS :
584
- args += ['-emscripten-emulated-function-pointers' ]
585
575
if shared .Settings .EMULATE_FUNCTION_POINTER_CASTS :
586
576
args += ['-emscripten-emulate-function-pointer-casts' ]
587
577
if shared .Settings .RELOCATABLE :
@@ -1119,17 +1109,6 @@ def make_bad(target=None):
1119
1109
start = raw .index ('[' )
1120
1110
end = raw .rindex (']' )
1121
1111
body = raw [start + 1 :end ].split (',' )
1122
- if shared .Settings .EMULATED_FUNCTION_POINTERS :
1123
- def receive (item ):
1124
- if item == '0' :
1125
- return item
1126
- if item not in all_implemented :
1127
- # this is not implemented; it would normally be wrapped, but with emulation, we just use it directly outside
1128
- return item
1129
- in_table .add (item )
1130
- return "asm['" + item + "']"
1131
-
1132
- body = [receive (b ) for b in body ]
1133
1112
for j in range (shared .Settings .RESERVED_FUNCTION_POINTERS ):
1134
1113
curr = 'jsCall_%s_%s' % (sig , j )
1135
1114
body [1 + j ] = curr
@@ -1144,9 +1123,6 @@ def fix_item(item):
1144
1123
# emulate all non-null pointer calls, if asked to
1145
1124
if j > 0 and shared .Settings .EMULATE_FUNCTION_POINTER_CASTS and not shared .Settings .WASM and j in function_pointer_targets :
1146
1125
proper_sig , proper_target = function_pointer_targets [j ]
1147
- if shared .Settings .EMULATED_FUNCTION_POINTERS :
1148
- if proper_target in all_implemented :
1149
- proper_target = "asm['" + proper_target + "']"
1150
1126
1151
1127
def make_emulated_param (i ):
1152
1128
if i >= len (sig ):
@@ -1182,7 +1158,7 @@ def make_emulated_param(i):
1182
1158
# when emulating function pointers, we don't need wrappers
1183
1159
# but if relocating, then we also have the copies in-module, and do
1184
1160
# in wasm we never need wrappers though
1185
- if clean_item not in implemented_functions and not ( shared .Settings .EMULATED_FUNCTION_POINTERS and not shared . Settings . RELOCATABLE ) and not shared .Settings .WASM :
1161
+ if clean_item not in implemented_functions and shared .Settings .RELOCATABLE and not shared .Settings .WASM :
1186
1162
# this is imported into asm, we must wrap it
1187
1163
call_ident = clean_item
1188
1164
if call_ident in metadata ['redirects' ]:
@@ -1223,38 +1199,22 @@ def math_fix(g):
1223
1199
return g if not g .startswith ('Math_' ) else g .split ('_' )[1 ]
1224
1200
1225
1201
1226
- # asm.js function tables have one table in each linked asm.js module, so we
1227
- # can't just dynCall into them - ftCall exists for that purpose. In wasm,
1228
- # even linked modules share the table, so it's all fine.
1229
- def asm_js_emulated_function_pointers ():
1230
- return shared .Settings .EMULATED_FUNCTION_POINTERS and not shared .Settings .WASM
1231
-
1232
-
1233
1202
def make_function_tables_impls (function_table_data ):
1234
1203
function_tables_impls = []
1235
1204
for sig , table in function_table_data .items ():
1236
1205
args = ',' .join (['a' + str (i ) for i in range (1 , len (sig ))])
1237
1206
arg_coercions = ' ' .join (['a' + str (i ) + '=' + shared .JS .make_coercion ('a' + str (i ), sig [i ]) + ';' for i in range (1 , len (sig ))])
1238
1207
coerced_args = ',' .join ([shared .JS .make_coercion ('a' + str (i ), sig [i ]) for i in range (1 , len (sig ))])
1239
1208
sig_mask = str (table .count (',' ))
1240
- if not (shared .Settings .WASM and shared .Settings .EMULATED_FUNCTION_POINTERS ):
1241
- ret = 'FUNCTION_TABLE_%s[index&%s](%s)' % (sig , sig_mask , coerced_args )
1242
- else :
1243
- # for wasm with emulated function pointers, emit an mft_SIG(..) call, we avoid asm.js function tables there.
1244
- ret = 'mftCall_%s(index%s%s)' % (sig , ',' if len (sig ) > 1 else '' , coerced_args )
1209
+ ret = 'FUNCTION_TABLE_%s[index&%s](%s)' % (sig , sig_mask , coerced_args )
1245
1210
ret = ('return ' if sig [0 ] != 'v' else '' ) + shared .JS .make_coercion (ret , sig [0 ])
1246
- if not asm_js_emulated_function_pointers ():
1247
- function_tables_impls .append ('''
1211
+ function_tables_impls .append ('''
1248
1212
function dynCall_%s(index%s%s) {
1249
1213
index = index|0;
1250
1214
%s
1251
1215
%s;
1252
1216
}
1253
1217
''' % (sig , ',' if len (sig ) > 1 else '' , args , arg_coercions , ret ))
1254
- else :
1255
- function_tables_impls .append ('''
1256
- var dynCall_%s = ftCall_%s;
1257
- ''' % (sig , sig ))
1258
1218
1259
1219
ffi_args = ',' .join ([shared .JS .make_coercion ('a' + str (i ), sig [i ], ffi_arg = True ) for i in range (1 , len (sig ))])
1260
1220
for i in range (shared .Settings .RESERVED_FUNCTION_POINTERS ):
@@ -1270,33 +1230,7 @@ def make_function_tables_impls(function_table_data):
1270
1230
1271
1231
1272
1232
def create_mftCall_funcs (function_table_data ):
1273
- if not asm_js_emulated_function_pointers ():
1274
- return []
1275
- if shared .Settings .WASM or not shared .Settings .RELOCATABLE :
1276
- return []
1277
-
1278
- mftCall_funcs = []
1279
- # in wasm, emulated function pointers are just simple table calls
1280
- for sig , table in function_table_data .items ():
1281
- return_type , sig_args = sig [0 ], sig [1 :]
1282
- num_args = len (sig_args )
1283
- params = ',' .join (['ptr' ] + ['p%d' % i for i in range (num_args )])
1284
- coerced_params = ',' .join ([shared .JS .make_coercion ('ptr' , 'i' )] + [shared .JS .make_coercion ('p%d' % i , unfloat (sig_args [i ])) for i in range (num_args )])
1285
- coercions = ';' .join (['ptr = ptr | 0' ] + ['p%d = %s' % (i , shared .JS .make_coercion ('p%d' % i , unfloat (sig_args [i ]))) for i in range (num_args )]) + ';'
1286
- mini_coerced_params = ',' .join ([shared .JS .make_coercion ('p%d' % i , sig_args [i ]) for i in range (num_args )])
1287
- maybe_return = '' if return_type == 'v' else 'return'
1288
- final_return = maybe_return + ' ' + shared .JS .make_coercion ('ftCall_' + sig + '(' + coerced_params + ')' , unfloat (return_type )) + ';'
1289
- if shared .Settings .EMULATED_FUNCTION_POINTERS == 1 :
1290
- body = final_return
1291
- else :
1292
- sig_mask = str (table .count (',' ))
1293
- body = ('if (((ptr|0) >= (fb|0)) & ((ptr|0) < (fb + ' + sig_mask + ' | 0))) { ' + maybe_return + ' ' +
1294
- shared .JS .make_coercion (
1295
- 'FUNCTION_TABLE_' + sig + '[(ptr-fb)&' + sig_mask + '](' +
1296
- mini_coerced_params + ')' , return_type , ffi_arg = True
1297
- ) + '; ' + ('return;' if return_type == 'v' else '' ) + ' }' + final_return )
1298
- mftCall_funcs .append (make_func ('mftCall_' + sig , body , params , coercions ) + '\n ' )
1299
- return mftCall_funcs
1233
+ return []
1300
1234
1301
1235
1302
1236
def get_function_pointer_error (sig , function_table_sigs ):
@@ -1416,10 +1350,6 @@ def check(extern):
1416
1350
asm_setup += create_invoke_wrappers (invoke_function_names )
1417
1351
asm_setup += setup_function_pointers (function_table_sigs )
1418
1352
1419
- if shared .Settings .EMULATED_FUNCTION_POINTERS :
1420
- function_tables_impls = make_function_tables_impls (function_table_data )
1421
- asm_setup += '\n ' + '\n ' .join (function_tables_impls ) + '\n '
1422
-
1423
1353
return asm_setup
1424
1354
1425
1355
@@ -1428,24 +1358,6 @@ def setup_function_pointers(function_table_sigs):
1428
1358
for sig in function_table_sigs :
1429
1359
if shared .Settings .RESERVED_FUNCTION_POINTERS :
1430
1360
asm_setup += '\n ' + shared .JS .make_jscall (sig ) + '\n '
1431
- # nothing special to do here for wasm, we just use dynCalls
1432
- if not shared .Settings .WASM :
1433
- if shared .Settings .EMULATED_FUNCTION_POINTERS :
1434
- args = ['a%d' % i for i in range (len (sig ) - 1 )]
1435
- full_args = ['x' ] + args
1436
- table_access = 'FUNCTION_TABLE_' + sig
1437
- if shared .Settings .SIDE_MODULE :
1438
- table_access = 'parentModule["' + table_access + '"]' # side module tables were merged into the parent, we need to access the global one
1439
- table_read = table_access + '[x]'
1440
- prelude = ''
1441
- if shared .Settings .ASSERTIONS :
1442
- prelude = '''
1443
- if (x < 0 || x >= %s.length) { err("Function table mask error (out of range)"); %s ; abort(x) }''' % (table_access , get_function_pointer_error (sig , function_table_sigs ))
1444
- asm_setup += '''
1445
- function ftCall_%s(%s) {%s
1446
- return %s(%s);
1447
- }
1448
- ''' % (sig , ', ' .join (full_args ), prelude , table_read , ', ' .join (args ))
1449
1361
return asm_setup
1450
1362
1451
1363
@@ -1471,8 +1383,6 @@ def create_basic_funcs(function_table_sigs, invoke_function_names):
1471
1383
for sig in function_table_sigs :
1472
1384
if shared .Settings .RESERVED_FUNCTION_POINTERS :
1473
1385
basic_funcs .append ('jsCall_%s' % sig )
1474
- if asm_js_emulated_function_pointers ():
1475
- basic_funcs .append ('ftCall_%s' % sig )
1476
1386
return basic_funcs
1477
1387
1478
1388
@@ -1493,12 +1403,6 @@ def create_basic_vars(exported_implemented_functions, forwarded_json, metadata):
1493
1403
1494
1404
def create_exports (exported_implemented_functions , in_table , function_table_data , metadata ):
1495
1405
all_exported = exported_implemented_functions + function_tables (function_table_data )
1496
- # In asm.js + emulated function pointers, export all the table because we use
1497
- # JS to add the asm.js module's functions to the table (which is external
1498
- # in this mode). In wasm, we don't need that since wasm modules can
1499
- # directly add functions to the imported Table.
1500
- if not shared .Settings .WASM and shared .Settings .EMULATED_FUNCTION_POINTERS :
1501
- all_exported += in_table
1502
1406
exports = []
1503
1407
for export in sorted (set (all_exported )):
1504
1408
exports .append (quote (export ) + ": " + export )
@@ -1518,10 +1422,7 @@ def create_exports(exported_implemented_functions, in_table, function_table_data
1518
1422
1519
1423
1520
1424
def function_tables (function_table_data ):
1521
- if not asm_js_emulated_function_pointers ():
1522
- return ['dynCall_' + table for table in function_table_data ]
1523
- else :
1524
- return []
1425
+ return ['dynCall_' + table for table in function_table_data ]
1525
1426
1526
1427
1527
1428
def create_the_global (metadata ):
@@ -1577,20 +1478,6 @@ def create_receiving(function_table_data, function_tables_defs, exported_impleme
1577
1478
table = table .replace ('var ' + tableName , 'var ' + tableName + ' = Module["' + tableName + '"]' )
1578
1479
receiving += table + '\n '
1579
1480
1580
- if shared .Settings .EMULATED_FUNCTION_POINTERS :
1581
- # in asm.js emulated function tables, emit the table on the outside, where
1582
- # JS can manage it (for wasm, a native wasm Table is used directly, and we
1583
- # don't need this)
1584
- if not shared .Settings .WASM :
1585
- receiving += '\n ' + function_tables_defs .replace ('// EMSCRIPTEN_END_FUNCS\n ' , '' )
1586
- # wasm still needs definitions for dyncalls on the outside, for JS
1587
- receiving += '\n ' + '' .join (['Module["dynCall_%s"] = dynCall_%s\n ' % (sig , sig ) for sig in function_table_data ])
1588
- if not shared .Settings .WASM :
1589
- for sig in function_table_data .keys ():
1590
- name = 'FUNCTION_TABLE_' + sig
1591
- fullname = name if not shared .Settings .SIDE_MODULE else ('SIDE_' + name )
1592
- receiving += 'Module["' + name + '"] = ' + fullname + ';\n '
1593
-
1594
1481
return receiving
1595
1482
1596
1483
0 commit comments