aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/compiler')
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp7
-rw-r--r--src/qml/compiler/qv4compileddata_p.h18
-rw-r--r--src/qml/compiler/qv4compiler.cpp7
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h4
-rw-r--r--src/qml/compiler/qv4isel_moth.cpp44
-rw-r--r--src/qml/compiler/qv4jsir_p.h30
-rw-r--r--src/qml/compiler/qv4ssa.cpp29
7 files changed, 87 insertions, 52 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index 1960f1d65b..065e91109b 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -1790,7 +1790,12 @@ void JSCodeGen::beginFunctionBodyHook()
#ifndef V4_BOOTSTRAP
QV4::IR::Temp *temp = _block->TEMP(_qmlContextTemp);
- move(temp, _block->NAME(QV4::IR::Name::builtin_qml_context, 0, 0));
+ temp->type = QV4::IR::QObjectType;
+ temp->memberResolver = _function->New<QV4::IR::MemberExpressionResolver>();
+ initMetaObjectResolver(temp->memberResolver, _scopeObject);
+ auto name = _block->NAME(QV4::IR::Name::builtin_qml_context, 0, 0);
+ name->type = temp->type;
+ move(temp, name);
move(_block->TEMP(_importedScriptsTemp), _block->NAME(QV4::IR::Name::builtin_qml_imported_scripts_object, 0, 0));
#endif
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index 8c617875e0..6f0b5f9b32 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -91,8 +91,8 @@ struct Unit;
struct Location
{
- qint32 line;
- qint32 column;
+ qint32 line : 20;
+ qint32 column : 12;
Location(): line(-1), column(-1) {}
@@ -109,8 +109,8 @@ struct RegExp
RegExp_IgnoreCase = 0x02,
RegExp_Multiline = 0x04
};
- quint32 flags;
- quint32 stringIndex;
+ quint32 flags : 4;
+ quint32 stringIndex : 28;
static int calculateSize() { return sizeof(RegExp); }
};
@@ -125,16 +125,16 @@ struct Lookup
Type_IndexedSetter = 4
};
- quint32 type_and_flags;
- quint32 nameIndex;
+ quint32 type_and_flags : 4;
+ quint32 nameIndex : 28;
static int calculateSize() { return sizeof(Lookup); }
};
struct JSClassMember
{
- uint nameOffset : 31;
- uint isAccessor : 1;
+ quint32 nameOffset : 31;
+ quint32 isAccessor : 1;
};
struct JSClass
@@ -147,7 +147,6 @@ struct JSClass
struct String
{
- quint32 flags; // isArrayIndex
qint32 size;
// uint16 strdata[]
@@ -326,7 +325,6 @@ struct Parameter
quint32 nameIndex;
quint32 type;
quint32 customTypeNameIndex;
- quint32 reserved;
Location location;
};
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp
index 5de29d38fd..aacf0e9928 100644
--- a/src/qml/compiler/qv4compiler.cpp
+++ b/src/qml/compiler/qv4compiler.cpp
@@ -82,7 +82,6 @@ void QV4::Compiler::StringTableGenerator::serialize(CompiledData::Unit *unit)
const QString &qstr = strings.at(i);
QV4::CompiledData::String *s = (QV4::CompiledData::String*)(stringData);
- s->flags = 0; // ###
s->size = qstr.length();
memcpy(s + 1, qstr.constData(), qstr.length()*sizeof(ushort));
@@ -385,15 +384,13 @@ int QV4::Compiler::JSUnitGenerator::writeFunction(char *f, int index, QV4::IR::F
*writtenDeps++ = id;
writtenDeps = (quint32 *)(f + function->dependingContextPropertiesOffset);
- for (QV4::IR::PropertyDependencyMap::ConstIterator property = irFunction->contextObjectPropertyDependencies.constBegin(), end = irFunction->contextObjectPropertyDependencies.constEnd();
- property != end; ++property) {
+ for (auto property : irFunction->contextObjectPropertyDependencies) {
*writtenDeps++ = property.key(); // property index
*writtenDeps++ = property.value(); // notify index
}
writtenDeps = (quint32 *)(f + function->dependingScopePropertiesOffset);
- for (QV4::IR::PropertyDependencyMap::ConstIterator property = irFunction->scopeObjectPropertyDependencies.constBegin(), end = irFunction->scopeObjectPropertyDependencies.constEnd();
- property != end; ++property) {
+ for (auto property : irFunction->scopeObjectPropertyDependencies) {
*writtenDeps++ = property.key(); // property index
*writtenDeps++ = property.value(); // notify index
}
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index 90010ccf52..93a7170e68 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -672,7 +672,7 @@ union Instr
};
struct instr_binop {
MOTH_INSTR_HEADER
- QV4::Runtime::BinaryOperation alu;
+ uint alu; // offset inside the runtime methods
Param lhs;
Param rhs;
Param result;
@@ -757,7 +757,7 @@ union Instr
};
struct instr_binopContext {
MOTH_INSTR_HEADER
- QV4::Runtime::BinaryOperationContext alu;
+ uint alu; // offset inside the runtime methods
Param lhs;
Param rhs;
Param result;
diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp
index be10d50e9b..edd8425678 100644
--- a/src/qml/compiler/qv4isel_moth.cpp
+++ b/src/qml/compiler/qv4isel_moth.cpp
@@ -54,7 +54,7 @@ using namespace QV4::Moth;
namespace {
-inline QV4::Runtime::BinaryOperation aluOpFunction(IR::AluOp op)
+inline uint aluOpFunction(IR::AluOp op)
{
switch (op) {
case IR::OpInvalid:
@@ -70,43 +70,43 @@ inline QV4::Runtime::BinaryOperation aluOpFunction(IR::AluOp op)
case IR::OpCompl:
return 0;
case IR::OpBitAnd:
- return QV4::Runtime::bitAnd;
+ return offsetof(QV4::Runtime, bitAnd);
case IR::OpBitOr:
- return QV4::Runtime::bitOr;
+ return offsetof(QV4::Runtime, bitOr);
case IR::OpBitXor:
- return QV4::Runtime::bitXor;
+ return offsetof(QV4::Runtime, bitXor);
case IR::OpAdd:
return 0;
case IR::OpSub:
- return QV4::Runtime::sub;
+ return offsetof(QV4::Runtime, sub);
case IR::OpMul:
- return QV4::Runtime::mul;
+ return offsetof(QV4::Runtime, mul);
case IR::OpDiv:
- return QV4::Runtime::div;
+ return offsetof(QV4::Runtime, div);
case IR::OpMod:
- return QV4::Runtime::mod;
+ return offsetof(QV4::Runtime, mod);
case IR::OpLShift:
- return QV4::Runtime::shl;
+ return offsetof(QV4::Runtime, shl);
case IR::OpRShift:
- return QV4::Runtime::shr;
+ return offsetof(QV4::Runtime, shr);
case IR::OpURShift:
- return QV4::Runtime::ushr;
+ return offsetof(QV4::Runtime, ushr);
case IR::OpGt:
- return QV4::Runtime::greaterThan;
+ return offsetof(QV4::Runtime, greaterThan);
case IR::OpLt:
- return QV4::Runtime::lessThan;
+ return offsetof(QV4::Runtime, lessThan);
case IR::OpGe:
- return QV4::Runtime::greaterEqual;
+ return offsetof(QV4::Runtime, greaterEqual);
case IR::OpLe:
- return QV4::Runtime::lessEqual;
+ return offsetof(QV4::Runtime, lessEqual);
case IR::OpEqual:
- return QV4::Runtime::equal;
+ return offsetof(QV4::Runtime, equal);
case IR::OpNotEqual:
- return QV4::Runtime::notEqual;
+ return offsetof(QV4::Runtime, notEqual);
case IR::OpStrictEqual:
- return QV4::Runtime::strictEqual;
+ return offsetof(QV4::Runtime, strictEqual);
case IR::OpStrictNotEqual:
- return QV4::Runtime::strictNotEqual;
+ return offsetof(QV4::Runtime, strictNotEqual);
case IR::OpInstanceof:
return 0;
case IR::OpIn:
@@ -1040,11 +1040,11 @@ Param InstructionSelection::binopHelper(IR::AluOp oper, IR::Expr *leftSource, IR
if (oper == IR::OpInstanceof || oper == IR::OpIn || oper == IR::OpAdd) {
Instruction::BinopContext binop;
if (oper == IR::OpInstanceof)
- binop.alu = QV4::Runtime::instanceof;
+ binop.alu = offsetof(QV4::Runtime, instanceof);
else if (oper == IR::OpIn)
- binop.alu = QV4::Runtime::in;
+ binop.alu = offsetof(QV4::Runtime, in);
else
- binop.alu = QV4::Runtime::add;
+ binop.alu = offsetof(QV4::Runtime, add);
binop.lhs = getParam(leftSource);
binop.rhs = getParam(rightSource);
binop.result = getResultParam(target);
diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h
index eafecae494..94fa65cf71 100644
--- a/src/qml/compiler/qv4jsir_p.h
+++ b/src/qml/compiler/qv4jsir_p.h
@@ -55,6 +55,7 @@
#include <private/qqmljsastfwd_p.h>
#include <private/qflagpointer_p.h>
+#include <QtCore/private/qnumeric_p.h>
#include <QtCore/QVector>
#include <QtCore/QString>
#include <QtCore/QBitArray>
@@ -1060,7 +1061,32 @@ private:
};
// Map from meta property index (existence implies dependency) to notify signal index
-typedef QHash<int, int> PropertyDependencyMap;
+struct KeyValuePair
+{
+ quint32 _key;
+ quint32 _value;
+
+ KeyValuePair(): _key(0), _value(0) {}
+ KeyValuePair(quint32 key, quint32 value): _key(key), _value(value) {}
+
+ quint32 key() const { return _key; }
+ quint32 value() const { return _value; }
+};
+
+class PropertyDependencyMap: public QVarLengthArray<KeyValuePair, 8>
+{
+public:
+ void insert(quint32 key, quint32 value)
+ {
+ for (auto it = begin(), eit = end(); it != eit; ++it) {
+ if (it->_key == key) {
+ it->_value = value;
+ return;
+ }
+ }
+ append(KeyValuePair(key, value));
+ }
+};
// The Function owns (manages), among things, a list of basic-blocks. All the blocks have an index,
// which corresponds to the index in the entry/index in the vector in which they are stored. This
@@ -1344,7 +1370,7 @@ inline Expr *BasicBlock::CONST(Type type, double value)
} else if (type == NullType) {
value = 0;
} else if (type == UndefinedType) {
- value = qQNaN();
+ value = qt_qnan();
}
e->init(type, value);
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index 6a4c1c54d6..6965d839ab 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -2435,13 +2435,22 @@ protected:
virtual void visitExp(Exp *s) { _ty = run(s->expr); }
virtual void visitMove(Move *s) {
- TypingResult sourceTy = run(s->source);
if (Temp *t = s->target->asTemp()) {
+ if (Name *n = s->source->asName()) {
+ if (n->builtin == Name::builtin_qml_context) {
+ _ty = TypingResult(t->memberResolver);
+ setType(n, _ty.type);
+ setType(t, _ty.type);
+ return;
+ }
+ }
+ TypingResult sourceTy = run(s->source);
setType(t, sourceTy.type);
_ty = sourceTy;
return;
}
+ TypingResult sourceTy = run(s->source);
_ty = run(s->target);
_ty.fullyTyped &= sourceTy.fullyTyped;
}
@@ -2658,7 +2667,7 @@ void convertConst(Const *c, Type targetType)
break;
case NullType:
case UndefinedType:
- c->value = qQNaN();
+ c->value = qt_qnan();
c->type = targetType;
default:
Q_UNIMPLEMENTED();
@@ -3739,42 +3748,42 @@ bool tryOptimizingComparison(Expr *&expr)
switch (b->op) {
case OpGt:
- leftConst->value = Runtime::compareGreaterThan(l, r);
+ leftConst->value = Runtime::method_compareGreaterThan(l, r);
leftConst->type = BoolType;
expr = leftConst;
return true;
case OpLt:
- leftConst->value = Runtime::compareLessThan(l, r);
+ leftConst->value = Runtime::method_compareLessThan(l, r);
leftConst->type = BoolType;
expr = leftConst;
return true;
case OpGe:
- leftConst->value = Runtime::compareGreaterEqual(l, r);
+ leftConst->value = Runtime::method_compareGreaterEqual(l, r);
leftConst->type = BoolType;
expr = leftConst;
return true;
case OpLe:
- leftConst->value = Runtime::compareLessEqual(l, r);
+ leftConst->value = Runtime::method_compareLessEqual(l, r);
leftConst->type = BoolType;
expr = leftConst;
return true;
case OpStrictEqual:
- leftConst->value = Runtime::compareStrictEqual(l, r);
+ leftConst->value = Runtime::method_compareStrictEqual(l, r);
leftConst->type = BoolType;
expr = leftConst;
return true;
case OpEqual:
- leftConst->value = Runtime::compareEqual(l, r);
+ leftConst->value = Runtime::method_compareEqual(l, r);
leftConst->type = BoolType;
expr = leftConst;
return true;
case OpStrictNotEqual:
- leftConst->value = Runtime::compareStrictNotEqual(l, r);
+ leftConst->value = Runtime::method_compareStrictNotEqual(l, r);
leftConst->type = BoolType;
expr = leftConst;
return true;
case OpNotEqual:
- leftConst->value = Runtime::compareNotEqual(l, r);
+ leftConst->value = Runtime::method_compareNotEqual(l, r);
leftConst->type = BoolType;
expr = leftConst;
return true;