diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-02-06 13:19:27 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-07 10:44:03 +0100 |
commit | 706a3cfc8751003aaa73368348b84b64c88173d0 (patch) | |
tree | f2cdb1e1ccc4b11c0b25afbd496bd9b4db5d59fb | |
parent | 39d7e330e64c2132828a040497a5b7326202b5b9 (diff) |
Add a MoveConst instruction to the interpreter
This simplifies and speeds up loading of constants
Change-Id: I05b4f7a34abd4ed6416fa800a31debbb28b37104
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r-- | src/qml/compiler/qv4instr_moth_p.h | 7 | ||||
-rw-r--r-- | src/qml/compiler/qv4isel_moth.cpp | 42 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 4 |
3 files changed, 39 insertions, 14 deletions
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index bd8fc2301d..a691f37b52 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -56,6 +56,7 @@ QT_BEGIN_NAMESPACE F(LoadRegExp, loadRegExp) \ F(LoadClosure, loadClosure) \ F(Move, move) \ + F(MoveConst, moveConst) \ F(SwapTemps, swapTemps) \ F(LoadName, loadName) \ F(GetGlobalLookup, getGlobalLookup) \ @@ -252,6 +253,11 @@ union Instr Param source; Param result; }; + struct instr_moveConst { + MOTH_INSTR_HEADER + QV4::ReturnedValue source; + Param result; + }; struct instr_swapTemps { MOTH_INSTR_HEADER Param left; @@ -710,6 +716,7 @@ union Instr instr_loadRuntimeString loadRuntimeString; instr_loadRegExp loadRegExp; instr_move move; + instr_moveConst moveConst; instr_swapTemps swapTemps; instr_loadClosure loadClosure; instr_loadName loadName; diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp index fd7e998ac4..b34f5891b3 100644 --- a/src/qml/compiler/qv4isel_moth.cpp +++ b/src/qml/compiler/qv4isel_moth.cpp @@ -442,8 +442,8 @@ void InstructionSelection::loadConst(V4IR::Const *sourceConst, V4IR::Temp *targe { assert(sourceConst); - Instruction::Move move; - move.source = getParam(sourceConst); + Instruction::MoveConst move; + move.source = convertToValue(sourceConst).asReturnedValue(); move.result = getResultParam(targetTemp); addInstruction(move); } @@ -645,7 +645,8 @@ void InstructionSelection::unop(V4IR::AluOp oper, V4IR::Temp *sourceTemp, V4IR:: Instruction::Move move; move.source = getParam(sourceTemp); move.result = getResultParam(targetTemp); - addInstruction(move); + if (move.source != move.result) + addInstruction(move); return; } Instruction::UPlus uplus; @@ -842,10 +843,17 @@ void InstructionSelection::prepareCallArgs(V4IR::ExprList *e, quint32 &argc, qui // We need to move all the temps into the function arg array assert(argLocation >= 0); while (e) { - Instruction::Move move; - move.source = getParam(e->expr); - move.result = Param::createTemp(argLocation); - addInstruction(move); + if (V4IR::Const *c = e->expr->asConst()) { + Instruction::MoveConst move; + move.source = convertToValue(c).asReturnedValue(); + move.result = Param::createTemp(argLocation); + addInstruction(move); + } else { + Instruction::Move move; + move.source = getParam(e->expr); + move.result = Param::createTemp(argLocation); + addInstruction(move); + } ++argLocation; ++argc; e = e->next; @@ -991,9 +999,8 @@ void InstructionSelection::callBuiltinDeleteName(const QString &name, V4IR::Temp void InstructionSelection::callBuiltinDeleteValue(V4IR::Temp *result) { - Instruction::Move move; - int idx = jsUnitGenerator()->registerConstant(QV4::Encode(false)); - move.source = Param::createConstant(idx); + Instruction::MoveConst move; + move.source = QV4::Encode(false); move.result = getResultParam(result); addInstruction(move); } @@ -1114,10 +1121,17 @@ void InstructionSelection::callBuiltinDefineObjectLiteral(V4IR::Temp *result, V4 bool isData = it->expr->asConst()->value; it = it->next; - Instruction::Move move; - move.source = getParam(it->expr); - move.result = Param::createTemp(argLocation); - addInstruction(move); + if (V4IR::Const *c = it->expr->asConst()) { + Instruction::MoveConst move; + move.source = convertToValue(c).asReturnedValue(); + move.result = Param::createTemp(argLocation); + addInstruction(move); + } else { + Instruction::Move move; + move.source = getParam(it->expr); + move.result = Param::createTemp(argLocation); + addInstruction(move); + } ++argLocation; if (!isData) { diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 5f079a7d05..260f7c9958 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -236,6 +236,10 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code, VALUE(instr.result) = VALUE(instr.source); MOTH_END_INSTR(Move) + MOTH_BEGIN_INSTR(MoveConst) + VALUE(instr.result) = instr.source; + MOTH_END_INSTR(MoveConst) + MOTH_BEGIN_INSTR(SwapTemps) qSwap(VALUE(instr.left), VALUE(instr.right)); MOTH_END_INSTR(MoveTemp) |