Index: runtime/vm/intermediate_language_x64.cc |
diff --git a/runtime/vm/intermediate_language_x64.cc b/runtime/vm/intermediate_language_x64.cc |
index e9c8f208bd53f20c50df4774d02553c538e7f99b..b947742092ea4131014fc362e4f07c3fb82019ec 100644 |
--- a/runtime/vm/intermediate_language_x64.cc |
+++ b/runtime/vm/intermediate_language_x64.cc |
@@ -165,8 +165,11 @@ void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
__ xorq(RDX, RDX); |
// Emit comparison code. This must not overwrite the result register. |
+ // IfThenElseInstr::Supports() should prevent EmitComparisonCode from using |
+ // the labels or returning an invalid condition. |
BranchLabels labels = {NULL, NULL, NULL}; |
Condition true_condition = comparison()->EmitComparisonCode(compiler, labels); |
+ ASSERT(true_condition != INVALID_CONDITION); |
const bool is_power_of_two_kind = IsPowerOfTwoKind(if_true_, if_false_); |
@@ -573,13 +576,13 @@ Condition EqualityCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
} |
-void EqualityCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
- ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); |
- |
+void ComparisonInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
Label is_true, is_false; |
BranchLabels labels = {&is_true, &is_false, &is_false}; |
Condition true_condition = EmitComparisonCode(compiler, labels); |
- EmitBranchOnCondition(compiler, true_condition, labels); |
+ if (true_condition != INVALID_CONDITION) { |
+ EmitBranchOnCondition(compiler, true_condition, labels); |
+ } |
Register result = locs()->out(0).reg(); |
Label done; |
@@ -592,13 +595,13 @@ void EqualityCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
} |
-void EqualityCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
- BranchInstr* branch) { |
- ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ)); |
- |
+void ComparisonInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
+ BranchInstr* branch) { |
BranchLabels labels = compiler->CreateBranchLabels(branch); |
Condition true_condition = EmitComparisonCode(compiler, labels); |
- EmitBranchOnCondition(compiler, true_condition, labels); |
+ if (true_condition != INVALID_CONDITION) { |
+ EmitBranchOnCondition(compiler, true_condition, labels); |
+ } |
} |
@@ -631,20 +634,6 @@ Condition TestSmiInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
} |
-void TestSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
- // Never emitted outside of the BranchInstr. |
- UNREACHABLE(); |
-} |
- |
- |
-void TestSmiInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
- BranchInstr* branch) { |
- BranchLabels labels = compiler->CreateBranchLabels(branch); |
- Condition true_condition = EmitComparisonCode(compiler, labels); |
- EmitBranchOnCondition(compiler, true_condition, labels); |
-} |
- |
- |
LocationSummary* TestCidsInstr::MakeLocationSummary(Zone* zone, |
bool opt) const { |
const intptr_t kNumInputs = 1; |
@@ -696,30 +685,9 @@ Condition TestCidsInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
} else { |
__ jmp(deopt); |
} |
- // Dummy result as the last instruction is a jump, any conditional |
- // branch using the result will therefore be skipped. |
- return ZERO; |
-} |
- |
- |
-void TestCidsInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
- BranchInstr* branch) { |
- BranchLabels labels = compiler->CreateBranchLabels(branch); |
- EmitComparisonCode(compiler, labels); |
-} |
- |
- |
-void TestCidsInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
- Register result_reg = locs()->out(0).reg(); |
- Label is_true, is_false, done; |
- BranchLabels labels = {&is_true, &is_false, &is_false}; |
- EmitComparisonCode(compiler, labels); |
- __ Bind(&is_false); |
- __ LoadObject(result_reg, Bool::False()); |
- __ jmp(&done, Assembler::kNearJump); |
- __ Bind(&is_true); |
- __ LoadObject(result_reg, Bool::True()); |
- __ Bind(&done); |
+ // Dummy result as this method already did the jump, there's no need |
+ // for the caller to branch on a condition. |
+ return INVALID_CONDITION; |
} |
@@ -767,31 +735,6 @@ Condition RelationalOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
} |
-void RelationalOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
- Label is_true, is_false; |
- BranchLabels labels = {&is_true, &is_false, &is_false}; |
- Condition true_condition = EmitComparisonCode(compiler, labels); |
- EmitBranchOnCondition(compiler, true_condition, labels); |
- |
- Register result = locs()->out(0).reg(); |
- Label done; |
- __ Bind(&is_false); |
- __ LoadObject(result, Bool::False()); |
- __ jmp(&done); |
- __ Bind(&is_true); |
- __ LoadObject(result, Bool::True()); |
- __ Bind(&done); |
-} |
- |
- |
-void RelationalOpInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
- BranchInstr* branch) { |
- BranchLabels labels = compiler->CreateBranchLabels(branch); |
- Condition true_condition = EmitComparisonCode(compiler, labels); |
- EmitBranchOnCondition(compiler, true_condition, labels); |
-} |
- |
- |
LocationSummary* NativeCallInstr::MakeLocationSummary(Zone* zone, |
bool opt) const { |
return MakeCallSummary(zone); |
@@ -3109,6 +3052,7 @@ void CheckedSmiComparisonInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
compiler->AddSlowPathCode(slow_path); |
EMIT_SMI_CHECK; |
Condition true_condition = EmitComparisonCode(compiler, labels); |
+ ASSERT(true_condition != INVALID_CONDITION); |
EmitBranchOnCondition(compiler, true_condition, labels); |
__ Bind(slow_path->exit_label()); |
} |
@@ -3123,6 +3067,7 @@ void CheckedSmiComparisonInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
compiler->AddSlowPathCode(slow_path); |
EMIT_SMI_CHECK; |
Condition true_condition = EmitComparisonCode(compiler, labels); |
+ ASSERT(true_condition != INVALID_CONDITION); |
EmitBranchOnCondition(compiler, true_condition, labels); |
Register result = locs()->out(0).reg(); |
__ Bind(&false_label); |
@@ -3951,32 +3896,6 @@ Condition DoubleTestOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
} |
-void DoubleTestOpInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
- BranchInstr* branch) { |
- ASSERT(compiler->is_optimizing()); |
- BranchLabels labels = compiler->CreateBranchLabels(branch); |
- Condition true_condition = EmitComparisonCode(compiler, labels); |
- EmitBranchOnCondition(compiler, true_condition, labels); |
-} |
- |
- |
-void DoubleTestOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
- Label is_true, is_false; |
- BranchLabels labels = {&is_true, &is_false, &is_false}; |
- Condition true_condition = EmitComparisonCode(compiler, labels); |
- EmitBranchOnCondition(compiler, true_condition, labels); |
- |
- Register result = locs()->out(0).reg(); |
- Label done; |
- __ Bind(&is_false); |
- __ LoadObject(result, Bool::False()); |
- __ jmp(&done); |
- __ Bind(&is_true); |
- __ LoadObject(result, Bool::True()); |
- __ Bind(&done); |
-} |
- |
- |
LocationSummary* BinaryFloat32x4OpInstr::MakeLocationSummary(Zone* zone, |
bool opt) const { |
const intptr_t kNumInputs = 2; |
@@ -6638,36 +6557,6 @@ Condition StrictCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
} |
-void StrictCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
- ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT); |
- |
- Label is_true, is_false; |
- BranchLabels labels = {&is_true, &is_false, &is_false}; |
- |
- Condition true_condition = EmitComparisonCode(compiler, labels); |
- EmitBranchOnCondition(compiler, true_condition, labels); |
- |
- Register result = locs()->out(0).reg(); |
- Label done; |
- __ Bind(&is_false); |
- __ LoadObject(result, Bool::False()); |
- __ jmp(&done); |
- __ Bind(&is_true); |
- __ LoadObject(result, Bool::True()); |
- __ Bind(&done); |
-} |
- |
- |
-void StrictCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
- BranchInstr* branch) { |
- ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT); |
- |
- BranchLabels labels = compiler->CreateBranchLabels(branch); |
- Condition true_condition = EmitComparisonCode(compiler, labels); |
- EmitBranchOnCondition(compiler, true_condition, labels); |
-} |
- |
- |
LocationSummary* ClosureCallInstr::MakeLocationSummary(Zone* zone, |
bool opt) const { |
const intptr_t kNumInputs = 1; |