Some smaller optimisations
authorLars Knoll <lars.knoll@digia.com>
Sun, 24 Feb 2013 21:31:58 +0000 (22:31 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Mon, 25 Feb 2013 07:05:35 +0000 (08:05 +0100)
Ideally these checks should get inlined in the generated
assembly.

Change-Id: I4f63f7235a7d3bbdf8413df9f7d674104ff95b07
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/v4/qmljs_runtime.h

index 54e3dbf..d0daed4 100644 (file)
@@ -600,12 +600,12 @@ inline void __qmljs_sne(ExecutionContext *, Value *result, const Value &left, co
 inline Bool __qmljs_cmp_gt(ExecutionContext *ctx, const Value &left, const Value &right)
 {
     TRACE2(left, right);
+    if (Value::integerCompatible(left, right))
+        return left.integerValue() > right.integerValue();
 
     Value l = __qmljs_to_primitive(left, ctx, NUMBER_HINT);
     Value r = __qmljs_to_primitive(right, ctx, NUMBER_HINT);
 
-    if (Value::integerCompatible(l, r))
-        return l.integerValue() > r.integerValue();
     if (Value::bothDouble(l, r)) {
         return l.doubleValue() > r.doubleValue();
     } else if (l.isString() && r.isString()) {
@@ -620,12 +620,12 @@ inline Bool __qmljs_cmp_gt(ExecutionContext *ctx, const Value &left, const Value
 inline Bool __qmljs_cmp_lt(ExecutionContext *ctx, const Value &left, const Value &right)
 {
     TRACE2(left, right);
+    if (Value::integerCompatible(left, right))
+        return left.integerValue() < right.integerValue();
 
     Value l = __qmljs_to_primitive(left, ctx, NUMBER_HINT);
     Value r = __qmljs_to_primitive(right, ctx, NUMBER_HINT);
 
-    if (Value::integerCompatible(l, r))
-        return l.integerValue() < r.integerValue();
     if (Value::bothDouble(l, r)) {
         return l.doubleValue() < r.doubleValue();
     } else if (l.isString() && r.isString()) {
@@ -640,12 +640,12 @@ inline Bool __qmljs_cmp_lt(ExecutionContext *ctx, const Value &left, const Value
 inline Bool __qmljs_cmp_ge(ExecutionContext *ctx, const Value &left, const Value &right)
 {
     TRACE2(left, right);
+    if (Value::integerCompatible(left, right))
+        return left.integerValue() >= right.integerValue();
 
     Value l = __qmljs_to_primitive(left, ctx, NUMBER_HINT);
     Value r = __qmljs_to_primitive(right, ctx, NUMBER_HINT);
 
-    if (Value::integerCompatible(l, r))
-        return l.integerValue() >= r.integerValue();
     if (Value::bothDouble(l, r)) {
         return l.doubleValue() >= r.doubleValue();
     } else if (l.isString() && r.isString()) {
@@ -660,12 +660,12 @@ inline Bool __qmljs_cmp_ge(ExecutionContext *ctx, const Value &left, const Value
 inline Bool __qmljs_cmp_le(ExecutionContext *ctx, const Value &left, const Value &right)
 {
     TRACE2(left, right);
+    if (Value::integerCompatible(left, right))
+        return left.integerValue() <= right.integerValue();
 
     Value l = __qmljs_to_primitive(left, ctx, NUMBER_HINT);
     Value r = __qmljs_to_primitive(right, ctx, NUMBER_HINT);
 
-    if (Value::integerCompatible(l, r))
-        return l.integerValue() <= r.integerValue();
     if (Value::bothDouble(l, r)) {
         return l.doubleValue() <= r.doubleValue();
     } else if (l.isString() && r.isString()) {