Skip to content

Commit 7919643

Browse files
committed
Remove final WASM_BACKEND usage in src/. See #11860
1 parent c6212ef commit 7919643

6 files changed

+1
-136
lines changed

src/runtime_functions.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
* SPDX-License-Identifier: MIT
55
*/
66

7-
#if !WASM_BACKEND
8-
var jsCallStartIndex = 1;
9-
var functionPointers = new Array({{{ RESERVED_FUNCTION_POINTERS }}});
10-
#endif // !WASM_BACKEND
11-
127
#if WASM
138
// Wraps a JS function as a wasm function with a given signature.
149
function convertJsFunctionToWasm(func, sig) {
@@ -147,11 +142,7 @@ function addFunctionWasm(func, sig) {
147142
if (!(err instanceof RangeError)) {
148143
throw err;
149144
}
150-
#if WASM_BACKEND
151145
throw 'Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.';
152-
#else
153-
throw 'Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH.';
154-
#endif
155146
}
156147
}
157148

@@ -193,26 +184,9 @@ function addFunction(func, sig) {
193184
#endif // ASSERTIONS == 2
194185
#endif // ASSERTIONS
195186

196-
#if WASM_BACKEND
197187
return addFunctionWasm(func, sig);
198-
#else
199-
200-
var base = 0;
201-
for (var i = base; i < base + {{{ RESERVED_FUNCTION_POINTERS }}}; i++) {
202-
if (!functionPointers[i]) {
203-
functionPointers[i] = func;
204-
return jsCallStartIndex + i;
205-
}
206-
}
207-
throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
208-
209-
#endif // WASM_BACKEND
210188
}
211189

212190
function removeFunction(index) {
213-
#if WASM_BACKEND
214191
removeFunctionWasm(index);
215-
#else
216-
functionPointers[index-jsCallStartIndex] = null;
217-
#endif // WASM_BACKEND
218192
}

src/runtime_init_table.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
var wasmTable = new WebAssembly.Table({
33
'initial': {{{ getQuoted('WASM_TABLE_SIZE') }}},
44
#if !ALLOW_TABLE_GROWTH
5-
#if WASM_BACKEND
65
'maximum': {{{ getQuoted('WASM_TABLE_SIZE') }}} + {{{ RESERVED_FUNCTION_POINTERS }}},
7-
#else
8-
'maximum': {{{ getQuoted('WASM_TABLE_SIZE') }}},
96
#endif
10-
#endif // WASM_BACKEND
117
'element': 'anyfunc'
128
});
139
#endif

