*/
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();
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()");
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.")
// Inserts collected profiling data into buffer.
void Insert(TickSample* sample) {
+ if (paused_)
+ return;
+
if (Succ(head_) == tail_) {
overflow_ = true;
} else {
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; }
// 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
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
if (FLAG_prof) {
profiler_ = new Profiler();
+ if (!FLAG_prof_auto)
+ profiler_->pause();
profiler_->Engage();
}
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.