diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-09 23:31:26 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-21 19:43:28 +0000 |
commit | 6969aa5932f0eb7171dea2b4da39c21d1c09cc60 (patch) | |
tree | a842b629c57bbc3e3486de0d9783f9ed61ea307b | |
parent | 0562ece42df80cd3ffe3c3fe6b2097202fe65500 (diff) |
Get rid of LoadElement and LoadProperty instruction overloads
Always use the overload where the value is in the accumulator.
Change-Id: I6a3d81fea7aae957e0cf6efd123d7739f8880c95
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | src/qml/compiler/qv4bytecodehandler.cpp | 6 | ||||
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 49 | ||||
-rw-r--r-- | src/qml/compiler/qv4codegen_p.h | 1 | ||||
-rw-r--r-- | src/qml/compiler/qv4instr_moth.cpp | 10 | ||||
-rw-r--r-- | src/qml/compiler/qv4instr_moth_p.h | 8 | ||||
-rw-r--r-- | src/qml/jit/qv4baselinejit.cpp | 25 | ||||
-rw-r--r-- | src/qml/jit/qv4baselinejit_p.h | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 16 |
8 files changed, 34 insertions, 87 deletions
diff --git a/src/qml/compiler/qv4bytecodehandler.cpp b/src/qml/compiler/qv4bytecodehandler.cpp index 18fef62dab..3e4844a1ac 100644 --- a/src/qml/compiler/qv4bytecodehandler.cpp +++ b/src/qml/compiler/qv4bytecodehandler.cpp @@ -197,18 +197,12 @@ std::vector<int> ByteCodeHandler::collectLabelsInBytecode(const char *code, uint COLLECTOR_BEGIN_INSTR(LoadElement) COLLECTOR_END_INSTR(LoadElement) - COLLECTOR_BEGIN_INSTR(LoadElementA) - COLLECTOR_END_INSTR(LoadElement) - COLLECTOR_BEGIN_INSTR(StoreElement) COLLECTOR_END_INSTR(StoreElement) COLLECTOR_BEGIN_INSTR(LoadProperty) COLLECTOR_END_INSTR(LoadProperty) - COLLECTOR_BEGIN_INSTR(LoadPropertyA) - COLLECTOR_END_INSTR(LoadElementA) - COLLECTOR_BEGIN_INSTR(GetLookup) COLLECTOR_END_INSTR(GetLookup) diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 72e6b2bdf5..6682f604de 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -3495,6 +3495,22 @@ Codegen::RValue Codegen::RValue::storeOnStack() const } } +void Codegen::RValue::loadInAccumulator() const +{ + switch (type) { + case Accumulator: + // nothing to do + return; + case StackSlot: + return Reference::fromStackSlot(codegen, theStackSlot).loadInAccumulator(); + case Const: + return Reference::fromConst(codegen, constant).loadInAccumulator(); + default: + Q_UNREACHABLE(); + } + +} + Codegen::Reference::Reference(const Codegen::Reference &other) { *this = other; @@ -3867,34 +3883,17 @@ QT_WARNING_POP codegen->bytecodeGenerator->addInstruction(load); } } else { - if (propertyBase.isAccumulator()) { - Instruction::LoadPropertyA load; - load.name = propertyNameIndex; - codegen->bytecodeGenerator->addInstruction(load); - } else { - Instruction::LoadProperty load; - load.base = propertyBase.storeOnStack().stackSlot(); - load.name = propertyNameIndex; - codegen->bytecodeGenerator->addInstruction(load); - } + propertyBase.loadInAccumulator(); + Instruction::LoadProperty load; + load.name = propertyNameIndex; + codegen->bytecodeGenerator->addInstruction(load); } return; case Subscript: { - if (elementSubscript.isAccumulator()) { - Instruction::LoadElementA load; - load.base = elementBase; - codegen->bytecodeGenerator->addInstruction(load); - } else if (elementSubscript.isConst()) { - Reference::fromConst(codegen, elementSubscript.constantValue()).loadInAccumulator(); - Instruction::LoadElementA load; - load.base = elementBase; - codegen->bytecodeGenerator->addInstruction(load); - } else { - Instruction::LoadElement load; - load.base = elementBase; - load.index = elementSubscript.storeOnStack().stackSlot(); - codegen->bytecodeGenerator->addInstruction(load); - } + elementSubscript.loadInAccumulator(); + Instruction::LoadElement load; + load.base = elementBase; + codegen->bytecodeGenerator->addInstruction(load); } return; case QmlScopeObject: { Instruction::LoadScopeObjectProperty load; diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h index 713b040ad1..3750811eaf 100644 --- a/src/qml/compiler/qv4codegen_p.h +++ b/src/qml/compiler/qv4codegen_p.h @@ -172,6 +172,7 @@ public: } Q_REQUIRED_RESULT RValue storeOnStack() const; + void loadInAccumulator() const; }; struct Reference { enum Type { diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp index b31b3f8584..6f603f9488 100644 --- a/src/qml/compiler/qv4instr_moth.cpp +++ b/src/qml/compiler/qv4instr_moth.cpp @@ -286,10 +286,6 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st MOTH_END_INSTR(StoreNameStrict) MOTH_BEGIN_INSTR(LoadElement) - d << dumpRegister(base, nFormals) << "[" << dumpRegister(index, nFormals) << "]"; - MOTH_END_INSTR(LoadElement) - - MOTH_BEGIN_INSTR(LoadElementA) d << dumpRegister(base, nFormals) << "[acc]"; MOTH_END_INSTR(LoadElement) @@ -298,12 +294,8 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st MOTH_END_INSTR(StoreElement) MOTH_BEGIN_INSTR(LoadProperty) - d << dumpRegister(base, nFormals) << "[" << name << "]"; - MOTH_END_INSTR(LoadProperty) - - MOTH_BEGIN_INSTR(LoadPropertyA) d << "acc[" << name << "]"; - MOTH_END_INSTR(LoadElementA) + MOTH_END_INSTR(LoadProperty) MOTH_BEGIN_INSTR(GetLookup) d << dumpRegister(base, nFormals) << "(" << index << ")"; diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index 4f6767f07f..d4d630dfaf 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -86,8 +86,7 @@ QT_BEGIN_NAMESPACE #define INSTR_LoadGlobalLookup(op) INSTRUCTION(op, LoadGlobalLookup, 1, index) #define INSTR_StoreNameSloppy(op) INSTRUCTION(op, StoreNameSloppy, 1, name) #define INSTR_StoreNameStrict(op) INSTRUCTION(op, StoreNameStrict, 1, name) -#define INSTR_LoadProperty(op) INSTRUCTION(op, LoadProperty, 2, name, base) -#define INSTR_LoadPropertyA(op) INSTRUCTION(op, LoadPropertyA, 1, name) +#define INSTR_LoadProperty(op) INSTRUCTION(op, LoadProperty, 1, name) #define INSTR_GetLookup(op) INSTRUCTION(op, GetLookup, 2, index, base) #define INSTR_GetLookupA(op) INSTRUCTION(op, GetLookupA, 1, index) #define INSTR_LoadScopeObjectProperty(op) INSTRUCTION(op, LoadScopeObjectProperty, 3, propertyIndex, base, captureRequired) @@ -99,8 +98,7 @@ QT_BEGIN_NAMESPACE #define INSTR_SetLookup(op) INSTRUCTION(op, SetLookup, 2, index, base) #define INSTR_StoreScopeObjectProperty(op) INSTRUCTION(op, StoreScopeObjectProperty, 2, base, propertyIndex) #define INSTR_StoreContextObjectProperty(op) INSTRUCTION(op, StoreContextObjectProperty, 2, base, propertyIndex) -#define INSTR_LoadElement(op) INSTRUCTION(op, LoadElement, 2, base, index) -#define INSTR_LoadElementA(op) INSTRUCTION(op, LoadElementA, 1, base) +#define INSTR_LoadElement(op) INSTRUCTION(op, LoadElement, 1, base) #define INSTR_StoreElement(op) INSTRUCTION(op, StoreElement, 2, base, index) #define INSTR_CallValue(op) INSTRUCTION(op, CallValue, 3, name, argc, argv) #define INSTR_CallProperty(op) INSTRUCTION(op, CallProperty, 4, name, base, argc, argv) @@ -215,10 +213,8 @@ QT_BEGIN_NAMESPACE F(StoreNameSloppy) \ F(StoreNameStrict) \ F(LoadElement) \ - F(LoadElementA) \ F(StoreElement) \ F(LoadProperty) \ - F(LoadPropertyA) \ F(GetLookup) \ F(GetLookupA) \ F(StoreProperty) \ diff --git a/src/qml/jit/qv4baselinejit.cpp b/src/qml/jit/qv4baselinejit.cpp index ac6fc976f4..7f9674c57f 100644 --- a/src/qml/jit/qv4baselinejit.cpp +++ b/src/qml/jit/qv4baselinejit.cpp @@ -233,18 +233,7 @@ void BaselineJIT::generate_StoreNameStrict(int name) as->checkException(); } -void BaselineJIT::generate_LoadElement(int base, int index) -{ - STORE_IP(); - as->prepareCallWithArgCount(3); - as->passRegAsArg(index, 2); - as->passRegAsArg(base, 1); - as->passEngineAsArg(0); - JIT_GENERATE_RUNTIME_CALL(Runtime::method_loadElement, Assembler::ResultInAccumulator); - as->checkException(); -} - -void BaselineJIT::generate_LoadElementA(int base) +void BaselineJIT::generate_LoadElement(int base) { STORE_IP(); STORE_ACC(); @@ -276,17 +265,7 @@ void BaselineJIT::generate_StoreElement(int base, int index) as->checkException(); } -void BaselineJIT::generate_LoadProperty(int name, int base) -{ - STORE_IP(); - as->prepareCallWithArgCount(3); - as->passInt32AsArg(name, 2); - as->passRegAsArg(base, 1); - as->passEngineAsArg(0); - JIT_GENERATE_RUNTIME_CALL(Runtime::method_loadProperty, Assembler::ResultInAccumulator); - as->checkException(); -} -void BaselineJIT::generate_LoadPropertyA(int name) +void BaselineJIT::generate_LoadProperty(int name) { STORE_IP(); STORE_ACC(); diff --git a/src/qml/jit/qv4baselinejit_p.h b/src/qml/jit/qv4baselinejit_p.h index fda410db69..b09efb1680 100644 --- a/src/qml/jit/qv4baselinejit_p.h +++ b/src/qml/jit/qv4baselinejit_p.h @@ -98,11 +98,9 @@ public: void generate_LoadGlobalLookup(int index) override; void generate_StoreNameSloppy(int name) override; void generate_StoreNameStrict(int name) override; - void generate_LoadElement(int base, int index) override; - void generate_LoadElementA(int base) override; + void generate_LoadElement(int base) override; void generate_StoreElement(int base, int index) override; - void generate_LoadProperty(int name, int base) override; - void generate_LoadPropertyA(int name) override; + void generate_LoadProperty(int name) override; void generate_GetLookup(int index, int base) override; void generate_GetLookupA(int index) override; void generate_StoreProperty(int name, int base) override; diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index bf77a96bec..73a28557c2 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -708,16 +708,10 @@ QV4::ReturnedValue VME::interpret(CppStackFrame &frame, const char *code) MOTH_BEGIN_INSTR(LoadElement) STORE_IP(); - acc = Runtime::method_loadElement(engine, STACK_VALUE(base), STACK_VALUE(index)); - CHECK_EXCEPTION; - MOTH_END_INSTR(LoadElement) - - MOTH_BEGIN_INSTR(LoadElementA) - STORE_IP(); STORE_ACC(); acc = Runtime::method_loadElement(engine, STACK_VALUE(base), accumulator); CHECK_EXCEPTION; - MOTH_END_INSTR(LoadElementA) + MOTH_END_INSTR(LoadElement) MOTH_BEGIN_INSTR(StoreElement) STORE_IP(); @@ -729,16 +723,10 @@ QV4::ReturnedValue VME::interpret(CppStackFrame &frame, const char *code) MOTH_BEGIN_INSTR(LoadProperty) STORE_IP(); - acc = Runtime::method_loadProperty(engine, STACK_VALUE(base), name); - CHECK_EXCEPTION; - MOTH_END_INSTR(LoadProperty) - - MOTH_BEGIN_INSTR(LoadPropertyA) - STORE_IP(); STORE_ACC(); acc = Runtime::method_loadProperty(engine, accumulator, name); CHECK_EXCEPTION; - MOTH_END_INSTR(LoadPropertyA) + MOTH_END_INSTR(LoadProperty) MOTH_BEGIN_INSTR(GetLookup) STORE_IP(); |