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

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

Issue 1867913004: Specialize instance calls when the call receiver is the method receiver and the method class has a … (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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_mips.cc ('k') | runtime/vm/flow_graph_inliner.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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
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 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 #endif 1527 #endif
1528 1528
1529 1529
1530 void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, 1530 void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data,
1531 intptr_t argument_count, 1531 intptr_t argument_count,
1532 const Array& argument_names, 1532 const Array& argument_names,
1533 Label* failed, 1533 Label* failed,
1534 Label* match_found, 1534 Label* match_found,
1535 intptr_t deopt_id, 1535 intptr_t deopt_id,
1536 TokenPosition token_index, 1536 TokenPosition token_index,
1537 LocationSummary* locs) { 1537 LocationSummary* locs,
1538 bool complete) {
1538 ASSERT(is_optimizing()); 1539 ASSERT(is_optimizing());
1539 1540
1540 __ Comment("EmitTestAndCall"); 1541 __ Comment("EmitTestAndCall");
1541 const Array& arguments_descriptor = 1542 const Array& arguments_descriptor =
1542 Array::ZoneHandle(zone(), ArgumentsDescriptor::New(argument_count, 1543 Array::ZoneHandle(zone(), ArgumentsDescriptor::New(argument_count,
1543 argument_names)); 1544 argument_names));
1544 // Load receiver into RAX. 1545 // Load receiver into RAX.
1545 __ movq(RAX, 1546 __ movq(RAX,
1546 Address(RSP, (argument_count - 1) * kWordSize)); 1547 Address(RSP, (argument_count - 1) * kWordSize));
1547 __ LoadObject(R10, arguments_descriptor); 1548 __ LoadObject(R10, arguments_descriptor);
1548 1549
1549 const bool kFirstCheckIsSmi = ic_data.GetReceiverClassIdAt(0) == kSmiCid; 1550 const bool kFirstCheckIsSmi = ic_data.GetReceiverClassIdAt(0) == kSmiCid;
1550 const intptr_t kNumChecks = ic_data.NumberOfChecks(); 1551 const intptr_t kNumChecks = ic_data.NumberOfChecks();
1551 1552
1552 ASSERT(!ic_data.IsNull() && (kNumChecks > 0)); 1553 ASSERT(!ic_data.IsNull() && (kNumChecks > 0));
1553 1554
1554 Label after_smi_test; 1555 Label after_smi_test;
1555 __ testq(RAX, Immediate(kSmiTagMask));
1556 if (kFirstCheckIsSmi) { 1556 if (kFirstCheckIsSmi) {
1557 __ testq(RAX, Immediate(kSmiTagMask));
1557 // Jump if receiver is not Smi. 1558 // Jump if receiver is not Smi.
1558 if (kNumChecks == 1) { 1559 if (kNumChecks == 1) {
1559 __ j(NOT_ZERO, failed); 1560 __ j(NOT_ZERO, failed);
1560 } else { 1561 } else {
1561 __ j(NOT_ZERO, &after_smi_test); 1562 __ j(NOT_ZERO, &after_smi_test);
1562 } 1563 }
1563 // Do not use the code from the function, but let the code be patched so 1564 // Do not use the code from the function, but let the code be patched so
1564 // that we can record the outgoing edges to other code. 1565 // that we can record the outgoing edges to other code.
1565 const Function& function = Function::ZoneHandle( 1566 const Function& function = Function::ZoneHandle(
1566 zone(), ic_data.GetTargetAt(0)); 1567 zone(), ic_data.GetTargetAt(0));
1567 GenerateStaticDartCall(deopt_id, 1568 GenerateStaticDartCall(deopt_id,
1568 token_index, 1569 token_index,
1569 *StubCode::CallStaticFunction_entry(), 1570 *StubCode::CallStaticFunction_entry(),
1570 RawPcDescriptors::kOther, 1571 RawPcDescriptors::kOther,
1571 locs, 1572 locs,
1572 function); 1573 function);
1573 __ Drop(argument_count, RCX); 1574 __ Drop(argument_count, RCX);
1574 if (kNumChecks > 1) { 1575 if (kNumChecks > 1) {
1575 __ jmp(match_found); 1576 __ jmp(match_found);
1576 } 1577 }
1577 } else { 1578 } else {
1578 // Receiver is Smi, but Smi is not a valid class therefore fail. 1579 // Receiver is Smi, but Smi is not a valid class therefore fail.
1579 // (Smi class must be first in the list). 1580 // (Smi class must be first in the list).
1580 __ j(ZERO, failed); 1581 if (!complete) {
1582 __ testq(RAX, Immediate(kSmiTagMask));
1583 __ j(ZERO, failed);
1584 }
1581 } 1585 }
1582 __ Bind(&after_smi_test); 1586 __ Bind(&after_smi_test);
1583 1587
1584 ASSERT(!ic_data.IsNull() && (kNumChecks > 0)); 1588 ASSERT(!ic_data.IsNull() && (kNumChecks > 0));
1585 GrowableArray<CidTarget> sorted(kNumChecks); 1589 GrowableArray<CidTarget> sorted(kNumChecks);
1586 SortICDataByCount(ic_data, &sorted, /* drop_smi = */ true); 1590 SortICDataByCount(ic_data, &sorted, /* drop_smi = */ true);
1587 1591
1588 const intptr_t kSortedLen = sorted.length(); 1592 const intptr_t kSortedLen = sorted.length();
1589 // If kSortedLen is 0 then only a Smi check was needed; the Smi check above 1593 // If kSortedLen is 0 then only a Smi check was needed; the Smi check above
1590 // will fail if there was only one check and receiver is not Smi. 1594 // will fail if there was only one check and receiver is not Smi.
1591 if (kSortedLen == 0) return; 1595 if (kSortedLen == 0) return;
1592 1596
1593 // Value is not Smi, 1597 // Value is not Smi,
1594 __ LoadClassId(RDI, RAX); 1598 __ LoadClassId(RDI, RAX);
1595 for (intptr_t i = 0; i < kSortedLen; i++) { 1599 for (intptr_t i = 0; i < kSortedLen; i++) {
1596 const bool kIsLastCheck = (i == (kSortedLen - 1)); 1600 const bool kIsLastCheck = (i == (kSortedLen - 1));
1597 ASSERT(sorted[i].cid != kSmiCid); 1601 ASSERT(sorted[i].cid != kSmiCid);
1598 Label next_test; 1602 Label next_test;
1599 __ cmpl(RDI, Immediate(sorted[i].cid)); 1603 if (!complete) {
1600 if (kIsLastCheck) { 1604 __ cmpl(RDI, Immediate(sorted[i].cid));
1601 __ j(NOT_EQUAL, failed); 1605 if (kIsLastCheck) {
1606 __ j(NOT_EQUAL, failed);
1607 } else {
1608 __ j(NOT_EQUAL, &next_test);
1609 }
1602 } else { 1610 } else {
1603 __ j(NOT_EQUAL, &next_test); 1611 if (!kIsLastCheck) {
1612 __ cmpl(RDI, Immediate(sorted[i].cid));
1613 __ j(NOT_EQUAL, &next_test);
1614 }
1604 } 1615 }
1605 // Do not use the code from the function, but let the code be patched so 1616 // Do not use the code from the function, but let the code be patched so
1606 // that we can record the outgoing edges to other code. 1617 // that we can record the outgoing edges to other code.
1607 const Function& function = *sorted[i].target; 1618 const Function& function = *sorted[i].target;
1608 GenerateStaticDartCall(deopt_id, 1619 GenerateStaticDartCall(deopt_id,
1609 token_index, 1620 token_index,
1610 *StubCode::CallStaticFunction_entry(), 1621 *StubCode::CallStaticFunction_entry(),
1611 RawPcDescriptors::kOther, 1622 RawPcDescriptors::kOther,
1612 locs, 1623 locs,
1613 function); 1624 function);
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 __ movups(reg, Address(RSP, 0)); 1862 __ movups(reg, Address(RSP, 0));
1852 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); 1863 __ AddImmediate(RSP, Immediate(kFpuRegisterSize));
1853 } 1864 }
1854 1865
1855 1866
1856 #undef __ 1867 #undef __
1857 1868
1858 } // namespace dart 1869 } // namespace dart
1859 1870
1860 #endif // defined TARGET_ARCH_X64 1871 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_mips.cc ('k') | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698