MCPcopy
hub / github.com/plasma-umass/browsix / integrateWasmJS

Function integrateWasmJS

src/ld.js:17–334  ·  view source on GitHub ↗
(Module)

Source from the content-addressed store, hash-verified

15 */
16
17function integrateWasmJS(Module) {
18 // wasm.js has several methods for creating the compiled code module here:
19 // * 'native-wasm' : use native WebAssembly support in the browser
20 // * 'interpret-s-expr': load s-expression code from a .wast and interpret
21 // * 'interpret-binary': load binary wasm and interpret
22 // * 'interpret-asm2wasm': load asm.js code, translate to wasm, and interpret
23 // * 'asmjs': no wasm, just load the asm.js code and use that (good for testing)
24 // The method can be set at compile time (BINARYEN_METHOD), or runtime by setting Module['wasmJSMethod'].
25 // The method can be a comma-separated list, in which case, we will try the
26 // options one by one. Some of them can fail gracefully, and then we can try
27 // the next.
28
29 // inputs
30
31 var method = Module['wasmJSMethod'] || (Module['wasmJSMethod'] || "native-wasm") || 'native-wasm,interpret-s-expr'; // by default, try native and then .wast
32 Module['wasmJSMethod'] = method;
33
34 var wasmTextFile = Module['wasmTextFile'] || undefined;
35 var wasmBinaryFile = Module['wasmBinaryFile'] || undefined;
36 var asmjsCodeFile = Module['asmjsCodeFile'] || undefined;
37
38 // utilities
39
40 var wasmPageSize = 64*1024;
41
42 var asm2wasmImports = { // special asm2wasm imports
43 "f64-rem": function(x, y) {
44 return x % y;
45 },
46 "f64-to-int": function(x) {
47 return x | 0;
48 },
49 "i32s-div": function(x, y) {
50 return ((x | 0) / (y | 0)) | 0;
51 },
52 "i32u-div": function(x, y) {
53 return ((x >>> 0) / (y >>> 0)) >>> 0;
54 },
55 "i32s-rem": function(x, y) {
56 return ((x | 0) % (y | 0)) | 0;
57 },
58 "i32u-rem": function(x, y) {
59 return ((x >>> 0) % (y >>> 0)) >>> 0;
60 },
61 "debugger": function() {
62 debugger;
63 },
64 };
65
66 var info = {
67 'global': null,
68 'env': null,
69 'asm2wasm': asm2wasmImports,
70 'parent': Module // Module inside wasm-js.cpp refers to wasm-js.cpp; this allows access to the outside program.
71 };
72
73 var exports = null;
74

Callers 2

ld.jsFile · 0.85
personalityChangedFunction · 0.85

Calls 4

fixImportsFunction · 0.85
doNativeWasmFunction · 0.85
doJustAsmFunction · 0.85
doWasmPolyfillFunction · 0.85

Tested by

no test coverage detected