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

Side by Side Diff: runtime/vm/flow_graph_compiler.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/dart_api_impl.cc ('k') | runtime/vm/flow_graph_compiler_arm.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_XXX. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX.
6 6
7 #include "vm/flow_graph_compiler.h" 7 #include "vm/flow_graph_compiler.h"
8 8
9 #include "vm/bit_vector.h" 9 #include "vm/bit_vector.h"
10 #include "vm/cha.h" 10 #include "vm/cha.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 // Returns true if OnebyteString is a frequent receiver class. We inline 155 // Returns true if OnebyteString is a frequent receiver class. We inline
156 // Smi check as well, since a Smi check must be done anyway. 156 // Smi check as well, since a Smi check must be done anyway.
157 // TODO(srdjan): Add check and code if Smi class is hot. 157 // TODO(srdjan): Add check and code if Smi class is hot.
158 bool FlowGraphCompiler::ShouldInlineSmiStringHashCode(const ICData& ic_data) { 158 bool FlowGraphCompiler::ShouldInlineSmiStringHashCode(const ICData& ic_data) {
159 if (!FLAG_inline_smi_string_hashcode || 159 if (!FLAG_inline_smi_string_hashcode ||
160 (ic_data.target_name() != Symbols::hashCode().raw())) { 160 (ic_data.target_name() != Symbols::hashCode().raw())) {
161 return false; 161 return false;
162 } 162 }
163 // Precompiled code has no ICData, optimistically inline it. 163 // Precompiled code has no ICData, optimistically inline it.
164 if (ic_data.IsNull() || (ic_data.NumberOfChecks() == 0)) { 164 if (ic_data.IsNull() || ic_data.NumberOfChecksIs(0)) {
165 return true; 165 return true;
166 } 166 }
167 // Check if OneByteString is hot enough. 167 // Check if OneByteString is hot enough.
168 const ICData& ic_data_sorted = 168 const ICData& ic_data_sorted =
169 ICData::Handle(ic_data.AsUnaryClassChecksSortedByCount()); 169 ICData::Handle(ic_data.AsUnaryClassChecksSortedByCount());
170 ASSERT(ic_data_sorted.NumberOfChecks() > 0); 170 ASSERT(!ic_data_sorted.NumberOfChecksIs(0));
171 if (ic_data_sorted.GetReceiverClassIdAt(0) == kOneByteStringCid) { 171 if (ic_data_sorted.GetReceiverClassIdAt(0) == kOneByteStringCid) {
172 const intptr_t total_count = ic_data_sorted.AggregateCount(); 172 const intptr_t total_count = ic_data_sorted.AggregateCount();
173 const intptr_t ratio = (ic_data_sorted.GetCountAt(0) * 100) / total_count; 173 const intptr_t ratio = (ic_data_sorted.GetCountAt(0) * 100) / total_count;
174 return ratio > FLAG_inline_smi_string_hashcode_ratio; 174 return ratio > FLAG_inline_smi_string_hashcode_ratio;
175 } 175 }
176 return false; 176 return false;
177 } 177 }
178 178
179 179
180 FlowGraphCompiler::FlowGraphCompiler( 180 FlowGraphCompiler::FlowGraphCompiler(
(...skipping 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 1886
1887 1887
1888 void FlowGraphCompiler::FrameStateClear() { 1888 void FlowGraphCompiler::FrameStateClear() {
1889 ASSERT(!is_optimizing()); 1889 ASSERT(!is_optimizing());
1890 frame_state_.TruncateTo(0); 1890 frame_state_.TruncateTo(0);
1891 } 1891 }
1892 #endif // defined(DEBUG) && !defined(TARGET_ARCH_DBC) 1892 #endif // defined(DEBUG) && !defined(TARGET_ARCH_DBC)
1893 1893
1894 1894
1895 } // namespace dart 1895 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/flow_graph_compiler_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698