aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-05-27 15:26:10 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-05-27 15:26:10 -0700
commit604377be4fc60057743a6ed226a743bf2f6b67c0 (patch)
tree194e3920a64384910eb5cece2964ffa04659c996
parent2f0867998ff917d44be000699db443737c153ed3 (diff)
option to not use FHEAP at all, with USE_TYPED_ARRAY_FHEAP=0
-rw-r--r--src/parseTools.js5
-rw-r--r--src/preamble.js20
-rw-r--r--src/settings.js3
3 files changed, 23 insertions, 5 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index bd68888b..e2ecd074 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -701,7 +701,7 @@ function makeCopyValue(dest, destPos, src, srcPos, type, modifier) {
}
// Null is special-cased: We copy over all heaps
return 'IHEAP[' + dest + '+' + destPos + '] = IHEAP[' + src + '+' + srcPos + ']; ' +
- 'FHEAP[' + dest + '+' + destPos + '] = FHEAP[' + src + '+' + srcPos + ']; ' +
+ (USE_TYPED_ARRAY_FHEAP ? 'FHEAP[' + dest + '+' + destPos + '] = FHEAP[' + src + '+' + srcPos + ']; ' : '') +
(SAFE_HEAP ? 'SAFE_HEAP_COPY_HISTORY(' + dest + ' + ' + destPos + ', ' + src + ' + ' + srcPos + ')' : '');
}
@@ -753,8 +753,9 @@ function makeGetSlabs(ptr, type, allowMultiple) {
return ['HEAP'];
} else {
if (type in Runtime.FLOAT_TYPES || type === 'int64') {
+ warn(USE_TYPED_ARRAY_FHEAP, 'Attempt to use FHEAP without USE_TYPED_ARRAY_FHEAP');
return ['FHEAP'];
- } else if (type in Runtime.INT_TYPES || isPointerType(type)) {
+ } else if (type in Runtime.INT_TYPES || isPointerType(type) || !USE_TYPED_ARRAY_FHEAP) {
return ['IHEAP'];
} else {
assert(allowMultiple, 'Unknown slab type and !allowMultiple: ' + type);
diff --git a/src/preamble.js b/src/preamble.js
index 1a4fdff3..f6b0b633 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -63,25 +63,31 @@ function SAFE_HEAP_STORE(dest, value, type, ignore) {
print((new Error()).stack);
throw "Bad store!" + dest;
}
+#if USE_TYPED_ARRAY_FHEAP
if (type === null) {
IHEAP[dest] = value;
FHEAP[dest] = value;
} else if (type in Runtime.FLOAT_TYPES) {
FHEAP[dest] = value;
- } else {
+ } else
+#endif
+ {
IHEAP[dest] = value;
}
}
function SAFE_HEAP_LOAD(dest, type, ignore) {
SAFE_HEAP_ACCESS(dest, type, ignore);
+#if USE_TYPED_ARRAY_FHEAP
if (type in Runtime.FLOAT_TYPES) {
#if SAFE_HEAP_LOG
print('load : ' + dest + ' [' + type + '] |' + FHEAP[dest] + '|');
#endif
return FHEAP[dest];
- } else {
+ } else
+#endif
+ {
#if SAFE_HEAP_LOG
- print('load : ' + dest + ' [' + type + '] |' + IHEAP[dest] + '|');
+ print('load : ' + dest + ' [' + type + '] |' + IHEAP[dest] + '|');
#endif
return IHEAP[dest];
}
@@ -299,12 +305,18 @@ function __initializeRuntime__() {
// TODO: Remove one of the 3 heaps!
HAS_TYPED_ARRAYS = false;
try {
+#if USE_TYPED_ARRAY_FHEAP
HAS_TYPED_ARRAYS = !!Int32Array && !!Float64Array && !!(new Int32Array()['subarray']); // check for full engine support (use string 'subarray' to avoid closure compiler confusion)
+#else
+ HAS_TYPED_ARRAYS = !!Int32Array && !!(new Int32Array()['subarray']); // check for full engine support (use string #endif
+#endif
} catch(e) {}
if (HAS_TYPED_ARRAYS) {
HEAP = IHEAP = new Int32Array(TOTAL_MEMORY);
+#if USE_TYPED_ARRAY_FHEAP
FHEAP = new Float64Array(TOTAL_MEMORY);
+#endif
} else
#endif
{
@@ -324,7 +336,9 @@ function __initializeRuntime__() {
Module['HEAP'] = HEAP;
Module['IHEAP'] = IHEAP;
+#if USE_TYPED_ARRAY_FHEAP
Module['FHEAP'] = FHEAP;
+#endif
STACK_ROOT = STACKTOP = alignMemoryPage(10);
var TOTAL_STACK = 1024*1024; // XXX: Changing this value can lead to bad perf on v8!
diff --git a/src/settings.js b/src/settings.js
index 45934c8d..d03d3aa9 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -39,6 +39,9 @@ INIT_HEAP = 0; // Whether to initialize memory anywhere other than the stack to
OPTIMIZE = 0; // Optimize llvm operations into js commands
RELOOP = 0; // Recreate js native loops from llvm data
USE_TYPED_ARRAYS = 0; // Try to use typed arrays for the heap
+USE_TYPED_ARRAY_FHEAP = 1; // When USE_TYPED_ARRAYS is enabled, enables a separate FHEAP of Float64.
+ // When disabled, assumes FHEAP is not needed, i.e., no float/int64/etc. operations
+ // are stored or loaded
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