aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/analyzer.js18
-rw-r--r--src/library.js46
-rw-r--r--src/parseTools.js11
-rw-r--r--src/preamble.js1
4 files changed, 32 insertions, 44 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index 751c0970..6f9bf44a 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -294,7 +294,7 @@ function analyzer(data, sidePass) {
i += removeAndAdd(label.lines, i, toAdd);
continue;
}
- // call, return: Return value is in an unlegalized array literal. Not fully optimal.
+ // call, return: Return the first 32 bits, the rest are in temp
case 'call': {
bits = getBits(value.type);
var elements = getLegalVars(item.assignTo, bits);
@@ -303,15 +303,17 @@ function analyzer(data, sidePass) {
legalizeFunctionParameters(value.params);
if (value.assignTo) {
// legalize return value
- var j = 0;
- toAdd = toAdd.concat(elements.map(function(element) {
- return {
+ value.assignTo = elements[0].ident;
+ for (var j = 1; j < elements.length; j++) {
+ var element = elements[j];
+ toAdd.push({
intertype: 'value',
assignTo: element.ident,
- type: 'i' + bits,
- ident: value.assignTo + '[' + (j++) + ']'
- };
- }));
+ type: element.bits,
+ ident: 'tempRet' + (j++)
+ });
+ assert(j<10); // TODO: dynamically create more than 10 tempRet-s
+ }
}
i += removeAndAdd(label.lines, i, toAdd);
continue;
diff --git a/src/library.js b/src/library.js
index a849cba7..d9321975 100644
--- a/src/library.js
+++ b/src/library.js
@@ -4938,12 +4938,12 @@ LibraryManager.library = {
// return the type of the catch block which should be called.
for (var i = 0; i < typeArray.length; i++) {
if (___cxa_does_inherit(typeArray[i], throwntype, thrown))
- return { f0:thrown, f1:typeArray[i] };
+ {{{ makeStructuralReturn(['thrown', 'typeArray[i]']) }}};
}
// Shouldn't happen unless we have bogus data in typeArray
// or encounter a type for which emscripten doesn't have suitable
// typeinfo defined. Best-efforts match just in case.
- return { f0:thrown, f1 :throwntype };
+ {{{ makeStructuralReturn(['thrown', 'throwntype']) }}};
},
// Recursively walks up the base types of 'possibilityType'
@@ -5009,73 +5009,51 @@ LibraryManager.library = {
llvm_uadd_with_overflow_i8: function(x, y) {
x = x & 0xff;
y = y & 0xff;
- return {
- f0: (x+y) & 0xff,
- f1: x+y > 255
- };
+ {{{ makeStructuralReturn(['(x+y) & 0xff', 'x+y > 255']) }}};
},
llvm_umul_with_overflow_i8: function(x, y) {
x = x & 0xff;
y = y & 0xff;
- return {
- f0: (x*y) & 0xff,
- f1: x*y > 255
- };
+ {{{ makeStructuralReturn(['(x*y) & 0xff', 'x*y > 255']) }}};
},
llvm_uadd_with_overflow_i16: function(x, y) {
x = x & 0xffff;
y = y & 0xffff;
- return {
- f0: (x+y) & 0xffff,
- f1: x+y > 65535
- };
+ {{{ makeStructuralReturn(['(x+y) & 0xffff', 'x+y > 65535']) }}};
},
llvm_umul_with_overflow_i16: function(x, y) {
x = x & 0xffff;
y = y & 0xffff;
- return {
- f0: (x*y) & 0xffff,
- f1: x*y > 65535
- };
+ {{{ makeStructuralReturn(['(x*y) & 0xffff', 'x*y > 65535']) }}};
},
llvm_uadd_with_overflow_i32: function(x, y) {
x = x>>>0;
y = y>>>0;
- return {
- f0: (x+y)>>>0,
- f1: x+y > 4294967295
- };
+ {{{ makeStructuralReturn(['(x+y)>>>0', 'x+y > 4294967295']) }}};
},
llvm_umul_with_overflow_i32: function(x, y) {
x = x>>>0;
y = y>>>0;
- return {
- f0: (x*y)>>>0,
- f1: x*y > 4294967295
- };
+ {{{ makeStructuralReturn(['(x*y)>>>0', 'x*y > 4294967295']) }}};
},
llvm_uadd_with_overflow_i64__deps: [function() { Types.preciseI64MathUsed = 1 }],
llvm_uadd_with_overflow_i64: function(xl, xh, yl, yh) {
i64Math.add(xl, xh, yl, yh);
- return {
- f0: [HEAP32[tempDoublePtr>>2], HEAP32[tempDoublePtr+4>>2]],
- f1: 0 // XXX Need to hack support for this in long.js
- };
+ {{{ makeStructuralReturn(['[HEAP32[tempDoublePtr>>2], HEAP32[tempDoublePtr+4>>2]]', '0']) }}};
+ // XXX Need to hack support for second param in long.js
},
llvm_umul_with_overflow_i64__deps: [function() { Types.preciseI64MathUsed = 1 }],
llvm_umul_with_overflow_i64: function(xl, xh, yl, yh) {
i64Math.multiply(xl, xh, yl, yh);
- return {
- f0: [HEAP32[tempDoublePtr>>2], HEAP32[tempDoublePtr+4>>2]],
- f1: 0 // XXX Need to hack support for this in long.js
- };
+ {{{ makeStructuralReturn(['[HEAP32[tempDoublePtr>>2], HEAP32[tempDoublePtr+4>>2]]', '0']) }}};
+ // XXX Need to hack support for second param in long.js
},
llvm_stacksave: function() {
diff --git a/src/parseTools.js b/src/parseTools.js
index a7a45f09..c1428353 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1539,8 +1539,15 @@ function handleOverflow(text, bits) {
}
}
-function makeLLVMStruct(values) { // TODO: Use this everywhere
- return '{ ' + values.map(function(value, i) { return 'f' + i + ': ' + value }).join(', ') + ' }'
+function makeLLVMStruct(values) {
+ return 'DEPRECATED' + (new Error().stack) + 'XXX';
+}
+
+function makeStructuralReturn(values) {
+ var i = 1;
+ return 'return (' + values.slice(1).map(function(value) {
+ return 'tempRet' + (i++) + ' = ' + value;
+ }).concat([values[0]]).join(',') + ')';
}
// From parseLLVMSegment
diff --git a/src/preamble.js b/src/preamble.js
index 816eae04..e7cceb36 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -285,6 +285,7 @@ var undef = 0;
var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD;
#if USE_TYPED_ARRAYS == 2
var tempI64, tempI64b;
+var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
#endif
function abort(text) {