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

Side by Side Diff: runtime/vm/flow_graph_compiler_ia32.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_arm64.cc ('k') | runtime/vm/flow_graph_compiler_mips.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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 ASSERT(is_optimizing()); 1434 ASSERT(is_optimizing());
1435 ASSERT(!complete); 1435 ASSERT(!complete);
1436 __ Comment("EmitTestAndCall"); 1436 __ Comment("EmitTestAndCall");
1437 const Array& arguments_descriptor = Array::ZoneHandle( 1437 const Array& arguments_descriptor = Array::ZoneHandle(
1438 zone(), ArgumentsDescriptor::New(argument_count, argument_names)); 1438 zone(), ArgumentsDescriptor::New(argument_count, argument_names));
1439 // Load receiver into EAX. 1439 // Load receiver into EAX.
1440 __ movl(EAX, Address(ESP, (argument_count - 1) * kWordSize)); 1440 __ movl(EAX, Address(ESP, (argument_count - 1) * kWordSize));
1441 __ LoadObject(EDX, arguments_descriptor); 1441 __ LoadObject(EDX, arguments_descriptor);
1442 1442
1443 const bool kFirstCheckIsSmi = ic_data.GetReceiverClassIdAt(0) == kSmiCid; 1443 const bool kFirstCheckIsSmi = ic_data.GetReceiverClassIdAt(0) == kSmiCid;
1444 const intptr_t kNumChecks = ic_data.NumberOfChecks(); 1444 const intptr_t num_checks = ic_data.NumberOfChecks();
1445 1445
1446 ASSERT(!ic_data.IsNull() && (kNumChecks > 0)); 1446 ASSERT(!ic_data.IsNull() && (num_checks > 0));
1447 1447
1448 Label after_smi_test; 1448 Label after_smi_test;
1449 __ testl(EAX, Immediate(kSmiTagMask)); 1449 __ testl(EAX, Immediate(kSmiTagMask));
1450 if (kFirstCheckIsSmi) { 1450 if (kFirstCheckIsSmi) {
1451 // Jump if receiver is not Smi. 1451 // Jump if receiver is not Smi.
1452 if (kNumChecks == 1) { 1452 if (num_checks == 1) {
1453 __ j(NOT_ZERO, failed); 1453 __ j(NOT_ZERO, failed);
1454 } else { 1454 } else {
1455 __ j(NOT_ZERO, &after_smi_test); 1455 __ j(NOT_ZERO, &after_smi_test);
1456 } 1456 }
1457 // Do not use the code from the function, but let the code be patched so 1457 // Do not use the code from the function, but let the code be patched so
1458 // that we can record the outgoing edges to other code. 1458 // that we can record the outgoing edges to other code.
1459 GenerateDartCall(deopt_id, token_index, 1459 GenerateDartCall(deopt_id, token_index,
1460 *StubCode::CallStaticFunction_entry(), 1460 *StubCode::CallStaticFunction_entry(),
1461 RawPcDescriptors::kOther, locs); 1461 RawPcDescriptors::kOther, locs);
1462 const Function& function = 1462 const Function& function =
1463 Function::ZoneHandle(zone(), ic_data.GetTargetAt(0)); 1463 Function::ZoneHandle(zone(), ic_data.GetTargetAt(0));
1464 AddStaticCallTarget(function); 1464 AddStaticCallTarget(function);
1465 __ Drop(argument_count); 1465 __ Drop(argument_count);
1466 if (kNumChecks > 1) { 1466 if (num_checks > 1) {
1467 __ jmp(match_found); 1467 __ jmp(match_found);
1468 } 1468 }
1469 } else { 1469 } else {
1470 // Receiver is Smi, but Smi is not a valid class therefore fail. 1470 // Receiver is Smi, but Smi is not a valid class therefore fail.
1471 // (Smi class must be first in the list). 1471 // (Smi class must be first in the list).
1472 __ j(ZERO, failed); 1472 __ j(ZERO, failed);
1473 } 1473 }
1474 __ Bind(&after_smi_test); 1474 __ Bind(&after_smi_test);
1475 1475
1476 ASSERT(!ic_data.IsNull() && (kNumChecks > 0)); 1476 ASSERT(!ic_data.IsNull() && (num_checks > 0));
1477 GrowableArray<CidTarget> sorted(kNumChecks); 1477 GrowableArray<CidTarget> sorted(num_checks);
1478 SortICDataByCount(ic_data, &sorted, /* drop_smi = */ true); 1478 SortICDataByCount(ic_data, &sorted, /* drop_smi = */ true);
1479 1479
1480 // Value is not Smi, 1480 // Value is not Smi,
1481 // LoadValueCid(this, EDI, EAX, failed); 1481 // LoadValueCid(this, EDI, EAX, failed);
1482 const intptr_t kSortedLen = sorted.length(); 1482 const intptr_t kSortedLen = sorted.length();
1483 // If kSortedLen is 0 then only a Smi check was needed; the Smi check above 1483 // If kSortedLen is 0 then only a Smi check was needed; the Smi check above
1484 // will fail if there was only one check and receiver is not Smi. 1484 // will fail if there was only one check and receiver is not Smi.
1485 if (kSortedLen == 0) return; 1485 if (kSortedLen == 0) return;
1486 1486
1487 __ LoadClassId(EDI, EAX); 1487 __ LoadClassId(EDI, EAX);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 __ movups(reg, Address(ESP, 0)); 1770 __ movups(reg, Address(ESP, 0));
1771 __ addl(ESP, Immediate(kFpuRegisterSize)); 1771 __ addl(ESP, Immediate(kFpuRegisterSize));
1772 } 1772 }
1773 1773
1774 1774
1775 #undef __ 1775 #undef __
1776 1776
1777 } // namespace dart 1777 } // namespace dart
1778 1778
1779 #endif // defined TARGET_ARCH_IA32 1779 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_arm64.cc ('k') | runtime/vm/flow_graph_compiler_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698