OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "lib/error.h" | 10 #include "lib/error.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 locs->set_in(0, Location::RequiresXmmRegister()); | 277 locs->set_in(0, Location::RequiresXmmRegister()); |
278 locs->set_in(1, Location::RequiresXmmRegister()); | 278 locs->set_in(1, Location::RequiresXmmRegister()); |
279 locs->set_out(Location::RequiresRegister()); | 279 locs->set_out(Location::RequiresRegister()); |
280 return locs; | 280 return locs; |
281 } | 281 } |
282 if (receiver_class_id() == kSmiCid) { | 282 if (receiver_class_id() == kSmiCid) { |
283 const intptr_t kNumTemps = 0; | 283 const intptr_t kNumTemps = 0; |
284 LocationSummary* locs = | 284 LocationSummary* locs = |
285 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 285 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
286 locs->set_in(0, Location::RegisterOrConstant(left())); | 286 locs->set_in(0, Location::RegisterOrConstant(left())); |
287 locs->set_in(1, Location::RegisterOrConstant(right())); | 287 // Only one input can be a constant operand. The case of two constant |
| 288 // operands should be handled by constant propagation. |
| 289 locs->set_in(1, locs->in(0).IsConstant() |
| 290 ? Location::RequiresRegister() |
| 291 : Location::RegisterOrConstant(right())); |
288 locs->set_out(Location::RequiresRegister()); | 292 locs->set_out(Location::RequiresRegister()); |
289 return locs; | 293 return locs; |
290 } | 294 } |
291 if (is_checked_strict_equal) { | 295 if (is_checked_strict_equal) { |
292 const intptr_t kNumTemps = 1; | 296 const intptr_t kNumTemps = 1; |
293 LocationSummary* locs = | 297 LocationSummary* locs = |
294 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 298 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
295 locs->set_in(0, Location::RequiresRegister()); | 299 locs->set_in(0, Location::RequiresRegister()); |
296 locs->set_in(1, Location::RequiresRegister()); | 300 locs->set_in(1, Location::RequiresRegister()); |
297 locs->set_temp(0, Location::RequiresRegister()); | 301 locs->set_temp(0, Location::RequiresRegister()); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 __ Bind(&done); | 605 __ Bind(&done); |
602 } | 606 } |
603 | 607 |
604 | 608 |
605 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, | 609 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, |
606 const LocationSummary& locs, | 610 const LocationSummary& locs, |
607 Token::Kind kind, | 611 Token::Kind kind, |
608 BranchInstr* branch) { | 612 BranchInstr* branch) { |
609 Location left = locs.in(0); | 613 Location left = locs.in(0); |
610 Location right = locs.in(1); | 614 Location right = locs.in(1); |
| 615 ASSERT(!left.IsConstant() || !right.IsConstant()); |
611 | 616 |
612 Condition true_condition = TokenKindToSmiCondition(kind); | 617 Condition true_condition = TokenKindToSmiCondition(kind); |
613 | 618 |
614 if (left.IsConstant() && right.IsConstant()) { | |
615 bool result = false; | |
616 // One of them could be NULL (for equality only). | |
617 if (left.constant().IsNull() || right.constant().IsNull()) { | |
618 ASSERT((kind == Token::kEQ) || (kind == Token::kNE)); | |
619 result = left.constant().IsNull() && right.constant().IsNull(); | |
620 if (kind == Token::kNE) { | |
621 result = !result; | |
622 } | |
623 } else { | |
624 // TODO(vegorov): should be eliminated earlier by constant propagation. | |
625 result = FlowGraphCompiler::EvaluateCondition( | |
626 true_condition, | |
627 Smi::Cast(left.constant()).Value(), | |
628 Smi::Cast(right.constant()).Value()); | |
629 } | |
630 | |
631 if (branch != NULL) { | |
632 branch->EmitBranchOnValue(compiler, result); | |
633 } else { | |
634 __ LoadObject(locs.out().reg(), result ? compiler->bool_true() | |
635 : compiler->bool_false()); | |
636 } | |
637 | |
638 return; | |
639 } | |
640 | |
641 if (left.IsConstant()) { | 619 if (left.IsConstant()) { |
642 __ CompareObject(right.reg(), left.constant()); | 620 __ CompareObject(right.reg(), left.constant()); |
643 true_condition = FlowGraphCompiler::FlipCondition(true_condition); | 621 true_condition = FlowGraphCompiler::FlipCondition(true_condition); |
644 } else if (right.IsConstant()) { | 622 } else if (right.IsConstant()) { |
645 __ CompareObject(left.reg(), right.constant()); | 623 __ CompareObject(left.reg(), right.constant()); |
646 } else { | 624 } else { |
647 __ cmpl(left.reg(), right.reg()); | 625 __ cmpl(left.reg(), right.reg()); |
648 } | 626 } |
649 | 627 |
650 if (branch != NULL) { | 628 if (branch != NULL) { |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 LocationSummary* summary = | 890 LocationSummary* summary = |
913 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 891 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
914 summary->set_in(0, Location::RequiresXmmRegister()); | 892 summary->set_in(0, Location::RequiresXmmRegister()); |
915 summary->set_in(1, Location::RequiresXmmRegister()); | 893 summary->set_in(1, Location::RequiresXmmRegister()); |
916 summary->set_out(Location::RequiresRegister()); | 894 summary->set_out(Location::RequiresRegister()); |
917 return summary; | 895 return summary; |
918 } else if (operands_class_id() == kSmiCid) { | 896 } else if (operands_class_id() == kSmiCid) { |
919 LocationSummary* summary = | 897 LocationSummary* summary = |
920 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 898 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
921 summary->set_in(0, Location::RegisterOrConstant(left())); | 899 summary->set_in(0, Location::RegisterOrConstant(left())); |
922 summary->set_in(1, Location::RegisterOrConstant(right())); | 900 // Only one input can be a constant operand. The case of two constant |
| 901 // operands should be handled by constant propagation. |
| 902 summary->set_in(1, summary->in(0).IsConstant() |
| 903 ? Location::RequiresRegister() |
| 904 : Location::RegisterOrConstant(right())); |
923 summary->set_out(Location::RequiresRegister()); | 905 summary->set_out(Location::RequiresRegister()); |
924 return summary; | 906 return summary; |
925 } | 907 } |
926 LocationSummary* locs = | 908 LocationSummary* locs = |
927 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 909 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
928 // Pick arbitrary fixed input registers because this is a call. | 910 // Pick arbitrary fixed input registers because this is a call. |
929 locs->set_in(0, Location::RegisterLocation(EAX)); | 911 locs->set_in(0, Location::RegisterLocation(EAX)); |
930 locs->set_in(1, Location::RegisterLocation(ECX)); | 912 locs->set_in(1, Location::RegisterLocation(ECX)); |
931 locs->set_out(Location::RegisterLocation(EAX)); | 913 locs->set_out(Location::RegisterLocation(EAX)); |
932 return locs; | 914 return locs; |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1710 summary->set_temp(0, Location::RegisterLocation(EBX)); | 1692 summary->set_temp(0, Location::RegisterLocation(EBX)); |
1711 // Will be used for for sign extension. | 1693 // Will be used for for sign extension. |
1712 summary->set_temp(1, Location::RegisterLocation(EDX)); | 1694 summary->set_temp(1, Location::RegisterLocation(EDX)); |
1713 summary->set_temp(2, Location::RequiresRegister()); | 1695 summary->set_temp(2, Location::RequiresRegister()); |
1714 return summary; | 1696 return summary; |
1715 } else if (op_kind() == Token::kSHR) { | 1697 } else if (op_kind() == Token::kSHR) { |
1716 const intptr_t kNumTemps = 0; | 1698 const intptr_t kNumTemps = 0; |
1717 LocationSummary* summary = | 1699 LocationSummary* summary = |
1718 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 1700 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
1719 summary->set_in(0, Location::RequiresRegister()); | 1701 summary->set_in(0, Location::RequiresRegister()); |
1720 summary->set_in(1, Location::FixedRegisterOrConstant(right(), ECX)); | 1702 summary->set_in(1, Location::FixedRegisterOrSmiConstant(right(), ECX)); |
1721 summary->set_out(Location::SameAsFirstInput()); | 1703 summary->set_out(Location::SameAsFirstInput()); |
1722 return summary; | 1704 return summary; |
1723 } else if (op_kind() == Token::kSHL) { | 1705 } else if (op_kind() == Token::kSHL) { |
1724 const intptr_t kNumTemps = 1; | 1706 const intptr_t kNumTemps = 1; |
1725 LocationSummary* summary = | 1707 LocationSummary* summary = |
1726 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 1708 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
1727 summary->set_in(0, Location::RequiresRegister()); | 1709 summary->set_in(0, Location::RequiresRegister()); |
1728 summary->set_in(1, Location::FixedRegisterOrConstant(right(), ECX)); | 1710 summary->set_in(1, Location::FixedRegisterOrSmiConstant(right(), ECX)); |
1729 summary->set_temp(0, Location::RequiresRegister()); | 1711 summary->set_temp(0, Location::RequiresRegister()); |
1730 summary->set_out(Location::SameAsFirstInput()); | 1712 summary->set_out(Location::SameAsFirstInput()); |
1731 return summary; | 1713 return summary; |
1732 } else { | 1714 } else { |
1733 const intptr_t kNumTemps = 0; | 1715 const intptr_t kNumTemps = 0; |
1734 LocationSummary* summary = | 1716 LocationSummary* summary = |
1735 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 1717 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
1736 summary->set_in(0, Location::RequiresRegister()); | 1718 summary->set_in(0, Location::RequiresRegister()); |
1737 summary->set_in(1, Location::RegisterOrConstant(right())); | 1719 summary->set_in(1, Location::RegisterOrSmiConstant(right())); |
1738 summary->set_out(Location::SameAsFirstInput()); | 1720 summary->set_out(Location::SameAsFirstInput()); |
1739 return summary; | 1721 return summary; |
1740 } | 1722 } |
1741 } | 1723 } |
1742 | 1724 |
1743 | 1725 |
1744 void BinarySmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1726 void BinarySmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
1745 Register left = locs()->in(0).reg(); | 1727 Register left = locs()->in(0).reg(); |
1746 Register result = locs()->out().reg(); | 1728 Register result = locs()->out().reg(); |
1747 ASSERT(left == result); | 1729 ASSERT(left == result); |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2362 __ testl(value, Immediate(kSmiTagMask)); | 2344 __ testl(value, Immediate(kSmiTagMask)); |
2363 __ j(NOT_ZERO, deopt); | 2345 __ j(NOT_ZERO, deopt); |
2364 } | 2346 } |
2365 | 2347 |
2366 | 2348 |
2367 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const { | 2349 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const { |
2368 const intptr_t kNumInputs = 2; | 2350 const intptr_t kNumInputs = 2; |
2369 const intptr_t kNumTemps = 0; | 2351 const intptr_t kNumTemps = 0; |
2370 LocationSummary* locs = | 2352 LocationSummary* locs = |
2371 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 2353 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
2372 locs->set_in(0, Location::RegisterOrConstant(array())); | 2354 locs->set_in(0, Location::RegisterOrSmiConstant(array())); |
2373 locs->set_in(1, Location::RegisterOrConstant(index())); | 2355 locs->set_in(1, Location::RegisterOrSmiConstant(index())); |
2374 return locs; | 2356 return locs; |
2375 } | 2357 } |
2376 | 2358 |
2377 | 2359 |
2378 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2360 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2379 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2361 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
2380 kDeoptCheckArrayBound); | 2362 kDeoptCheckArrayBound); |
2381 if (locs()->in(0).IsConstant() && locs()->in(1).IsConstant()) { | 2363 if (locs()->in(0).IsConstant() && locs()->in(1).IsConstant()) { |
2382 // Unconditionally deoptimize for constant bounds checks because they | 2364 // Unconditionally deoptimize for constant bounds checks because they |
2383 // only occur only when index is out-of-bounds. | 2365 // only occur only when index is out-of-bounds. |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2709 __ pcmpeqq(XMM0, XMM0); // Generate all 1's. | 2691 __ pcmpeqq(XMM0, XMM0); // Generate all 1's. |
2710 __ pxor(value, XMM0); | 2692 __ pxor(value, XMM0); |
2711 } | 2693 } |
2712 | 2694 |
2713 | 2695 |
2714 } // namespace dart | 2696 } // namespace dart |
2715 | 2697 |
2716 #undef __ | 2698 #undef __ |
2717 | 2699 |
2718 #endif // defined TARGET_ARCH_X64 | 2700 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |