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

Side by Side Diff: src/profile-generator.cc

Issue 1582004: C++ profiles processor: wire up to VM. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 16 matching lines...) Expand all
27 27
28 #ifdef ENABLE_CPP_PROFILES_PROCESSOR 28 #ifdef ENABLE_CPP_PROFILES_PROCESSOR
29 29
30 #include "v8.h" 30 #include "v8.h"
31 31
32 #include "profile-generator-inl.h" 32 #include "profile-generator-inl.h"
33 33
34 namespace v8 { 34 namespace v8 {
35 namespace internal { 35 namespace internal {
36 36
37
38 const char* CodeEntry::kEmptyNamePrefix = "";
39 const int CodeEntry::kNoLineNumberInfo = -1;
40
41
37 ProfileNode* ProfileNode::FindChild(CodeEntry* entry) { 42 ProfileNode* ProfileNode::FindChild(CodeEntry* entry) {
38 HashMap::Entry* map_entry = 43 HashMap::Entry* map_entry =
39 children_.Lookup(entry, CodeEntryHash(entry), false); 44 children_.Lookup(entry, CodeEntryHash(entry), false);
40 return map_entry != NULL ? 45 return map_entry != NULL ?
41 reinterpret_cast<ProfileNode*>(map_entry->value) : NULL; 46 reinterpret_cast<ProfileNode*>(map_entry->value) : NULL;
42 } 47 }
43 48
44 49
45 ProfileNode* ProfileNode::FindOrAddChild(CodeEntry* entry) { 50 ProfileNode* ProfileNode::FindOrAddChild(CodeEntry* entry) {
46 HashMap::Entry* map_entry = 51 HashMap::Entry* map_entry =
47 children_.Lookup(entry, CodeEntryHash(entry), true); 52 children_.Lookup(entry, CodeEntryHash(entry), true);
48 if (map_entry->value == NULL) { 53 if (map_entry->value == NULL) {
49 // New node added. 54 // New node added.
50 ProfileNode* new_node = new ProfileNode(entry); 55 ProfileNode* new_node = new ProfileNode(entry);
51 map_entry->value = new_node; 56 map_entry->value = new_node;
52 children_list_.Add(new_node); 57 children_list_.Add(new_node);
53 } 58 }
54 return reinterpret_cast<ProfileNode*>(map_entry->value); 59 return reinterpret_cast<ProfileNode*>(map_entry->value);
55 } 60 }
56 61
57 62
58 void ProfileNode::Print(int indent) { 63 void ProfileNode::Print(int indent) {
59 OS::Print("%5u %5u %*c %s\n", 64 OS::Print("%5u %5u %*c %s%s\n",
60 total_ticks_, self_ticks_, 65 total_ticks_, self_ticks_,
61 indent, ' ', 66 indent, ' ',
67 entry_ != NULL ? entry_->name_prefix() : "",
62 entry_ != NULL ? entry_->name() : ""); 68 entry_ != NULL ? entry_->name() : "");
63 for (HashMap::Entry* p = children_.Start(); 69 for (HashMap::Entry* p = children_.Start();
64 p != NULL; 70 p != NULL;
65 p = children_.Next(p)) { 71 p = children_.Next(p)) {
66 reinterpret_cast<ProfileNode*>(p->value)->Print(indent + 2); 72 reinterpret_cast<ProfileNode*>(p->value)->Print(indent + 2);
67 } 73 }
68 } 74 }
69 75
70 76
71 namespace { 77 namespace {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 false); 352 false);
347 return entry != NULL ? reinterpret_cast<CpuProfile*>(entry->value) : NULL; 353 return entry != NULL ? reinterpret_cast<CpuProfile*>(entry->value) : NULL;
348 } 354 }
349 355
350 356
351 CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag, 357 CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag,
352 String* name, 358 String* name,
353 String* resource_name, 359 String* resource_name,
354 int line_number) { 360 int line_number) {
355 CodeEntry* entry = new CodeEntry(tag, 361 CodeEntry* entry = new CodeEntry(tag,
362 CodeEntry::kEmptyNamePrefix,
356 GetName(name), 363 GetName(name),
357 GetName(resource_name), 364 GetName(resource_name),
358 line_number); 365 line_number);
359 code_entries_.Add(entry); 366 code_entries_.Add(entry);
360 return entry; 367 return entry;
361 } 368 }
362 369
363 370
364 CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag, 371 CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag,
365 const char* name) { 372 const char* name) {
366 CodeEntry* entry = new CodeEntry(tag, 373 CodeEntry* entry = new CodeEntry(tag,
374 CodeEntry::kEmptyNamePrefix,
367 name, 375 name,
368 "", 376 "",
369 kNoLineNumberInfo); 377 CodeEntry::kNoLineNumberInfo);
370 code_entries_.Add(entry); 378 code_entries_.Add(entry);
371 return entry; 379 return entry;
372 } 380 }
381
382
383 CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag,
384 const char* name_prefix,
385 String* name) {
386 CodeEntry* entry = new CodeEntry(tag,
387 name_prefix,
388 GetName(name),
389 "",
390 CodeEntry::kNoLineNumberInfo);
391 code_entries_.Add(entry);
392 return entry;
393 }
373 394
374 395
375 CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag, 396 CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag,
376 int args_count) { 397 int args_count) {
377 CodeEntry* entry = new CodeEntry(tag, 398 CodeEntry* entry = new CodeEntry(tag,
399 "args_count: ",
378 GetName(args_count), 400 GetName(args_count),
379 "", 401 "",
380 kNoLineNumberInfo); 402 CodeEntry::kNoLineNumberInfo);
381 code_entries_.Add(entry); 403 code_entries_.Add(entry);
382 return entry; 404 return entry;
383 } 405 }
384 406
385 407
386 const char* CpuProfilesCollection::GetName(String* name) { 408 const char* CpuProfilesCollection::GetName(String* name) {
387 if (name->IsString()) { 409 if (name->IsString()) {
388 char* c_name = 410 char* c_name =
389 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL).Detach(); 411 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL).Detach();
390 HashMap::Entry* cache_entry = 412 HashMap::Entry* cache_entry =
(...skipping 15 matching lines...) Expand all
406 428
407 const char* CpuProfilesCollection::GetName(int args_count) { 429 const char* CpuProfilesCollection::GetName(int args_count) {
408 ASSERT(args_count >= 0); 430 ASSERT(args_count >= 0);
409 if (args_count_names_.length() <= args_count) { 431 if (args_count_names_.length() <= args_count) {
410 args_count_names_.AddBlock( 432 args_count_names_.AddBlock(
411 NULL, args_count - args_count_names_.length() + 1); 433 NULL, args_count - args_count_names_.length() + 1);
412 } 434 }
413 if (args_count_names_[args_count] == NULL) { 435 if (args_count_names_[args_count] == NULL) {
414 const int kMaximumNameLength = 32; 436 const int kMaximumNameLength = 32;
415 char* name = NewArray<char>(kMaximumNameLength); 437 char* name = NewArray<char>(kMaximumNameLength);
416 OS::SNPrintF(Vector<char>(name, kMaximumNameLength), 438 OS::SNPrintF(Vector<char>(name, kMaximumNameLength), "%d", args_count);
417 "args_count: %d", args_count);
418 args_count_names_[args_count] = name; 439 args_count_names_[args_count] = name;
419 } 440 }
420 return args_count_names_[args_count]; 441 return args_count_names_[args_count];
421 } 442 }
422 443
423 444
424 void CpuProfilesCollection::AddPathToCurrentProfiles( 445 void CpuProfilesCollection::AddPathToCurrentProfiles(
425 const Vector<CodeEntry*>& path) { 446 const Vector<CodeEntry*>& path) {
426 // As starting / stopping profiles is rare relatively to this 447 // As starting / stopping profiles is rare relatively to this
427 // method, we don't bother minimizing the duration of lock holding, 448 // method, we don't bother minimizing the duration of lock holding,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 ++stack_pos) { 486 ++stack_pos) {
466 *entry++ = code_map_.FindEntry(*stack_pos); 487 *entry++ = code_map_.FindEntry(*stack_pos);
467 } 488 }
468 489
469 profiles_->AddPathToCurrentProfiles(entries); 490 profiles_->AddPathToCurrentProfiles(entries);
470 } 491 }
471 492
472 } } // namespace v8::internal 493 } } // namespace v8::internal
473 494
474 #endif // ENABLE_CPP_PROFILES_PROCESSOR 495 #endif // ENABLE_CPP_PROFILES_PROCESSOR
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698