| 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 UNREACHABLE(); | 242 UNREACHABLE(); |
| 243 return OVERFLOW; | 243 return OVERFLOW; |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 | 246 |
| 247 | 247 |
| 248 LocationSummary* EqualityCompareComp::MakeLocationSummary() const { | 248 LocationSummary* EqualityCompareComp::MakeLocationSummary() const { |
| 249 const intptr_t kNumInputs = 2; | 249 const intptr_t kNumInputs = 2; |
| 250 const bool is_checked_strict_equal = | 250 const bool is_checked_strict_equal = |
| 251 HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid); | 251 HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid); |
| 252 if ((receiver_class_id() == kSmiCid) || | 252 if ((receiver_class_id() == kSmiCid) || is_checked_strict_equal) { |
| 253 (receiver_class_id() == kDoubleCid) || | |
| 254 is_checked_strict_equal) { | |
| 255 const intptr_t kNumTemps = 1; | 253 const intptr_t kNumTemps = 1; |
| 256 LocationSummary* locs = | 254 LocationSummary* locs = |
| 257 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 255 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 258 locs->set_in(0, Location::RequiresRegister()); | 256 locs->set_in(0, Location::RequiresRegister()); |
| 259 locs->set_in(1, Location::RequiresRegister()); | 257 locs->set_in(1, Location::RequiresRegister()); |
| 260 locs->set_temp(0, Location::RequiresRegister()); | 258 locs->set_temp(0, Location::RequiresRegister()); |
| 261 locs->set_out(Location::RequiresRegister()); | 259 locs->set_out(Location::RequiresRegister()); |
| 262 return locs; | 260 return locs; |
| 263 } | 261 } |
| 262 if (receiver_class_id() == kDoubleCid) { |
| 263 const intptr_t kNumTemps = 2; |
| 264 LocationSummary* locs = |
| 265 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 266 locs->set_in(0, Location::RequiresRegister()); |
| 267 locs->set_in(1, Location::RequiresRegister()); |
| 268 locs->set_out(Location::RequiresRegister()); |
| 269 locs->set_temp(0, Location::RequiresRegister()); |
| 270 locs->set_temp(1, Location::XmmRegisterLocation(XMM1)); |
| 271 return locs; |
| 272 } |
| 264 if (HasICData() && (ic_data()->NumberOfChecks() > 0)) { | 273 if (HasICData() && (ic_data()->NumberOfChecks() > 0)) { |
| 265 const intptr_t kNumTemps = 1; | 274 const intptr_t kNumTemps = 1; |
| 266 LocationSummary* locs = | 275 LocationSummary* locs = |
| 267 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 276 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| 268 locs->set_in(0, Location::RegisterLocation(RCX)); | 277 locs->set_in(0, Location::RegisterLocation(RCX)); |
| 269 locs->set_in(1, Location::RegisterLocation(RDX)); | 278 locs->set_in(1, Location::RegisterLocation(RDX)); |
| 270 locs->set_temp(0, Location::RegisterLocation(RBX)); | 279 locs->set_temp(0, Location::RegisterLocation(RBX)); |
| 271 locs->set_out(Location::RegisterLocation(RAX)); | 280 locs->set_out(Location::RegisterLocation(RAX)); |
| 272 return locs; | 281 return locs; |
| 273 } | 282 } |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 } | 542 } |
| 534 | 543 |
| 535 | 544 |
| 536 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, | 545 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, |
| 537 const LocationSummary& locs, | 546 const LocationSummary& locs, |
| 538 Token::Kind kind, | 547 Token::Kind kind, |
| 539 BranchInstr* branch, | 548 BranchInstr* branch, |
| 540 intptr_t deopt_id) { | 549 intptr_t deopt_id) { |
| 541 Register left = locs.in(0).reg(); | 550 Register left = locs.in(0).reg(); |
| 542 Register right = locs.in(1).reg(); | 551 Register right = locs.in(1).reg(); |
| 543 const bool left_is_smi = (branch == NULL) ? | |
| 544 false : (branch->computation()->left()->ResultCid() == kSmiCid); | |
| 545 const bool right_is_smi = (branch == NULL) ? | |
| 546 false : (branch->computation()->right()->ResultCid() == kSmiCid); | |
| 547 // TODO(fschneider): Move smi smi checks outside this instruction. | |
| 548 if (!left_is_smi || !right_is_smi) { | |
| 549 Register temp = locs.temp(0).reg(); | |
| 550 Label* deopt = compiler->AddDeoptStub(deopt_id, kDeoptSmiCompareSmi); | |
| 551 __ movq(temp, left); | |
| 552 __ orq(temp, right); | |
| 553 __ testq(temp, Immediate(kSmiTagMask)); | |
| 554 __ j(NOT_ZERO, deopt); | |
| 555 } | |
| 556 | 552 |
| 557 Condition true_condition = TokenKindToSmiCondition(kind); | 553 Condition true_condition = TokenKindToSmiCondition(kind); |
| 558 __ cmpq(left, right); | 554 __ cmpq(left, right); |
| 559 | 555 |
| 560 if (branch != NULL) { | 556 if (branch != NULL) { |
| 561 branch->EmitBranchOnCondition(compiler, true_condition); | 557 branch->EmitBranchOnCondition(compiler, true_condition); |
| 562 } else { | 558 } else { |
| 563 Register result = locs.out().reg(); | 559 Register result = locs.out().reg(); |
| 564 Label done, is_true; | 560 Label done, is_true; |
| 565 __ j(true_condition, &is_true); | 561 __ j(true_condition, &is_true); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 Token::kEQ, // kNE reverse occurs at branch. | 680 Token::kEQ, // kNE reverse occurs at branch. |
| 685 locs()); | 681 locs()); |
| 686 Condition branch_condition = (kind() == Token::kNE) ? NOT_EQUAL : EQUAL; | 682 Condition branch_condition = (kind() == Token::kNE) ? NOT_EQUAL : EQUAL; |
| 687 __ CompareObject(RAX, compiler->bool_true()); | 683 __ CompareObject(RAX, compiler->bool_true()); |
| 688 branch->EmitBranchOnCondition(compiler, branch_condition); | 684 branch->EmitBranchOnCondition(compiler, branch_condition); |
| 689 } | 685 } |
| 690 | 686 |
| 691 | 687 |
| 692 LocationSummary* RelationalOpComp::MakeLocationSummary() const { | 688 LocationSummary* RelationalOpComp::MakeLocationSummary() const { |
| 693 const intptr_t kNumInputs = 2; | 689 const intptr_t kNumInputs = 2; |
| 694 if (operands_class_id() == kSmiCid || operands_class_id() == kDoubleCid) { | 690 if (operands_class_id() == kSmiCid) { |
| 695 const intptr_t kNumTemps = 1; | 691 const intptr_t kNumTemps = 1; |
| 696 LocationSummary* summary = | 692 LocationSummary* summary = |
| 697 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 693 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 698 summary->set_in(0, Location::RequiresRegister()); | 694 summary->set_in(0, Location::RequiresRegister()); |
| 699 summary->set_in(1, Location::RequiresRegister()); | 695 summary->set_in(1, Location::RequiresRegister()); |
| 700 summary->set_out(Location::RequiresRegister()); | 696 summary->set_out(Location::RequiresRegister()); |
| 701 summary->set_temp(0, Location::RequiresRegister()); | 697 summary->set_temp(0, Location::RequiresRegister()); |
| 702 return summary; | 698 return summary; |
| 703 } | 699 } |
| 700 if (operands_class_id() == kDoubleCid) { |
| 701 const intptr_t kNumTemps = 2; |
| 702 LocationSummary* summary = |
| 703 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 704 summary->set_in(0, Location::RequiresRegister()); |
| 705 summary->set_in(1, Location::RequiresRegister()); |
| 706 summary->set_out(Location::RequiresRegister()); |
| 707 summary->set_temp(0, Location::RequiresRegister()); |
| 708 summary->set_temp(1, Location::XmmRegisterLocation(XMM1)); |
| 709 return summary; |
| 710 } |
| 704 const intptr_t kNumTemps = 0; | 711 const intptr_t kNumTemps = 0; |
| 705 LocationSummary* locs = | 712 LocationSummary* locs = |
| 706 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 713 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| 707 // Pick arbitrary fixed input registers because this is a call. | 714 // Pick arbitrary fixed input registers because this is a call. |
| 708 locs->set_in(0, Location::RegisterLocation(RAX)); | 715 locs->set_in(0, Location::RegisterLocation(RAX)); |
| 709 locs->set_in(1, Location::RegisterLocation(RCX)); | 716 locs->set_in(1, Location::RegisterLocation(RCX)); |
| 710 locs->set_out(Location::RegisterLocation(RAX)); | 717 locs->set_out(Location::RegisterLocation(RAX)); |
| 711 return locs; | 718 return locs; |
| 712 } | 719 } |
| 713 | 720 |
| (...skipping 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2221 } | 2228 } |
| 2222 __ j(ABOVE_EQUAL, deopt); | 2229 __ j(ABOVE_EQUAL, deopt); |
| 2223 } | 2230 } |
| 2224 | 2231 |
| 2225 | 2232 |
| 2226 } // namespace dart | 2233 } // namespace dart |
| 2227 | 2234 |
| 2228 #undef __ | 2235 #undef __ |
| 2229 | 2236 |
| 2230 #endif // defined TARGET_ARCH_X64 | 2237 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |