Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: runtime/vm/intermediate_language_ia32.cc

Issue 2949513002: Revert "Reduce copying, redundancy & repetition for codegen of comparison instructions" (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language_dbc.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_ia32.cc
diff --git a/runtime/vm/intermediate_language_ia32.cc b/runtime/vm/intermediate_language_ia32.cc
index e71680d574138d6d5f40614f192b936184fdf48d..42da2f0ad77bc63b08030a43302c44652ba146b9 100644
--- a/runtime/vm/intermediate_language_ia32.cc
+++ b/runtime/vm/intermediate_language_ia32.cc
@@ -600,13 +600,13 @@ Condition EqualityCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
}
-void ComparisonInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
+void EqualityCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ));
+
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;
@@ -619,13 +619,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);
}
@@ -658,6 +658,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;
@@ -709,9 +723,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);
}
@@ -765,6 +800,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, Assembler::kNearJump);
+ __ 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);
@@ -3935,6 +3995,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;
@@ -6631,6 +6717,35 @@ 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, Assembler::kNearJump);
+ __ 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);
+}
+
+
// Detect pattern when one value is zero and another is a power of 2.
static bool IsPowerOfTwoKind(intptr_t v1, intptr_t v2) {
return (Utils::IsPowerOfTwo(v1) && (v2 == 0)) ||
@@ -6655,11 +6770,8 @@ void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
__ xorl(EDX, EDX);
// 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_);
« no previous file with comments | « runtime/vm/intermediate_language_dbc.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698