Move the Param struct out of the Instr union.
authorErik Verbruggen <erik.verbruggen@me.com>
Fri, 9 Aug 2013 13:57:28 +0000 (15:57 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 14 Aug 2013 08:50:44 +0000 (10:50 +0200)
The parameter struct was accidentally put in the instruction union. As
it is not an instruction, it should not be part of that union.

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

index 69c7c36..8ddecd0 100644 (file)
@@ -129,79 +129,79 @@ QT_BEGIN_NAMESPACE
 namespace QQmlJS {
 namespace Moth {
 
-union Instr
-{
-    struct Param {
-        enum {
-            ValueType    = 0,
-            ArgumentType = 1,
-            LocalType    = 2,
-            TempType     = 3,
-            ScopedLocalType  = 4
-        };
-        QV4::Value value;
-        unsigned type  : 3;
-        unsigned scope : 29;
-        unsigned index;
+struct Param {
+    enum {
+        ValueType    = 0,
+        ArgumentType = 1,
+        LocalType    = 2,
+        TempType     = 3,
+        ScopedLocalType  = 4
+    };
+    QV4::Value value;
+    unsigned type  : 3;
+    unsigned scope : 29;
+    unsigned index;
 
-        bool isValue() const { return type == ValueType; }
-        bool isArgument() const { return type == ArgumentType; }
-        bool isLocal() const { return type == LocalType; }
-        bool isTemp() const { return type == TempType; }
-        bool isScopedLocal() const { return type == ScopedLocalType; }
+    bool isValue() const { return type == ValueType; }
+    bool isArgument() const { return type == ArgumentType; }
+    bool isLocal() const { return type == LocalType; }
+    bool isTemp() const { return type == TempType; }
+    bool isScopedLocal() const { return type == ScopedLocalType; }
 
-        static Param createValue(const QV4::Value &v)
-        {
-            Param p;
-            p.type = ValueType;
-            p.scope = 0;
-            p.value = v;
-            return p;
-        }
+    static Param createValue(const QV4::Value &v)
+    {
+        Param p;
+        p.type = ValueType;
+        p.scope = 0;
+        p.value = v;
+        return p;
+    }
 
-        static Param createArgument(unsigned idx, uint scope)
-        {
-            Param p;
-            p.type = ArgumentType;
-            p.scope = scope;
-            p.index = idx;
-            return p;
-        }
+    static Param createArgument(unsigned idx, uint scope)
+    {
+        Param p;
+        p.type = ArgumentType;
+        p.scope = scope;
+        p.index = idx;
+        return p;
+    }
 
-        static Param createLocal(unsigned idx)
-        {
-            Param p;
-            p.type = LocalType;
-            p.scope = 0;
-            p.index = idx;
-            return p;
-        }
+    static Param createLocal(unsigned idx)
+    {
+        Param p;
+        p.type = LocalType;
+        p.scope = 0;
+        p.index = idx;
+        return p;
+    }
 
-        static Param createTemp(unsigned idx)
-        {
-            Param p;
-            p.type = TempType;
-            p.scope = 0;
-            p.index = idx;
-            return p;
-        }
+    static Param createTemp(unsigned idx)
+    {
+        Param p;
+        p.type = TempType;
+        p.scope = 0;
+        p.index = idx;
+        return p;
+    }
 
-        static Param createScopedLocal(unsigned idx, uint scope)
-        {
-            Param p;
-            p.type = ScopedLocalType;
-            p.scope = scope;
-            p.index = idx;
-            return p;
-        }
+    static Param createScopedLocal(unsigned idx, uint scope)
+    {
+        Param p;
+        p.type = ScopedLocalType;
+        p.scope = scope;
+        p.index = idx;
+        return p;
+    }
 
-        inline bool operator==(const Param &other) const
-        { return type == other.type && scope == other.scope && index == other.index; }
+    inline bool operator==(const Param &other) const
+    { return type == other.type && scope == other.scope && index == other.index; }
 
-        inline bool operator!=(const Param &other) const
-        { return !(*this == other); }
-    };
+    inline bool operator!=(const Param &other) const
+    { return !(*this == other); }
+};
 
+union Instr
+{
     enum Type {
         FOR_EACH_MOTH_INSTR(MOTH_INSTR_ENUM)
     };
index 8b86055..6edb2e4 100644 (file)
@@ -387,7 +387,7 @@ void InstructionSelection::loadConst(V4IR::Const *sourceConst, V4IR::Temp *targe
 void InstructionSelection::loadString(const QString &str, V4IR::Temp *targetTemp)
 {
     Instruction::LoadValue load;
-    load.value = Instr::Param::createValue(QV4::Value::fromString(identifier(str)));
+    load.value = Param::createValue(QV4::Value::fromString(identifier(str)));
     load.result = getResultParam(targetTemp);
     addInstruction(load);
 }
@@ -400,7 +400,7 @@ void InstructionSelection::loadRegexp(V4IR::RegExp *sourceRegexp, V4IR::Temp *ta
     _vmFunction->generatedValues.append(v);
 
     Instruction::LoadValue load;
-    load.value = Instr::Param::createValue(v);
+    load.value = Param::createValue(v);
     load.result = getResultParam(targetTemp);
     addInstruction(load);
 }
@@ -509,7 +509,7 @@ void InstructionSelection::binop(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR:
     binopHelper(oper, leftSource, rightSource, target);
 }
 
-Instr::Param InstructionSelection::binopHelper(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target)
+Param InstructionSelection::binopHelper(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target)
 {
 #ifdef USE_TYPE_INFO
     if (leftSource->type & V4IR::NumberType && rightSource->type & V4IR::NumberType) {
@@ -555,6 +555,7 @@ Instr::Param InstructionSelection::binopHelper(V4IR::AluOp oper, V4IR::Expr *lef
         binop.lhs = getParam(leftSource);
         binop.rhs = getParam(rightSource);
         binop.result = getResultParam(target);
+        Q_ASSERT(binop.alu);
         addInstruction(binop);
         return binop.result;
     } else {
@@ -563,6 +564,7 @@ Instr::Param InstructionSelection::binopHelper(V4IR::AluOp oper, V4IR::Expr *lef
         binop.lhs = getParam(leftSource);
         binop.rhs = getParam(rightSource);
         binop.result = getResultParam(target);
+        Q_ASSERT(binop.alu);
         addInstruction(binop);
         return binop.result;
     }
@@ -667,7 +669,7 @@ void InstructionSelection::prepareCallArgs(V4IR::ExprList *e, quint32 &argc, qui
         while (e) {
             Instruction::MoveTemp move;
             move.source = getParam(e->expr);
-            move.result = Instr::Param::createTemp(argLocation);
+            move.result = Param::createTemp(argLocation);
             addInstruction(move);
             ++argLocation;
             ++argc;
@@ -693,7 +695,7 @@ void InstructionSelection::visitJump(V4IR::Jump *s)
 
 void InstructionSelection::visitCJump(V4IR::CJump *s)
 {
-    Instr::Param condition;
+    Param condition;
     if (V4IR::Temp *t = s->cond->asTemp()) {
         condition = getResultParam(t);
     } else if (V4IR::Binop *b = s->cond->asBinop()) {
@@ -811,7 +813,7 @@ void InstructionSelection::callBuiltinDeleteName(const QString &name, V4IR::Temp
 void InstructionSelection::callBuiltinDeleteValue(V4IR::Temp *result)
 {
     Instruction::LoadValue load;
-    load.value = Instr::Param::createValue(QV4::Value::fromBoolean(false));
+    load.value = Param::createValue(QV4::Value::fromBoolean(false));
     load.result = getResultParam(result);
     addInstruction(load);
 }
@@ -977,7 +979,7 @@ void InstructionSelection::callBuiltinDefineObjectLiteral(V4IR::Temp *result, V4
 
         Instruction::MoveTemp move;
         move.source = getParam(it->expr);
-        move.result = Instr::Param::createTemp(argLocation);
+        move.result = Param::createTemp(argLocation);
         addInstruction(move);
         ++argLocation;
 
@@ -986,7 +988,7 @@ void InstructionSelection::callBuiltinDefineObjectLiteral(V4IR::Temp *result, V4
 
             Instruction::MoveTemp move;
             move.source = getParam(it->expr);
-            move.result = Instr::Param::createTemp(argLocation);
+            move.result = Param::createTemp(argLocation);
             addInstruction(move);
             ++argLocation;
         }
@@ -1063,8 +1065,8 @@ QV4::String *InstructionSelection::identifier(const QString &s)
     return str;
 }
 
-Instr::Param InstructionSelection::getParam(V4IR::Expr *e) {
-    typedef Instr::Param Param;
+Param InstructionSelection::getParam(V4IR::Expr *e) {
+    typedef Param Param;
     assert(e);
 
     if (V4IR::Const *c = e->asConst()) {
index 57fc964..f5fffe7 100644 (file)
@@ -126,7 +126,7 @@ protected:
     virtual void inplaceMemberOp(V4IR::AluOp oper, V4IR::Temp *source, V4IR::Temp *targetBase, const QString &targetName);
 
 private:
-    Instr::Param binopHelper(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target);
+    Param binopHelper(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target);
 
     struct Instruction {
 #define MOTH_INSTR_DATA_TYPEDEF(I, FMT) typedef InstrData<Instr::I> I;
@@ -136,14 +136,14 @@ private:
         Instruction();
     };
 
-    Instr::Param getParam(V4IR::Expr *e);
+    Param getParam(V4IR::Expr *e);
 
-    Instr::Param getResultParam(V4IR::Temp *result)
+    Param getResultParam(V4IR::Temp *result)
     {
         if (result)
             return getParam(result);
         else
-            return Instr::Param::createTemp(scratchTempIndex());
+            return Param::createTemp(scratchTempIndex());
     }
 
     void simpleMove(V4IR::Move *);
index a06ce41..32313c3 100644 (file)
@@ -136,7 +136,7 @@ static VMStats vmStats;
 
 static inline QV4::Value *getValueRef(QV4::ExecutionContext *context,
                                      QV4::Value* stack,
-                                     const Instr::Param &param
+                                     const Param &param
 #if !defined(QT_NO_DEBUG)
                                      , unsigned stackSize
 #endif