Index: src/cpu-profiler.h |
diff --git a/src/cpu-profiler.h b/src/cpu-profiler.h |
index 42d5d0abd32f22a784968e249babf6fec3bb1e23..864df78ea3fbe9ca12bd3e76af4f57905425bd1a 100644 |
--- a/src/cpu-profiler.h |
+++ b/src/cpu-profiler.h |
@@ -31,11 +31,18 @@ |
#ifdef ENABLE_CPP_PROFILES_PROCESSOR |
#include "circular-queue.h" |
-#include "profile-generator.h" |
namespace v8 { |
namespace internal { |
+// Forward declarations. |
+class CodeEntry; |
+class CodeMap; |
+class CpuProfile; |
+class CpuProfilesCollection; |
+class ProfileGenerator; |
+ |
+ |
#define CODE_EVENTS_TYPE_LIST(V) \ |
V(CODE_CREATION, CodeCreateEventRecord) \ |
V(CODE_MOVE, CodeMoveEventRecord) \ |
@@ -64,9 +71,7 @@ class CodeCreateEventRecord : public CodeEventRecord { |
CodeEntry* entry; |
unsigned size; |
- INLINE(void UpdateCodeMap(CodeMap* code_map)) { |
- code_map->AddCode(start, entry, size); |
- } |
+ INLINE(void UpdateCodeMap(CodeMap* code_map)); |
}; |
@@ -75,9 +80,7 @@ class CodeMoveEventRecord : public CodeEventRecord { |
Address from; |
Address to; |
- INLINE(void UpdateCodeMap(CodeMap* code_map)) { |
- code_map->MoveCode(from, to); |
- } |
+ INLINE(void UpdateCodeMap(CodeMap* code_map)); |
}; |
@@ -85,9 +88,7 @@ class CodeDeleteEventRecord : public CodeEventRecord { |
public: |
Address start; |
- INLINE(void UpdateCodeMap(CodeMap* code_map)) { |
- code_map->DeleteCode(start); |
- } |
+ INLINE(void UpdateCodeMap(CodeMap* code_map)); |
}; |
@@ -96,9 +97,7 @@ class CodeAliasEventRecord : public CodeEventRecord { |
Address alias; |
Address start; |
- INLINE(void UpdateCodeMap(CodeMap* code_map)) { |
- code_map->AddAlias(alias, start); |
- } |
+ INLINE(void UpdateCodeMap(CodeMap* code_map)); |
}; |
@@ -133,6 +132,9 @@ class ProfilerEventsProcessor : public Thread { |
INLINE(bool running()) { return running_; } |
// Events adding methods. Called by VM threads. |
+ void CallbackCreateEvent(Logger::LogEventsAndTags tag, |
+ const char* prefix, String* name, |
+ Address start); |
void CodeCreateEvent(Logger::LogEventsAndTags tag, |
String* name, |
String* resource_name, int line_number, |
@@ -176,6 +178,91 @@ class ProfilerEventsProcessor : public Thread { |
} } // namespace v8::internal |
+ |
+#define PROFILE(Call) \ |
+ LOG(Call); \ |
+ do { \ |
+ if (v8::internal::CpuProfiler::is_profiling()) { \ |
+ v8::internal::CpuProfiler::Call; \ |
+ } \ |
+ } while (false) |
+#else |
+#define PROFILE(Call) LOG(Call) |
+#endif // ENABLE_CPP_PROFILES_PROCESSOR |
+ |
+ |
+namespace v8 { |
+namespace internal { |
+ |
+class CpuProfiler { |
+ public: |
+ static void Setup(); |
+ static void TearDown(); |
+ |
+#ifdef ENABLE_CPP_PROFILES_PROCESSOR |
+ static void StartProfiling(const char* title); |
+ static void StartProfiling(String* title); |
+ static CpuProfile* StopProfiling(const char* title); |
+ static CpuProfile* StopProfiling(String* title); |
+ static int GetProfilesCount(); |
+ static CpuProfile* GetProfile(int index); |
+ static CpuProfile* FindProfile(unsigned uid); |
+ |
+ // Invoked from stack sampler (thread or signal handler.) |
+ static TickSample* TickSampleEvent(); |
+ |
+ // Must be called via PROFILE macro, otherwise will crash when |
+ // profiling is not enabled. |
+ static void CallbackEvent(String* name, Address entry_point); |
+ static void CodeCreateEvent(Logger::LogEventsAndTags tag, |
+ Code* code, const char* comment); |
+ static void CodeCreateEvent(Logger::LogEventsAndTags tag, |
+ Code* code, String* name); |
+ static void CodeCreateEvent(Logger::LogEventsAndTags tag, |
+ Code* code, String* name, |
+ String* source, int line); |
+ static void CodeCreateEvent(Logger::LogEventsAndTags tag, |
+ Code* code, int args_count); |
+ static void CodeMoveEvent(Address from, Address to); |
+ static void CodeDeleteEvent(Address from); |
+ static void FunctionCreateEvent(JSFunction* function); |
+ static void FunctionMoveEvent(Address from, Address to); |
+ static void FunctionDeleteEvent(Address from); |
+ static void GetterCallbackEvent(String* name, Address entry_point); |
+ static void RegExpCodeCreateEvent(Code* code, String* source); |
+ static void SetterCallbackEvent(String* name, Address entry_point); |
+ |
+ static INLINE(bool is_profiling()) { |
+ ASSERT(singleton_ != NULL); |
+ return singleton_->processor_ != NULL; |
+ } |
+ |
+ private: |
+ CpuProfiler(); |
+ ~CpuProfiler(); |
+ void StartCollectingProfile(const char* title); |
+ void StartCollectingProfile(String* title); |
+ void StartProcessorIfNotStarted(); |
+ CpuProfile* StopCollectingProfile(const char* title); |
+ CpuProfile* StopCollectingProfile(String* title); |
+ void StopProcessorIfLastProfile(); |
+ |
+ CpuProfilesCollection* profiles_; |
+ unsigned next_profile_uid_; |
+ ProfileGenerator* generator_; |
+ ProfilerEventsProcessor* processor_; |
+ |
+ static CpuProfiler* singleton_; |
+ |
+#else |
+ static INLINE(bool is_profiling()) { return false; } |
#endif // ENABLE_CPP_PROFILES_PROCESSOR |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(CpuProfiler); |
+}; |
+ |
+} } // namespace v8::internal |
+ |
+ |
#endif // V8_CPU_PROFILER_H_ |