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

Unified Diff: src/profile-generator.h

Issue 1514006: C++ profiles processor: put under #ifdef and fix issues. (Closed)
Patch Set: Created 10 years, 9 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
Index: src/profile-generator.h
diff --git a/src/profile-generator.h b/src/profile-generator.h
index c0454cb821f6902b35f7e480023d2fab0bdd07e1..78e64a958e6e89eaf0a133fa7339b57e2adb5d64 100644
--- a/src/profile-generator.h
+++ b/src/profile-generator.h
@@ -33,6 +33,7 @@
namespace v8 {
namespace internal {
+#ifdef ENABLE_CPP_PROFILES_PROCESSOR
class CodeEntry {
public:
@@ -44,6 +45,8 @@ class CodeEntry {
INLINE(bool is_js_function());
INLINE(const char* name()) { return name_; }
+ INLINE(const char* resource_name()) { return name_; }
+ INLINE(int line_number()) { return line_number_; }
private:
Logger::LogEventsAndTags tag_;
@@ -67,7 +70,7 @@ class ProfileNode {
INLINE(CodeEntry* entry() const) { return entry_; }
INLINE(unsigned total_ticks() const) { return total_ticks_; }
INLINE(unsigned self_ticks() const) { return self_ticks_; }
- void GetChildren(List<ProfileNode*>* children);
+ INLINE(const List<ProfileNode*>* children() const) { return &children_list_; }
void Print(int indent);
@@ -85,14 +88,13 @@ class ProfileNode {
unsigned self_ticks_;
// CodeEntry* -> ProfileNode*
HashMap children_;
-
- friend class ProfileTree;
+ List<ProfileNode*> children_list_;
DISALLOW_COPY_AND_ASSIGN(ProfileNode);
};
-class ProfileTree BASE_EMBEDDED {
+class ProfileTree {
public:
ProfileTree() : root_(new ProfileNode(NULL)) { }
~ProfileTree();
@@ -101,7 +103,7 @@ class ProfileTree BASE_EMBEDDED {
void AddPathFromStart(const Vector<CodeEntry*>& path);
void CalculateTotalTicks();
- ProfileNode* root() { return root_; }
+ ProfileNode* root() const { return root_; }
void ShortPrint();
void Print() {
@@ -120,18 +122,24 @@ class ProfileTree BASE_EMBEDDED {
class CpuProfile {
public:
- CpuProfile() { }
+ CpuProfile(const char* title, unsigned uid)
+ : title_(title), uid_(uid) { }
+
// Add pc -> ... -> main() call path to the profile.
void AddPath(const Vector<CodeEntry*>& path);
void CalculateTotalTicks();
- INLINE(ProfileTree* top_down()) { return &top_down_; }
- INLINE(ProfileTree* bottom_up()) { return &bottom_up_; }
+ INLINE(const char* title() const) { return title_; }
+ INLINE(unsigned uid() const) { return uid_; }
+ INLINE(const ProfileTree* top_down() const) { return &top_down_; }
+ INLINE(const ProfileTree* bottom_up() const) { return &bottom_up_; }
void ShortPrint();
void Print();
private:
+ const char* title_;
+ unsigned uid_;
ProfileTree top_down_;
ProfileTree bottom_up_;
@@ -139,7 +147,7 @@ class CpuProfile {
};
-class CodeMap BASE_EMBEDDED {
+class CodeMap {
public:
CodeMap() { }
INLINE(void AddCode(Address addr, CodeEntry* entry, unsigned size));
@@ -148,6 +156,8 @@ class CodeMap BASE_EMBEDDED {
void AddAlias(Address alias, Address addr);
CodeEntry* FindEntry(Address addr);
+ void Print();
+
private:
struct CodeEntryInfo {
CodeEntryInfo(CodeEntry* an_entry, unsigned a_size)
@@ -167,6 +177,11 @@ class CodeMap BASE_EMBEDDED {
};
typedef SplayTree<CodeTreeConfig> CodeTree;
+ class CodeTreePrinter {
+ public:
+ void Call(const Address& key, const CodeEntryInfo& value);
+ };
+
CodeTree tree_;
DISALLOW_COPY_AND_ASSIGN(CodeMap);
@@ -178,14 +193,24 @@ class CpuProfilesCollection {
CpuProfilesCollection();
~CpuProfilesCollection();
- void AddProfile(unsigned uid);
+ bool StartProfiling(const char* title, unsigned uid);
+ bool StartProfiling(String* title, unsigned uid);
+ CpuProfile* StopProfiling(const char* title);
+ CpuProfile* StopProfiling(String* title);
+ INLINE(List<CpuProfile*>* profiles()) { return &profiles_; }
+ CpuProfile* GetProfile(unsigned uid);
+ inline bool is_last_profile();
CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag,
String* name, String* resource_name, int line_number);
CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name);
CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, int args_count);
- INLINE(CpuProfile* profile()) { return profiles_.last(); }
+ // Called from profile generator thread.
+ void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path);
+
+ // This will be moved to V8 API.
+ static const int kNoLineNumberInfo = -1;
private:
const char* GetName(String* name);
@@ -196,12 +221,22 @@ class CpuProfilesCollection {
reinterpret_cast<char*>(key2)) == 0;
}
+ INLINE(static bool CpuProfilesMatch(void* key1, void* key2)) {
+ return key1 == key2;
+ }
+
// String::Hash -> const char*
HashMap function_and_resource_names_;
// args_count -> char*
List<char*> args_count_names_;
List<CodeEntry*> code_entries_;
List<CpuProfile*> profiles_;
+ // uid -> CpuProfile*
+ HashMap profiles_uids_;
+
+ // Accessed by VM thread and profile generator thread.
+ List<CpuProfile*> current_profiles_;
+ Semaphore* current_profiles_semaphore_;
DISALLOW_COPY_AND_ASSIGN(CpuProfilesCollection);
};
@@ -233,14 +268,13 @@ class ProfileGenerator {
INLINE(CodeMap* code_map()) { return &code_map_; }
private:
- INLINE(CpuProfile* profile()) { return profiles_->profile(); }
-
CpuProfilesCollection* profiles_;
CodeMap code_map_;
DISALLOW_COPY_AND_ASSIGN(ProfileGenerator);
};
+#endif // ENABLE_CPP_PROFILES_PROCESSOR
} } // namespace v8::internal
« src/cpu-profiler-inl.h ('K') | « src/cpu-profiler-inl.h ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698