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. |
288 locs->set_in(1, locs->in(0).IsConstant() | |
289 ? Location::RequiresRegister() | |
290 : Location::RegisterOrConstant(right())); | |
288 locs->set_out(Location::RequiresRegister()); | 291 locs->set_out(Location::RequiresRegister()); |
289 return locs; | 292 return locs; |
290 } | 293 } |
291 if (is_checked_strict_equal) { | 294 if (is_checked_strict_equal) { |
292 const intptr_t kNumTemps = 1; | 295 const intptr_t kNumTemps = 1; |
293 LocationSummary* locs = | 296 LocationSummary* locs = |
294 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 297 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
295 locs->set_in(0, Location::RequiresRegister()); | 298 locs->set_in(0, Location::RequiresRegister()); |
296 locs->set_in(1, Location::RequiresRegister()); | 299 locs->set_in(1, Location::RequiresRegister()); |
297 locs->set_temp(0, Location::RequiresRegister()); | 300 locs->set_temp(0, Location::RequiresRegister()); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
601 __ Bind(&done); | 604 __ Bind(&done); |
602 } | 605 } |
603 | 606 |
604 | 607 |
605 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, | 608 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, |
606 const LocationSummary& locs, | 609 const LocationSummary& locs, |
607 Token::Kind kind, | 610 Token::Kind kind, |
608 BranchInstr* branch) { | 611 BranchInstr* branch) { |
609 Location left = locs.in(0); | 612 Location left = locs.in(0); |
610 Location right = locs.in(1); | 613 Location right = locs.in(1); |
614 ASSERT(!left.IsConstant() || !right.IsConstant()); | |
611 | 615 |
612 Condition true_condition = TokenKindToSmiCondition(kind); | 616 Condition true_condition = TokenKindToSmiCondition(kind); |
613 | 617 |
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()) { | 618 if (left.IsConstant()) { |
642 __ CompareObject(right.reg(), left.constant()); | 619 __ CompareObject(right.reg(), left.constant()); |
643 true_condition = FlowGraphCompiler::FlipCondition(true_condition); | 620 true_condition = FlowGraphCompiler::FlipCondition(true_condition); |
644 } else if (right.IsConstant()) { | 621 } else if (right.IsConstant()) { |
645 __ CompareObject(left.reg(), right.constant()); | 622 __ CompareObject(left.reg(), right.constant()); |
646 } else { | 623 } else { |
647 __ cmpl(left.reg(), right.reg()); | 624 __ cmpl(left.reg(), right.reg()); |
648 } | 625 } |
649 | 626 |
650 if (branch != NULL) { | 627 if (branch != NULL) { |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
912 LocationSummary* summary = | 889 LocationSummary* summary = |
913 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 890 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
914 summary->set_in(0, Location::RequiresXmmRegister()); | 891 summary->set_in(0, Location::RequiresXmmRegister()); |
915 summary->set_in(1, Location::RequiresXmmRegister()); | 892 summary->set_in(1, Location::RequiresXmmRegister()); |
916 summary->set_out(Location::RequiresRegister()); | 893 summary->set_out(Location::RequiresRegister()); |
917 return summary; | 894 return summary; |
918 } else if (operands_class_id() == kSmiCid) { | 895 } else if (operands_class_id() == kSmiCid) { |
919 LocationSummary* summary = | 896 LocationSummary* summary = |
920 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 897 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
921 summary->set_in(0, Location::RegisterOrConstant(left())); | 898 summary->set_in(0, Location::RegisterOrConstant(left())); |
922 summary->set_in(1, Location::RegisterOrConstant(right())); | 899 // Only one input can be a constant operand. |
srdjan
2012/11/12 20:48:18
Why don't you allow both to be constant? You expec
Florian Schneider
2012/11/12 22:43:45
Done.
| |
900 summary->set_in(1, summary->in(0).IsConstant() | |
901 ? Location::RequiresRegister() | |
902 : Location::RegisterOrConstant(right())); | |
923 summary->set_out(Location::RequiresRegister()); | 903 summary->set_out(Location::RequiresRegister()); |
924 return summary; | 904 return summary; |
925 } | 905 } |
926 LocationSummary* locs = | 906 LocationSummary* locs = |
927 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 907 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
928 // Pick arbitrary fixed input registers because this is a call. | 908 // Pick arbitrary fixed input registers because this is a call. |
929 locs->set_in(0, Location::RegisterLocation(EAX)); | 909 locs->set_in(0, Location::RegisterLocation(EAX)); |
930 locs->set_in(1, Location::RegisterLocation(ECX)); | 910 locs->set_in(1, Location::RegisterLocation(ECX)); |
931 locs->set_out(Location::RegisterLocation(EAX)); | 911 locs->set_out(Location::RegisterLocation(EAX)); |
932 return locs; | 912 return locs; |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1710 summary->set_temp(0, Location::RegisterLocation(EBX)); | 1690 summary->set_temp(0, Location::RegisterLocation(EBX)); |
1711 // Will be used for for sign extension. | 1691 // Will be used for for sign extension. |
1712 summary->set_temp(1, Location::RegisterLocation(EDX)); | 1692 summary->set_temp(1, Location::RegisterLocation(EDX)); |
1713 summary->set_temp(2, Location::RequiresRegister()); | 1693 summary->set_temp(2, Location::RequiresRegister()); |
1714 return summary; | 1694 return summary; |
1715 } else if (op_kind() == Token::kSHR) { | 1695 } else if (op_kind() == Token::kSHR) { |
1716 const intptr_t kNumTemps = 0; | 1696 const intptr_t kNumTemps = 0; |
1717 LocationSummary* summary = | 1697 LocationSummary* summary = |
1718 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 1698 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
1719 summary->set_in(0, Location::RequiresRegister()); | 1699 summary->set_in(0, Location::RequiresRegister()); |
1720 summary->set_in(1, Location::FixedRegisterOrConstant(right(), ECX)); | 1700 summary->set_in(1, Location::FixedRegisterOrSmiConstant(right(), ECX)); |
1721 summary->set_out(Location::SameAsFirstInput()); | 1701 summary->set_out(Location::SameAsFirstInput()); |
1722 return summary; | 1702 return summary; |
1723 } else if (op_kind() == Token::kSHL) { | 1703 } else if (op_kind() == Token::kSHL) { |
1724 const intptr_t kNumTemps = 1; | 1704 const intptr_t kNumTemps = 1; |
1725 LocationSummary* summary = | 1705 LocationSummary* summary = |
1726 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 1706 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
1727 summary->set_in(0, Location::RequiresRegister()); | 1707 summary->set_in(0, Location::RequiresRegister()); |
1728 summary->set_in(1, Location::FixedRegisterOrConstant(right(), ECX)); | 1708 summary->set_in(1, Location::FixedRegisterOrSmiConstant(right(), ECX)); |
1729 summary->set_temp(0, Location::RequiresRegister()); | 1709 summary->set_temp(0, Location::RequiresRegister()); |
1730 summary->set_out(Location::SameAsFirstInput()); | 1710 summary->set_out(Location::SameAsFirstInput()); |
1731 return summary; | 1711 return summary; |
1732 } else { | 1712 } else { |
1733 const intptr_t kNumTemps = 0; | 1713 const intptr_t kNumTemps = 0; |
1734 LocationSummary* summary = | 1714 LocationSummary* summary = |
1735 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 1715 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
1736 summary->set_in(0, Location::RequiresRegister()); | 1716 summary->set_in(0, Location::RequiresRegister()); |
1737 summary->set_in(1, Location::RegisterOrConstant(right())); | 1717 summary->set_in(1, Location::RegisterOrSmiConstant(right())); |
1738 summary->set_out(Location::SameAsFirstInput()); | 1718 summary->set_out(Location::SameAsFirstInput()); |
1739 return summary; | 1719 return summary; |
1740 } | 1720 } |
1741 } | 1721 } |
1742 | 1722 |
1743 | 1723 |
1744 void BinarySmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1724 void BinarySmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
1745 Register left = locs()->in(0).reg(); | 1725 Register left = locs()->in(0).reg(); |
1746 Register result = locs()->out().reg(); | 1726 Register result = locs()->out().reg(); |
1747 ASSERT(left == result); | 1727 ASSERT(left == result); |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2362 __ testl(value, Immediate(kSmiTagMask)); | 2342 __ testl(value, Immediate(kSmiTagMask)); |
2363 __ j(NOT_ZERO, deopt); | 2343 __ j(NOT_ZERO, deopt); |
2364 } | 2344 } |
2365 | 2345 |
2366 | 2346 |
2367 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const { | 2347 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const { |
2368 const intptr_t kNumInputs = 2; | 2348 const intptr_t kNumInputs = 2; |
2369 const intptr_t kNumTemps = 0; | 2349 const intptr_t kNumTemps = 0; |
2370 LocationSummary* locs = | 2350 LocationSummary* locs = |
2371 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 2351 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
2372 locs->set_in(0, Location::RegisterOrConstant(array())); | 2352 locs->set_in(0, Location::RegisterOrSmiConstant(array())); |
2373 locs->set_in(1, Location::RegisterOrConstant(index())); | 2353 locs->set_in(1, Location::RegisterOrSmiConstant(index())); |
2374 return locs; | 2354 return locs; |
2375 } | 2355 } |
2376 | 2356 |
2377 | 2357 |
2378 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2358 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2379 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2359 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
2380 kDeoptCheckArrayBound); | 2360 kDeoptCheckArrayBound); |
2381 if (locs()->in(0).IsConstant() && locs()->in(1).IsConstant()) { | 2361 if (locs()->in(0).IsConstant() && locs()->in(1).IsConstant()) { |
2382 // Unconditionally deoptimize for constant bounds checks because they | 2362 // Unconditionally deoptimize for constant bounds checks because they |
2383 // only occur only when index is out-of-bounds. | 2363 // 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. | 2689 __ pcmpeqq(XMM0, XMM0); // Generate all 1's. |
2710 __ pxor(value, XMM0); | 2690 __ pxor(value, XMM0); |
2711 } | 2691 } |
2712 | 2692 |
2713 | 2693 |
2714 } // namespace dart | 2694 } // namespace dart |
2715 | 2695 |
2716 #undef __ | 2696 #undef __ |
2717 | 2697 |
2718 #endif // defined TARGET_ARCH_X64 | 2698 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |