aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-06-06 07:40:27 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-06-06 07:40:27 -0700
commitaa1b54bbb54aaf9bbb690ed232c01a20751d3355 (patch)
treef149ba344323a559024de681a2c23a53aa2e63a7
parente068f02137c1de07480886c0f6181150d77816dd (diff)
fixes for USE_TYPED_ARRAYS == 2
-rw-r--r--src/preamble.js23
-rw-r--r--tests/runner.py8
2 files changed, 24 insertions, 7 deletions
diff --git a/src/preamble.js b/src/preamble.js
index e0f97f48..f991cb4a 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -51,6 +51,17 @@ function SAFE_HEAP_ACCESS(dest, type, store, ignore) {
}
}
}
+#if USE_TYPED_ARRAYS == 2
+var warned64 = false;
+function warn64() {
+ if (!warned64) {
+ __ATEXIT__.push(function() {
+ print('Warning: using a 64-bit type with USE_TYPED_ARRAYS == 2. This is emulated as a 32-bit value, and will likely fail horribly.');
+ });
+ warned64 = true;
+ }
+}
+#endif
function SAFE_HEAP_STORE(dest, value, type, ignore) {
#if SAFE_HEAP_LOG
print('SAFE_HEAP store: ' + [dest, type, value, ignore]);
@@ -78,12 +89,12 @@ function SAFE_HEAP_STORE(dest, value, type, ignore) {
assert(type != 'null', 'typed arrays 2 with null type!');
if (type[type.length-1] === '*') type = 'i32'; // hardcoded pointers as 32-bit
switch(type) {
- case 'i8': HEAP8[dest] = value; break;
+ case 'i1': case 'i8': HEAP8[dest] = value; break;
case 'i16': assert(dest % 2 === 0, type + ' loads must be aligned'); HEAP16[dest>>1] = value; break;
case 'i32': assert(dest % 4 === 0, type + ' loads must be aligned'); HEAP32[dest>>2] = value; break;
- case 'i64': assert(dest % 4 === 0, type + ' loads must be aligned'); HEAP32[dest>>2] = value; break; // XXX store int64 as int32
+ case 'i64': assert(dest % 4 === 0, type + ' loads must be aligned'); warn64(); HEAP32[dest>>2] = value; break; // XXX store int64 as int32
case 'float': assert(dest % 4 === 0, type + ' loads must be aligned'); HEAPF32[dest>>2] = value; break;
- case 'double': assert(dest % 4 === 0, type + ' loads must be aligned'); HEAPF32[dest>>2] = value; break; // XXX store doubles as floats
+ case 'double': assert(dest % 4 === 0, type + ' loads must be aligned'); warn64(); HEAPF32[dest>>2] = value; break; // XXX store doubles as floats
default: throw 'weird type for typed array II: ' + type + new Error().stack;
}
#else
@@ -113,7 +124,7 @@ function SAFE_HEAP_LOAD(dest, type, ignore) {
#endif
if (type[type.length-1] === '*') type = 'i32'; // hardcoded pointers as 32-bit
switch(type) {
- case 'i8': {
+ case 'i1': case 'i8': {
#if SAFE_HEAP_LOG
print('SAFE_HEAP load: ' + [dest, originalType, HEAP8[dest], ignore]);
#endif
@@ -133,6 +144,7 @@ function SAFE_HEAP_LOAD(dest, type, ignore) {
print('SAFE_HEAP load: ' + [dest, originalType, HEAP32[dest], ignore]);
#endif
assert(dest % 4 === 0, type + ' loads must be aligned');
+ if (type === 'i64') warn64();
return HEAP32[dest>>2];
break;
}
@@ -141,6 +153,7 @@ function SAFE_HEAP_LOAD(dest, type, ignore) {
print('SAFE_HEAP load: ' + [dest, originalType, HEAPF32[dest], ignore]);
#endif
assert(dest % 4 === 0, type + ' loads must be aligned');
+ if (type === 'double') warn64();
return HEAPF32[dest>>2];
break;
}
@@ -452,7 +465,7 @@ function __initializeRuntime__() {
}
function __shutdownRuntime__() {
- while( __ATEXIT__.length > 0) {
+ while(__ATEXIT__.length > 0) {
var atexit = __ATEXIT__.pop();
var func = atexit.func;
if (typeof func === 'number') {
diff --git a/tests/runner.py b/tests/runner.py
index 738f639e..c94906f2 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1715,6 +1715,9 @@ if 'benchmark' not in sys.argv:
self.do_test(src, 'Pfannkuchen(%d) = %d.' % (i,j), [str(i)], no_build=i>1)
def test_raytrace(self):
+ global USE_TYPED_ARRAYS
+ if USE_TYPED_ARRAYS == 2: return self.skip() # relies on double values
+
src = open(path_from_root('tests', 'raytrace.cpp'), 'r').read()
output = open(path_from_root('tests', 'raytrace.ppm'), 'r').read()
self.do_test(src, output, ['3', '16'])
@@ -2492,6 +2495,7 @@ class %s(T):
USE_TYPED_ARRAYS = %d
INVOKE_RUN = 1
RELOOP = OPTIMIZE = embetter
+ if USE_TYPED_ARRAYS == 2: RELOOP = 0 # XXX
QUANTUM_SIZE = quantum_size
ASSERTIONS = 1-embetter
SAFE_HEAP = 1-(embetter and llvm_opts)
@@ -2517,8 +2521,8 @@ TT = %s
for name, compiler, quantum, embetter, typed_arrays in [
('clang', CLANG, 1, 0, 0), ('clang', CLANG, 4, 0, 0), ('llvm_gcc', LLVM_GCC, 4, 0, 0),
('clang', CLANG, 1, 1, 1), ('clang', CLANG, 4, 1, 1), ('llvm_gcc', LLVM_GCC, 4, 1, 1),
-# ('clang', CLANG, 4, 1, 2),
-# ('llvm_gcc', LLVM_GCC, 4, 0, 2)
+ #('clang', CLANG, 4, 1, 2),
+ #('llvm_gcc', LLVM_GCC, 4, 1, 2),
]:
fullname = '%s_%d_%d%s%s' % (
name, llvm_opts, embetter, '' if quantum == 4 else '_q' + str(quantum), '' if typed_arrays in [0, 1] else '_t' + str(typed_arrays)