Index: runtime/vm/intermediate_language_x64.cc |
diff --git a/runtime/vm/intermediate_language_x64.cc b/runtime/vm/intermediate_language_x64.cc |
index b947742092ea4131014fc362e4f07c3fb82019ec..e9c8f208bd53f20c50df4774d02553c538e7f99b 100644 |
--- a/runtime/vm/intermediate_language_x64.cc |
+++ b/runtime/vm/intermediate_language_x64.cc |
@@ -165,11 +165,8 @@ 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_); |
@@ -576,13 +573,13 @@ Condition EqualityCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
} |
-void ComparisonInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
+void EqualityCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
+ ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); |
+ |
Label is_true, is_false; |
BranchLabels labels = {&is_true, &is_false, &is_false}; |
Condition true_condition = EmitComparisonCode(compiler, labels); |
- if (true_condition != INVALID_CONDITION) { |
- EmitBranchOnCondition(compiler, true_condition, labels); |
- } |
+ EmitBranchOnCondition(compiler, true_condition, labels); |
Register result = locs()->out(0).reg(); |
Label done; |
@@ -595,13 +592,13 @@ void ComparisonInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
} |
-void ComparisonInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
- BranchInstr* branch) { |
+void EqualityCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
+ BranchInstr* branch) { |
+ ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ)); |
+ |
BranchLabels labels = compiler->CreateBranchLabels(branch); |
Condition true_condition = EmitComparisonCode(compiler, labels); |
- if (true_condition != INVALID_CONDITION) { |
- EmitBranchOnCondition(compiler, true_condition, labels); |
- } |
+ EmitBranchOnCondition(compiler, true_condition, labels); |
} |
@@ -634,6 +631,20 @@ 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; |
@@ -685,9 +696,30 @@ Condition TestCidsInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
} else { |
__ jmp(deopt); |
} |
- // Dummy result as this method already did the jump, there's no need |
- // for the caller to branch on a condition. |
- return INVALID_CONDITION; |
+ // 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); |
} |
@@ -735,6 +767,31 @@ 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); |
@@ -3052,7 +3109,6 @@ 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()); |
} |
@@ -3067,7 +3123,6 @@ 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); |
@@ -3896,6 +3951,32 @@ 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; |
@@ -6557,6 +6638,36 @@ 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; |