Author: [email protected]
Date: Thu Jan 29 11:47:00 2009
New Revision: 1185

Modified:
    branches/bleeding_edge/include/v8.h
    branches/bleeding_edge/src/api.cc
    branches/bleeding_edge/src/flag-definitions.h
    branches/bleeding_edge/src/log.cc
    branches/bleeding_edge/src/log.h

Log:
Enable programmatic access to Profile pause/resume

Modified: branches/bleeding_edge/include/v8.h
==============================================================================
--- branches/bleeding_edge/include/v8.h (original)
+++ branches/bleeding_edge/include/v8.h Thu Jan 29 11:47:00 2009
@@ -1970,6 +1970,23 @@
     */
    static int AdjustAmountOfExternalAllocatedMemory(int change_in_bytes);

+  /**
+   * Suspends recording of tick samples in the profiler.
+   * When the V8 profiling mode is enabled (usually via command line
+   * switches) this function suspends recording of tick samples.
+   * Profiling ticks are discarded until ResumeProfiler() is called.
+   *
+   * See also the --prof and --prof_auto command line switches to
+   * enable V8 profiling.
+   */
+  static void PauseProfiler();
+
+  /**
+   * Resumes recording of tick samples in the profiler.
+   * See also PauseProfiler().
+   */
+  static void ResumeProfiler();
+
   private:
    V8();


Modified: branches/bleeding_edge/src/api.cc
==============================================================================
--- branches/bleeding_edge/src/api.cc   (original)
+++ branches/bleeding_edge/src/api.cc   Thu Jan 29 11:47:00 2009
@@ -2652,6 +2652,18 @@
    i::Heap::SetExternalSymbolCallback(callback);
  }

+void V8::PauseProfiler() {
+#ifdef ENABLE_LOGGING_AND_PROFILING
+  i::Logger::PauseProfiler();
+#endif
+}
+
+void V8::ResumeProfiler() {
+#ifdef ENABLE_LOGGING_AND_PROFILING
+  i::Logger::ResumeProfiler();
+#endif
+}
+

  String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) {
    EnsureInitialized("v8::String::Utf8Value::Utf8Value()");

Modified: branches/bleeding_edge/src/flag-definitions.h
==============================================================================
--- branches/bleeding_edge/src/flag-definitions.h       (original)
+++ branches/bleeding_edge/src/flag-definitions.h       Thu Jan 29 11:47:00 2009
@@ -324,6 +324,8 @@
  DEFINE_bool(log_suspect, false, "Log suspect operations.")
  DEFINE_bool(prof, false,
              "Log statistical profiling information (implies --log-code).")
+DEFINE_bool(prof_auto, true,
+            "Used with --prof, starts profiling automatically")
  DEFINE_bool(log_regexp, false, "Log regular expression execution.")
  DEFINE_bool(sliding_state_window, false,
              "Update sliding state window counters.")

Modified: branches/bleeding_edge/src/log.cc
==============================================================================
--- branches/bleeding_edge/src/log.cc   (original)
+++ branches/bleeding_edge/src/log.cc   Thu Jan 29 11:47:00 2009
@@ -81,6 +81,9 @@

    // Inserts collected profiling data into buffer.
    void Insert(TickSample* sample) {
+    if (paused_)
+      return;
+
      if (Succ(head_) == tail_) {
        overflow_ = true;
      } else {
@@ -102,6 +105,11 @@

    void Run();

+  // Pause and Resume TickSample data collection.
+  static bool paused() { return paused_; }
+  static void pause() { paused_ = true; }
+  static void resume() { paused_ = false; }
+
   private:
    // Returns the next index in the cyclic buffer.
    int Succ(int index) { return (index + 1) % kBufferSize; }
@@ -117,8 +125,13 @@

    // Tells whether worker thread should continue running.
    bool running_;
+
+  // Tells whether we are currently recording tick samples.
+  static bool paused_;
  };

+bool Profiler::paused_ = false;
+

  //
  // Ticker used to provide ticks to the profiler and the sliding state
@@ -744,6 +757,21 @@
    if (overflow) fprintf(logfile_, ",overflow");
    fprintf(logfile_, "\n");
  }
+
+
+bool Logger::IsProfilerPaused() {
+  return profiler_->paused();
+}
+
+
+void Logger::PauseProfiler() {
+  profiler_->pause();
+}
+
+
+void Logger::ResumeProfiler() {
+  profiler_->resume();
+}
  #endif


@@ -822,6 +850,8 @@

    if (FLAG_prof) {
      profiler_ = new Profiler();
+    if (!FLAG_prof_auto)
+      profiler_->pause();
      profiler_->Engage();
    }


Modified: branches/bleeding_edge/src/log.h
==============================================================================
--- branches/bleeding_edge/src/log.h    (original)
+++ branches/bleeding_edge/src/log.h    Thu Jan 29 11:47:00 2009
@@ -203,6 +203,13 @@

    static bool is_enabled() { return logfile_ != NULL; }

+  // Pause/Resume collection of profiling data.
+  // When data collection is paused, Tick events are discarded until
+  // data collection is Resumed.
+  static bool IsProfilerPaused();
+  static void PauseProfiler();
+  static void ResumeProfiler();
+
   private:

    // Emits the source code of a regexp. Used by regexp events.

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

Reply via email to