aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-13 22:54:11 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-08-18 10:07:08 +0000
commit6b7194492624dc1b492593b011b56a165f13dacd (patch)
tree735078ddf9328a8d844a88ca98bc5538af5b20f8 /src/qml/compiler
parentb5d89b3e539399e692fc056e3e03e09038adb6d8 (diff)
Add a LoadZero instruction
as 0 is used quite often. Change-Id: I2c952ef077590f6e6cfe9aad50807f5e0f8686e4 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r--src/qml/compiler/qv4codegen.cpp5
-rw-r--r--src/qml/compiler/qv4instr_moth.cpp3
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h5
3 files changed, 13 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 9e075fbe6f..9e05c77966 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -3040,6 +3040,11 @@ void Codegen::Reference::loadInAccumulator() const
double d = p.asDouble();
int i = static_cast<int>(d);
if (d == i && (d != 0 || !std::signbit(d))) {
+ if (!i) {
+ Instruction::LoadZero load;
+ codegen->bytecodeGenerator->addInstruction(load);
+ return;
+ }
Instruction::LoadInt load;
load.value = Primitive::fromReturnedValue(constant).toInt32();
codegen->bytecodeGenerator->addInstruction(load);
diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp
index 95cbfc07bf..5f5c1d2d50 100644
--- a/src/qml/compiler/qv4instr_moth.cpp
+++ b/src/qml/compiler/qv4instr_moth.cpp
@@ -136,6 +136,9 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals)
MOTH_BEGIN_INSTR(LoadNull)
MOTH_END_INSTR(LoadNull)
+ MOTH_BEGIN_INSTR(LoadZero)
+ MOTH_END_INSTR(LoadZero)
+
MOTH_BEGIN_INSTR(LoadTrue)
MOTH_END_INSTR(LoadTrue)
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index d972f64ba4..2f181f806c 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -72,6 +72,7 @@ QT_BEGIN_NAMESPACE
F(Ret, ret) \
MOTH_DEBUG_INSTR(F) \
F(LoadConst, loadConst) \
+ F(LoadZero, loadZero) \
F(LoadTrue, loadTrue) \
F(LoadFalse, loadFalse) \
F(LoadNull, loadNull) \
@@ -268,6 +269,9 @@ union Instr
MOTH_INSTR_HEADER
int index;
};
+ struct instr_loadZero {
+ MOTH_INSTR_HEADER
+ };
struct instr_loadTrue {
MOTH_INSTR_HEADER
};
@@ -716,6 +720,7 @@ union Instr
instr_line line;
instr_debug debug;
instr_loadConst loadConst;
+ instr_loadZero loadZero;
instr_loadTrue loadTrue;
instr_loadFalse loadFalse;
instr_loadNull loadNull;