| 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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 __ Bind(&non_null_compare); // Receiver is not null. | 502 __ Bind(&non_null_compare); // Receiver is not null. |
| 503 __ pushq(left); | 503 __ pushq(left); |
| 504 __ pushq(right); | 504 __ pushq(right); |
| 505 EmitEqualityAsPolymorphicCall(compiler, ic_data, locs, branch, kind, | 505 EmitEqualityAsPolymorphicCall(compiler, ic_data, locs, branch, kind, |
| 506 deopt_id, token_pos, try_index, | 506 deopt_id, token_pos, try_index, |
| 507 locs.stack_bitmap()); | 507 locs.stack_bitmap()); |
| 508 __ Bind(&done); | 508 __ Bind(&done); |
| 509 } | 509 } |
| 510 | 510 |
| 511 | 511 |
| 512 static intptr_t GetCid(const Value& v) { | |
| 513 // TODO(srdjan): CompileType does not give us correct type for optimizations. | |
| 514 // const AbstractType& type = AbstractType::Handle(v.CompileType()); | |
| 515 // return Class::Handle(type.type_class()).id(); | |
| 516 return kIllegalCid; | |
| 517 } | |
| 518 | |
| 519 | |
| 520 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, | 512 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, |
| 521 const LocationSummary& locs, | 513 const LocationSummary& locs, |
| 522 Token::Kind kind, | 514 Token::Kind kind, |
| 523 BranchInstr* branch, | 515 BranchInstr* branch, |
| 524 intptr_t deopt_id, | 516 intptr_t deopt_id, |
| 525 intptr_t token_pos, | 517 intptr_t token_pos, |
| 526 intptr_t try_index) { | 518 intptr_t try_index) { |
| 527 Register left = locs.in(0).reg(); | 519 Register left = locs.in(0).reg(); |
| 528 Register right = locs.in(1).reg(); | 520 Register right = locs.in(1).reg(); |
| 529 const bool left_is_smi = (branch == NULL) ? | 521 const bool left_is_smi = (branch == NULL) ? |
| 530 false : (GetCid(*branch->left()) == kSmiCid); | 522 false : (branch->left()->ResultCid() == kSmiCid); |
| 531 const bool right_is_smi = (branch == NULL) ? | 523 const bool right_is_smi = (branch == NULL) ? |
| 532 false : (GetCid(*branch->right()) == kSmiCid); | 524 false : (branch->right()->ResultCid() == kSmiCid); |
| 533 if (!left_is_smi || !right_is_smi) { | 525 if (!left_is_smi || !right_is_smi) { |
| 534 Register temp = locs.temp(0).reg(); | 526 Register temp = locs.temp(0).reg(); |
| 535 Label* deopt = compiler->AddDeoptStub(deopt_id, | 527 Label* deopt = compiler->AddDeoptStub(deopt_id, |
| 536 try_index, | 528 try_index, |
| 537 kDeoptSmiCompareSmi, | 529 kDeoptSmiCompareSmi, |
| 538 left, | 530 left, |
| 539 right); | 531 right); |
| 540 __ movq(temp, left); | 532 __ movq(temp, left); |
| 541 __ orq(temp, right); | 533 __ orq(temp, right); |
| 542 __ testq(temp, Immediate(kSmiTagMask)); | 534 __ testq(temp, Immediate(kSmiTagMask)); |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 } | 1450 } |
| 1459 } | 1451 } |
| 1460 | 1452 |
| 1461 | 1453 |
| 1462 static void EmitSmiBinaryOp(FlowGraphCompiler* compiler, BinaryOpComp* comp) { | 1454 static void EmitSmiBinaryOp(FlowGraphCompiler* compiler, BinaryOpComp* comp) { |
| 1463 Register left = comp->locs()->in(0).reg(); | 1455 Register left = comp->locs()->in(0).reg(); |
| 1464 Register right = comp->locs()->in(1).reg(); | 1456 Register right = comp->locs()->in(1).reg(); |
| 1465 Register result = comp->locs()->out().reg(); | 1457 Register result = comp->locs()->out().reg(); |
| 1466 Register temp = comp->locs()->temp(0).reg(); | 1458 Register temp = comp->locs()->temp(0).reg(); |
| 1467 ASSERT(left == result); | 1459 ASSERT(left == result); |
| 1468 const bool left_is_smi = (GetCid(*comp->left()) == kSmiCid); | 1460 const bool left_is_smi = comp->left()->ResultCid() == kSmiCid; |
| 1469 const bool right_is_smi = (GetCid(*comp->right()) == kSmiCid); | 1461 const bool right_is_smi = comp->right()->ResultCid() == kSmiCid; |
| 1470 bool can_deopt; | 1462 bool can_deopt; |
| 1471 switch (comp->op_kind()) { | 1463 switch (comp->op_kind()) { |
| 1472 case Token::kBIT_AND: | 1464 case Token::kBIT_AND: |
| 1473 case Token::kBIT_OR: | 1465 case Token::kBIT_OR: |
| 1474 case Token::kBIT_XOR: | 1466 case Token::kBIT_XOR: |
| 1475 can_deopt = !(right_is_smi && left_is_smi); | 1467 can_deopt = !(right_is_smi && left_is_smi); |
| 1476 break; | 1468 break; |
| 1477 default: | 1469 default: |
| 1478 can_deopt = true; | 1470 can_deopt = true; |
| 1479 } | 1471 } |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1896 // Result is in RAX. | 1888 // Result is in RAX. |
| 1897 ASSERT(result != temp); | 1889 ASSERT(result != temp); |
| 1898 __ movq(result, RAX); | 1890 __ movq(result, RAX); |
| 1899 __ popq(temp); | 1891 __ popq(temp); |
| 1900 __ movsd(XMM0, FieldAddress(temp, Double::value_offset())); | 1892 __ movsd(XMM0, FieldAddress(temp, Double::value_offset())); |
| 1901 __ DoubleNegate(XMM0); | 1893 __ DoubleNegate(XMM0); |
| 1902 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); | 1894 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); |
| 1903 } else { | 1895 } else { |
| 1904 UNREACHABLE(); | 1896 UNREACHABLE(); |
| 1905 } | 1897 } |
| 1898 ASSERT(ResultCid() == kDoubleCid); |
| 1906 } | 1899 } |
| 1907 | 1900 |
| 1908 | 1901 |
| 1909 LocationSummary* DoubleToDoubleComp::MakeLocationSummary() const { | 1902 LocationSummary* DoubleToDoubleComp::MakeLocationSummary() const { |
| 1910 const intptr_t kNumInputs = 1; | 1903 const intptr_t kNumInputs = 1; |
| 1911 const intptr_t kNumTemps = 0; | 1904 const intptr_t kNumTemps = 0; |
| 1912 LocationSummary* locs = | 1905 LocationSummary* locs = |
| 1913 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 1906 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 1914 locs->set_in(0, Location::RequiresRegister()); | 1907 locs->set_in(0, Location::RequiresRegister()); |
| 1915 locs->set_out(Location::SameAsFirstInput()); | 1908 locs->set_out(Location::SameAsFirstInput()); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2148 locs()->stack_bitmap()); | 2141 locs()->stack_bitmap()); |
| 2149 __ CompareObject(RAX, compiler->bool_true()); | 2142 __ CompareObject(RAX, compiler->bool_true()); |
| 2150 EmitBranchOnCondition(compiler, branch_condition); | 2143 EmitBranchOnCondition(compiler, branch_condition); |
| 2151 } | 2144 } |
| 2152 | 2145 |
| 2153 } // namespace dart | 2146 } // namespace dart |
| 2154 | 2147 |
| 2155 #undef __ | 2148 #undef __ |
| 2156 | 2149 |
| 2157 #endif // defined TARGET_ARCH_X64 | 2150 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |