Remove add/sub/mul instruction specializations for numbers
authorLars Knoll <lars.knoll@digia.com>
Thu, 6 Feb 2014 14:13:33 +0000 (15:13 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 7 Feb 2014 09:44:34 +0000 (10:44 +0100)
These instructions did hurt more than help, as they converted
ints to doubles. Since the regular add/sub/mul runtime methods
have fast paths for both ints and doubles, we're better off
using those instead.

Change-Id: I0b7a6f95818943bfc8a0669c1c56f7db4e7246e0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/compiler/qv4instr_moth_p.h
src/qml/compiler/qv4isel_moth.cpp
src/qml/jsruntime/qv4vme_moth.cpp

index 7d15b4b010c5044dd8100f87e196b5a8600dd2c7..e3e227796eff07bcc7b3a0fb829d215d0cf9a19b 100644 (file)
@@ -132,9 +132,6 @@ QT_BEGIN_NAMESPACE
     F(Mul, mul) \
     F(Sub, sub) \
     F(BinopContext, binopContext) \
-    F(AddNumberParams, addNumberParams) \
-    F(MulNumberParams, mulNumberParams) \
-    F(SubNumberParams, subNumberParams) \
     F(LoadThis, loadThis) \
     F(LoadQmlIdArray, loadQmlIdArray) \
     F(LoadQmlImportedScripts, loadQmlImportedScripts) \
@@ -699,24 +696,6 @@ union Instr
         Param rhs;
         Param result;
     };
-    struct instr_addNumberParams {
-        MOTH_INSTR_HEADER
-        Param lhs;
-        Param rhs;
-        Param result;
-    };
-    struct instr_mulNumberParams {
-        MOTH_INSTR_HEADER
-        Param lhs;
-        Param rhs;
-        Param result;
-    };
-    struct instr_subNumberParams {
-        MOTH_INSTR_HEADER
-        Param lhs;
-        Param rhs;
-        Param result;
-    };
     struct instr_loadThis {
         MOTH_INSTR_HEADER
         Param result;
@@ -826,9 +805,6 @@ union Instr
     instr_mul mul;
     instr_sub sub;
     instr_binopContext binopContext;
-    instr_addNumberParams addNumberParams;
-    instr_mulNumberParams mulNumberParams;
-    instr_subNumberParams subNumberParams;
     instr_loadThis loadThis;
     instr_loadQmlIdArray loadQmlIdArray;
     instr_loadQmlImportedScripts loadQmlImportedScripts;
index df102af73bcf68f3484c1aa46153b154243c18b3..09f4a88b30e1ce896bc6c53b2ca553d6e250be09 100644 (file)
@@ -697,37 +697,6 @@ void InstructionSelection::binop(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR:
 
 Param InstructionSelection::binopHelper(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target)
 {
-    if (isNumberType(leftSource) && isNumberType(rightSource)) {
-        switch (oper) {
-        case V4IR::OpAdd: {
-            Instruction::AddNumberParams instr;
-            instr.lhs = getParam(leftSource);
-            instr.rhs = getParam(rightSource);
-            instr.result = getResultParam(target);
-            addInstruction(instr);
-            return instr.result;
-        }
-        case V4IR::OpMul: {
-            Instruction::MulNumberParams instr;
-            instr.lhs = getParam(leftSource);
-            instr.rhs = getParam(rightSource);
-            instr.result = getResultParam(target);
-            addInstruction(instr);
-            return instr.result;
-        }
-        case V4IR::OpSub: {
-            Instruction::SubNumberParams instr;
-            instr.lhs = getParam(leftSource);
-            instr.rhs = getParam(rightSource);
-            instr.result = getResultParam(target);
-            addInstruction(instr);
-            return instr.result;
-        }
-        default:
-            break;
-        }
-    }
-
     if (oper == V4IR::OpAdd) {
         Instruction::Add add;
         add.lhs = getParam(leftSource);
index 3d7ce0efcf30343f0c24b10765108f3352581dd6..df8e3632fbd4f5155ea5975db3678c4d95cc1403 100644 (file)
@@ -662,24 +662,6 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code
         STOREVALUE(instr.result, instr.alu(context, VALUEPTR(instr.lhs), VALUEPTR(instr.rhs)));
     MOTH_END_INSTR(BinopContext)
 
-    MOTH_BEGIN_INSTR(AddNumberParams)
-        double lhs = VALUE(instr.lhs).asDouble();
-        double rhs = VALUE(instr.rhs).asDouble();
-        VALUEPTR(instr.result)->setDouble(lhs + rhs);
-    MOTH_END_INSTR(AddNumberParams)
-
-    MOTH_BEGIN_INSTR(MulNumberParams)
-        double lhs = VALUE(instr.lhs).asDouble();
-        double rhs = VALUE(instr.rhs).asDouble();
-        VALUEPTR(instr.result)->setDouble(lhs * rhs);
-    MOTH_END_INSTR(MulNumberParams)
-
-    MOTH_BEGIN_INSTR(SubNumberParams)
-        double lhs = VALUE(instr.lhs).asDouble();
-        double rhs = VALUE(instr.rhs).asDouble();
-        VALUEPTR(instr.result)->setDouble(lhs - rhs);
-    MOTH_END_INSTR(SubNumberParams)
-
     MOTH_BEGIN_INSTR(Ret)
         context->engine->stackPop(stackSize);
 //        TRACE(Ret, "returning value %s", result.toString(context)->toQString().toUtf8().constData());