diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-08-26 23:13:53 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-08-28 13:19:49 +0000 |
commit | 8bad53758386735050bcf71348ed949988850ec6 (patch) | |
tree | 850b53e6dd8ce633dd3f914f23d9d683038cfeee /src/qml | |
parent | a50911bc0bfca1185e99ce6638fbf03cf592789d (diff) |
Add a load/storeLocal instruction
Change-Id: I084979a6fef7cce9a825cae9ce57234583ceb3ce
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 28 | ||||
-rw-r--r-- | src/qml/compiler/qv4instr_moth.cpp | 14 | ||||
-rw-r--r-- | src/qml/compiler/qv4instr_moth_p.h | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 11 |
4 files changed, 49 insertions, 8 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 2254cc8808..ba2f856b4b 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -3009,10 +3009,16 @@ void Codegen::Reference::storeAccumulator() const return; } case ScopedLocal: { - Instruction::StoreScopedLocal store; - store.index = index; - store.scope = scope; - codegen->bytecodeGenerator->addInstruction(store); + if (scope == 0) { + Instruction::StoreLocal store; + store.index = index; + codegen->bytecodeGenerator->addInstruction(store); + } else { + Instruction::StoreScopedLocal store; + store.index = index; + store.scope = scope; + codegen->bytecodeGenerator->addInstruction(store); + } return; } case Name: { @@ -3116,10 +3122,16 @@ void Codegen::Reference::loadInAccumulator() const codegen->bytecodeGenerator->addInstruction(load); } return; case ScopedLocal: { - Instruction::LoadScopedLocal load; - load.index = index; - load.scope = scope; - codegen->bytecodeGenerator->addInstruction(load); + if (!scope) { + Instruction::LoadLocal load; + load.index = index; + codegen->bytecodeGenerator->addInstruction(load); + } else { + Instruction::LoadScopedLocal load; + load.index = index; + load.scope = scope; + codegen->bytecodeGenerator->addInstruction(load); + } return; } case Name: diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp index 4a440e8d0a..110076b3e3 100644 --- a/src/qml/compiler/qv4instr_moth.cpp +++ b/src/qml/compiler/qv4instr_moth.cpp @@ -174,6 +174,20 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int star d << StackSlot::dump(destTemp, nFormals) << ", C" << constIndex; MOTH_END_INSTR(MoveConst) + MOTH_BEGIN_INSTR(LoadLocal) + if (index < nLocals) + d << "l" << index; + else + d << "a" << (index - nLocals); + MOTH_END_INSTR(LoadLocal) + + MOTH_BEGIN_INSTR(StoreLocal) + if (index < nLocals) + d << ", " << "l" << index; + else + d << ", " << "a" << (index - nLocals); + MOTH_END_INSTR(StoreLocal) + MOTH_BEGIN_INSTR(LoadScopedLocal) if (index < nLocals) d << "l" << index << "@" << scope; diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index 1e1968a91d..8c00c7e5a9 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -84,6 +84,8 @@ QT_BEGIN_NAMESPACE #define INSTR_LoadReg(op) INSTRUCTION(op, LoadReg, 1, reg) #define INSTR_StoreReg(op) INSTRUCTION(op, StoreReg, 1, reg) #define INSTR_MoveReg(op) INSTRUCTION(op, MoveReg, 2, srcReg, destReg) +#define INSTR_LoadLocal(op) INSTRUCTION(op, LoadLocal, 1, index) +#define INSTR_StoreLocal(op) INSTRUCTION(op, StoreLocal, 1, index) #define INSTR_LoadScopedLocal(op) INSTRUCTION(op, LoadScopedLocal, 2, scope, index) #define INSTR_StoreScopedLocal(op) INSTRUCTION(op, StoreScopedLocal, 2, scope, index) #define INSTR_LoadRuntimeString(op) INSTRUCTION(op, LoadRuntimeString, 1, stringId) @@ -196,6 +198,8 @@ QT_BEGIN_NAMESPACE F(LoadReg) \ F(StoreReg) \ F(MoveReg) \ + F(LoadLocal) \ + F(StoreLocal) \ F(LoadScopedLocal) \ F(StoreScopedLocal) \ F(LoadRuntimeString) \ diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 417c955eaa..a5a907391c 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -571,6 +571,17 @@ QV4::ReturnedValue VME::exec(const FunctionObject *jsFunction, CallData *callDat STACK_VALUE(destReg) = STACK_VALUE(srcReg); MOTH_END_INSTR(MoveReg) + MOTH_BEGIN_INSTR(LoadLocal) + auto cc = static_cast<Heap::CallContext *>(frame.jsFrame->context.m()); + accumulator = cc->locals[index]; + MOTH_END_INSTR(LoadLocal) + + MOTH_BEGIN_INSTR(StoreLocal) + CHECK_EXCEPTION; + auto cc = static_cast<Heap::CallContext *>(frame.jsFrame->context.m()); + QV4::WriteBarrier::write(engine, cc, cc->locals.values + index, accumulator); + MOTH_END_INSTR(StoreLocal) + MOTH_BEGIN_INSTR(LoadScopedLocal) accumulator = loadScopedLocal(frame, index, scope); MOTH_END_INSTR(LoadScopedLocal) |