Merge "Revert "Revert "Fix ArtMethod::GetInvokeType for static methods on interfaces."""
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index 150d6b0..ae3c4b0 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -785,22 +785,6 @@
RemoveInstruction(initial);
}
-void HBasicBlock::MoveInstructionBefore(HInstruction* insn, HInstruction* cursor) {
- DCHECK(!cursor->IsPhi());
- DCHECK(!insn->IsPhi());
- DCHECK(!insn->IsControlFlow());
- DCHECK(insn->CanBeMoved());
- DCHECK(!insn->HasSideEffects());
-
- HBasicBlock* from_block = insn->GetBlock();
- HBasicBlock* to_block = cursor->GetBlock();
- DCHECK(from_block != to_block);
-
- from_block->RemoveInstruction(insn, /* ensure_safety */ false);
- insn->SetBlock(to_block);
- to_block->instructions_.InsertInstructionBefore(insn, cursor);
-}
-
static void Add(HInstructionList* instruction_list,
HBasicBlock* block,
HInstruction* instruction) {
@@ -1352,6 +1336,11 @@
}
void HInstruction::MoveBefore(HInstruction* cursor) {
+ DCHECK(!IsPhi());
+ DCHECK(!IsControlFlow());
+ DCHECK(CanBeMoved());
+ DCHECK(!cursor->IsPhi());
+
next_->previous_ = previous_;
if (previous_ != nullptr) {
previous_->next_ = next_;
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index da84afb..711a6c1 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -1049,7 +1049,6 @@
// Replace instruction `initial` with `replacement` within this block.
void ReplaceAndRemoveInstructionWith(HInstruction* initial,
HInstruction* replacement);
- void MoveInstructionBefore(HInstruction* insn, HInstruction* cursor);
void AddPhi(HPhi* phi);
void InsertPhiAfter(HPhi* instruction, HPhi* cursor);
// RemoveInstruction and RemovePhi delete a given instruction from the respective
diff --git a/compiler/optimizing/nodes_arm.h b/compiler/optimizing/nodes_arm.h
index 371e8ef..d9f9740e 100644
--- a/compiler/optimizing/nodes_arm.h
+++ b/compiler/optimizing/nodes_arm.h
@@ -26,6 +26,8 @@
dex_file_(&dex_file),
element_offset_(static_cast<size_t>(-1)) { }
+ bool CanBeMoved() const OVERRIDE { return true; }
+
void UpdateElementOffset(size_t element_offset) {
// Use the lowest offset from the requested elements so that all offsets from
// this base are non-negative because our assemblers emit negative-offset loads
diff --git a/compiler/optimizing/nodes_x86.h b/compiler/optimizing/nodes_x86.h
index c3696b5..fa47976 100644
--- a/compiler/optimizing/nodes_x86.h
+++ b/compiler/optimizing/nodes_x86.h
@@ -26,6 +26,8 @@
HX86ComputeBaseMethodAddress()
: HExpression(Primitive::kPrimInt, SideEffects::None(), kNoDexPc) {}
+ bool CanBeMoved() const OVERRIDE { return true; }
+
DECLARE_INSTRUCTION(X86ComputeBaseMethodAddress);
private:
diff --git a/compiler/optimizing/select_generator.cc b/compiler/optimizing/select_generator.cc
index e52476e..e409035 100644
--- a/compiler/optimizing/select_generator.cc
+++ b/compiler/optimizing/select_generator.cc
@@ -96,10 +96,10 @@
// TODO(dbrazdil): This puts an instruction between If and its condition.
// Implement moving of conditions to first users if possible.
if (!true_block->IsSingleGoto()) {
- true_block->MoveInstructionBefore(true_block->GetFirstInstruction(), if_instruction);
+ true_block->GetFirstInstruction()->MoveBefore(if_instruction);
}
if (!false_block->IsSingleGoto()) {
- false_block->MoveInstructionBefore(false_block->GetFirstInstruction(), if_instruction);
+ false_block->GetFirstInstruction()->MoveBefore(if_instruction);
}
DCHECK(true_block->IsSingleGoto());
DCHECK(false_block->IsSingleGoto());