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

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

Issue 1920103004: Added flag --inline_smi_string_hashcode and --inline_smi_string_hashcode_ratio to decide when/if sh… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Review addressed Created 4 years, 7 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.h ('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 14 matching lines...) Expand all
25 #include "vm/raw_object.h" 25 #include "vm/raw_object.h"
26 #include "vm/stack_frame.h" 26 #include "vm/stack_frame.h"
27 #include "vm/stub_code.h" 27 #include "vm/stub_code.h"
28 #include "vm/symbols.h" 28 #include "vm/symbols.h"
29 #include "vm/timeline.h" 29 #include "vm/timeline.h"
30 30
31 namespace dart { 31 namespace dart {
32 32
33 DEFINE_FLAG(bool, enable_simd_inline, true, 33 DEFINE_FLAG(bool, enable_simd_inline, true,
34 "Enable inlining of SIMD related method calls."); 34 "Enable inlining of SIMD related method calls.");
35 DEFINE_FLAG(bool, inline_smi_string_hashcode, true,
36 "Inline hashcode for Smi and one-byte strings in case of megamorphic call");
37 DEFINE_FLAG(int, inline_smi_string_hashcode_ratio, 50,
38 "Minimal hotness (0..100) of one-byte-string before inlining its hashcode");
35 DEFINE_FLAG(int, min_optimization_counter_threshold, 5000, 39 DEFINE_FLAG(int, min_optimization_counter_threshold, 5000,
36 "The minimum invocation count for a function."); 40 "The minimum invocation count for a function.");
37 DEFINE_FLAG(int, optimization_counter_scale, 2000, 41 DEFINE_FLAG(int, optimization_counter_scale, 2000,
38 "The scale of invocation count, by size of the function."); 42 "The scale of invocation count, by size of the function.");
39 DEFINE_FLAG(bool, source_lines, false, "Emit source line as assembly comment."); 43 DEFINE_FLAG(bool, source_lines, false, "Emit source line as assembly comment.");
40 DEFINE_FLAG(bool, trace_inlining_intervals, false, 44 DEFINE_FLAG(bool, trace_inlining_intervals, false,
41 "Inlining interval diagnostics"); 45 "Inlining interval diagnostics");
42 DEFINE_FLAG(bool, use_megamorphic_stub, true, "Out of line megamorphic lookup"); 46 DEFINE_FLAG(bool, use_megamorphic_stub, true, "Out of line megamorphic lookup");
43 47
44 DECLARE_FLAG(bool, code_comments); 48 DECLARE_FLAG(bool, code_comments);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (it.CurrentLocation().IsInvalid()) { 153 if (it.CurrentLocation().IsInvalid()) {
150 MaterializeObjectInstr* mat = 154 MaterializeObjectInstr* mat =
151 it.CurrentValue()->definition()->AsMaterializeObject(); 155 it.CurrentValue()->definition()->AsMaterializeObject();
152 ASSERT(mat != NULL); 156 ASSERT(mat != NULL);
153 builder->AddMaterialization(mat); 157 builder->AddMaterialization(mat);
154 } 158 }
155 } 159 }
156 } 160 }
157 161
158 162
163 // Returns true if OnebyteString is a frequent receiver class. We inline
164 // Smi check as well, since a Smi check must be done anyway.
165 // TODO(srdjan): Add check and code if Smi class is hot.
166 bool FlowGraphCompiler::ShouldInlineSmiStringHashCode(const ICData& ic_data) {
167 if (!FLAG_inline_smi_string_hashcode ||
168 (ic_data.target_name() != Symbols::hashCode().raw())) {
169 return false;
170 }
171 // Precompiled code has no ICData, optimistically inline it.
172 if (ic_data.IsNull() || (ic_data.NumberOfChecks() == 0)) {
173 return true;
174 }
175 // Check if OneByteString is hot enough.
176 const ICData& ic_data_sorted =
177 ICData::Handle(ic_data.AsUnaryClassChecksSortedByCount());
178 ASSERT(ic_data_sorted.NumberOfChecks() > 0);
179 if (ic_data_sorted.GetReceiverClassIdAt(0) == kOneByteStringCid) {
180 const intptr_t total_count = ic_data_sorted.AggregateCount();
181 const intptr_t ratio = (ic_data_sorted.GetCountAt(0) * 100) / total_count;
182 return ratio > FLAG_inline_smi_string_hashcode_ratio;
183 }
184 return false;
185 }
186
187
159 FlowGraphCompiler::FlowGraphCompiler( 188 FlowGraphCompiler::FlowGraphCompiler(
160 Assembler* assembler, 189 Assembler* assembler,
161 FlowGraph* flow_graph, 190 FlowGraph* flow_graph,
162 const ParsedFunction& parsed_function, 191 const ParsedFunction& parsed_function,
163 bool is_optimizing, 192 bool is_optimizing,
164 const GrowableArray<const Function*>& inline_id_to_function, 193 const GrowableArray<const Function*>& inline_id_to_function,
165 const GrowableArray<TokenPosition>& inline_id_to_token_pos, 194 const GrowableArray<TokenPosition>& inline_id_to_token_pos,
166 const GrowableArray<intptr_t>& caller_inline_id) 195 const GrowableArray<intptr_t>& caller_inline_id)
167 : thread_(Thread::Current()), 196 : thread_(Thread::Current()),
168 zone_(Thread::Current()->zone()), 197 zone_(Thread::Current()->zone()),
(...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 1994
1966 1995
1967 void FlowGraphCompiler::FrameStateClear() { 1996 void FlowGraphCompiler::FrameStateClear() {
1968 ASSERT(!is_optimizing()); 1997 ASSERT(!is_optimizing());
1969 frame_state_.TruncateTo(0); 1998 frame_state_.TruncateTo(0);
1970 } 1999 }
1971 #endif // defined(DEBUG) && !defined(TARGET_ARCH_DBC) 2000 #endif // defined(DEBUG) && !defined(TARGET_ARCH_DBC)
1972 2001
1973 2002
1974 } // namespace dart 2003 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler.h ('k') | runtime/vm/flow_graph_compiler_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698