src/runtime_stack_check.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,9 @@ function writeStackCookie() {
1010
#if ASSERTIONS
1111
assert((STACK_MAX & 3) == 0);
1212
#endif
13-
#if WASM_BACKEND
1413
// The stack grows downwards
1514
HEAPU32[(STACK_MAX >> 2)+1] = 0x2135467;
1615
HEAPU32[(STACK_MAX >> 2)+2] = 0x89BACDFE;
17-
#else
18-
HEAPU32[(STACK_MAX >> 2)-1] = 0x2135467;
19-
HEAPU32[(STACK_MAX >> 2)-2] = 0x89BACDFE;
20-
#endif
2116
#if !USE_ASAN
2217
// Also test the global address 0 for integrity.
2318
// We don't do this with ASan because ASan does its own checks for this.
@@ -26,13 +21,8 @@ function writeStackCookie() {
2621
}
2722

2823
function checkStackCookie() {
29-
#if WASM_BACKEND
3024
var cookie1 = HEAPU32[(STACK_MAX >> 2)+1];
3125
var cookie2 = HEAPU32[(STACK_MAX >> 2)+2];
32-
#else
33-
var cookie1 = HEAPU32[(STACK_MAX >> 2)-1];
34-
var cookie2 = HEAPU32[(STACK_MAX >> 2)-2];
35-
#endif
3626
if (cookie1 != 0x2135467 || cookie2 != 0x89BACDFE) {
3727
abort('Stack overflow! Stack cookie has been overwritten, expected hex dwords 0x89BACDFE and 0x2135467, but received 0x' + cookie2.toString(16) + ' ' + cookie1.toString(16));
3828
}

src/shell_minimal.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -96,29 +96,6 @@ if (ENVIRONMENT_IS_SHELL) {
9696
}
9797
#endif
9898

99-
#if !WASM && !WASM_BACKEND
100-
// asm.js loading in fastcomp backend:
101-
102-
#if ENVIRONMENT_MAY_BE_NODE
103-
if (ENVIRONMENT_IS_NODE) {
104-
var fs = require('fs');
105-
#if MEM_INIT_METHOD == 1 && !MEM_INIT_IN_WASM
106-
Module['mem'] = fs.readFileSync(__dirname + '/{{{ TARGET_BASENAME }}}.mem');
107-
#endif
108-
}
109-
#endif
110-
111-
#if ENVIRONMENT_MAY_BE_SHELL
112-
if (ENVIRONMENT_IS_SHELL) {
113-
eval(read('{{{ TARGET_BASENAME }}}.asm.js')+'');
114-
#if MEM_INIT_METHOD == 1 && !MEM_INIT_IN_WASM
115-
Module['mem'] = read('{{{ TARGET_BASENAME }}}.mem', 'binary');
116-
#endif
117-
}
118-
#endif
119-
120-
#endif
121-
12299
#endif // !SINGLE_FILE
123100

124101
// Redefine these in a --pre-js to override behavior. If you would like to

src/support.js

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,6 @@ function warnOnce(text) {
3636
}
3737
}
3838

39-
#if !WASM_BACKEND
40-
var asm2wasmImports = { // special asm2wasm imports
41-
"f64-rem": function(x, y) {
42-
return x % y;
43-
},
44-
"debugger": function() {
45-
#if ASSERTIONS // Disable debugger; statement from being present in release builds to avoid Firefox deoptimizations, see https://bugzilla.mozilla.org/show_bug.cgi?id=1538375
46-
debugger;
47-
#endif
48-
}
49-
#if NEED_ALL_ASM2WASM_IMPORTS
50-
,
51-
"f64-to-int": function(x) {
52-
return x | 0;
53-
},
54-
"i32s-div": function(x, y) {
55-
return ((x | 0) / (y | 0)) | 0;
56-
},
57-
"i32u-div": function(x, y) {
58-
return ((x >>> 0) / (y >>> 0)) >>> 0;
59-
},
60-
"i32s-rem": function(x, y) {
61-
return ((x | 0) % (y | 0)) | 0;
62-
},
63-
"i32u-rem": function(x, y) {
64-
return ((x >>> 0) % (y >>> 0)) >>> 0;
65-
}
66-
#endif // NEED_ALL_ASM2WASM_IMPORTS
67-
};
68-
#endif
69-
7039
#if RELOCATABLE
7140
// dynamic linker/loader (a-la ld.so on ELF systems)
7241
var LDSO = {
@@ -104,12 +73,8 @@ function fetchBinary(url) {
10473
}
10574

10675
function asmjsMangle(x) {
107-
#if WASM_BACKEND
10876
var unmangledSymbols = {{{ buildStringArray(WASM_FUNCTIONS_THAT_ARE_NOT_NAME_MANGLED) }}};
10977
return x.indexOf('dynCall_') == 0 || unmangledSymbols.indexOf(x) != -1 ? x : '_' + x;
110-
#else
111-
return x;
112-
#endif
11378
}
11479

11580
// loadDynamicLibrary loads dynamic library @ lib URL / path and returns handle for loaded DSO.
@@ -260,18 +225,6 @@ function loadDynamicLibrary(lib, flags) {
260225
// We should copy the symbols (which include methods and variables) from SIDE_MODULE to MAIN_MODULE.
261226

262227
var module_sym = asmjsMangle(sym);
263-
#if !WASM_BACKEND
264-
// Module of SIDE_MODULE has not only the symbols (which should be copied)
265-
// but also others (print*, asmGlobal*, FUNCTION_TABLE_**, NAMED_GLOBALS, and so on).
266-
//
267-
// When the symbol (which should be copied) is method, Module.* 's type becomes function.
268-
// When the symbol (which should be copied) is variable, Module.* 's type becomes number.
269-
// Except for the symbol prefix (_), there is no difference in the symbols (which should be copied) and others.
270-
// So this just copies over compiled symbols (which start with _).
271-
if (!sym.startsWith('dynCall_') && sym[0] !== '_') {
272-
continue;
273-
}
274-
#endif
275228

276229
if (!Module.hasOwnProperty(module_sym)) {
277230
Module[module_sym] = libModule[sym];
@@ -334,11 +287,7 @@ function relocateExports(exports, memoryBase, tableBase, moduleLocal) {
334287
}
335288
relocated[e] = value;
336289
if (moduleLocal) {
337-
#if WASM_BACKEND
338290
moduleLocal['_' + e] = value;
339-
#else
340-
moduleLocal[e] = value;
341-
#endif
342291
}
343292
}
344293
return relocated;
@@ -549,9 +498,6 @@ function loadWebAssemblyModule(binary, flags) {
549498
'global.Math': Math,
550499
env: proxy,
551500
{{{ WASI_MODULE_NAME }}}: proxy,
552-
#if !WASM_BACKEND
553-
'asm2wasm': asm2wasmImports
554-
#endif
555501
};
556502
#if ASSERTIONS
557503
var oldTable = [];
@@ -711,7 +657,7 @@ var GLOBAL_BASE = {{{ GLOBAL_BASE }}};
711657
GLOBAL_BASE = alignMemory(GLOBAL_BASE, {{{ MAX_GLOBAL_ALIGN || 1 }}});
712658
#endif
713659

714-
#if WASM_BACKEND && USE_PTHREADS
660+
#if USE_PTHREADS
715661
// JS library code refers to Atomics in the manner used from asm.js, provide
716662
// the same API here.
717663
var Atomics_load = Atomics.load;

src/worker.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,6 @@ this.onmessage = function(e) {
7272
var imports = {};
7373
#endif
7474

75-
#if !WASM_BACKEND
76-
// Initialize the thread-local field(s):
77-
#if MINIMAL_RUNTIME
78-
var imports = {};
79-
#endif
80-
#endif
81-
8275
// Initialize the global "process"-wide fields:
8376
#if !MINIMAL_RUNTIME
8477
Module['DYNAMIC_BASE'] = e.data.DYNAMIC_BASE;
@@ -178,31 +171,20 @@ this.onmessage = function(e) {
178171
selfThreadId = e.data.selfThreadId;
179172
parentThreadId = e.data.parentThreadId;
180173
// Establish the stack frame for this thread in global scope
181-
#if WASM_BACKEND
182174
// The stack grows downwards
183175
var max = e.data.stackBase;
184176
var top = e.data.stackBase + e.data.stackSize;
185-
#else
186-
var max = e.data.stackBase + e.data.stackSize;
187-
var top = e.data.stackBase;
188-
#endif
189177
#if ASSERTIONS
190178
assert(threadInfoStruct);
191179
assert(selfThreadId);
192180
assert(parentThreadId);
193181
assert(top != 0);
194182
assert(max != 0);
195-
#if WASM_BACKEND
196183
assert(top > max);
197-
#else
198-
assert(max > top);
199-
#endif
200184
#endif
201185
// Also call inside JS module to set up the stack frame for this pthread in JS module scope
202186
Module['establishStackSpace'](top, max);
203-
#if WASM_BACKEND
204187
Module['_emscripten_tls_init']();
205-
#endif
206188
#if STACK_OVERFLOW_CHECK
207189
Module['writeStackCookie']();
208190
#endif

0 commit comments

Comments
 (0)