diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-11-21 10:00:45 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-11-23 15:05:22 +0000 |
commit | 1f5c79c59aa43e416778a2046e4121731b34bb6a (patch) | |
tree | 27dbc03f147d484e79c40b42c79abc2a2291655b /src/qml/compiler | |
parent | 8df195c8765429652ccf31e9de9829bbae5ba5bb (diff) |
V4: Collapse LoadRegExp+StoreReg into MoveRegExp
LoadRegExp is nearly always followed by a store of the accumulator, so
change LoadRegExp to be MoveRegExp. This saves an instruction.
Change-Id: I5d47c5bf6ffd7f28247c328410872c3b229ca23c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 5 | ||||
-rw-r--r-- | src/qml/compiler/qv4instr_moth.cpp | 6 | ||||
-rw-r--r-- | src/qml/compiler/qv4instr_moth_p.h | 4 |
3 files changed, 8 insertions, 7 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index b9d223bab0..68bda2dcd3 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -1885,12 +1885,13 @@ bool Codegen::visit(RegExpLiteral *ast) if (hasError) return false; - auto r = Reference::fromAccumulator(this); + auto r = Reference::fromStackSlot(this); r.isReadonly = true; _expr.setResult(r); - Instruction::LoadRegExp instr; + Instruction::MoveRegExp instr; instr.regExpId = jsUnitGenerator->registerRegExp(ast); + instr.destReg = r.stackSlot(); bytecodeGenerator->addInstruction(instr); return false; } diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp index 9cfde99e6b..3fc8882937 100644 --- a/src/qml/compiler/qv4instr_moth.cpp +++ b/src/qml/compiler/qv4instr_moth.cpp @@ -261,9 +261,9 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st d << stringId; MOTH_END_INSTR(LoadRuntimeString) - MOTH_BEGIN_INSTR(LoadRegExp) - d << regExpId; - MOTH_END_INSTR(LoadRegExp) + MOTH_BEGIN_INSTR(MoveRegExp) + d << dumpRegister(destReg, nFormals) << ", " <<regExpId; + MOTH_END_INSTR(MoveRegExp) MOTH_BEGIN_INSTR(LoadClosure) d << value; diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index e0b013eb95..06cf34481c 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -89,7 +89,7 @@ QT_BEGIN_NAMESPACE #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) -#define INSTR_LoadRegExp(op) INSTRUCTION(op, LoadRegExp, 1, regExpId) +#define INSTR_MoveRegExp(op) INSTRUCTION(op, MoveRegExp, 2, regExpId, destReg) #define INSTR_LoadClosure(op) INSTRUCTION(op, LoadClosure, 1, value) #define INSTR_LoadName(op) INSTRUCTION(op, LoadName, 1, name) #define INSTR_LoadGlobalLookup(op) INSTRUCTION(op, LoadGlobalLookup, 1, index) @@ -205,7 +205,7 @@ QT_BEGIN_NAMESPACE F(LoadScopedLocal) \ F(StoreScopedLocal) \ F(LoadRuntimeString) \ - F(LoadRegExp) \ + F(MoveRegExp) \ F(LoadClosure) \ F(LoadName) \ F(LoadGlobalLookup) \ |