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

Unified Diff: runtime/vm/code_generator.cc

Issue 9460015: Do not count invocations but usage of a function, i.e., increment a function's counter at IC calls … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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 | « no previous file | runtime/vm/code_generator_arm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator.cc
===================================================================
--- runtime/vm/code_generator.cc (revision 4582)
+++ runtime/vm/code_generator.cc (working copy)
@@ -24,10 +24,21 @@
DEFINE_FLAG(bool, trace_ic, false, "trace IC handling");
DEFINE_FLAG(bool, trace_patching, false, "Trace patching of code.");
DEFINE_FLAG(bool, trace_runtime_calls, false, "Trace runtime calls.");
+DEFINE_FLAG(int, optimization_counter_threshold, 2000,
+ "function's usage-counter value before it is optimized, -1 means never.");
+DECLARE_FLAG(bool, trace_type_checks);
+DECLARE_FLAG(bool, report_usage_count);
DECLARE_FLAG(int, deoptimization_counter_threshold);
-DECLARE_FLAG(bool, trace_type_checks);
+bool CodeGenerator::CanOptimize() {
+ return
+ !FLAG_report_usage_count &&
+ (FLAG_optimization_counter_threshold >= 0) &&
+ !Isolate::Current()->debugger()->IsActive();
+}
+
+
void CodeGenerator::DescriptorList::AddDescriptor(
PcDescriptors::Kind kind,
intptr_t pc_offset,
@@ -952,9 +963,18 @@
if (function.deoptimization_counter() >=
FLAG_deoptimization_counter_threshold) {
// TODO(srdjan): Investigate excessive deoptimization.
- function.set_invocation_counter(0);
+ function.set_usage_counter(0);
return;
}
+ if (Code::Handle(function.code()).is_optimized()) {
+ // The caller has been already optimized.
+ // TODO(srdjan): This is a significant slowdown, the caller is probably in
+ // a loop. Maybe test if the code has been optimized before calling.
+ // If this happens from optimized code, then it means that the optimized
+ // code needs to be reoptimized.
+ function.set_usage_counter(0);
+ return;
+ }
if (function.is_optimizable()) {
ASSERT(!Code::Handle(function.code()).is_optimized());
const Code& unoptimized_code = Code::Handle(function.code());
@@ -969,7 +989,7 @@
ASSERT(!unoptimized_code.IsNull());
} else {
// TODO(5442338): Abort as this should not happen.
- function.set_invocation_counter(0);
+ function.set_usage_counter(0);
}
}
@@ -1061,7 +1081,7 @@
caller_frame->set_pc(continue_at_pc);
// Clear invocation counter so that the function gets optimized after
// types/classes have been collected.
- function.set_invocation_counter(0);
+ function.set_usage_counter(0);
function.set_deoptimization_counter(function.deoptimization_counter() + 1);
// We have to skip the following otherwise the compiler will complain
« no previous file with comments | « no previous file | runtime/vm/code_generator_arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698