Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Side by Side Diff: runtime/vm/flow_graph_compiler_mips.cc

Issue 1184093004: Faster checks in polymorphic instance calls if Smi-s are involved (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: m Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.cc ('k') | runtime/vm/flow_graph_compiler_x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
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 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 if (tmp.IsRegister() && 1533 if (tmp.IsRegister() &&
1534 !locs->live_registers()->ContainsRegister(tmp.reg())) { 1534 !locs->live_registers()->ContainsRegister(tmp.reg())) {
1535 __ LoadImmediate(tmp.reg(), 0xf7); 1535 __ LoadImmediate(tmp.reg(), 0xf7);
1536 } 1536 }
1537 } 1537 }
1538 } 1538 }
1539 #endif 1539 #endif
1540 1540
1541 1541
1542 void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, 1542 void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data,
1543 Register class_id_reg,
1544 intptr_t argument_count, 1543 intptr_t argument_count,
1545 const Array& argument_names, 1544 const Array& argument_names,
1546 Label* deopt, 1545 Label* failed,
1546 Label* match_found,
1547 intptr_t deopt_id, 1547 intptr_t deopt_id,
1548 intptr_t token_index, 1548 intptr_t token_index,
1549 LocationSummary* locs) { 1549 LocationSummary* locs) {
1550 ASSERT(is_optimizing()); 1550 ASSERT(is_optimizing());
1551 ASSERT(!ic_data.IsNull() && (ic_data.NumberOfUsedChecks() > 0)); 1551 __ Comment("EmitTestAndCall");
1552 Label match_found;
1553 const intptr_t len = ic_data.NumberOfChecks();
1554 GrowableArray<CidTarget> sorted(len);
1555 SortICDataByCount(ic_data, &sorted, /* drop_smi = */ false);
1556 ASSERT(class_id_reg != S4);
1557 ASSERT(len > 0); // Why bother otherwise.
1558 const Array& arguments_descriptor = 1552 const Array& arguments_descriptor =
1559 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, 1553 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count,
1560 argument_names)); 1554 argument_names));
1561 StubCode* stub_code = isolate()->stub_code(); 1555 StubCode* stub_code = isolate()->stub_code();
1562 1556
1563 __ Comment("EmitTestAndCall"); 1557 // Load receiver into T0.
1558 __ LoadFromOffset(T0, SP, (argument_count - 1) * kWordSize);
1564 __ LoadObject(S4, arguments_descriptor); 1559 __ LoadObject(S4, arguments_descriptor);
1565 for (intptr_t i = 0; i < len; i++) { 1560
1566 const bool is_last_check = (i == (len - 1)); 1561 const bool kFirstCheckIsSmi = ic_data.GetReceiverClassIdAt(0) == kSmiCid;
1567 Label next_test; 1562 const intptr_t kNumChecks = ic_data.NumberOfChecks();
1568 if (is_last_check) { 1563
1569 __ BranchNotEqual(class_id_reg, Immediate(sorted[i].cid), deopt); 1564 ASSERT(!ic_data.IsNull() && (kNumChecks > 0));
1565
1566 Label after_smi_test;
1567 __ andi(CMPRES1, T0, Immediate(kSmiTagMask));
1568 if (kFirstCheckIsSmi) {
1569 // Jump if receiver is not Smi.
1570 if (kNumChecks == 1) {
1571 __ bne(CMPRES1, ZR, failed);
1570 } else { 1572 } else {
1571 __ BranchNotEqual(class_id_reg, Immediate(sorted[i].cid), &next_test); 1573 __ bne(CMPRES1, ZR, &after_smi_test);
1572 } 1574 }
1573 // Do not use the code from the function, but let the code be patched so 1575 // Do not use the code from the function, but let the code be patched so
1574 // that we can record the outgoing edges to other code. 1576 // that we can record the outgoing edges to other code.
1577 GenerateDartCall(deopt_id,
1578 token_index,
1579 &stub_code->CallStaticFunctionLabel(),
1580 RawPcDescriptors::kOther,
1581 locs);
1582 const Function& function = Function::Handle(ic_data.GetTargetAt(0));
1583 AddStaticCallTarget(function);
1584 __ Drop(argument_count);
1585 if (kNumChecks > 1) {
1586 __ b(match_found);
1587 }
1588 } else {
1589 // Receiver is Smi, but Smi is not a valid class therefore fail.
1590 // (Smi class must be first in the list).
1591 __ beq(CMPRES1, ZR, failed);
1592 }
1593
1594 __ Bind(&after_smi_test);
1595
1596 GrowableArray<CidTarget> sorted(kNumChecks);
1597 SortICDataByCount(ic_data, &sorted, /* drop_smi = */ true);
1598
1599 // Value is not Smi,
1600 const intptr_t kSortedLen = sorted.length();
1601 // If kSortedLen is 0 then only a Smi check was needed; the Smi check above
1602 // will fail if there was only one check and receiver is not Smi.
1603 if (kSortedLen == 0) return;
1604
1605 __ LoadClassId(T2, T0);
1606 for (intptr_t i = 0; i < kSortedLen; i++) {
1607 const bool kIsLastCheck = (i == (kSortedLen - 1));
1608 ASSERT(sorted[i].cid != kSmiCid);
1609 Label next_test;
1610 if (kIsLastCheck) {
1611 __ BranchNotEqual(T2, Immediate(sorted[i].cid), failed);
1612 } else {
1613 __ BranchNotEqual(T2, Immediate(sorted[i].cid), &next_test);
1614 }
1615 // Do not use the code from the function, but let the code be patched so
1616 // that we can record the outgoing edges to other code.
1575 GenerateDartCall(deopt_id, 1617 GenerateDartCall(deopt_id,
1576 token_index, 1618 token_index,
1577 &stub_code->CallStaticFunctionLabel(), 1619 &stub_code->CallStaticFunctionLabel(),
1578 RawPcDescriptors::kOther, 1620 RawPcDescriptors::kOther,
1579 locs); 1621 locs);
1580 const Function& function = *sorted[i].target; 1622 const Function& function = *sorted[i].target;
1581 AddStaticCallTarget(function); 1623 AddStaticCallTarget(function);
1582 __ Drop(argument_count); 1624 __ Drop(argument_count);
1583 if (!is_last_check) { 1625 if (!kIsLastCheck) {
1584 __ b(&match_found); 1626 __ b(match_found);
1585 } 1627 }
1586 __ Bind(&next_test); 1628 __ Bind(&next_test);
1587 } 1629 }
1588 __ Bind(&match_found);
1589 } 1630 }
1590 1631
1591 1632
1592 #undef __ 1633 #undef __
1593 #define __ compiler_->assembler()-> 1634 #define __ compiler_->assembler()->
1594 1635
1595 1636
1596 void ParallelMoveResolver::EmitMove(int index) { 1637 void ParallelMoveResolver::EmitMove(int index) {
1597 MoveOperands* move = moves_[index]; 1638 MoveOperands* move = moves_[index];
1598 const Location source = move->src(); 1639 const Location source = move->src();
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 __ AddImmediate(SP, kDoubleSize); 1868 __ AddImmediate(SP, kDoubleSize);
1828 } 1869 }
1829 1870
1830 1871
1831 #undef __ 1872 #undef __
1832 1873
1833 1874
1834 } // namespace dart 1875 } // namespace dart
1835 1876
1836 #endif // defined TARGET_ARCH_MIPS 1877 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.cc ('k') | runtime/vm/flow_graph_compiler_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698