OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
7 | 7 |
8 #include "vm/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
9 | 9 |
10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
(...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 if (tmp.IsRegister() && | 1505 if (tmp.IsRegister() && |
1506 !locs->live_registers()->ContainsRegister(tmp.reg())) { | 1506 !locs->live_registers()->ContainsRegister(tmp.reg())) { |
1507 __ mov(tmp.reg(), Operand(0xf7)); | 1507 __ mov(tmp.reg(), Operand(0xf7)); |
1508 } | 1508 } |
1509 } | 1509 } |
1510 } | 1510 } |
1511 #endif | 1511 #endif |
1512 | 1512 |
1513 | 1513 |
1514 void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, | 1514 void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, |
1515 Register class_id_reg, | |
1516 intptr_t argument_count, | 1515 intptr_t argument_count, |
1517 const Array& argument_names, | 1516 const Array& argument_names, |
1518 Label* deopt, | 1517 Label* failed, |
| 1518 Label* match_found, |
1519 intptr_t deopt_id, | 1519 intptr_t deopt_id, |
1520 intptr_t token_index, | 1520 intptr_t token_index, |
1521 LocationSummary* locs) { | 1521 LocationSummary* locs) { |
1522 ASSERT(is_optimizing()); | 1522 ASSERT(is_optimizing()); |
1523 ASSERT(!ic_data.IsNull() && (ic_data.NumberOfUsedChecks() > 0)); | 1523 __ Comment("EmitTestAndCall"); |
1524 Label match_found; | |
1525 const intptr_t len = ic_data.NumberOfChecks(); | |
1526 GrowableArray<CidTarget> sorted(len); | |
1527 SortICDataByCount(ic_data, &sorted, /* drop_smi = */ false); | |
1528 ASSERT(class_id_reg != R4); | |
1529 ASSERT(len > 0); // Why bother otherwise. | |
1530 const Array& arguments_descriptor = | 1524 const Array& arguments_descriptor = |
1531 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, | 1525 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, |
1532 argument_names)); | 1526 argument_names)); |
1533 StubCode* stub_code = isolate()->stub_code(); | 1527 StubCode* stub_code = isolate()->stub_code(); |
1534 | 1528 |
| 1529 // Load receiver into R0. |
| 1530 __ LoadFromOffset(kWord, R0, SP, (argument_count - 1) * kWordSize); |
1535 __ LoadObject(R4, arguments_descriptor); | 1531 __ LoadObject(R4, arguments_descriptor); |
1536 for (intptr_t i = 0; i < len; i++) { | 1532 |
1537 const bool is_last_check = (i == (len - 1)); | 1533 const bool kFirstCheckIsSmi = ic_data.GetReceiverClassIdAt(0) == kSmiCid; |
| 1534 const intptr_t kNumChecks = ic_data.NumberOfChecks(); |
| 1535 |
| 1536 ASSERT(!ic_data.IsNull() && (kNumChecks > 0)); |
| 1537 |
| 1538 Label after_smi_test; |
| 1539 __ tst(R0, Operand(kSmiTagMask)); |
| 1540 if (kFirstCheckIsSmi) { |
| 1541 // Jump if receiver is not Smi. |
| 1542 if (kNumChecks == 1) { |
| 1543 __ b(failed, NE); |
| 1544 } else { |
| 1545 __ b(&after_smi_test, NE); |
| 1546 } |
| 1547 // Do not use the code from the function, but let the code be patched so |
| 1548 // that we can record the outgoing edges to other code. |
| 1549 GenerateDartCall(deopt_id, |
| 1550 token_index, |
| 1551 &stub_code->CallStaticFunctionLabel(), |
| 1552 RawPcDescriptors::kOther, |
| 1553 locs); |
| 1554 const Function& function = Function::Handle(ic_data.GetTargetAt(0)); |
| 1555 AddStaticCallTarget(function); |
| 1556 __ Drop(argument_count); |
| 1557 if (kNumChecks > 1) { |
| 1558 __ b(match_found); |
| 1559 } |
| 1560 } else { |
| 1561 // Receiver is Smi, but Smi is not a valid class therefore fail. |
| 1562 // (Smi class must be first in the list). |
| 1563 __ b(failed, EQ); |
| 1564 } |
| 1565 __ Bind(&after_smi_test); |
| 1566 |
| 1567 ASSERT(!ic_data.IsNull() && (kNumChecks > 0)); |
| 1568 GrowableArray<CidTarget> sorted(kNumChecks); |
| 1569 SortICDataByCount(ic_data, &sorted, /* drop_smi = */ true); |
| 1570 |
| 1571 // Value is not Smi, |
| 1572 const intptr_t kSortedLen = sorted.length(); |
| 1573 // If kSortedLen is 0 then only a Smi check was needed; the Smi check above |
| 1574 // will fail if there was only one check and receiver is not Smi. |
| 1575 if (kSortedLen == 0) return; |
| 1576 |
| 1577 __ LoadClassId(R2, R0); |
| 1578 for (intptr_t i = 0; i < kSortedLen; i++) { |
| 1579 const bool kIsLastCheck = (i == (kSortedLen - 1)); |
| 1580 ASSERT(sorted[i].cid != kSmiCid); |
1538 Label next_test; | 1581 Label next_test; |
1539 __ CompareImmediate(class_id_reg, sorted[i].cid); | 1582 __ CompareImmediate(R2, sorted[i].cid); |
1540 if (is_last_check) { | 1583 if (kIsLastCheck) { |
1541 __ b(deopt, NE); | 1584 __ b(failed, NE); |
1542 } else { | 1585 } else { |
1543 __ b(&next_test, NE); | 1586 __ b(&next_test, NE); |
1544 } | 1587 } |
1545 // Do not use the code from the function, but let the code be patched so | 1588 // Do not use the code from the function, but let the code be patched so |
1546 // that we can record the outgoing edges to other code. | 1589 // that we can record the outgoing edges to other code. |
1547 GenerateDartCall(deopt_id, | 1590 GenerateDartCall(deopt_id, |
1548 token_index, | 1591 token_index, |
1549 &stub_code->CallStaticFunctionLabel(), | 1592 &stub_code->CallStaticFunctionLabel(), |
1550 RawPcDescriptors::kOther, | 1593 RawPcDescriptors::kOther, |
1551 locs); | 1594 locs); |
1552 const Function& function = *sorted[i].target; | 1595 const Function& function = *sorted[i].target; |
1553 AddStaticCallTarget(function); | 1596 AddStaticCallTarget(function); |
1554 __ Drop(argument_count); | 1597 __ Drop(argument_count); |
1555 if (!is_last_check) { | 1598 if (!kIsLastCheck) { |
1556 __ b(&match_found); | 1599 __ b(match_found); |
1557 } | 1600 } |
1558 __ Bind(&next_test); | 1601 __ Bind(&next_test); |
1559 } | 1602 } |
1560 __ Bind(&match_found); | |
1561 } | 1603 } |
1562 | 1604 |
1563 | 1605 |
1564 #undef __ | 1606 #undef __ |
1565 #define __ compiler_->assembler()-> | 1607 #define __ compiler_->assembler()-> |
1566 | 1608 |
1567 | 1609 |
1568 void ParallelMoveResolver::EmitMove(int index) { | 1610 void ParallelMoveResolver::EmitMove(int index) { |
1569 MoveOperands* move = moves_[index]; | 1611 MoveOperands* move = moves_[index]; |
1570 const Location source = move->src(); | 1612 const Location source = move->src(); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 DRegister dreg = EvenDRegisterOf(reg); | 1899 DRegister dreg = EvenDRegisterOf(reg); |
1858 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); | 1900 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); |
1859 } | 1901 } |
1860 | 1902 |
1861 | 1903 |
1862 #undef __ | 1904 #undef __ |
1863 | 1905 |
1864 } // namespace dart | 1906 } // namespace dart |
1865 | 1907 |
1866 #endif // defined TARGET_ARCH_ARM | 1908 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |