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

Unified Diff: src/profile-generator.cc

Issue 1523015: C++ profiles processor: align browser mode with the old implementation, sample VM state. (Closed)
Patch Set: Using Script::type to filter out native scripts. Created 10 years, 8 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/profile-generator.h ('k') | src/profile-generator-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/profile-generator.cc
diff --git a/src/profile-generator.cc b/src/profile-generator.cc
index 17c0835727cf5d5e353e23eb5eaaf5e62fd0f340..46e7aabcdbe5ad470490df3c340e2ea6e226aa11 100644
--- a/src/profile-generator.cc
+++ b/src/profile-generator.cc
@@ -383,7 +383,7 @@ CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag,
const char* name) {
CodeEntry* entry = new CodeEntry(tag,
CodeEntry::kEmptyNamePrefix,
- name,
+ GetFunctionName(name),
"",
v8::CpuProfileNode::kNoLineNumberInfo);
code_entries_.Add(entry);
@@ -416,13 +416,6 @@ CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag,
}
-const char* CpuProfilesCollection::GetFunctionName(String* name) {
- const char* maybe_empty_name = GetName(name);
- return strlen(maybe_empty_name) > 0 ?
- maybe_empty_name : "(anonymous function)";
-}
-
-
const char* CpuProfilesCollection::GetName(String* name) {
if (name->IsString()) {
char* c_name =
@@ -473,44 +466,56 @@ void CpuProfilesCollection::AddPathToCurrentProfiles(
}
+const char* ProfileGenerator::kAnonymousFunctionName = "(anonymous function)";
+const char* ProfileGenerator::kProgramEntryName = "(program)";
+const char* ProfileGenerator::kGarbageCollectorEntryName =
+ "(garbage collector)";
+
ProfileGenerator::ProfileGenerator(CpuProfilesCollection* profiles)
: profiles_(profiles),
program_entry_(
- profiles->NewCodeEntry(Logger::FUNCTION_TAG, "(program)")) {
+ profiles->NewCodeEntry(Logger::FUNCTION_TAG, kProgramEntryName)),
+ gc_entry_(
+ profiles->NewCodeEntry(Logger::BUILTIN_TAG,
+ kGarbageCollectorEntryName)) {
}
void ProfileGenerator::RecordTickSample(const TickSample& sample) {
- // Allocate space for stack frames + pc + function + (program).
+ // Allocate space for stack frames + pc + function + vm-state.
ScopedVector<CodeEntry*> entries(sample.frames_count + 3);
+ // As actual number of decoded code entries may vary, initialize
+ // entries vector with NULL values.
CodeEntry** entry = entries.start();
- *entry++ = code_map_.FindEntry(sample.pc);
+ memset(entry, 0, entries.length() * sizeof(*entry));
+ if (sample.pc != NULL) {
+ *entry++ = code_map_.FindEntry(sample.pc);
- if (sample.function != NULL) {
- *entry = code_map_.FindEntry(sample.function);
- if (*entry != NULL && !(*entry)->is_js_function()) {
- *entry = NULL;
- } else {
- CodeEntry* pc_entry = *entries.start();
- if (pc_entry == NULL || pc_entry->is_js_function())
+ if (sample.function != NULL) {
+ *entry = code_map_.FindEntry(sample.function);
+ if (*entry != NULL && !(*entry)->is_js_function()) {
*entry = NULL;
+ } else {
+ CodeEntry* pc_entry = *entries.start();
+ if (pc_entry == NULL || pc_entry->is_js_function())
+ *entry = NULL;
+ }
+ entry++;
}
- entry++;
- } else {
- *entry++ = NULL;
- }
- for (const Address *stack_pos = sample.stack,
- *stack_end = stack_pos + sample.frames_count;
- stack_pos != stack_end;
- ++stack_pos) {
- *entry++ = code_map_.FindEntry(*stack_pos);
+ for (const Address *stack_pos = sample.stack,
+ *stack_end = stack_pos + sample.frames_count;
+ stack_pos != stack_end;
+ ++stack_pos) {
+ *entry++ = code_map_.FindEntry(*stack_pos);
+ }
}
- // WebKit CPU profiles visualization requires "(program)" to be the
- // topmost entry.
- *entry++ = FLAG_prof_browser_mode ? program_entry_ : NULL;
+ if (FLAG_prof_browser_mode) {
+ // Put VM state as the topmost entry.
+ *entry++ = EntryForVMState(sample.state);
+ }
profiles_->AddPathToCurrentProfiles(entries);
}
« no previous file with comments | « src/profile-generator.h ('k') | src/profile-generator-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698