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

Side by Side Diff: runtime/vm/flow_graph_compiler_arm.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_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
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 // It is Smi, butSmi is not handled here.
zra 2015/06/15 20:17:22 butSmi -> but Smi
srdjan 2015/06/15 20:54:13 Done.
1562 __ b(failed, EQ);
zra 2015/06/15 20:17:22 Why isn't this: if (kNumChecks == 1) { __ b(fai
srdjan 2015/06/15 20:54:13 Added/changed comment: // Receiver is Smi, bu
1563 }
1564 __ Bind(&after_smi_test);
1565
1566 ASSERT(!ic_data.IsNull() && (kNumChecks > 0));
1567 GrowableArray<CidTarget> sorted(kNumChecks);
1568 SortICDataByCount(ic_data, &sorted, /* drop_smi = */ true);
1569
1570 // Value is not Smi,
1571 const intptr_t kSortedLen = sorted.length();
1572 if (kSortedLen == 0) return;
zra 2015/06/15 20:17:23 Should this branch to the 'failed' label? If the
srdjan 2015/06/15 20:54:13 Added comment: // If kSortedLen is 0 then only
1573
1574 __ LoadClassId(R2, R0);
1575 for (intptr_t i = 0; i < kSortedLen; i++) {
1576 const bool kIsLastCheck = (i == (kSortedLen - 1));
1538 Label next_test; 1577 Label next_test;
srdjan 2015/06/15 20:54:13 Added assert that sorted[i].cid is not kSMiCid
1539 __ CompareImmediate(class_id_reg, sorted[i].cid); 1578 __ CompareImmediate(R2, sorted[i].cid);
1540 if (is_last_check) { 1579 if (kIsLastCheck) {
1541 __ b(deopt, NE); 1580 __ b(failed, NE);
1542 } else { 1581 } else {
1543 __ b(&next_test, NE); 1582 __ b(&next_test, NE);
1544 } 1583 }
1545 // Do not use the code from the function, but let the code be patched so 1584 // 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. 1585 // that we can record the outgoing edges to other code.
1547 GenerateDartCall(deopt_id, 1586 GenerateDartCall(deopt_id,
1548 token_index, 1587 token_index,
1549 &stub_code->CallStaticFunctionLabel(), 1588 &stub_code->CallStaticFunctionLabel(),
1550 RawPcDescriptors::kOther, 1589 RawPcDescriptors::kOther,
1551 locs); 1590 locs);
1552 const Function& function = *sorted[i].target; 1591 const Function& function = *sorted[i].target;
1553 AddStaticCallTarget(function); 1592 AddStaticCallTarget(function);
1554 __ Drop(argument_count); 1593 __ Drop(argument_count);
1555 if (!is_last_check) { 1594 if (!kIsLastCheck) {
1556 __ b(&match_found); 1595 __ b(match_found);
1557 } 1596 }
1558 __ Bind(&next_test); 1597 __ Bind(&next_test);
1559 } 1598 }
1560 __ Bind(&match_found);
1561 } 1599 }
1562 1600
1563 1601
1564 #undef __ 1602 #undef __
1565 #define __ compiler_->assembler()-> 1603 #define __ compiler_->assembler()->
1566 1604
1567 1605
1568 void ParallelMoveResolver::EmitMove(int index) { 1606 void ParallelMoveResolver::EmitMove(int index) {
1569 MoveOperands* move = moves_[index]; 1607 MoveOperands* move = moves_[index];
1570 const Location source = move->src(); 1608 const Location source = move->src();
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 DRegister dreg = EvenDRegisterOf(reg); 1895 DRegister dreg = EvenDRegisterOf(reg);
1858 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); 1896 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex));
1859 } 1897 }
1860 1898
1861 1899
1862 #undef __ 1900 #undef __
1863 1901
1864 } // namespace dart 1902 } // namespace dart
1865 1903
1866 #endif // defined TARGET_ARCH_ARM 1904 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698