| 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 __ Bind(&non_null_compare); // Receiver is not null. | 492 __ Bind(&non_null_compare); // Receiver is not null. |
| 493 __ pushl(left); | 493 __ pushl(left); |
| 494 __ pushl(right); | 494 __ pushl(right); |
| 495 EmitEqualityAsPolymorphicCall(compiler, ic_data, locs, branch, kind, | 495 EmitEqualityAsPolymorphicCall(compiler, ic_data, locs, branch, kind, |
| 496 deopt_id, token_pos, try_index, | 496 deopt_id, token_pos, try_index, |
| 497 locs.stack_bitmap()); | 497 locs.stack_bitmap()); |
| 498 __ Bind(&done); | 498 __ Bind(&done); |
| 499 } | 499 } |
| 500 | 500 |
| 501 | 501 |
| 502 static intptr_t GetCid(const Value& v) { | |
| 503 // TODO(srdjan): CompileType does not give us correct type for optimizations. | |
| 504 // const AbstractType& type = AbstractType::Handle(v.CompileType()); | |
| 505 // return Class::Handle(type.type_class()).id(); | |
| 506 return kIllegalCid; | |
| 507 } | |
| 508 | |
| 509 | |
| 510 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, | 502 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, |
| 511 const LocationSummary& locs, | 503 const LocationSummary& locs, |
| 512 Token::Kind kind, | 504 Token::Kind kind, |
| 513 BranchInstr* branch, | 505 BranchInstr* branch, |
| 514 intptr_t deopt_id, | 506 intptr_t deopt_id, |
| 515 intptr_t token_pos, | 507 intptr_t token_pos, |
| 516 intptr_t try_index) { | 508 intptr_t try_index) { |
| 517 Register left = locs.in(0).reg(); | 509 Register left = locs.in(0).reg(); |
| 518 Register right = locs.in(1).reg(); | 510 Register right = locs.in(1).reg(); |
| 519 const bool left_is_smi = (branch == NULL) ? | 511 const bool left_is_smi = (branch == NULL) ? |
| 520 false : (GetCid(*branch->left()) == kSmiCid); | 512 false : (branch->left()->ResultCid() == kSmiCid); |
| 521 const bool right_is_smi = (branch == NULL) ? | 513 const bool right_is_smi = (branch == NULL) ? |
| 522 false : (GetCid(*branch->right()) == kSmiCid); | 514 false : (branch->right()->ResultCid() == kSmiCid); |
| 523 if (!left_is_smi || !right_is_smi) { | 515 if (!left_is_smi || !right_is_smi) { |
| 524 Register temp = locs.temp(0).reg(); | 516 Register temp = locs.temp(0).reg(); |
| 525 Label* deopt = compiler->AddDeoptStub(deopt_id, | 517 Label* deopt = compiler->AddDeoptStub(deopt_id, |
| 526 try_index, | 518 try_index, |
| 527 kDeoptSmiCompareSmi, | 519 kDeoptSmiCompareSmi, |
| 528 left, | 520 left, |
| 529 right); | 521 right); |
| 530 __ movl(temp, left); | 522 __ movl(temp, left); |
| 531 __ orl(temp, right); | 523 __ orl(temp, right); |
| 532 __ testl(temp, Immediate(kSmiTagMask)); | 524 __ testl(temp, Immediate(kSmiTagMask)); |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1443 } | 1435 } |
| 1444 } | 1436 } |
| 1445 | 1437 |
| 1446 | 1438 |
| 1447 static void EmitSmiBinaryOp(FlowGraphCompiler* compiler, BinaryOpComp* comp) { | 1439 static void EmitSmiBinaryOp(FlowGraphCompiler* compiler, BinaryOpComp* comp) { |
| 1448 Register left = comp->locs()->in(0).reg(); | 1440 Register left = comp->locs()->in(0).reg(); |
| 1449 Register right = comp->locs()->in(1).reg(); | 1441 Register right = comp->locs()->in(1).reg(); |
| 1450 Register result = comp->locs()->out().reg(); | 1442 Register result = comp->locs()->out().reg(); |
| 1451 Register temp = comp->locs()->temp(0).reg(); | 1443 Register temp = comp->locs()->temp(0).reg(); |
| 1452 ASSERT(left == result); | 1444 ASSERT(left == result); |
| 1453 const bool left_is_smi = (GetCid(*comp->left()) == kSmiCid); | 1445 const bool left_is_smi = comp->left()->ResultCid() == kSmiCid; |
| 1454 const bool right_is_smi = (GetCid(*comp->right()) == kSmiCid); | 1446 const bool right_is_smi = comp->right()->ResultCid() == kSmiCid; |
| 1455 bool can_deopt; | 1447 bool can_deopt; |
| 1456 switch (comp->op_kind()) { | 1448 switch (comp->op_kind()) { |
| 1457 case Token::kBIT_AND: | 1449 case Token::kBIT_AND: |
| 1458 case Token::kBIT_OR: | 1450 case Token::kBIT_OR: |
| 1459 case Token::kBIT_XOR: | 1451 case Token::kBIT_XOR: |
| 1460 can_deopt = !(right_is_smi && left_is_smi); | 1452 can_deopt = !(right_is_smi && left_is_smi); |
| 1461 break; | 1453 break; |
| 1462 default: | 1454 default: |
| 1463 can_deopt = true; | 1455 can_deopt = true; |
| 1464 } | 1456 } |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1882 // Result is in EAX. | 1874 // Result is in EAX. |
| 1883 ASSERT(result != temp); | 1875 ASSERT(result != temp); |
| 1884 __ movl(result, EAX); | 1876 __ movl(result, EAX); |
| 1885 __ popl(temp); | 1877 __ popl(temp); |
| 1886 __ movsd(XMM0, FieldAddress(temp, Double::value_offset())); | 1878 __ movsd(XMM0, FieldAddress(temp, Double::value_offset())); |
| 1887 __ DoubleNegate(XMM0); | 1879 __ DoubleNegate(XMM0); |
| 1888 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); | 1880 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); |
| 1889 } else { | 1881 } else { |
| 1890 UNREACHABLE(); | 1882 UNREACHABLE(); |
| 1891 } | 1883 } |
| 1884 ASSERT(ResultCid() == kDoubleCid); |
| 1892 } | 1885 } |
| 1893 | 1886 |
| 1894 | 1887 |
| 1895 LocationSummary* DoubleToDoubleComp::MakeLocationSummary() const { | 1888 LocationSummary* DoubleToDoubleComp::MakeLocationSummary() const { |
| 1896 const intptr_t kNumInputs = 1; | 1889 const intptr_t kNumInputs = 1; |
| 1897 const intptr_t kNumTemps = 1; | 1890 const intptr_t kNumTemps = 1; |
| 1898 LocationSummary* locs = | 1891 LocationSummary* locs = |
| 1899 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 1892 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 1900 locs->set_in(0, Location::RequiresRegister()); | 1893 locs->set_in(0, Location::RequiresRegister()); |
| 1901 locs->set_temp(0, Location::RequiresRegister()); | 1894 locs->set_temp(0, Location::RequiresRegister()); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2135 locs()->stack_bitmap()); | 2128 locs()->stack_bitmap()); |
| 2136 __ CompareObject(EAX, compiler->bool_true()); | 2129 __ CompareObject(EAX, compiler->bool_true()); |
| 2137 EmitBranchOnCondition(compiler, branch_condition); | 2130 EmitBranchOnCondition(compiler, branch_condition); |
| 2138 } | 2131 } |
| 2139 | 2132 |
| 2140 } // namespace dart | 2133 } // namespace dart |
| 2141 | 2134 |
| 2142 #undef __ | 2135 #undef __ |
| 2143 | 2136 |
| 2144 #endif // defined TARGET_ARCH_X64 | 2137 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |