Bug 934174 - SpiderMonkey: Micro-optimize AddOperation for int32 values r=luke
authorDan Gohman <sunfish@google.com>
Mon, 04 Nov 2013 09:41:17 -0800
changeset 153370 d0cad525a6b4f6e4739c17f2a195ef91d91982a1
parent 153369 6ccca624372a3bdf9dc06465c3016ce9985a28df
child 153371 10cf6a6309447b03229fa1aac272e6a0c93858e8
push id35790
push usersunfish@google.com
push dateMon, 04 Nov 2013 19:49:37 +0000
treeherdermozilla-inbound@d0cad525a6b4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs934174
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 934174 - SpiderMonkey: Micro-optimize AddOperation for int32 values r=luke
js/src/vm/Interpreter.cpp
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -1062,19 +1062,21 @@ ComputeImplicitThis(JSContext *cx, Handl
     return true;
 }
 
 static JS_ALWAYS_INLINE bool
 AddOperation(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Value *res)
 {
     if (lhs.isInt32() && rhs.isInt32()) {
         int32_t l = lhs.toInt32(), r = rhs.toInt32();
-        double d = double(l) + double(r);
-        res->setNumber(d);
-        return true;
+        int32_t t;
+        if (JS_LIKELY(SafeAdd(l, r, &t))) {
+            res->setInt32(t);
+            return true;
+        }
     }
 
     if (!ToPrimitive(cx, lhs))
         return false;
     if (!ToPrimitive(cx, rhs))
         return false;
 
     bool lIsString, rIsString;