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

Unified Diff: src/api.cc

Issue 159787: Add snapshot mode for heap profiling. (Closed)
Patch Set: Reworked to hide explicit GC inside Profiler API Created 11 years, 4 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
« include/v8.h ('K') | « include/v8.h ('k') | src/log.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 08281012bdb05a012884b6375fa59f5357f85790..a94bd797413d7c5c0a72d581382ec5cc997489ad 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3214,21 +3214,21 @@ void V8::SetGlobalGCEpilogueCallback(GCCallback callback) {
void V8::PauseProfiler() {
#ifdef ENABLE_LOGGING_AND_PROFILING
- i::Logger::PauseProfiler();
+ i::Logger::PauseProfiler(PROFILER_MODULE_CPU);
#endif
}
void V8::ResumeProfiler() {
#ifdef ENABLE_LOGGING_AND_PROFILING
- i::Logger::ResumeProfiler();
+ i::Logger::ResumeProfiler(PROFILER_MODULE_CPU);
#endif
}
bool V8::IsProfilerPaused() {
#ifdef ENABLE_LOGGING_AND_PROFILING
- return i::Logger::IsProfilerPaused();
+ return i::Logger::GetActiveProfilerModules() & PROFILER_MODULE_CPU;
#else
return true;
#endif
@@ -3237,11 +3237,19 @@ bool V8::IsProfilerPaused() {
void V8::ResumeProfilerEx(int flags) {
#ifdef ENABLE_LOGGING_AND_PROFILING
- if (flags & PROFILER_MODULE_CPU) {
- i::Logger::ResumeProfiler();
- }
- if (flags & (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) {
- i::FLAG_log_gc = true;
+ if (flags & PROFILER_MODULE_HEAP_SNAPSHOT) {
+ // Snapshot mode: resume modules, perform GC, then pause only
+ // those modules which haven't been started prior to making a
+ // snapshot.
+
+ // Reset snapshot flag.
+ flags &= ~PROFILER_MODULE_HEAP_SNAPSHOT;
Søren Thygesen Gjesse 2009/08/04 13:44:55 Should PROFILER_MODULE_CPU be masked out here as w
mnaganov (inactive) 2009/08/04 14:12:38 Combining CPU profiling with snapshot makes no sen
+ const int current_flags = i::Logger::GetActiveProfilerModules();
+ i::Logger::ResumeProfiler(flags);
+ i::Heap::CollectAllGarbage();
+ i::Logger::PauseProfiler(~current_flags & flags);
+ } else {
+ i::Logger::ResumeProfiler(flags);
}
#endif
}
@@ -3249,26 +3257,14 @@ void V8::ResumeProfilerEx(int flags) {
void V8::PauseProfilerEx(int flags) {
#ifdef ENABLE_LOGGING_AND_PROFILING
- if (flags & PROFILER_MODULE_CPU) {
- i::Logger::PauseProfiler();
- }
- if (flags & (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) {
- i::FLAG_log_gc = false;
- }
+ i::Logger::PauseProfiler(flags);
#endif
}
int V8::GetActiveProfilerModules() {
#ifdef ENABLE_LOGGING_AND_PROFILING
- int result = PROFILER_MODULE_NONE;
- if (!i::Logger::IsProfilerPaused()) {
- result |= PROFILER_MODULE_CPU;
- }
- if (i::FLAG_log_gc) {
- result |= PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS;
- }
- return result;
+ return i::Logger::GetActiveProfilerModules();
#else
return PROFILER_MODULE_NONE;
#endif
« include/v8.h ('K') | « include/v8.h ('k') | src/log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698