diff options
| author | Simon Hausmann <simon.hausmann@digia.com> | 2013-10-28 15:18:31 +0100 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-31 18:54:59 +0100 |
| commit | b0afac3daf1cbb9daacbeac0183ef6254de6cc95 (patch) | |
| tree | 1eb69941be2d3c47e5d711705cd5f910eefafdca /src/qml/compiler | |
| parent | c7a3089c146d6063f3b3201149e42c720c8ca5b3 (diff) | |
Implement setting of values to resolved QObject properties
After the resolution of a property, we can set it by index at run-time instead
of via name resolution.
Change-Id: I479599dabe343cf9e6582dcda12291aebfcce418
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler')
| -rw-r--r-- | src/qml/compiler/qv4instr_moth_p.h | 8 | ||||
| -rw-r--r-- | src/qml/compiler/qv4isel_masm.cpp | 6 | ||||
| -rw-r--r-- | src/qml/compiler/qv4isel_masm_p.h | 1 | ||||
| -rw-r--r-- | src/qml/compiler/qv4isel_moth.cpp | 9 | ||||
| -rw-r--r-- | src/qml/compiler/qv4isel_moth_p.h | 1 | ||||
| -rw-r--r-- | src/qml/compiler/qv4isel_p.cpp | 9 | ||||
| -rw-r--r-- | src/qml/compiler/qv4isel_p.h | 1 | ||||
| -rw-r--r-- | src/qml/compiler/qv4regalloc.cpp | 7 |
8 files changed, 40 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index d1619962f5..99aed0db97 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -65,6 +65,7 @@ QT_BEGIN_NAMESPACE F(GetLookup, getLookup) \ F(StoreProperty, storeProperty) \ F(SetLookup, setLookup) \ + F(StoreQObjectProperty, storeQObjectProperty) \ F(LoadQObjectProperty, loadQObjectProperty) \ F(Push, push) \ F(CallValue, callValue) \ @@ -296,6 +297,12 @@ union Instr Param base; Param source; }; + struct instr_storeQObjectProperty { + MOTH_INSTR_HEADER + Param base; + int propertyIndex; + Param source; + }; struct instr_loadElement { MOTH_INSTR_HEADER Param base; @@ -663,6 +670,7 @@ union Instr instr_loadQObjectProperty loadQObjectProperty; instr_storeProperty storeProperty; instr_setLookup setLookup; + instr_storeQObjectProperty storeQObjectProperty; instr_push push; instr_callValue callValue; instr_callProperty callProperty; diff --git a/src/qml/compiler/qv4isel_masm.cpp b/src/qml/compiler/qv4isel_masm.cpp index a012273c12..ecfe7dd0a0 100644 --- a/src/qml/compiler/qv4isel_masm.cpp +++ b/src/qml/compiler/qv4isel_masm.cpp @@ -1061,6 +1061,12 @@ void InstructionSelection::setProperty(V4IR::Expr *source, V4IR::Expr *targetBas } } +void InstructionSelection::setQObjectProperty(V4IR::Expr *source, V4IR::Expr *targetBase, int propertyIndex) +{ + generateFunctionCall(Assembler::Void, __qmljs_set_qobject_property, Assembler::ContextRegister, Assembler::PointerToValue(targetBase), + Assembler::TrustedImm32(propertyIndex), Assembler::PointerToValue(source)); +} + void InstructionSelection::getElement(V4IR::Expr *base, V4IR::Expr *index, V4IR::Temp *target) { #if QT_POINTER_SIZE == 8 diff --git a/src/qml/compiler/qv4isel_masm_p.h b/src/qml/compiler/qv4isel_masm_p.h index 46144f22d1..b5f95f0062 100644 --- a/src/qml/compiler/qv4isel_masm_p.h +++ b/src/qml/compiler/qv4isel_masm_p.h @@ -1480,6 +1480,7 @@ protected: virtual void initClosure(V4IR::Closure *closure, V4IR::Temp *target); virtual void getProperty(V4IR::Expr *base, const QString &name, V4IR::Temp *target); virtual void setProperty(V4IR::Expr *source, V4IR::Expr *targetBase, const QString &targetName); + virtual void setQObjectProperty(V4IR::Expr *source, V4IR::Expr *targetBase, int propertyIndex); virtual void getQObjectProperty(V4IR::Expr *base, int propertyIndex, V4IR::Temp *target); virtual void getElement(V4IR::Expr *base, V4IR::Expr *index, V4IR::Temp *target); virtual void setElement(V4IR::Expr *source, V4IR::Expr *targetBase, V4IR::Expr *targetIndex); diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp index ca0977e057..954c4f532e 100644 --- a/src/qml/compiler/qv4isel_moth.cpp +++ b/src/qml/compiler/qv4isel_moth.cpp @@ -569,6 +569,15 @@ void InstructionSelection::setProperty(V4IR::Expr *source, V4IR::Expr *targetBas addInstruction(store); } +void InstructionSelection::setQObjectProperty(V4IR::Expr *source, V4IR::Expr *targetBase, int propertyIndex) +{ + Instruction::StoreQObjectProperty store; + store.base = getParam(targetBase); + store.propertyIndex = propertyIndex; + store.source = getParam(source); + addInstruction(store); +} + void InstructionSelection::getQObjectProperty(V4IR::Expr *base, int propertyIndex, V4IR::Temp *target) { Instruction::LoadQObjectProperty load; diff --git a/src/qml/compiler/qv4isel_moth_p.h b/src/qml/compiler/qv4isel_moth_p.h index 0b44bf35ca..61fc092c57 100644 --- a/src/qml/compiler/qv4isel_moth_p.h +++ b/src/qml/compiler/qv4isel_moth_p.h @@ -125,6 +125,7 @@ protected: virtual void initClosure(V4IR::Closure *closure, V4IR::Temp *target); virtual void getProperty(V4IR::Expr *base, const QString &name, V4IR::Temp *target); virtual void setProperty(V4IR::Expr *source, V4IR::Expr *targetBase, const QString &targetName); + virtual void setQObjectProperty(V4IR::Expr *source, V4IR::Expr *targetBase, int propertyIndex); virtual void getQObjectProperty(V4IR::Expr *base, int propertyIndex, V4IR::Temp *target); virtual void getElement(V4IR::Expr *base, V4IR::Expr *index, V4IR::Temp *target); virtual void setElement(V4IR::Expr *source, V4IR::Expr *targetBase, V4IR::Expr *targetIndex); diff --git a/src/qml/compiler/qv4isel_p.cpp b/src/qml/compiler/qv4isel_p.cpp index 1a56ddabf1..d6f0b4b804 100644 --- a/src/qml/compiler/qv4isel_p.cpp +++ b/src/qml/compiler/qv4isel_p.cpp @@ -183,8 +183,13 @@ void IRDecoder::visitMove(V4IR::Move *s) } else if (V4IR::Member *m = s->target->asMember()) { if (m->base->asTemp() || m->base->asConst()) { if (s->source->asTemp() || s->source->asConst()) { - setProperty(s->source, m->base, *m->name); - return; + if (m->type == V4IR::Member::MemberOfQObject) { + setQObjectProperty(s->source, m->base, m->property->coreIndex); + return; + } else { + setProperty(s->source, m->base, *m->name); + return; + } } } } else if (V4IR::Subscript *ss = s->target->asSubscript()) { diff --git a/src/qml/compiler/qv4isel_p.h b/src/qml/compiler/qv4isel_p.h index 5b9dbafb50..bdb998fc0b 100644 --- a/src/qml/compiler/qv4isel_p.h +++ b/src/qml/compiler/qv4isel_p.h @@ -152,6 +152,7 @@ public: // to implement by subclasses: virtual void getProperty(V4IR::Expr *base, const QString &name, V4IR::Temp *target) = 0; virtual void getQObjectProperty(V4IR::Expr *base, int propertyIndex, V4IR::Temp *targetTemp) = 0; virtual void setProperty(V4IR::Expr *source, V4IR::Expr *targetBase, const QString &targetName) = 0; + virtual void setQObjectProperty(V4IR::Expr *source, V4IR::Expr *targetBase, int propertyIndex) = 0; virtual void getElement(V4IR::Expr *base, V4IR::Expr *index, V4IR::Temp *target) = 0; virtual void setElement(V4IR::Expr *source, V4IR::Expr *targetBase, V4IR::Expr *targetIndex) = 0; virtual void copyValue(V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp) = 0; diff --git a/src/qml/compiler/qv4regalloc.cpp b/src/qml/compiler/qv4regalloc.cpp index 84efdbb920..501f5b7edb 100644 --- a/src/qml/compiler/qv4regalloc.cpp +++ b/src/qml/compiler/qv4regalloc.cpp @@ -400,6 +400,13 @@ protected: // IRDecoder addCall(); } + virtual void setQObjectProperty(V4IR::Expr *source, V4IR::Expr *targetBase, int /*propertyIndex*/) + { + addUses(source->asTemp(), Use::CouldHaveRegister); + addUses(targetBase->asTemp(), Use::CouldHaveRegister); + addCall(); + } + virtual void getQObjectProperty(V4IR::Expr *base, int /*propertyIndex*/, V4IR::Temp *target) { addDef(target); |
