Chromium Code Reviews| Index: runtime/vm/flow_graph_compiler.cc |
| diff --git a/runtime/vm/flow_graph_compiler.cc b/runtime/vm/flow_graph_compiler.cc |
| index 6632df81ee0d88310c547462cd99173c52346506..4a1f51a7895ce1eaa51d4186d46e603ca75e2cc0 100644 |
| --- a/runtime/vm/flow_graph_compiler.cc |
| +++ b/runtime/vm/flow_graph_compiler.cc |
| @@ -32,6 +32,10 @@ namespace dart { |
| DEFINE_FLAG(bool, enable_simd_inline, true, |
| "Enable inlining of SIMD related method calls."); |
| +DEFINE_FLAG(bool, inline_smi_string_hashcode, true, |
| + "Inline hashcode for Smi and one-byte strings in case of megamorphic call"); |
| +DEFINE_FLAG(int, inline_smi_string_hashcode_ratio, 50, |
| + "Minimal hotness (0..100) of one-byte-string before inlining its hashcode"); |
| DEFINE_FLAG(int, min_optimization_counter_threshold, 5000, |
| "The minimum invocation count for a function."); |
| DEFINE_FLAG(int, optimization_counter_scale, 2000, |
| @@ -157,6 +161,21 @@ void CompilerDeoptInfo::EmitMaterializations(Environment* env, |
| } |
| +bool FlowGraphCompiler::ShouldInlineSmiStringHashCode(const ICData& ic_data) { |
| + 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.
|
| + if (ic_data.target_name() != Symbols::hashCode().raw()) return false; |
| + // Precompiled code has no ICData, optimistically inline it. |
| + 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.
|
| + // 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
|
| + const ICData& ic_data_sorted = |
| + ICData::Handle(ic_data.AsUnaryClassChecksSortedByCount()); |
| + ASSERT(ic_data_sorted.NumberOfChecks() > 0); |
| + const intptr_t total_count = ic_data_sorted.AggregateCount(); |
| + 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.
|
| + return ratio > FLAG_inline_smi_string_hashcode_ratio; |
| +} |
| + |
| + |
| FlowGraphCompiler::FlowGraphCompiler( |
| Assembler* assembler, |
| FlowGraph* flow_graph, |