Skip to content

Commit

Permalink
Remove yet more WASM_BACKEND usage in src/. See #11860
Browse files Browse the repository at this point in the history
  • Loading branch information
kripken committed Aug 12, 2020
1 parent c6212ef commit b644e12
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 79 deletions.
13 changes: 0 additions & 13 deletions src/library_stack_trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
*/

var LibraryStackTrace = {

$demangle__deps: [
#if MINIMAL_RUNTIME && !WASM_BACKEND
'$stackSave', '$stackAlloc', '$stackRestore'
#if ASSERTIONS
, '$warnOnce'
#endif
#endif
],
$demangle: function(func) {
#if DEMANGLE_SUPPORT
// If demangle has failed before, stop demangling any further function names
Expand Down Expand Up @@ -54,11 +45,7 @@ var LibraryStackTrace = {

$demangleAll: function(text) {
var regex =
#if WASM_BACKEND
/\b_Z[\w\d_]+/g;
#else
/\b__Z[\w\d_]+/g;
#endif
return text.replace(regex,
function(x) {
var y = demangle(x);
Expand Down
8 changes: 0 additions & 8 deletions src/memoryprofiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ var emscriptenMemoryProfiler = {
totalTimesFreeCalled: 0,

// Tracks the highest seen location of the STACKTOP variable.
#if WASM_BACKEND
stackTopWatermark: Infinity,
#else
stackTopWatermark: 0,
#endif

// The canvas DOM element to which to draw the allocation map.
canvas: null,
Expand Down Expand Up @@ -160,11 +156,7 @@ var emscriptenMemoryProfiler = {

recordStackWatermark: function() {
var self = emscriptenMemoryProfiler;
#if WASM_BACKEND
self.stackTopWatermark = Math.min(self.stackTopWatermark, STACKTOP);
#else
self.stackTopWatermark = Math.max(self.stackTopWatermark, STACKTOP);
#endif
},

onMalloc: function onMalloc(ptr, size) {
Expand Down
10 changes: 4 additions & 6 deletions src/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,10 @@ var LibraryManager = {
}
}

if (WASM_BACKEND) {
// all asm.js methods should just be run in JS. We should optimize them eventually into wasm. TODO
for (var x in lib) {
if (lib[x + '__asm']) {
lib[x + '__asm'] = undefined;
}
// all asm.js methods should just be run in JS. We should optimize them eventually into wasm. TODO
for (var x in lib) {
if (lib[x + '__asm']) {
lib[x + '__asm'] = undefined;
}
}

Expand Down
7 changes: 1 addition & 6 deletions src/postamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@

// === Auto-generated postamble setup entry stuff ===

#if !WASM_BACKEND && !WASM
// asm.js startup is synchronous
Module['asm'] = asm;
#endif

{{{ exportRuntime() }}}

#if MEM_INIT_IN_WASM == 0
Expand Down Expand Up @@ -194,7 +189,7 @@ function callMain(args) {
var start = Date.now();
#endif

#if WASM_BACKEND && STACK_OVERFLOW_CHECK >= 2
#if STACK_OVERFLOW_CHECK >= 2
Module['___set_stack_limit'](STACK_MAX);
#endif

Expand Down
21 changes: 2 additions & 19 deletions src/postamble_minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ function initRuntime(asm) {

#if USE_PTHREADS
// Export needed variables that worker.js needs to Module.
#if WASM_BACKEND
Module['_emscripten_tls_init'] = _emscripten_tls_init;
#endif
Module['HEAPU32'] = HEAPU32;
Module['dynCall_ii'] = dynCall_ii;
Module['registerPthreadPtr'] = registerPthreadPtr;
Expand Down Expand Up @@ -88,26 +86,11 @@ var imports = {
'env': asmLibraryArg
, '{{{ WASI_MODULE_NAME }}}': asmLibraryArg
#endif // MINIFY_WASM_IMPORTED_MODULES
#if WASM_BACKEND == 0
, 'global': {
'NaN': NaN,
'Infinity': Infinity
},
'global.Math': Math,
'asm2wasm': {
'f64-rem': function(x, y) { return x % y; },
'debugger': function() {
#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
debugger;
#endif
}
}
#endif
};

// In non-fastcomp non-asm.js builds, grab wasm exports to outer scope
// for emscripten_get_exported_function() to be able to access them.
#if (LibraryManager.has('library_exports.js')) && (WASM || WASM_BACKEND)
#if LibraryManager.has('library_exports.js')) && WASM
var asm;
#endif

Expand Down Expand Up @@ -164,7 +147,7 @@ WebAssembly.instantiate(Module['wasm'], imports).then(function(output) {
wasmModule = output.module || Module['wasm'];
#endif

#if !(LibraryManager.has('library_exports.js') && (WASM || WASM_BACKEND)) && !EMBIND
#if !(LibraryManager.has('library_exports.js') && WASM) && !EMBIND
// If not using the emscripten_get_exported_function() API or embind, keep the 'asm'
// exports variable in local scope to this instantiate function to save code size.
// (otherwise access it without to export it to outer scope)
Expand Down
20 changes: 0 additions & 20 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ var wasmMemory;
// In fastcomp asm.js, we don't need a wasm Table at all.
// In the wasm backend, we polyfill the WebAssembly object,
// so this creates a (non-native-wasm) table for us.
#if WASM_BACKEND || WASM
#include "runtime_init_table.js"
#endif // WASM_BACKEND || WASM
#if USE_PTHREADS
// For sending to workers.
Expand Down Expand Up @@ -790,11 +788,6 @@ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
function createExportWrapper(name, fixedasm) {
return function() {
var displayName = name;
#if !WASM_BACKEND
if (name[0] == '_') {
displayName = name.substr(1);
}
#endif
var asm = fixedasm;
if (!fixedasm) {
asm = Module['asm'];
Expand Down Expand Up @@ -887,15 +880,6 @@ function createWasm() {
'env': asmLibraryArg,
'{{{ WASI_MODULE_NAME }}}': asmLibraryArg
#endif // MINIFY_WASM_IMPORTED_MODULES
#if WASM_BACKEND == 0
,
'global': {
'NaN': NaN,
'Infinity': Infinity
},
'global.Math': Math,
'asm2wasm': asm2wasmImports
#endif
};
// Load the wasm module and create an instance of using native support in the JS engine.
// handle a generated wasm instance, receiving its exports and
Expand Down Expand Up @@ -1148,10 +1132,6 @@ function createWasm() {
}
#endif

#if WASM && !WASM_BACKEND // fastcomp wasm support: create an asm.js-like function
Module['asm'] = createWasm;
#endif

// Globals used by JS i64 conversions
var tempDouble;
var tempI64;
Expand Down
9 changes: 2 additions & 7 deletions src/preamble_minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ var HEAPF32 = new Float32Array(buffer);
var HEAPF64 = new Float64Array(buffer);
#endif
#if USE_PTHREADS && ((MEM_INIT_METHOD == 1 && !MEM_INIT_IN_WASM && !SINGLE_FILE) || (SINGLE_FILE && !WASM && !WASM_BACKEND) || USES_DYNAMIC_ALLOC)
#if USE_PTHREADS && ((MEM_INIT_METHOD == 1 && !MEM_INIT_IN_WASM && !SINGLE_FILE) || USES_DYNAMIC_ALLOC)
if (!ENVIRONMENT_IS_PTHREAD) {
#endif
Expand All @@ -179,16 +179,11 @@ HEAPU8.set(new Uint8Array(Module['mem']), GLOBAL_BASE);
#endif
#if SINGLE_FILE && !WASM && !WASM_BACKEND
#include "base64Decode.js"
HEAPU8.set(base64Decode('{{{ getQuoted("BASE64_MEMORY_INITIALIZER") }}}'), GLOBAL_BASE);
#endif

#if USES_DYNAMIC_ALLOC
HEAP32[DYNAMICTOP_PTR>>2] = {{{ getQuoted('DYNAMIC_BASE') }}};
#endif
#if USE_PTHREADS && ((MEM_INIT_METHOD == 1 && !MEM_INIT_IN_WASM && !SINGLE_FILE) || (SINGLE_FILE && !WASM && !WASM_BACKEND) || USES_DYNAMIC_ALLOC)
#if USE_PTHREADS && ((MEM_INIT_METHOD == 1 && !MEM_INIT_IN_WASM && !SINGLE_FILE) || USES_DYNAMIC_ALLOC)
}
#endif
Expand Down

0 comments on commit b644e12

Please sign in to comment.