Reviewers: Michael Starzinger,

Message:
PTAL.

Description:
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).

Please review this at https://codereview.chromium.org/22926025/

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

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


Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 0460da1d089c6c79478bb6b64782a6dbfdc082fa..d82f33d7865774529ebe77d6fd3364cde27e3c38 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -1258,9 +1258,11 @@ CompilationPhase::~CompilationPhase() {
 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()->function()->debug_name()->PassesFilter(
+             FLAG_trace_hydrogen_filter));
   return (tracing_on &&
       OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
 }
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index 33397a7807cbe571e7de4d247112da495b26a1e5..9591b9b2cfe98355bec502dd4bb61464720dea2f 100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -256,6 +256,7 @@ DEFINE_bool(collect_megamorphic_maps_from_stub_cache,
             "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")
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index daa5a4a5bdad825e7d73fc42531df9e23ac848b6..2a5fea22ee8b2be93e441c241fa4cc9ccac1a843 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -9032,6 +9032,23 @@ void String::PrintOn(FILE* file) {
 }


+bool String::PassesFilter(const char* raw_filter) {
+  if (*raw_filter == '*') return true;
+  Vector<const char> filter = CStrVector(raw_filter);
+  if (filter.length() == 0) return this->length() == 0;
+  if (filter[0] != '-' && this->IsUtf8EqualTo(filter)) return true;
+  if (filter[0] == '-' &&
+      !this->IsUtf8EqualTo(filter.SubVector(1, filter.length()))) {
+    return true;
+  }
+  if (filter[filter.length() - 1] == '*' &&
+ this->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) {
+    return true;
+  }
+  return false;
+}
+
+
static void TrimEnumCache(Heap* heap, Map* map, DescriptorArray* descriptors) {
   int live_enum = map->EnumLength();
   if (live_enum == Map::kInvalidEnumCache) {
@@ -9621,30 +9638,7 @@ Context* JSFunction::NativeContextFromLiterals(FixedArray* literals) {


 bool JSFunction::PassesHydrogenFilter() {
-  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;
-  }
-
-  return true;
+  return shared()->DebugName()->PassesFilter(FLAG_hydrogen_filter);
 }


Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index c75a419072654a7a62e5863c0d61d7cbd768b674..0a014e49a51f30b7a2595df06b5a89402e96d66d 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -8299,6 +8299,16 @@ class String: public Name {

   void PrintOn(FILE* out);

+  // Used for flags such as --hydrogen-filter.
+  // The filter is a pattern that matches strings in this way:
+  //   "*"      all; the default
+  //   "-"      all but the empty string (e.g. top-level function's name)
+  //   "-name"  all but the string "name"
+  //   ""       only the empty string (e.g. top-level function's name)
+  //   "name"   only the string "name"
+  //   "name*"  only strings starting with "name"
+  bool PassesFilter(const char* raw_filter);
+
   // For use during stack traces.  Performs rudimentary sanity check.
   bool LooksValid();



--
--
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