aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-09-29 16:50:14 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-10-02 17:31:36 -0700
commitd229313b7dc08e40a160ace49a38acd5be5503b3 (patch)
treeceac95a060190b1c031dcfb6faec22d7f3945f8e /src
parent42dde1ea07e2f8cb2c1dec48f7bee4318b39dc2f (diff)
if not running js opts, ensure a . in asmEnsureFloat immediately
Diffstat (limited to 'src')
-rw-r--r--src/parseTools.js17
-rw-r--r--src/settings.js2
2 files changed, 17 insertions, 2 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index 863d6bba..7e7a8307 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1136,7 +1136,16 @@ function asmEnsureFloat(value, type) { // ensures that a float type has either 5
if (!ASM_JS) return value;
// coerce if missing a '.', or if smaller than 1, so could be 1e-5 which has no .
if (type in Runtime.FLOAT_TYPES && isNumber(value) && (value.toString().indexOf('.') < 0 || Math.abs(value) < 1)) {
- return '(+(' + value + '))';
+ if (RUNNING_JS_OPTS) {
+ return '(+' + value + ')'; // JS optimizer will run, we must do +x, and it will be corrected later
+ } else {
+ // ensure a .
+ value = value.toString();
+ if (value.indexOf('.') >= 0) return value;
+ var e = value.indexOf('e');
+ if (e < 0) return value + '.0';
+ return value.substr(0, e) + '.0' + value.substr(e);
+ }
} else {
return value;
}
@@ -1144,7 +1153,11 @@ function asmEnsureFloat(value, type) { // ensures that a float type has either 5
function asmInitializer(type, impl) {
if (type in Runtime.FLOAT_TYPES) {
- return '+0';
+ if (RUNNING_JS_OPTS) {
+ return '+0';
+ } else {
+ return '.0';
+ }
} else {
return '0';
}
diff --git a/src/settings.js b/src/settings.js
index 5e5d50f6..6894b535 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -434,6 +434,8 @@ var JS_CHUNK_SIZE = 10240; // Used as a maximum size before breaking up expressi
var EXPORT_NAME = 'Module'; // Global variable to export the module as for environments without a standardized module
// loading system (e.g. the browser and SM shell).
+var RUNNING_JS_OPTS = 0; // whether js opts will be run, after the main compiler
+
var COMPILER_ASSERTIONS = 0; // costly (slow) compile-time assertions
var COMPILER_FASTPATHS = 1; // use fast-paths to speed up compilation