forked from emscripten-core/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreamble_minimal.js
More file actions
149 lines (128 loc) · 3.29 KB
/
preamble_minimal.js
File metadata and controls
149 lines (128 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/**
* @license
* Copyright 2019 The Emscripten Authors
* SPDX-License-Identifier: MIT
*/
#include "runtime_safe_heap.js"
#if ASSERTIONS
/** @type {function(*, string=)} */
function assert(condition, text) {
if (!condition) throw text;
}
#endif
/** @param {string|number=} what */
function abort(what) {
#if ASSERTIONS
throw new Error(what);
#else
throw what;
#endif
}
#if SAFE_HEAP
// Globals used by JS i64 conversions (see makeSetValue)
var tempDouble;
var tempI64;
#endif
var tempRet0 = 0;
var setTempRet0 = function(value) {
tempRet0 = value;
}
var getTempRet0 = function() {
return tempRet0;
}
function alignUp(x, multiple) {
if (x % multiple > 0) {
x += multiple - (x % multiple);
}
return x;
}
#if WASM != 2 && MAYBE_WASM2JS
#if !WASM2JS
if (Module['doWasm2JS']) {
#endif
#include "wasm2js.js"
#if !WASM2JS
}
#endif
#endif
#if SINGLE_FILE && WASM == 1 && !WASM2JS
#include "base64Decode.js"
Module['wasm'] = base64Decode('<<< WASM_BINARY_DATA >>>');
#endif
#include "runtime_functions.js"
#include "runtime_strings.js"
var HEAP8, HEAP16, HEAP32, HEAPU8, HEAPU16, HEAPU32, HEAPF32, HEAPF64;
var wasmMemory, buffer, wasmTable;
#if SUPPORT_BIG_ENDIAN
var HEAP_DATA_VIEW;
#endif
function updateGlobalBufferAndViews(b) {
#if ASSERTIONS && USE_PTHREADS
assert(b instanceof SharedArrayBuffer, 'requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag');
#endif
buffer = b;
#if SUPPORT_BIG_ENDIAN
HEAP_DATA_VIEW = new DataView(b);
#endif
HEAP8 = new Int8Array(b);
HEAP16 = new Int16Array(b);
HEAP32 = new Int32Array(b);
HEAPU8 = new Uint8Array(b);
HEAPU16 = new Uint16Array(b);
HEAPU32 = new Uint32Array(b);
HEAPF32 = new Float32Array(b);
HEAPF64 = new Float64Array(b);
}
#if IMPORTED_MEMORY
#if USE_PTHREADS
if (!ENVIRONMENT_IS_PTHREAD) {
#endif
#if ALLOW_MEMORY_GROWTH && MAXIMUM_MEMORY != FOUR_GB
var wasmMaximumMemory = {{{ MAXIMUM_MEMORY >>> 16 }}};
#else
var wasmMaximumMemory = {{{ INITIAL_MEMORY >>> 16}}};
#endif
wasmMemory = new WebAssembly.Memory({
'initial': {{{ INITIAL_MEMORY >>> 16 }}}
#if USE_PTHREADS || !ALLOW_MEMORY_GROWTH || MAXIMUM_MEMORY != FOUR_GB
, 'maximum': wasmMaximumMemory
#endif
#if USE_PTHREADS
, 'shared': true
#endif
});
updateGlobalBufferAndViews(wasmMemory.buffer);
#if USE_PTHREADS
} else {
#if MODULARIZE
updateGlobalBufferAndViews({{{EXPORT_NAME}}}.buffer);
#else
updateGlobalBufferAndViews(wasmMemory.buffer);
#endif
}
#endif // USE_PTHREADS
#endif // IMPORTED_MEMORY
#include "runtime_stack_check.js"
#include "runtime_assertions.js"
#if LOAD_SOURCE_MAP
var wasmSourceMap;
#include "source_map_support.js"
#endif
#if USE_OFFSET_CONVERTER
var wasmOffsetConverter;
#include "wasm_offset_converter.js"
#endif
#if EXIT_RUNTIME
var __ATEXIT__ = []; // functions called during shutdown
#endif
#if ASSERTIONS || SAFE_HEAP || USE_ASAN
var runtimeInitialized = false;
// This is always false in minimal_runtime - the runtime does not have a concept
// of exiting (keeping this variable here for now since it is referenced from
// generated code)
var runtimeExited = false;
#endif
#include "runtime_math.js"
#include "memoryprofiler.js"
#include "runtime_debug.js"
// === Body ===