diff options
author | Erik Verbruggen <erik.verbruggen@me.com> | 2013-09-09 14:00:06 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-20 12:42:25 +0200 |
commit | d33fe17cd1fddd8dee0a26dc46f5062c34f11216 (patch) | |
tree | c07d1f356a717cd6e0e7fba630751a6102eda8ce | |
parent | 3ef88c539ff63d9cb33af71f44653b328f36d0db (diff) |
V4 IR: rename ObjectType to VarType
The ObjectType was a misnomer: it was used to indicate that the
expression could have multiple types, or that the type could not be
inferred statically.
Change-Id: Ic48a0cd1dd7ae7bfafd361e0c9792ab161417039
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r-- | src/qml/compiler/qv4isel_masm.cpp | 6 | ||||
-rw-r--r-- | src/qml/compiler/qv4jsir.cpp | 2 | ||||
-rw-r--r-- | src/qml/compiler/qv4jsir_p.h | 2 | ||||
-rw-r--r-- | src/qml/compiler/qv4regalloc.cpp | 2 | ||||
-rw-r--r-- | src/qml/compiler/qv4ssa.cpp | 42 |
5 files changed, 29 insertions, 25 deletions
diff --git a/src/qml/compiler/qv4isel_masm.cpp b/src/qml/compiler/qv4isel_masm.cpp index f041c7916c..c0245dd7fb 100644 --- a/src/qml/compiler/qv4isel_masm.cpp +++ b/src/qml/compiler/qv4isel_masm.cpp @@ -1500,7 +1500,7 @@ void InstructionSelection::convertTypeToDouble(V4IR::Temp *source, V4IR::Temp *t break; case V4IR::UndefinedType: case V4IR::StringType: - case V4IR::ObjectType: { + case V4IR::VarType: { // load the tag: Assembler::Pointer tagAddr = _as->loadTempAddress(Assembler::ScratchRegister, source); tagAddr.offset += 4; @@ -1585,7 +1585,7 @@ void InstructionSelection::convertTypeToBool(V4IR::Temp *source, V4IR::Temp *tar _as->storeBool(false, target); break; case V4IR::StringType: - case V4IR::ObjectType: + case V4IR::VarType: default: generateFunctionCall(Assembler::ReturnValueRegister, __qmljs_to_boolean, Assembler::PointerToValue(source)); @@ -1597,7 +1597,7 @@ void InstructionSelection::convertTypeToBool(V4IR::Temp *source, V4IR::Temp *tar void InstructionSelection::convertTypeToSInt32(V4IR::Temp *source, V4IR::Temp *target) { switch (source->type) { - case V4IR::ObjectType: { + case V4IR::VarType: { // load the tag: Assembler::Pointer tagAddr = _as->loadTempAddress(Assembler::ScratchRegister, source); tagAddr.offset += 4; diff --git a/src/qml/compiler/qv4jsir.cpp b/src/qml/compiler/qv4jsir.cpp index 74f31bd83e..224b55a1a4 100644 --- a/src/qml/compiler/qv4jsir.cpp +++ b/src/qml/compiler/qv4jsir.cpp @@ -70,7 +70,7 @@ QString typeName(Type t) case DoubleType: return QStringLiteral("double"); case NumberType: return QStringLiteral("number"); case StringType: return QStringLiteral("string"); - case ObjectType: return QStringLiteral("object"); + case VarType: return QStringLiteral("var"); default: return QStringLiteral("multiple"); } } diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h index 4ccf5de139..d849b50ea2 100644 --- a/src/qml/compiler/qv4jsir_p.h +++ b/src/qml/compiler/qv4jsir_p.h @@ -181,7 +181,7 @@ enum Type { NumberType = SInt32Type | UInt32Type | DoubleType, StringType = 1 << 7, - ObjectType = 1 << 8 + VarType = 1 << 8 }; inline bool strictlyEqualTypes(Type t1, Type t2) diff --git a/src/qml/compiler/qv4regalloc.cpp b/src/qml/compiler/qv4regalloc.cpp index a6364a25d4..8a879aa40c 100644 --- a/src/qml/compiler/qv4regalloc.cpp +++ b/src/qml/compiler/qv4regalloc.cpp @@ -542,7 +542,7 @@ private: Q_ASSERT(!_defs.contains(*t)); bool canHaveReg = true; switch (t->type) { - case ObjectType: + case VarType: case StringType: case UndefinedType: case NullType: diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index 5f62adb1b1..f44203817b 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -1315,7 +1315,7 @@ private: qout<<"Setting type for "<< (t->scope?"scoped temp ":"temp ") <<t->index<< " to "<<typeName(Type(ty)) << " (" << ty << ")" << endl; #endif if (isAlwaysAnObject(t)) - ty = ObjectType; + ty = VarType; if (_tempTypes[*t] != ty) { _tempTypes[*t] = ty; @@ -1347,16 +1347,16 @@ protected: _ty = TypingResult(e->type); } virtual void visitString(String *) { _ty = TypingResult(StringType); } - virtual void visitRegExp(RegExp *) { _ty = TypingResult(ObjectType); } - virtual void visitName(Name *) { _ty = TypingResult(ObjectType); } + virtual void visitRegExp(RegExp *) { _ty = TypingResult(VarType); } + virtual void visitName(Name *) { _ty = TypingResult(VarType); } virtual void visitTemp(Temp *e) { if (isAlwaysAnObject(e)) - _ty = TypingResult(ObjectType); + _ty = TypingResult(VarType); else _ty = TypingResult(_tempTypes.value(*e, UnknownType)); setType(e, _ty.type); } - virtual void visitClosure(Closure *) { _ty = TypingResult(ObjectType); } // TODO: VERIFY THIS! + virtual void visitClosure(Closure *) { _ty = TypingResult(VarType); } virtual void visitConvert(Convert *e) { _ty = TypingResult(e->type); } @@ -1385,8 +1385,8 @@ protected: switch (e->op) { case OpAdd: - if (leftTy.type & ObjectType || rightTy.type & ObjectType) - _ty.type = ObjectType; + if (leftTy.type & VarType || rightTy.type & VarType) + _ty.type = VarType; else if (leftTy.type & StringType || rightTy.type & StringType) _ty.type = StringType; else if (leftTy.type != UnknownType && rightTy.type != UnknownType) @@ -1440,23 +1440,23 @@ protected: _ty = run(e->base); for (ExprList *it = e->args; it; it = it->next) _ty.fullyTyped &= run(it->expr).fullyTyped; - _ty.type = ObjectType; + _ty.type = VarType; } virtual void visitNew(New *e) { _ty = run(e->base); for (ExprList *it = e->args; it; it = it->next) _ty.fullyTyped &= run(it->expr).fullyTyped; - _ty.type = ObjectType; + _ty.type = VarType; } virtual void visitSubscript(Subscript *e) { _ty.fullyTyped = run(e->base).fullyTyped && run(e->index).fullyTyped; - _ty.type = ObjectType; + _ty.type = VarType; } virtual void visitMember(Member *e) { // TODO: for QML, try to do a static lookup _ty = run(e->base); - _ty.type = ObjectType; + _ty.type = VarType; } virtual void visitExp(Exp *s) { _ty = run(s->expr); } @@ -1476,7 +1476,7 @@ protected: virtual void visitJump(Jump *) { _ty = TypingResult(MissingType); } virtual void visitCJump(CJump *s) { _ty = run(s->cond); } virtual void visitRet(Ret *s) { _ty = run(s->expr); } - virtual void visitTry(Try *s) { setType(s->exceptionVar, ObjectType); _ty = TypingResult(MissingType); } + virtual void visitTry(Try *s) { setType(s->exceptionVar, VarType); _ty = TypingResult(MissingType); } virtual void visitPhi(Phi *s) { _ty = run(s->d->incoming[0]); for (int i = 1, ei = s->d->incoming.size(); i != ei; ++i) { @@ -1493,7 +1493,7 @@ protected: case UInt32Type: case DoubleType: case StringType: - case ObjectType: + case VarType: // The type is not a combination of two or more types, so we're done. break; @@ -1505,7 +1505,7 @@ protected: _ty.type = DoubleType; else // There just is no single type that can hold this combination, so: - _ty.type = ObjectType; + _ty.type = VarType; } setType(s->targetTemp, _ty.type); @@ -2173,10 +2173,10 @@ bool tryOptimizingComparison(Expr *&expr) if (!b) return false; Const *leftConst = b->left->asConst(); - if (!leftConst || leftConst->type == StringType || leftConst->type == ObjectType) + if (!leftConst || leftConst->type == StringType || leftConst->type == VarType) return false; Const *rightConst = b->right->asConst(); - if (!rightConst || rightConst->type == StringType || rightConst->type == ObjectType) + if (!rightConst || rightConst->type == StringType || rightConst->type == VarType) return false; QV4::Value l = convertToValue(leftConst); @@ -2310,8 +2310,8 @@ void optimizeSSA(Function *function, DefUsesCalculator &defUses) continue; } - // Constant unary expression evaluation: if (Unop *u = m->source->asUnop()) { + // Constant unary expression evaluation: if (Const *c = u->expr->asConst()) { if (c->type & NumberType || c->type == BoolType) { // TODO: implement unop propagation for other constant types @@ -2369,6 +2369,8 @@ void optimizeSSA(Function *function, DefUsesCalculator &defUses) } } } + // TODO: if the result of a unary not operation is only used in a cjump, + // then inline it. continue; } @@ -2378,10 +2380,10 @@ void optimizeSSA(Function *function, DefUsesCalculator &defUses) // TODO: If the result of the move is only used in one single cjump, then // inline the binop into the cjump. Const *leftConst = b->left->asConst(); - if (!leftConst || leftConst->type == StringType || leftConst->type == ObjectType) + if (!leftConst || leftConst->type == StringType || leftConst->type == VarType) continue; Const *rightConst = b->right->asConst(); - if (!rightConst || rightConst->type == StringType || rightConst->type == ObjectType) + if (!rightConst || rightConst->type == StringType || rightConst->type == VarType) continue; QV4::Value lc = convertToValue(leftConst); @@ -2451,6 +2453,8 @@ void optimizeSSA(Function *function, DefUsesCalculator &defUses) continue; } // TODO: Constant unary expression evaluation + // TODO: if the expression is an unary not operation, lift the expression, and switch + // the then/else blocks. } } |