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

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: 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
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 // It is Smi, butSmi is not handled here.
1590 __ beq(CMPRES1, ZR, failed);
1591 }
1592
1593 __ Bind(&after_smi_test);
1594
1595 GrowableArray<CidTarget> sorted(kNumChecks);
1596 SortICDataByCount(ic_data, &sorted, /* drop_smi = */ true);
1597
1598 // Value is not Smi,
1599 const intptr_t kSortedLen = sorted.length();
1600 if (kSortedLen == 0) return;
1601
1602 __ LoadClassId(T2, T0);
1603 for (intptr_t i = 0; i < kSortedLen; i++) {
1604 const bool kIsLastCheck = (i == (kSortedLen - 1));
1605 Label next_test;
1606 if (kIsLastCheck) {
1607 __ BranchNotEqual(T2, Immediate(sorted[i].cid), failed);
1608 } else {
1609 __ BranchNotEqual(T2, Immediate(sorted[i].cid), &next_test);
1610 }
1611 // Do not use the code from the function, but let the code be patched so
1612 // that we can record the outgoing edges to other code.
1575 GenerateDartCall(deopt_id, 1613 GenerateDartCall(deopt_id,
1576 token_index, 1614 token_index,
1577 &stub_code->CallStaticFunctionLabel(), 1615 &stub_code->CallStaticFunctionLabel(),
1578 RawPcDescriptors::kOther, 1616 RawPcDescriptors::kOther,
1579 locs); 1617 locs);
1580 const Function& function = *sorted[i].target; 1618 const Function& function = *sorted[i].target;
1581 AddStaticCallTarget(function); 1619 AddStaticCallTarget(function);
1582 __ Drop(argument_count); 1620 __ Drop(argument_count);
1583 if (!is_last_check) { 1621 if (!kIsLastCheck) {
1584 __ b(&match_found); 1622 __ b(match_found);
1585 } 1623 }
1586 __ Bind(&next_test); 1624 __ Bind(&next_test);
1587 } 1625 }
1588 __ Bind(&match_found);
1589 } 1626 }
1590 1627
1591 1628
1592 #undef __ 1629 #undef __
1593 #define __ compiler_->assembler()-> 1630 #define __ compiler_->assembler()->
1594 1631
1595 1632
1596 void ParallelMoveResolver::EmitMove(int index) { 1633 void ParallelMoveResolver::EmitMove(int index) {
1597 MoveOperands* move = moves_[index]; 1634 MoveOperands* move = moves_[index];
1598 const Location source = move->src(); 1635 const Location source = move->src();
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 __ AddImmediate(SP, kDoubleSize); 1864 __ AddImmediate(SP, kDoubleSize);
1828 } 1865 }
1829 1866
1830 1867
1831 #undef __ 1868 #undef __
1832 1869
1833 1870
1834 } // namespace dart 1871 } // namespace dart
1835 1872
1836 #endif // defined TARGET_ARCH_MIPS 1873 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698