aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parseTools.js10
-rw-r--r--src/preamble.js16
-rw-r--r--src/settings.js2
3 files changed, 23 insertions, 5 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index 96007489..ade54f20 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -881,7 +881,7 @@ function makeCopyValues(dest, src, num, type, modifier) {
'}';
} else { // USE_TYPED_ARRAYS == 1
return 'for (var $mcpi_s$=' + src + ',$mcpi_e$=' + src + '+' + num + ',$mcpi_d$=' + dest + '; $mcpi_s$<$mcpi_e$; $mcpi_s$++, $mcpi_d$++) {\n' +
- ' IHEAP[$mcpi_d$] = IHEAP[$mcpi_s$]; FHEAP[$mcpi_d$] = FHEAP[$mcpi_s$];\n' +
+ ' IHEAP[$mcpi_d$] = IHEAP[$mcpi_s$];' + (USE_FHEAP ? ' FHEAP[$mcpi_d$] = FHEAP[$mcpi_s$];' : '') + '\n' +
'}';
}
} else { // USE_TYPED_ARRAYS == 2
@@ -1026,12 +1026,16 @@ function makeGetSlabs(ptr, type, allowMultiple, unsigned) {
return ['HEAP'];
} else if (USE_TYPED_ARRAYS == 1) {
if (type in Runtime.FLOAT_TYPES || type === 'int64') { // XXX should be i64, no?
- return ['FHEAP'];
+ return ['FHEAP']; // If USE_FHEAP is false, will fail at runtime. At compiletime we do need it for library stuff.
} else if (type in Runtime.INT_TYPES || isPointerType(type)) {
return ['IHEAP'];
} else {
assert(allowMultiple, 'Unknown slab type and !allowMultiple: ' + type);
- return ['IHEAP', 'FHEAP']; // unknown, so assign to both typed arrays
+ if (USE_FHEAP) {
+ return ['IHEAP', 'FHEAP']; // unknown, so assign to both typed arrays
+ } else {
+ return ['IHEAP'];
+ }
}
} else { // USE_TYPED_ARRAYS == 2)
if (isPointerType(type)) type = 'i32'; // Hardcoded 32-bit
diff --git a/src/preamble.js b/src/preamble.js
index faf7aa72..ec9e672e 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -89,7 +89,9 @@ function SAFE_HEAP_STORE(dest, value, type, ignore) {
#if USE_TYPED_ARRAYS == 1
if (type === null) {
IHEAP[dest] = value;
+#if USE_FHEAP
FHEAP[dest] = value;
+#endif
} else if (type in Runtime.FLOAT_TYPES) {
FHEAP[dest] = value;
} else {
@@ -516,7 +518,10 @@ function alignMemoryPage(x) {
var HEAP;
#if USE_TYPED_ARRAYS == 1
-var IHEAP, FHEAP;
+var IHEAP;
+#if USE_FHEAP
+var FHEAP;
+#endif
#endif
#if USE_TYPED_ARRAYS == 2
var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32;
@@ -539,8 +544,10 @@ try {
if (HAS_TYPED_ARRAYS) {
#if USE_TYPED_ARRAYS == 1
HEAP = IHEAP = new Int32Array(TOTAL_MEMORY);
+#if USE_FHEAP
FHEAP = new Float64Array(TOTAL_MEMORY);
#endif
+#endif
#if USE_TYPED_ARRAYS == 2
var buffer = new ArrayBuffer(TOTAL_MEMORY);
HEAP8 = new Int8Array(buffer);
@@ -564,7 +571,10 @@ if (HAS_TYPED_ARRAYS) {
HEAP[i] = 0; // XXX We do *not* use {{| makeSetValue(0, 'i', 0, 'null') |}} here, since this is done just to optimize runtime speed
}
#if USE_TYPED_ARRAYS == 1
- IHEAP = FHEAP = HEAP;
+ IHEAP = HEAP;
+#if USE_FHEAP
+ FHEAP = HEAP;
+#endif
#endif
#if USE_TYPED_ARRAYS == 2
abort('Cannot fallback to non-typed array case in USE_TYPED_ARRAYS == 2: Code is too specialized');
@@ -580,8 +590,10 @@ for (var i = 0; i < base.length; i++) {
Module['HEAP'] = HEAP;
#if USE_TYPED_ARRAYS == 1
Module['IHEAP'] = IHEAP;
+#if USE_FHEAP
Module['FHEAP'] = FHEAP;
#endif
+#endif
#if USE_TYPED_ARRAYS == 2
Module['HEAP8'] = HEAP8;
Module['HEAP16'] = HEAP16;
diff --git a/src/settings.js b/src/settings.js
index 0e70316f..17f3f5e8 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -48,6 +48,8 @@ USE_TYPED_ARRAYS = 0; // Try to use typed arrays for the heap
// 64-bit aligned values with a 64-bit typed array. Likewise int64s are stored as int32's,
// which is potentially very dangerous!
// TODO: require compiling with -malign-double, which does align doubles
+USE_FHEAP = 1; // Relevant in USE_TYPED_ARRAYS == 1. If this is disabled, only IHEAP will be used, and FHEAP
+ // not generated at all. This is useful if your code is 100% ints without floats or doubles
SKIP_STACK_IN_SMALL = 1; // When enabled, does not push/pop the stack at all in
// functions that have no basic stack usage. But, they
// may allocate stack later, and in a loop, this can be