Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(927)

Unified Diff: src/log.cc

Issue 125141: Attempt to reduce performance penalty for logging and profiling (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/log.h ('k') | src/log-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/log.cc
===================================================================
--- src/log.cc (revision 2260)
+++ src/log.cc (working copy)
@@ -31,9 +31,7 @@
#include "bootstrapper.h"
#include "log.h"
-#include "log-utils.h"
#include "macro-assembler.h"
-#include "platform.h"
#include "serialize.h"
#include "string-stream.h"
@@ -304,6 +302,7 @@
SlidingStateWindow* Logger::sliding_state_window_ = NULL;
const char** Logger::log_events_ = NULL;
CompressionHelper* Logger::compression_helper_ = NULL;
+bool Logger::is_logging_ = false;
#define DECLARE_LONG_EVENT(ignore1, long_name, ignore2) long_name,
const char* kLongLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = {
@@ -318,11 +317,6 @@
#undef DECLARE_SHORT_EVENT
-bool Logger::IsEnabled() {
- return Log::IsEnabled();
-}
-
-
void Logger::ProfilerBeginEvent() {
if (!Log::IsEnabled()) return;
LogMessageBuilder msg;
@@ -946,6 +940,7 @@
// Must be the same message as Log::kDynamicBufferSeal.
LOG(UncheckedStringEvent("profiler", "pause"));
}
+ is_logging_ = false;
}
@@ -953,6 +948,7 @@
if (!profiler_->paused() || !Log::IsEnabled()) {
return;
}
+ is_logging_ = true;
if (FLAG_prof_lazy) {
LOG(UncheckedStringEvent("profiler", "resume"));
FLAG_log_code = true;
@@ -1069,10 +1065,12 @@
FLAG_prof_auto = false;
}
- bool open_log_file = FLAG_log || FLAG_log_runtime || FLAG_log_api
+ bool start_logging = FLAG_log || FLAG_log_runtime || FLAG_log_api
|| FLAG_log_code || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect
- || FLAG_log_regexp || FLAG_log_state_changes || FLAG_prof_lazy;
+ || FLAG_log_regexp || FLAG_log_state_changes;
+ bool open_log_file = start_logging || FLAG_prof_lazy;
+
// If we're logging anything, we need to open the log file.
if (open_log_file) {
if (strcmp(FLAG_logfile, "-") == 0) {
@@ -1134,10 +1132,15 @@
compression_helper_ = new CompressionHelper(kCompressionWindowSize);
}
+ is_logging_ = start_logging;
+
if (FLAG_prof) {
profiler_ = new Profiler();
- if (!FLAG_prof_auto)
+ if (!FLAG_prof_auto) {
profiler_->pause();
+ } else {
+ is_logging_ = true;
+ }
profiler_->Engage();
}
@@ -1195,85 +1198,4 @@
}
-//
-// VMState class implementation. A simple stack of VM states held by the
-// logger and partially threaded through the call stack. States are pushed by
-// VMState construction and popped by destruction.
-//
-#ifdef ENABLE_LOGGING_AND_PROFILING
-static const char* StateToString(StateTag state) {
- switch (state) {
- case JS:
- return "JS";
- case GC:
- return "GC";
- case COMPILER:
- return "COMPILER";
- case OTHER:
- return "OTHER";
- default:
- UNREACHABLE();
- return NULL;
- }
-}
-
-VMState::VMState(StateTag state) {
-#if !defined(ENABLE_HEAP_PROTECTION)
- // When not protecting the heap, there is no difference between
- // EXTERNAL and OTHER. As an optimization in that case, we will not
- // perform EXTERNAL->OTHER transitions through the API. We thus
- // compress the two states into one.
- if (state == EXTERNAL) state = OTHER;
-#endif
- state_ = state;
- previous_ = Logger::current_state_;
- Logger::current_state_ = this;
-
- if (FLAG_log_state_changes) {
- LOG(UncheckedStringEvent("Entering", StateToString(state_)));
- if (previous_ != NULL) {
- LOG(UncheckedStringEvent("From", StateToString(previous_->state_)));
- }
- }
-
-#ifdef ENABLE_HEAP_PROTECTION
- if (FLAG_protect_heap && previous_ != NULL) {
- if (state_ == EXTERNAL) {
- // We are leaving V8.
- ASSERT(previous_->state_ != EXTERNAL);
- Heap::Protect();
- } else if (previous_->state_ == EXTERNAL) {
- // We are entering V8.
- Heap::Unprotect();
- }
- }
-#endif
-}
-
-
-VMState::~VMState() {
- Logger::current_state_ = previous_;
-
- if (FLAG_log_state_changes) {
- LOG(UncheckedStringEvent("Leaving", StateToString(state_)));
- if (previous_ != NULL) {
- LOG(UncheckedStringEvent("To", StateToString(previous_->state_)));
- }
- }
-
-#ifdef ENABLE_HEAP_PROTECTION
- if (FLAG_protect_heap && previous_ != NULL) {
- if (state_ == EXTERNAL) {
- // We are reentering V8.
- ASSERT(previous_->state_ != EXTERNAL);
- Heap::Unprotect();
- } else if (previous_->state_ == EXTERNAL) {
- // We are leaving V8.
- Heap::Protect();
- }
- }
-#endif
-}
-#endif
-
} } // namespace v8::internal
« no previous file with comments | « src/log.h ('k') | src/log-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698