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 /src/qml/compiler/qv4isel_moth.cpp | |
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>
Diffstat (limited to 'src/qml/compiler/qv4isel_moth.cpp')
-rw-r--r-- | src/qml/compiler/qv4isel_moth.cpp | 42 |
1 files changed, 28 insertions, 14 deletions
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) { |