| 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..beef3555538fccfe5cac5cfce2e42ee2b874eda0 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,15 +576,19 @@ Condition EqualityCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
|
| }
|
|
|
|
|
| -void EqualityCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
| - ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE));
|
| -
|
| +template <intptr_t N,
|
| + typename ThrowsTrait,
|
| + template <typename Impure, typename Pure> class CSETrait>
|
| +void TemplateComparison<N, ThrowsTrait, CSETrait>::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();
|
| + Register result = this->locs()->out(0).reg();
|
| Label done;
|
| __ Bind(&is_false);
|
| __ LoadObject(result, Bool::False());
|
| @@ -592,16 +599,33 @@ void EqualityCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
| }
|
|
|
|
|
| -void EqualityCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler,
|
| - BranchInstr* branch) {
|
| - ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ));
|
| -
|
| +template <intptr_t N,
|
| + typename ThrowsTrait,
|
| + template <typename Impure, typename Pure> class CSETrait>
|
| +void TemplateComparison<N, ThrowsTrait, CSETrait>::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);
|
| + }
|
| }
|
|
|
|
|
| +// Explicit template instantiations.
|
| +template void TemplateComparison<1, NoThrow, Pure>::EmitNativeCode(
|
| + FlowGraphCompiler*);
|
| +template void TemplateComparison<2, NoThrow, Pure>::EmitNativeCode(
|
| + FlowGraphCompiler*);
|
| +template void TemplateComparison<1, NoThrow, Pure>::EmitBranchCode(
|
| + FlowGraphCompiler* compiler,
|
| + BranchInstr* branch);
|
| +template void TemplateComparison<2, NoThrow, Pure>::EmitBranchCode(
|
| + FlowGraphCompiler* compiler,
|
| + BranchInstr* branch);
|
| +
|
| +
|
| LocationSummary* TestSmiInstr::MakeLocationSummary(Zone* zone, bool opt) const {
|
| const intptr_t kNumInputs = 2;
|
| const intptr_t kNumTemps = 0;
|
| @@ -631,20 +655,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 +706,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 +756,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 +3073,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 +3088,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 +3917,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 +6578,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;
|
|
|