aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-01-11 18:30:05 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-01-11 18:30:05 -0800
commit8ccf524149bbe222164b79c847628c966d0e9557 (patch)
tree9ad860b0839176cbcd440c36d2eca9616d412bf5
parent654f554f1251e8daaf6f63881ffbf00337cc8664 (diff)
refactor makeGetTempDouble
-rw-r--r--src/analyzer.js2
-rw-r--r--src/library.js2
-rw-r--r--src/parseTools.js17
3 files changed, 13 insertions, 8 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index 0ad3e017..8146c75c 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -656,7 +656,7 @@ function analyzer(data, sidePass) {
value.intertype = 'value';
value.ident = 'Runtime' + (ASM_JS ? '_' : '.') + 'bitshift64(' + sourceElements[0].ident + ', ' +
sourceElements[1].ident + ',"' + value.op + '",' + value.params[1].ident + '$0);' +
- 'var ' + value.assignTo + '$0 = ' + makeGetTempDouble(0) + ', ' + value.assignTo + '$1 = ' + makeGetTempDouble(1) + ';';
+ 'var ' + value.assignTo + '$0 = ' + makeGetTempDouble(0, 'i32') + ', ' + value.assignTo + '$1 = ' + makeGetTempDouble(1, 'i32') + ';';
value.assignTo = null;
i++;
continue;
diff --git a/src/library.js b/src/library.js
index be57e445..8b5c8474 100644
--- a/src/library.js
+++ b/src/library.js
@@ -3905,7 +3905,7 @@ LibraryManager.library = {
___setErrNo(ERRNO_CODES.ERANGE); // not quite correct
}
- {{{ makeStructuralReturn([makeGetTempDouble(0), makeGetTempDouble(1)]) }}};
+ {{{ makeStructuralReturn([makeGetTempDouble(0, 'i32'), makeGetTempDouble(1, 'i32')]) }}};
},
#endif
strtoll__deps: ['_parseInt64'],
diff --git a/src/parseTools.js b/src/parseTools.js
index 6cb3e776..1056fbe4 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1034,8 +1034,13 @@ function asmMultiplyI32(a, b) {
return '(~~(+' + a + ' * +' + b + '))';
}
-function makeGetTempDouble(i) { // TODO: Support other than i32
- return makeGetValue('tempDoublePtr', Runtime.getNativeTypeSize('i32')*i, 'i32');
+function makeGetTempDouble(i, type) { // get an aliased part of the tempDouble temporary storage
+ // Cannot use makeGetValue because it uses us
+ // this is a unique case where we *can* use HEAPF64
+ var slab = type == 'double' ? 'HEAPF64' : makeGetSlabs(null, type)[0];
+ var ptr = getFastValue('tempDoublePtr', '+', Runtime.getNativeTypeSize(type)*i);
+ var offset = type == 'double' ? ptr + '>>3' : getHeapOffset(ptr, type);
+ return slab + '[' + offset + ']';
}
// See makeSetValue
@@ -1051,9 +1056,9 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa
}
if (DOUBLE_MODE == 1 && USE_TYPED_ARRAYS == 2 && type == 'double') {
- return '(HEAP32[tempDoublePtr>>2]=' + makeGetValue(ptr, pos, 'i32', noNeedFirst, unsigned, ignore, align) + ',' +
- 'HEAP32[tempDoublePtr+4>>2]=' + makeGetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'i32', noNeedFirst, unsigned, ignore, align) + ',' +
- 'HEAPF64[tempDoublePtr>>3])';
+ return '(' + makeGetTempDouble(0, 'i32') + '=' + makeGetValue(ptr, pos, 'i32', noNeedFirst, unsigned, ignore, align) + ',' +
+ makeGetTempDouble(1, 'i32') + '=' + makeGetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'i32', noNeedFirst, unsigned, ignore, align) + ',' +
+ makeGetTempDouble(0, 'double') + ')';
}
if (USE_TYPED_ARRAYS == 2 && align) {
@@ -1877,7 +1882,7 @@ function processMathop(item) {
case 'lshr': {
if (!isNumber(idents[1])) {
return '(Runtime' + (ASM_JS ? '_' : '.') + 'bitshift64(' + idents[0] + '[0], ' + idents[0] + '[1],"' + op + '",' + stripCorrections(idents[1]) + '[0]|0),' +
- '[' + makeGetTempDouble(0) + ',' + makeGetTempDouble(1) + '])';
+ '[' + makeGetTempDouble(0, 'i32') + ',' + makeGetTempDouble(1, 'i32') + '])';
}
bits = parseInt(idents[1]);
var ander = Math.pow(2, bits)-1;