aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-12 16:41:28 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-08-18 10:00:56 +0000
commit26dfa98e6bb21089dc6caaed49ac69a57b1b3b24 (patch)
treed90cf6eb9e2b3a7d7dd82081b69790a0c57b3d4c /src
parent721e96e8836d81d79f3ea9d6a7d25cbc2c04bac0 (diff)
Optimize byte codes for loading true/false
Change-Id: Ib726d55a32d868a4a547b0530b8b6dc6cd99a3cf Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/compiler/qv4codegen.cpp6
-rw-r--r--src/qml/compiler/qv4instr_moth.cpp6
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h10
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp8
4 files changed, 30 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 2ad5ee8610..b8a6b4c974 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -3035,6 +3035,12 @@ void Codegen::Reference::loadInAccumulator() const
if (constant == Encode::null()) {
Instruction::LoadNull load;
codegen->bytecodeGenerator->addInstruction(load);
+ } else if (constant == Encode(true)) {
+ Instruction::LoadTrue load;
+ codegen->bytecodeGenerator->addInstruction(load);
+ } else if (constant == Encode(false)) {
+ Instruction::LoadFalse load;
+ codegen->bytecodeGenerator->addInstruction(load);
} else if (constant == Encode::undefined()) {
Instruction::LoadUndefined load;
codegen->bytecodeGenerator->addInstruction(load);
diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp
index b885db30bf..e23f85ca96 100644
--- a/src/qml/compiler/qv4instr_moth.cpp
+++ b/src/qml/compiler/qv4instr_moth.cpp
@@ -136,6 +136,12 @@ void dumpBytecode(const char *code, int len, int nFormals)
MOTH_BEGIN_INSTR(LoadNull)
MOTH_END_INSTR(LoadNull)
+ MOTH_BEGIN_INSTR(LoadTrue)
+ MOTH_END_INSTR(LoadTrue)
+
+ MOTH_BEGIN_INSTR(LoadFalse)
+ MOTH_END_INSTR(LoadFalse)
+
MOTH_BEGIN_INSTR(LoadUndefined)
MOTH_END_INSTR(LoadUndefined)
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index df1c9ddef7..2d3113fabe 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -72,6 +72,8 @@ QT_BEGIN_NAMESPACE
F(Ret, ret) \
MOTH_DEBUG_INSTR(F) \
F(LoadConst, loadConst) \
+ F(LoadTrue, loadTrue) \
+ F(LoadFalse, loadFalse) \
F(LoadNull, loadNull) \
F(LoadUndefined, loadUndefined) \
F(LoadInt, loadInt) \
@@ -269,6 +271,12 @@ union Instr
MOTH_INSTR_HEADER
int index;
};
+ struct instr_loadTrue {
+ MOTH_INSTR_HEADER
+ };
+ struct instr_loadFalse {
+ MOTH_INSTR_HEADER
+ };
struct instr_loadNull {
MOTH_INSTR_HEADER
};
@@ -724,6 +732,8 @@ union Instr
instr_line line;
instr_debug debug;
instr_loadConst loadConst;
+ instr_loadTrue loadTrue;
+ instr_loadFalse loadFalse;
instr_loadNull loadNull;
instr_loadUndefined loadUndefined;
instr_loadInt loadInt;
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index defbf2bde9..22e16cbe99 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -472,6 +472,14 @@ QV4::ReturnedValue VME::exec(const FunctionObject *jsFunction, CallData *callDat
accumulator = Encode::null();
MOTH_END_INSTR(LoadNull)
+ MOTH_BEGIN_INSTR(LoadTrue)
+ accumulator = Encode(true);
+ MOTH_END_INSTR(LoadTrue)
+
+ MOTH_BEGIN_INSTR(LoadFalse)
+ accumulator = Encode(false);
+ MOTH_END_INSTR(LoadFalse)
+
MOTH_BEGIN_INSTR(LoadUndefined)
accumulator = Encode::undefined();
MOTH_END_INSTR(LoadUndefined)