Reviewers: titzer,

Description:
Make standalone D8 trace to single hydrogen.cfg file.

[email protected]

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

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

Affected files:
  M src/d8.cc
  M src/flag-definitions.h
  M src/hydrogen.h


Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 5343174d1741489877f29ecfc9885fa568fc506f..e9258eaec1933530f8d6ad38c4ae4adb33b3a626 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1547,11 +1547,12 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) {


 #ifdef V8_SHARED
-static void EnableHarmonyTypedArraysViaCommandLine() {
-  int fake_argc = 2;
-  char **fake_argv = new char*[2];
+static void SetStandaloneFlagsViaCommandLine() {
+  int fake_argc = 3;
+  char **fake_argv = new char*[3];
   fake_argv[0] = NULL;
   fake_argv[1] = strdup("--harmony-typed-arrays");
+  fake_argv[1] = strdup("--trace-hydrogen-file=hydrogen.cfg");
   v8::V8::SetFlagsFromCommandLine(&fake_argc, fake_argv, false);
   free(fake_argv[1]);
   delete[] fake_argv;
@@ -1572,8 +1573,9 @@ int Shell::Main(int argc, char* argv[]) {
 #ifndef V8_SHARED
   i::FLAG_harmony_array_buffer = true;
   i::FLAG_harmony_typed_arrays = true;
+  i::FLAG_trace_hydrogen_file = "hydrogen.cfg";
 #else
-  EnableHarmonyTypedArraysViaCommandLine();
+  SetStandaloneFlagsViaCommandLine();
 #endif
   ShellArrayBufferAllocator array_buffer_allocator;
   v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index 72159c0a6db468162047a62ce1da3ed5032d457a..8888aed26c04d41138d7deb4bd75a4f5caa7c674 100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -238,6 +238,7 @@ DEFINE_bool(collect_megamorphic_maps_from_stub_cache,
 DEFINE_bool(hydrogen_stats, false, "print statistics for hydrogen")
 DEFINE_bool(trace_hydrogen, false, "trace generated hydrogen to file")
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")
 DEFINE_bool(trace_inlining, false, "trace inlining decisions")
 DEFINE_bool(trace_alloc, false, "trace register allocator")
Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index 46d23da1ceadf50b574d26265b6d50eb76840a6c..895b9849c97d36c16bb6ecdbd6c93f1eb951eb2c 100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -2085,10 +2085,14 @@ class HTracer: public Malloced {
  public:
   explicit HTracer(int isolate_id)
       : trace_(&string_allocator_), indent_(0) {
-    OS::SNPrintF(filename_,
-                 "hydrogen-%d-%d.cfg",
-                 OS::GetCurrentProcessId(),
-                 isolate_id);
+    if (FLAG_trace_hydrogen_file == NULL) {
+      OS::SNPrintF(filename_,
+                   "hydrogen-%d-%d.cfg",
+                   OS::GetCurrentProcessId(),
+                   isolate_id);
+    } else {
+      OS::StrNCpy(filename_, FLAG_trace_hydrogen_file, filename_.length());
+    }
     WriteChars(filename_.start(), "", 0, false);
   }



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