aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-10-14 21:00:06 -0700
committeralon@honor <none@none>2010-10-14 21:00:06 -0700
commit64facbdbb9e406cbe7284a4c939263c684469083 (patch)
tree9ecbc0ba9c7b6d46996693c181d349d2c96cfe7c /src
parent971976f42a3fafc2e7829370e6a401aa5830237f (diff)
remove unnecessary boolean ==> int conversions; fix uncovered bug; 20% speedup
Diffstat (limited to 'src')
-rw-r--r--src/jsifier.js26
-rw-r--r--src/preamble.js4
2 files changed, 15 insertions, 15 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 51e37d8a..a4ea85d9 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -639,28 +639,28 @@ function JSify(data) {
case 'fptoui': case 'fptosi': return 'Math.floor(' + ident1 + ')';
case 'icmp': {
switch (variant) {
- case 'uge': case 'sge': return '0+(' + ident1 + ' >= ' + ident2 + ')';
- case 'ule': case 'sle': return '0+(' + ident1 + ' <= ' + ident2 + ')';
- case 'ugt': case 'sgt': return '0+(' + ident1 + ' > ' + ident2 + ')';
- case 'ult': case 'slt': return '0+(' + ident1 + ' < ' + ident2 + ')';
- case 'ne': case 'une': return '0+(' + ident1 + ' != ' + ident2 + ')';
- case 'eq': return '0+(' + ident1 + ' == ' + ident2 + ')';
+ case 'uge': case 'sge': return ident1 + ' >= ' + ident2;
+ case 'ule': case 'sle': return ident1 + ' <= ' + ident2;
+ case 'ugt': case 'sgt': return ident1 + ' > ' + ident2;
+ case 'ult': case 'slt': return ident1 + ' < ' + ident2;
+ case 'ne': case 'une': return ident1 + ' != ' + ident2;
+ case 'eq': return ident1 + ' == ' + ident2;
default: throw 'Unknown icmp variant: ' + variant
}
}
case 'fcmp': {
switch (variant) {
- case 'uge': case 'oge': return '0+(' + ident1 + ' >= ' + ident2 + ')';
- case 'ule': case 'ole': return '0+(' + ident1 + ' <= ' + ident2 + ')';
- case 'ugt': case 'ogt': return '0+(' + ident1 + ' > ' + ident2 + ')';
- case 'ult': case 'olt': return '0+(' + ident1 + ' < ' + ident2 + ')';
- case 'une': case 'one': return '0+(' + ident1 + ' != ' + ident2 + ')';
- case 'ueq': case 'oeq': return '0+(' + ident1 + ' == ' + ident2 + ')';
+ case 'uge': case 'oge': return ident1 + ' >= ' + ident2;
+ case 'ule': case 'ole': return ident1 + ' <= ' + ident2;
+ case 'ugt': case 'ogt': return ident1 + ' > ' + ident2;
+ case 'ult': case 'olt': return ident1 + ' < ' + ident2;
+ case 'une': case 'one': return ident1 + ' != ' + ident2;
+ case 'ueq': case 'oeq': return ident1 + ' == ' + ident2;
default: throw 'Unknown fcmp variant: ' + variant
}
}
case 'zext': case 'fpext': case 'trunc': case 'sext': case 'fptrunc': return ident1;
- case 'select': return '(' + ident1 + ' ? ' + ident2 + ' : ' + ident3 + ')';
+ case 'select': return ident1 + ' ? ' + ident2 + ' : ' + ident3;
case 'ptrtoint': {
if (type != 'i8*') print('// XXX Warning: Risky ptrtoint operation on line ' + lineNum);
return ident1;
diff --git a/src/preamble.js b/src/preamble.js
index 1af1a6e9..c930bb77 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -77,7 +77,7 @@ function Pointer_make(slab, pos, allocator) {
#if USE_TYPED_ARRAYS
// TODO: Check - also in non-typedarray case - for functions, and if so add |.__index__|
var curr = slab[pos + i];
- if (typeof curr === 'number') {
+ if (typeof curr === 'number' || typeof curr === 'boolean') {
IHEAP[ret + i] = curr; // TODO: optimize. Can easily detect floats, but 1.0 might look like an int...
FHEAP[ret + i] = curr;
} else {
@@ -177,7 +177,7 @@ function __formatString() {
next = HEAP[textIndex+1];
#endif
if (curr == '%'.charCodeAt(0) && ['d', 'u', 'f', '.'].indexOf(String.fromCharCode(next)) != -1) {
- var argText = String(arguments[argIndex]);
+ var argText = String(+arguments[argIndex]); // +: boolean=>int
// Handle very very simply formatting, namely only %.Xf
if (next == '.'.charCodeAt(0)) {
#if USE_TYPED_ARRAYS