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

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: 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
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 if (it.CurrentLocation().IsInvalid()) { 154 if (it.CurrentLocation().IsInvalid()) {
151 MaterializeObjectInstr* mat = 155 MaterializeObjectInstr* mat =
152 it.CurrentValue()->definition()->AsMaterializeObject(); 156 it.CurrentValue()->definition()->AsMaterializeObject();
153 ASSERT(mat != NULL); 157 ASSERT(mat != NULL);
154 builder->AddMaterialization(mat); 158 builder->AddMaterialization(mat);
155 } 159 }
156 } 160 }
157 } 161 }
158 162
159 163
164 bool FlowGraphCompiler::ShouldInlineSmiStringHashCode(const ICData& ic_data) {
165 if (!FLAG_inline_smi_string_hashcode) return false;
zra 2016/04/27 16:28:17 Please add curly braces. Maybe also merge with the
srdjan 2016/04/27 18:10:22 Done.
166 if (ic_data.target_name() != Symbols::hashCode().raw()) return false;
167 // Precompiled code has no ICData, optimistically inline it.
168 if (ic_data.IsNull() || (ic_data.NumberOfChecks() == 0)) return true;
zra 2016/04/27 16:28:17 ditto.
srdjan 2016/04/27 18:10:22 Done.
169 // Check if OneByteString is hot enough.
zra 2016/04/27 16:28:17 Sorry if I'm confused. So Smi hashcode will only b
srdjan 2016/04/27 18:10:22 Yes, because Smi test must be done anyway. Added
170 const ICData& ic_data_sorted =
171 ICData::Handle(ic_data.AsUnaryClassChecksSortedByCount());
172 ASSERT(ic_data_sorted.NumberOfChecks() > 0);
173 const intptr_t total_count = ic_data_sorted.AggregateCount();
174 const intptr_t ratio = ic_data_sorted.GetCountAt(0) * 100 / total_count;
zra 2016/04/27 16:28:17 Maybe add parens around the multiply.
srdjan 2016/04/27 18:10:22 Done.
175 return ratio > FLAG_inline_smi_string_hashcode_ratio;
176 }
177
178
160 FlowGraphCompiler::FlowGraphCompiler( 179 FlowGraphCompiler::FlowGraphCompiler(
161 Assembler* assembler, 180 Assembler* assembler,
162 FlowGraph* flow_graph, 181 FlowGraph* flow_graph,
163 const ParsedFunction& parsed_function, 182 const ParsedFunction& parsed_function,
164 bool is_optimizing, 183 bool is_optimizing,
165 const GrowableArray<const Function*>& inline_id_to_function, 184 const GrowableArray<const Function*>& inline_id_to_function,
166 const GrowableArray<TokenPosition>& inline_id_to_token_pos, 185 const GrowableArray<TokenPosition>& inline_id_to_token_pos,
167 const GrowableArray<intptr_t>& caller_inline_id) 186 const GrowableArray<intptr_t>& caller_inline_id)
168 : thread_(Thread::Current()), 187 : thread_(Thread::Current()),
169 zone_(Thread::Current()->zone()), 188 zone_(Thread::Current()->zone()),
(...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 1985
1967 1986
1968 void FlowGraphCompiler::FrameStateClear() { 1987 void FlowGraphCompiler::FrameStateClear() {
1969 ASSERT(!is_optimizing()); 1988 ASSERT(!is_optimizing());
1970 frame_state_.TruncateTo(0); 1989 frame_state_.TruncateTo(0);
1971 } 1990 }
1972 #endif // defined(DEBUG) && !defined(TARGET_ARCH_DBC) 1991 #endif // defined(DEBUG) && !defined(TARGET_ARCH_DBC)
1973 1992
1974 1993
1975 } // namespace dart 1994 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698