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

Side by Side Diff: runtime/vm/flow_graph_compiler_x64.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_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 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 ASSERT(is_optimizing()); 1458 ASSERT(is_optimizing());
1459 1459
1460 __ Comment("EmitTestAndCall"); 1460 __ Comment("EmitTestAndCall");
1461 const Array& arguments_descriptor = Array::ZoneHandle( 1461 const Array& arguments_descriptor = Array::ZoneHandle(
1462 zone(), ArgumentsDescriptor::New(argument_count, argument_names)); 1462 zone(), ArgumentsDescriptor::New(argument_count, argument_names));
1463 // Load receiver into RAX. 1463 // Load receiver into RAX.
1464 __ movq(RAX, Address(RSP, (argument_count - 1) * kWordSize)); 1464 __ movq(RAX, Address(RSP, (argument_count - 1) * kWordSize));
1465 __ LoadObject(R10, arguments_descriptor); 1465 __ LoadObject(R10, arguments_descriptor);
1466 1466
1467 const bool kFirstCheckIsSmi = ic_data.GetReceiverClassIdAt(0) == kSmiCid; 1467 const bool kFirstCheckIsSmi = ic_data.GetReceiverClassIdAt(0) == kSmiCid;
1468 const intptr_t kNumChecks = ic_data.NumberOfChecks(); 1468 const intptr_t num_checks = ic_data.NumberOfChecks();
1469 1469
1470 ASSERT(!ic_data.IsNull() && (kNumChecks > 0)); 1470 ASSERT(!ic_data.IsNull() && (num_checks > 0));
1471 1471
1472 Label after_smi_test; 1472 Label after_smi_test;
1473 if (kFirstCheckIsSmi) { 1473 if (kFirstCheckIsSmi) {
1474 __ testq(RAX, Immediate(kSmiTagMask)); 1474 __ testq(RAX, Immediate(kSmiTagMask));
1475 // Jump if receiver is not Smi. 1475 // Jump if receiver is not Smi.
1476 if (kNumChecks == 1) { 1476 if (num_checks == 1) {
1477 __ j(NOT_ZERO, failed); 1477 __ j(NOT_ZERO, failed);
1478 } else { 1478 } else {
1479 __ j(NOT_ZERO, &after_smi_test); 1479 __ j(NOT_ZERO, &after_smi_test);
1480 } 1480 }
1481 // Do not use the code from the function, but let the code be patched so 1481 // Do not use the code from the function, but let the code be patched so
1482 // that we can record the outgoing edges to other code. 1482 // that we can record the outgoing edges to other code.
1483 const Function& function = 1483 const Function& function =
1484 Function::ZoneHandle(zone(), ic_data.GetTargetAt(0)); 1484 Function::ZoneHandle(zone(), ic_data.GetTargetAt(0));
1485 GenerateStaticDartCall(deopt_id, token_index, 1485 GenerateStaticDartCall(deopt_id, token_index,
1486 *StubCode::CallStaticFunction_entry(), 1486 *StubCode::CallStaticFunction_entry(),
1487 RawPcDescriptors::kOther, locs, function); 1487 RawPcDescriptors::kOther, locs, function);
1488 __ Drop(argument_count, RCX); 1488 __ Drop(argument_count, RCX);
1489 if (kNumChecks > 1) { 1489 if (num_checks > 1) {
1490 __ jmp(match_found); 1490 __ jmp(match_found);
1491 } 1491 }
1492 } else { 1492 } else {
1493 // Receiver is Smi, but Smi is not a valid class therefore fail. 1493 // Receiver is Smi, but Smi is not a valid class therefore fail.
1494 // (Smi class must be first in the list). 1494 // (Smi class must be first in the list).
1495 if (!complete) { 1495 if (!complete) {
1496 __ testq(RAX, Immediate(kSmiTagMask)); 1496 __ testq(RAX, Immediate(kSmiTagMask));
1497 __ j(ZERO, failed); 1497 __ j(ZERO, failed);
1498 } 1498 }
1499 } 1499 }
1500 __ Bind(&after_smi_test); 1500 __ Bind(&after_smi_test);
1501 1501
1502 ASSERT(!ic_data.IsNull() && (kNumChecks > 0)); 1502 ASSERT(!ic_data.IsNull() && (num_checks > 0));
1503 GrowableArray<CidTarget> sorted(kNumChecks); 1503 GrowableArray<CidTarget> sorted(num_checks);
1504 SortICDataByCount(ic_data, &sorted, /* drop_smi = */ true); 1504 SortICDataByCount(ic_data, &sorted, /* drop_smi = */ true);
1505 1505
1506 const intptr_t kSortedLen = sorted.length(); 1506 const intptr_t kSortedLen = sorted.length();
1507 // If kSortedLen is 0 then only a Smi check was needed; the Smi check above 1507 // If kSortedLen is 0 then only a Smi check was needed; the Smi check above
1508 // will fail if there was only one check and receiver is not Smi. 1508 // will fail if there was only one check and receiver is not Smi.
1509 if (kSortedLen == 0) return; 1509 if (kSortedLen == 0) return;
1510 1510
1511 // Value is not Smi, 1511 // Value is not Smi,
1512 __ LoadClassId(RDI, RAX); 1512 __ LoadClassId(RDI, RAX);
1513 for (intptr_t i = 0; i < kSortedLen; i++) { 1513 for (intptr_t i = 0; i < kSortedLen; i++) {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 __ movups(reg, Address(RSP, 0)); 1772 __ movups(reg, Address(RSP, 0));
1773 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); 1773 __ AddImmediate(RSP, Immediate(kFpuRegisterSize));
1774 } 1774 }
1775 1775
1776 1776
1777 #undef __ 1777 #undef __
1778 1778
1779 } // namespace dart 1779 } // namespace dart
1780 1780
1781 #endif // defined TARGET_ARCH_X64 1781 #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