aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-10-29 11:59:54 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-31 21:49:21 +0100
commitbbc36ebbc38de276b85947b65d89897bf430add5 (patch)
tree31c4a4754210fe3e97391c9dffdc31e105885390 /src/qml/compiler
parent7d850df7e68e0eab0f07d5f7a03050175080fb81 (diff)
Speed up lookups of imported scripts
The QQmlContextData stores the JS objects of imported scripts in a QList<PersistentValue>. Instead of indexing into that list, this patch changes ctxt->importedScripts to be a JavaScript array, that in the IR we can index via subscript. Change-Id: Ie2c35fb5294a20a0b7084bb51d19671a27195fec Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r--src/qml/compiler/qqmlcodegenerator.cpp7
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h7
-rw-r--r--src/qml/compiler/qv4isel_masm.cpp4
-rw-r--r--src/qml/compiler/qv4isel_masm_p.h2
-rw-r--r--src/qml/compiler/qv4isel_moth.cpp5
-rw-r--r--src/qml/compiler/qv4isel_moth_p.h2
-rw-r--r--src/qml/compiler/qv4isel_p.cpp5
-rw-r--r--src/qml/compiler/qv4isel_p.h2
-rw-r--r--src/qml/compiler/qv4jsir.cpp4
-rw-r--r--src/qml/compiler/qv4jsir_p.h2
-rw-r--r--src/qml/compiler/qv4regalloc.cpp2
11 files changed, 21 insertions, 21 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp
index 40e64205ae..51a4961050 100644
--- a/src/qml/compiler/qqmlcodegenerator.cpp
+++ b/src/qml/compiler/qqmlcodegenerator.cpp
@@ -47,6 +47,10 @@
#include <private/qqmlcompiler_p.h>
#include <QCoreApplication>
+#ifdef CONST
+#undef CONST
+#endif
+
QT_USE_NAMESPACE
using namespace QtQml;
@@ -1372,8 +1376,7 @@ V4IR::Expr *JSCodeGen::fallbackNameLookup(const QString &name, int line, int col
QQmlTypeNameCache::Result r = imports->query(name);
if (r.isValid()) {
if (r.scriptIndex != -1) {
- result = _block->QML_CONTEXT_MEMBER(_block->NAME(V4IR::Name::builtin_qml_imported_scripts_scope, line, col),
- _function->newString(name), r.scriptIndex);
+ result = subscript(_block->NAME(V4IR::Name::builtin_qml_imported_scripts_object, line, col), _block->CONST(V4IR::NumberType, r.scriptIndex));
} else {
return 0; // TODO: We can't do fast lookup for these yet.
}
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index d99e0fee0d..854b9a3a8d 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -125,7 +125,7 @@ QT_BEGIN_NAMESPACE
F(SubNumberParams, subNumberParams) \
F(LoadThis, loadThis) \
F(LoadQmlIdObject, loadQmlIdObject) \
- F(LoadQmlImportedScript, loadQmlImportedScript) \
+ F(LoadQmlImportedScripts, loadQmlImportedScripts) \
F(LoadQmlContextObject, loadQmlContextObject) \
F(LoadQmlScopeObject, loadQmlScopeObject)
@@ -645,10 +645,9 @@ union Instr
Param result;
int id;
};
- struct instr_loadQmlImportedScript {
+ struct instr_loadQmlImportedScripts {
MOTH_INSTR_HEADER
Param result;
- int index;
};
struct instr_loadQmlContextObject {
MOTH_INSTR_HEADER
@@ -735,7 +734,7 @@ union Instr
instr_subNumberParams subNumberParams;
instr_loadThis loadThis;
instr_loadQmlIdObject loadQmlIdObject;
- instr_loadQmlImportedScript loadQmlImportedScript;
+ instr_loadQmlImportedScripts loadQmlImportedScripts;
instr_loadQmlContextObject loadQmlContextObject;
instr_loadQmlScopeObject loadQmlScopeObject;
diff --git a/src/qml/compiler/qv4isel_masm.cpp b/src/qml/compiler/qv4isel_masm.cpp
index 7162fe905e..4eeab0f184 100644
--- a/src/qml/compiler/qv4isel_masm.cpp
+++ b/src/qml/compiler/qv4isel_masm.cpp
@@ -953,9 +953,9 @@ void InstructionSelection::loadQmlIdObject(int id, V4IR::Temp *temp)
generateFunctionCall(temp, __qmljs_get_id_object, Assembler::ContextRegister, Assembler::TrustedImm32(id));
}
-void InstructionSelection::loadQmlImportedScript(int index, V4IR::Temp *temp)
+void InstructionSelection::loadQmlImportedScripts(V4IR::Temp *temp)
{
- generateFunctionCall(temp, __qmljs_get_imported_script, Assembler::ContextRegister, Assembler::TrustedImm32(index));
+ generateFunctionCall(temp, __qmljs_get_imported_scripts, Assembler::ContextRegister);
}
void InstructionSelection::loadQmlContextObject(V4IR::Temp *temp)
diff --git a/src/qml/compiler/qv4isel_masm_p.h b/src/qml/compiler/qv4isel_masm_p.h
index 1db7c5f59e..37e99bd359 100644
--- a/src/qml/compiler/qv4isel_masm_p.h
+++ b/src/qml/compiler/qv4isel_masm_p.h
@@ -1470,7 +1470,7 @@ protected:
virtual void convertType(V4IR::Temp *source, V4IR::Temp *target);
virtual void loadThisObject(V4IR::Temp *temp);
virtual void loadQmlIdObject(int id, V4IR::Temp *temp);
- virtual void loadQmlImportedScript(int index, V4IR::Temp *temp);
+ virtual void loadQmlImportedScripts(V4IR::Temp *temp);
virtual void loadQmlContextObject(V4IR::Temp *temp);
virtual void loadQmlScopeObject(V4IR::Temp *temp);
virtual void loadConst(V4IR::Const *sourceConst, V4IR::Temp *targetTemp);
diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp
index a8d8d7454f..a67675ecdf 100644
--- a/src/qml/compiler/qv4isel_moth.cpp
+++ b/src/qml/compiler/qv4isel_moth.cpp
@@ -462,11 +462,10 @@ void InstructionSelection::loadQmlIdObject(int id, V4IR::Temp *temp)
addInstruction(load);
}
-void InstructionSelection::loadQmlImportedScript(int index, V4IR::Temp *temp)
+void InstructionSelection::loadQmlImportedScripts(V4IR::Temp *temp)
{
- Instruction::LoadQmlImportedScript load;
+ Instruction::LoadQmlImportedScripts load;
load.result = getResultParam(temp);
- load.index = index;
addInstruction(load);
}
diff --git a/src/qml/compiler/qv4isel_moth_p.h b/src/qml/compiler/qv4isel_moth_p.h
index 8c00954bd3..c5ef1e44ba 100644
--- a/src/qml/compiler/qv4isel_moth_p.h
+++ b/src/qml/compiler/qv4isel_moth_p.h
@@ -115,7 +115,7 @@ protected:
virtual void constructValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result);
virtual void loadThisObject(V4IR::Temp *temp);
virtual void loadQmlIdObject(int id, V4IR::Temp *temp);
- virtual void loadQmlImportedScript(int index, V4IR::Temp *temp);
+ virtual void loadQmlImportedScripts(V4IR::Temp *temp);
virtual void loadQmlContextObject(V4IR::Temp *temp);
virtual void loadQmlScopeObject(V4IR::Temp *temp);
virtual void loadConst(V4IR::Const *sourceConst, V4IR::Temp *targetTemp);
diff --git a/src/qml/compiler/qv4isel_p.cpp b/src/qml/compiler/qv4isel_p.cpp
index 3b7509d7bf..0afd25315e 100644
--- a/src/qml/compiler/qv4isel_p.cpp
+++ b/src/qml/compiler/qv4isel_p.cpp
@@ -107,6 +107,8 @@ void IRDecoder::visitMove(V4IR::Move *s)
loadQmlContextObject(t);
else if (n->builtin == V4IR::Name::builtin_qml_scope_object)
loadQmlScopeObject(t);
+ else if (n->builtin == V4IR::Name::builtin_qml_imported_scripts_object)
+ loadQmlImportedScripts(t);
else
getActivationProperty(n, t);
return;
@@ -147,9 +149,6 @@ void IRDecoder::visitMove(V4IR::Move *s)
if (base->builtin == V4IR::Name::builtin_qml_id_scope) {
loadQmlIdObject(m->memberIndex, t);
return;
- } else if (base->builtin == V4IR::Name::builtin_qml_imported_scripts_scope) {
- loadQmlImportedScript(m->memberIndex, t);
- return;
}
} else if (m->type == V4IR::Member::MemberOfQObject) {
getQObjectProperty(m->base, m->property->coreIndex, t);
diff --git a/src/qml/compiler/qv4isel_p.h b/src/qml/compiler/qv4isel_p.h
index 177bbeb0d4..fafe741fd5 100644
--- a/src/qml/compiler/qv4isel_p.h
+++ b/src/qml/compiler/qv4isel_p.h
@@ -141,7 +141,7 @@ public: // to implement by subclasses:
virtual void constructValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result) = 0;
virtual void loadThisObject(V4IR::Temp *temp) = 0;
virtual void loadQmlIdObject(int id, V4IR::Temp *temp) = 0;
- virtual void loadQmlImportedScript(int index, V4IR::Temp *temp) = 0;
+ virtual void loadQmlImportedScripts(V4IR::Temp *temp) = 0;
virtual void loadQmlContextObject(V4IR::Temp *temp) = 0;
virtual void loadQmlScopeObject(V4IR::Temp *temp) = 0;
virtual void loadConst(V4IR::Const *sourceConst, V4IR::Temp *targetTemp) = 0;
diff --git a/src/qml/compiler/qv4jsir.cpp b/src/qml/compiler/qv4jsir.cpp
index 2e80fc1f31..4c5847f778 100644
--- a/src/qml/compiler/qv4jsir.cpp
+++ b/src/qml/compiler/qv4jsir.cpp
@@ -424,8 +424,8 @@ static const char *builtin_to_string(Name::Builtin b)
return "builtin_setup_argument_object";
case V4IR::Name::builtin_qml_id_scope:
return "builtin_qml_id_scope";
- case V4IR::Name::builtin_qml_imported_scripts_scope:
- return "builtin_qml_imported_scripts_scope";
+ case V4IR::Name::builtin_qml_imported_scripts_object:
+ return "builtin_qml_imported_scripts_object";
case V4IR::Name::builtin_qml_scope_object:
return "builtin_qml_scope_object";
case V4IR::Name::builtin_qml_context_object:
diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h
index 3cd8bfccb5..41191b0bec 100644
--- a/src/qml/compiler/qv4jsir_p.h
+++ b/src/qml/compiler/qv4jsir_p.h
@@ -325,7 +325,7 @@ struct Name: Expr {
builtin_define_object_literal,
builtin_setup_argument_object,
builtin_qml_id_scope,
- builtin_qml_imported_scripts_scope,
+ builtin_qml_imported_scripts_object,
builtin_qml_context_object,
builtin_qml_scope_object
};
diff --git a/src/qml/compiler/qv4regalloc.cpp b/src/qml/compiler/qv4regalloc.cpp
index 15b0d42169..62013fc2b7 100644
--- a/src/qml/compiler/qv4regalloc.cpp
+++ b/src/qml/compiler/qv4regalloc.cpp
@@ -340,7 +340,7 @@ protected: // IRDecoder
addCall();
}
- virtual void loadQmlImportedScript(int index, V4IR::Temp *temp)
+ virtual void loadQmlImportedScripts(V4IR::Temp *temp)
{
addDef(temp);
addCall();