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

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: Review addressed 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
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_compiler.cc
diff --git a/runtime/vm/flow_graph_compiler.cc b/runtime/vm/flow_graph_compiler.cc
index 9d448ab5ef722658ef1e16f5e40512fe283a3c83..006053fe3a75998d51f3a4a8b610bece82adcdb0 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,
@@ -156,6 +160,31 @@ void CompilerDeoptInfo::EmitMaterializations(Environment* env,
}
+// Returns true if OnebyteString is a frequent receiver class. We inline
+// Smi check as well, since a Smi check must be done anyway.
+// TODO(srdjan): Add check and code if Smi class is hot.
+bool FlowGraphCompiler::ShouldInlineSmiStringHashCode(const ICData& ic_data) {
+ if (!FLAG_inline_smi_string_hashcode ||
+ (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;
+ }
+ // Check if OneByteString is hot enough.
+ const ICData& ic_data_sorted =
+ ICData::Handle(ic_data.AsUnaryClassChecksSortedByCount());
+ ASSERT(ic_data_sorted.NumberOfChecks() > 0);
+ if (ic_data_sorted.GetReceiverClassIdAt(0) == kOneByteStringCid) {
+ const intptr_t total_count = ic_data_sorted.AggregateCount();
+ const intptr_t ratio = (ic_data_sorted.GetCountAt(0) * 100) / total_count;
+ return ratio > FLAG_inline_smi_string_hashcode_ratio;
+ }
+ return false;
+}
+
+
FlowGraphCompiler::FlowGraphCompiler(
Assembler* assembler,
FlowGraph* flow_graph,
« 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