aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-02-20 13:57:49 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-02-20 13:57:49 -0800
commit7cad64ba5c02c6efa80b6686f27439133d103978 (patch)
treeaad7eb29f6dfda773da8946b239ab1c95b4e9cc5 /src
parent3d2d7c27ded744e69587b84a393c8fe5327fd78e (diff)
handle bitcasts of doubles to i64s and vice versa properly
Diffstat (limited to 'src')
-rw-r--r--src/jsifier.js8
-rw-r--r--src/parseTools.js12
2 files changed, 16 insertions, 4 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 21ffa7e9..b3701112 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1046,10 +1046,14 @@ function JSify(data, functionsOnly, givenFunctions) {
makeFuncLineActor('mathop', processMathop);
makeFuncLineActor('bitcast', function(item) {
- return processMathop({
+ var temp = {
op: 'bitcast', variant: null, type: item.type,
+ assignTo: item.assignTo,
param1: item.params[0]
- });
+ };
+ var ret = processMathop(temp);
+ if (!temp.assignTo) item.assignTo = null; // If the assign was stolen, propagate that
+ return ret;
});
function makeFunctionCall(ident, params, funcData, type) {
diff --git a/src/parseTools.js b/src/parseTools.js
index 5a92335e..d3cb7795 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1699,9 +1699,17 @@ function processMathop(item) {
var inType = item.param1.type;
var outType = item.type;
if (inType in Runtime.INT_TYPES && outType in Runtime.FLOAT_TYPES) {
- return makeInlineCalculation('tempDoubleI32[0]=VALUE[0],tempDoubleI32[1]=VALUE[1],tempDoubleF64[0]', ident1, 'tempI64');
+ if (legalizedI64s) {
+ return '(tempDoubleI32[0]=' + ident1 + '$0, tempDoubleI32[1]=' + ident1 + '$1, tempDoubleF64[0])';
+ } else {
+ return makeInlineCalculation('tempDoubleI32[0]=VALUE[0],tempDoubleI32[1]=VALUE[1],tempDoubleF64[0]', ident1, 'tempI64');
+ }
} else if (inType in Runtime.FLOAT_TYPES && outType in Runtime.INT_TYPES) {
- return '(tempDoubleF64[0]=' + ident1 + ',[tempDoubleI32[0],tempDoubleI32[1]])';
+ if (legalizedI64s) {
+ return 'tempDoubleF64[0]=' + ident1 + '; ' + finish(['tempDoubleI32[0]','tempDoubleI32[1]']);
+ } else {
+ return '(tempDoubleF64[0]=' + ident1 + ',[tempDoubleI32[0],tempDoubleI32[1]])';
+ }
} else {
throw 'Invalid I64_MODE1 bitcast: ' + dump(item) + ' : ' + item.param1.type;
}