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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
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,

Powered by Google App Engine
This is Rietveld 408576698