aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/library.js4
-rw-r--r--src/preamble.js35
-rw-r--r--src/runtime.js6
-rw-r--r--src/settings.js7
4 files changed, 45 insertions, 7 deletions
diff --git a/src/library.js b/src/library.js
index 1d296981..a4278b9f 100644
--- a/src/library.js
+++ b/src/library.js
@@ -5493,8 +5493,8 @@ LibraryManager.library = {
eval(Pointer_stringify(ptr));
},
- _Z21emscripten_run_scriptPKc: function(ptr) {
- eval(Pointer_stringify(ptr));
+ emscripten_run_script_int: function(ptr) {
+ return eval(Pointer_stringify(ptr));
},
$Profiling: {
diff --git a/src/preamble.js b/src/preamble.js
index 3fcdf1f8..7fd51733 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -532,6 +532,41 @@ var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32;
var STACK_ROOT, STACKTOP, STACK_MAX;
var STATICTOP;
+#if USE_TYPED_ARRAYS
+var LAST_STATICTOP;
+function enlargeMemory() {
+ // LAST_STATICTOP is the previous top, TOTAL_MEMORY is the current size of the actual array, and STATICTOP is the new top.
+#if ASSERTIONS
+ assert(STATICTOP >= TOTAL_MEMORY && LAST_STATICTOP < TOTAL_MEMORY);
+ assert(TOTAL_MEMORY > 4); // So the loop below will not be infinite
+#endif
+ while (TOTAL_MEMORY <= STATICTOP) { // Simple heuristic. Override enlargeMemory() if your program has something more optimal for it
+ TOTAL_MEMORY = alignMemoryPage(TOTAL_MEMORY*1.25);
+ }
+#if USE_TYPED_ARRAYS == 1
+ var oldIHEAP = IHEAP;
+ HEAP = IHEAP = new Int32Array(TOTAL_MEMORY);
+ IHEAP.set(oldIHEAP);
+#if USE_FHEAP
+ var oldFHEAP = FHEAP;
+ FHEAP = new Float64Array(TOTAL_MEMORY);
+ FHEAP.set(oldFHEAP);
+#endif
+#endif
+#if USE_TYPED_ARRAYS == 2
+ var oldHEAP8 = HEAP8;
+ var buffer = new ArrayBuffer(TOTAL_MEMORY);
+ HEAP8 = new Int8Array(buffer);
+ HEAP16 = new Int16Array(buffer);
+ HEAP32 = new Int32Array(buffer);
+ HEAPU8 = new Uint8Array(buffer);
+ HEAPU16 = new Uint16Array(buffer);
+ HEAPU32 = new Uint32Array(buffer);
+ HEAPF32 = new Float32Array(buffer);
+ HEAP8.set(oldHEAP8);
+#endif
+}
+#endif
var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || {{{ TOTAL_MEMORY }}};
var FAST_MEMORY = Module['FAST_MEMORY'] || {{{ FAST_MEMORY }}};
diff --git a/src/runtime.js b/src/runtime.js
index a6261c74..e0eb7404 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -56,7 +56,11 @@ var RuntimeGenerator = {
// An allocation that cannot be free'd
staticAlloc: function(size) {
- return RuntimeGenerator.alloc(size, 'STATIC', INIT_HEAP);
+ var ret = '';
+ if (USE_TYPED_ARRAYS) ret += 'LAST_STATICTOP = STATICTOP;'
+ ret += RuntimeGenerator.alloc(size, 'STATIC', INIT_HEAP);
+ if (USE_TYPED_ARRAYS) ret += 'if (STATICTOP >= TOTAL_MEMORY) enlargeMemory();'
+ return ret;
},
alignMemory: function(target, quantum) {
diff --git a/src/settings.js b/src/settings.js
index 0964d4bb..4dc94f4a 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -33,10 +33,9 @@ var INIT_STACK = 1; // Whether to initialize memory on the stack to 0.
var INIT_HEAP = 0; // Whether to initialize memory anywhere other than the stack to 0.
var FAST_MEMORY = 2*1024*1024; // The amount of memory to initialize to 0. This ensures it will be
// in a flat array. This only matters in non-typed array builds.
-var TOTAL_MEMORY = 50*1024*1024; // The total amount of memory to use. This mainly matters in
- // typed array builds - accessing memory about this value will
- // return undefined values and lead to serious problems, and there
- // is currently no warning about that!
+var TOTAL_MEMORY = 50*1024*1024; // The total amount of memory to use. Using more memory than this will
+ // cause us to expand the heap, which can be costly with typed arrays:
+ // we need to copy the old heap into a new one in that case.
// Code embetterments
var MICRO_OPTS = 0; // Various micro-optimizations, like nativizing variables