Reviewers: Michael Starzinger,

Description:
Change the maximum optimization count into a commandline flag.

This is needed for some unit tests, which otherwise do not test what people
think they do. ;-)


Please review this at https://chromiumcodereview.appspot.com/10823362/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/compiler.h
  M src/compiler.cc
  M src/flag-definitions.h
  M src/hydrogen.cc
  M src/objects.cc
  M src/runtime-profiler.cc


Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index dc82b8fbb36b6c457a7e1ad1743d75280da1cb2d..32570286b3a4d36e101062ac3143e898789b85b2 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -240,7 +240,7 @@ OptimizingCompiler::Status OptimizingCompiler::CreateGraph() {
   // Limit the number of times we re-compile a functions with
   // the optimizing compiler.
   const int kMaxOptCount =
-      FLAG_deopt_every_n_times == 0 ? Compiler::kDefaultMaxOptCount : 1000;
+      FLAG_deopt_every_n_times == 0 ? FLAG_max_opt_count : 1000;
   if (info()->shared_info()->opt_count() > kMaxOptCount) {
     return AbortOptimization();
   }
Index: src/compiler.h
diff --git a/src/compiler.h b/src/compiler.h
index 7a227bc9fcabc846c1b3277eb474d557f0c81b9b..e60e510e143f5eefd263848703670d6af324ba0a 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -410,10 +410,6 @@ class OptimizingCompiler: public ZoneObject {

 class Compiler : public AllStatic {
  public:
-  // Default maximum number of function optimization attempts before we
-  // give up.
-  static const int kDefaultMaxOptCount = 10;
-
   static const int kMaxInliningLevels = 3;

   // Call count before primitive functions trigger their own optimization.
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index 6ac882da02262ecba4f646bf01123570b1026e6e..48b3b402d8f22f80cd1b29c1c5c404b585a61ff7 100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -324,6 +324,8 @@ DEFINE_bool(always_full_compiler, false,
             "try to use the dedicated run-once backend for all code")
 DEFINE_bool(trace_bailout, false,
"print reasons for falling back to using the classic V8 backend")
+DEFINE_int(max_opt_count, 10,
+           "maximum number of optimization attempts before giving up.")

 // compilation-cache.cc
 DEFINE_bool(compilation_cache, true, "enable compilation cache")
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 1091622ea2802586a6d1a126c3c148e359f22979..1cd446434eb6d34dd872a66ca8689b1008a65192 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -2029,7 +2029,7 @@ void HGlobalValueNumberer::ProcessLoopBlock(


 bool HGlobalValueNumberer::AllowCodeMotion() {
- return info()->shared_info()->opt_count() + 1 < Compiler::kDefaultMaxOptCount;
+  return info()->shared_info()->opt_count() + 1 < FLAG_max_opt_count;
 }


Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 1067691335b9727e37aa6b1b9bdd4d54dc058c45..569b5d030bdf4b3e16f697874db164a46110dc67 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -7935,7 +7935,7 @@ void SharedFunctionInfo::ResetForNewContext(int new_ic_age) {
   if (code()->kind() == Code::FUNCTION) {
     code()->set_profiler_ticks(0);
     if (optimization_disabled() &&
-        opt_count() >= Compiler::kDefaultMaxOptCount) {
+        opt_count() >= FLAG_max_opt_count) {
// Re-enable optimizations if they were disabled due to opt_count limit.
       set_optimization_disabled(false);
       code()->set_optimizable(true);
Index: src/runtime-profiler.cc
diff --git a/src/runtime-profiler.cc b/src/runtime-profiler.cc
index e0e981271205b5016b9d56eb4b57b8c29c505012..23f41fa7d21cce30aace740db33228b6e9192acd 100644
--- a/src/runtime-profiler.cc
+++ b/src/runtime-profiler.cc
@@ -304,7 +304,7 @@ void RuntimeProfiler::OptimizeNow() {

     // Do not record non-optimizable functions.
     if (shared->optimization_disabled()) {
-      if (shared->deopt_count() >= Compiler::kDefaultMaxOptCount) {
+      if (shared->deopt_count() >= FLAG_max_opt_count) {
         // If optimization was disabled due to many deoptimizations,
// then check if the function is hot and try to reenable optimization.
         int ticks = shared_code->profiler_ticks();


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to