Revision: 16302
Author:   [email protected]
Date:     Fri Aug 23 13:30:02 2013 UTC
Log:      Add --trace-hydrogen-filter flag.

The flag restricts hydrogen.cfg output to functions passing the filter,
similar to what --hydrogen-filter does for optimization in general.

This is useful for investigating large repro cases where tracing all
functions would lead to an impractically large hydrogen.cfg file, but
restricting optimization using --hydrogen-filter is undesirable
(e.g. because it might cause the issue to no longer reproduce).

[email protected]

Review URL: https://codereview.chromium.org/22926025
http://code.google.com/p/v8/source/detail?r=16302

Modified:
 /branches/bleeding_edge/src/compiler.cc
 /branches/bleeding_edge/src/flag-definitions.h
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/runtime-profiler.cc

=======================================
--- /branches/bleeding_edge/src/compiler.cc     Thu Aug 22 16:14:37 2013 UTC
+++ /branches/bleeding_edge/src/compiler.cc     Fri Aug 23 13:30:02 2013 UTC
@@ -362,7 +362,7 @@
   }

   // Take --hydrogen-filter into account.
-  if (!info()->closure()->PassesHydrogenFilter()) {
+  if (!info()->closure()->PassesFilter(FLAG_hydrogen_filter)) {
     info()->AbortOptimization();
     return SetLastStatus(BAILED_OUT);
   }
@@ -1258,9 +1258,10 @@
 bool CompilationPhase::ShouldProduceTraceOutput() const {
   // Trace if the appropriate trace flag is set and the phase name's first
   // character is in the FLAG_trace_phase command line parameter.
-  bool tracing_on = info()->IsStub() ?
-      FLAG_trace_hydrogen_stubs :
-      FLAG_trace_hydrogen;
+  bool tracing_on = info()->IsStub()
+      ? FLAG_trace_hydrogen_stubs
+      : (FLAG_trace_hydrogen &&
+         info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
   return (tracing_on &&
       OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
 }
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h Fri Aug 23 13:24:48 2013 UTC +++ /branches/bleeding_edge/src/flag-definitions.h Fri Aug 23 13:30:02 2013 UTC
@@ -256,6 +256,7 @@
             "crankshaft harvests type feedback from stub cache")
 DEFINE_bool(hydrogen_stats, false, "print statistics for hydrogen")
 DEFINE_bool(trace_hydrogen, false, "trace generated hydrogen to file")
+DEFINE_string(trace_hydrogen_filter, "*", "hydrogen tracing filter")
DEFINE_bool(trace_hydrogen_stubs, false, "trace generated hydrogen for stubs") DEFINE_string(trace_hydrogen_file, NULL, "trace hydrogen to given file name") DEFINE_string(trace_phase, "HLZ", "trace generated IR for specified phases")
=======================================
--- /branches/bleeding_edge/src/objects.cc      Fri Aug 23 13:21:01 2013 UTC
+++ /branches/bleeding_edge/src/objects.cc      Fri Aug 23 13:30:02 2013 UTC
@@ -9620,31 +9620,28 @@
 }


-bool JSFunction::PassesHydrogenFilter() {
+// The filter is a pattern that matches function names in this way:
+//   "*"      all; the default
+//   "-"      all but the top-level function
+//   "-name"  all but the function "name"
+//   ""       only the top-level function
+//   "name"   only the function "name"
+//   "name*"  only functions starting with "name"
+bool JSFunction::PassesFilter(const char* raw_filter) {
+  if (*raw_filter == '*') return true;
   String* name = shared()->DebugName();
-  // The filter string is a pattern that matches functions in this way:
-  //   "*"      all; the default
-  //   "-"      all but the top-level function
-  //   "-name"  all but the function "name"
-  //   ""       only the top-level function
-  //   "name"   only the function "name"
-  //   "name*"  only functions starting with "name"
-  if (*FLAG_hydrogen_filter != '*') {
-    Vector<const char> filter = CStrVector(FLAG_hydrogen_filter);
-    if (filter.length() == 0) return name->length() == 0;
-    if (filter[0] != '-' && name->IsUtf8EqualTo(filter)) return true;
-    if (filter[0] == '-' &&
-        !name->IsUtf8EqualTo(filter.SubVector(1, filter.length()))) {
-      return true;
-    }
-    if (filter[filter.length() - 1] == '*' &&
- name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) {
-      return true;
-    }
-    return false;
+  Vector<const char> filter = CStrVector(raw_filter);
+  if (filter.length() == 0) return name->length() == 0;
+  if (filter[0] != '-' && name->IsUtf8EqualTo(filter)) return true;
+  if (filter[0] == '-' &&
+      !name->IsUtf8EqualTo(filter.SubVector(1, filter.length()))) {
+    return true;
+  }
+  if (filter[filter.length() - 1] == '*' &&
+ name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) {
+    return true;
   }
-
-  return true;
+  return false;
 }


=======================================
--- /branches/bleeding_edge/src/objects.h       Fri Aug 23 13:21:01 2013 UTC
+++ /branches/bleeding_edge/src/objects.h       Fri Aug 23 13:30:02 2013 UTC
@@ -7081,7 +7081,8 @@
   // Retrieve the native context from a function's literal array.
   static Context* NativeContextFromLiterals(FixedArray* literals);

-  bool PassesHydrogenFilter();
+  // Used for flags such as --hydrogen-filter.
+  bool PassesFilter(const char* raw_filter);

   // Layout descriptors. The last property (from kNonWeakFieldsEndOffset to
   // kSize) is weak and has special handling during garbage collection.
=======================================
--- /branches/bleeding_edge/src/runtime-profiler.cc Thu Aug 22 16:14:37 2013 UTC +++ /branches/bleeding_edge/src/runtime-profiler.cc Fri Aug 23 13:30:02 2013 UTC
@@ -127,7 +127,7 @@
 void RuntimeProfiler::Optimize(JSFunction* function, const char* reason) {
   ASSERT(function->IsOptimizable());

-  if (FLAG_trace_opt && function->PassesHydrogenFilter()) {
+  if (FLAG_trace_opt && function->PassesFilter(FLAG_hydrogen_filter)) {
     PrintF("[marking ");
     function->ShortPrint();
     PrintF(" for recompilation, reason: %s", reason);

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to