diff options
author | Alon Zakai <azakai@mozilla.com> | 2011-02-27 20:36:30 -0800 |
---|---|---|
committer | Alon Zakai <azakai@mozilla.com> | 2011-02-27 20:36:30 -0800 |
commit | 9feb459b526a71962d9459094e4e426e031f5591 (patch) | |
tree | b247e1e1726103e04d2558adc0f21c16d06c652d | |
parent | 6b7f4ffa844bd3e1f2690af2501807e1da161034 (diff) |
comments
-rw-r--r-- | src/jsifier.js | 5 | ||||
-rw-r--r-- | tests/runner.py | 15 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 5f0f11c6..0c7e56be 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -851,7 +851,10 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) { case 'fdiv': return ident1 + ' / ' + ident2; case 'fmul': return ident1 + ' * ' + ident2; case 'uitofp': case 'sitofp': return ident1; - case 'fptoui': case 'fptosi': return 'Math.floor(' + ident1 + ')'; + case 'fptoui': case 'fptosi': return 'Math.floor(' + ident1 + ')'; // Note that this is different than C/C++ style rounding - they + // round -2.75 to -2 and +2.75 to +2, in other words, they + // floor the absolute value then restore the sign. JS doesn't + // have a fast operator to do that // TODO: We sometimes generate false instead of 0, etc., in the *cmps. It seemed slightly faster before, but worth rechecking // Note that with typed arrays, these become 0 when written. So that is a potential difference with non-typed array runs. diff --git a/tests/runner.py b/tests/runner.py index b2d914bd..67022f3f 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -407,11 +407,20 @@ if 'benchmark' not in sys.argv: float x = 1.234, y = 3.5; y *= 3; int z = x < y; - printf("*%d,%d,%f,%d,%f\\n", z, int(y), y, (int)x, x); + printf("*%d,%d,%.1f,%d,%.4f*\\n", z, int(y), y, (int)x, x); + + /* + // Rounding behavior + float fs[6] = { -2.75, -2.50, -2.25, 2.25, 2.50, 2.75 }; + double ds[6] = { -2.75, -2.50, -2.25, 2.25, 2.50, 2.75 }; + for (int i = 0; i < 6; i++) + printf("*int(%.2f)=%d,%d*\\n", fs[i], int(fs[i]), int(ds[i])); + */ + return 0; } ''' - self.do_test(src, '*1,10,10.5,1,1.2339') + self.do_test(src, '*1,10,10.5,1,1.2339*') def test_math(self): src = ''' @@ -1672,9 +1681,9 @@ if 'benchmark' not in sys.argv: diff_mean = diff_total/float(num) image_mean = 83 + #print js_mean, image_mean, lli_mean, diff_mean, num assert abs(js_mean - image_mean) < 1 assert abs(lli_mean - image_mean) < 1 - #print js_mean, image_mean, lli_mean, diff_mean, num assert diff_mean < 1.1 # 1+epsilon out of 255 values, means basically 1 - a rounding error return output |