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

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

Issue 2734883002: ICData::NumberOfChecks is O(n) so don't call it in loops (Closed)
Patch Set: Add const Created 3 years, 9 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 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 ASSERT(is_optimizing()); 1551 ASSERT(is_optimizing());
1552 __ Comment("EmitTestAndCall"); 1552 __ Comment("EmitTestAndCall");
1553 const Array& arguments_descriptor = Array::ZoneHandle( 1553 const Array& arguments_descriptor = Array::ZoneHandle(
1554 zone(), ArgumentsDescriptor::New(argument_count, argument_names)); 1554 zone(), ArgumentsDescriptor::New(argument_count, argument_names));
1555 1555
1556 // Load receiver into T0. 1556 // Load receiver into T0.
1557 __ LoadFromOffset(T0, SP, (argument_count - 1) * kWordSize); 1557 __ LoadFromOffset(T0, SP, (argument_count - 1) * kWordSize);
1558 __ LoadObject(S4, arguments_descriptor); 1558 __ LoadObject(S4, arguments_descriptor);
1559 1559
1560 const bool kFirstCheckIsSmi = ic_data.GetReceiverClassIdAt(0) == kSmiCid; 1560 const bool kFirstCheckIsSmi = ic_data.GetReceiverClassIdAt(0) == kSmiCid;
1561 const intptr_t kNumChecks = ic_data.NumberOfChecks(); 1561 const intptr_t num_checks = ic_data.NumberOfChecks();
1562 1562
1563 ASSERT(!ic_data.IsNull() && (kNumChecks > 0)); 1563 ASSERT(!ic_data.IsNull() && (num_checks > 0));
1564 1564
1565 Label after_smi_test; 1565 Label after_smi_test;
1566 if (kFirstCheckIsSmi) { 1566 if (kFirstCheckIsSmi) {
1567 __ andi(CMPRES1, T0, Immediate(kSmiTagMask)); 1567 __ andi(CMPRES1, T0, Immediate(kSmiTagMask));
1568 // Jump if receiver is not Smi. 1568 // Jump if receiver is not Smi.
1569 if (kNumChecks == 1) { 1569 if (num_checks == 1) {
1570 __ bne(CMPRES1, ZR, failed); 1570 __ bne(CMPRES1, ZR, failed);
1571 } else { 1571 } else {
1572 __ bne(CMPRES1, ZR, &after_smi_test); 1572 __ bne(CMPRES1, ZR, &after_smi_test);
1573 } 1573 }
1574 // Do not use the code from the function, but let the code be patched so 1574 // Do not use the code from the function, but let the code be patched so
1575 // that we can record the outgoing edges to other code. 1575 // that we can record the outgoing edges to other code.
1576 const Function& function = 1576 const Function& function =
1577 Function::ZoneHandle(zone(), ic_data.GetTargetAt(0)); 1577 Function::ZoneHandle(zone(), ic_data.GetTargetAt(0));
1578 GenerateStaticDartCall(deopt_id, token_index, 1578 GenerateStaticDartCall(deopt_id, token_index,
1579 *StubCode::CallStaticFunction_entry(), 1579 *StubCode::CallStaticFunction_entry(),
1580 RawPcDescriptors::kOther, locs, function); 1580 RawPcDescriptors::kOther, locs, function);
1581 __ Drop(argument_count); 1581 __ Drop(argument_count);
1582 if (kNumChecks > 1) { 1582 if (num_checks > 1) {
1583 __ b(match_found); 1583 __ b(match_found);
1584 } 1584 }
1585 } else { 1585 } else {
1586 // Receiver is Smi, but Smi is not a valid class therefore fail. 1586 // Receiver is Smi, but Smi is not a valid class therefore fail.
1587 // (Smi class must be first in the list). 1587 // (Smi class must be first in the list).
1588 if (!complete) { 1588 if (!complete) {
1589 __ andi(CMPRES1, T0, Immediate(kSmiTagMask)); 1589 __ andi(CMPRES1, T0, Immediate(kSmiTagMask));
1590 __ beq(CMPRES1, ZR, failed); 1590 __ beq(CMPRES1, ZR, failed);
1591 } 1591 }
1592 } 1592 }
1593 1593
1594 __ Bind(&after_smi_test); 1594 __ Bind(&after_smi_test);
1595 1595
1596 GrowableArray<CidTarget> sorted(kNumChecks); 1596 GrowableArray<CidTarget> sorted(num_checks);
1597 SortICDataByCount(ic_data, &sorted, /* drop_smi = */ true); 1597 SortICDataByCount(ic_data, &sorted, /* drop_smi = */ true);
1598 1598
1599 // Value is not Smi, 1599 // Value is not Smi,
1600 const intptr_t kSortedLen = sorted.length(); 1600 const intptr_t kSortedLen = sorted.length();
1601 // If kSortedLen is 0 then only a Smi check was needed; the Smi check above 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. 1602 // will fail if there was only one check and receiver is not Smi.
1603 if (kSortedLen == 0) return; 1603 if (kSortedLen == 0) return;
1604 1604
1605 __ LoadClassId(T2, T0); 1605 __ LoadClassId(T2, T0);
1606 for (intptr_t i = 0; i < kSortedLen; i++) { 1606 for (intptr_t i = 0; i < kSortedLen; i++) {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 __ AddImmediate(SP, kDoubleSize); 1869 __ AddImmediate(SP, kDoubleSize);
1870 } 1870 }
1871 1871
1872 1872
1873 #undef __ 1873 #undef __
1874 1874
1875 1875
1876 } // namespace dart 1876 } // namespace dart
1877 1877
1878 #endif // defined TARGET_ARCH_MIPS 1878 #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