| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 23 matching lines...) Expand all Loading... |
| 34 #include "sampler.h" | 34 #include "sampler.h" |
| 35 #include "global-handles.h" | 35 #include "global-handles.h" |
| 36 #include "scopeinfo.h" | 36 #include "scopeinfo.h" |
| 37 #include "unicode.h" | 37 #include "unicode.h" |
| 38 #include "zone-inl.h" | 38 #include "zone-inl.h" |
| 39 | 39 |
| 40 namespace v8 { | 40 namespace v8 { |
| 41 namespace internal { | 41 namespace internal { |
| 42 | 42 |
| 43 | 43 |
| 44 StringsStorage::StringsStorage() | 44 StringsStorage::StringsStorage(Heap* heap) |
| 45 : names_(StringsMatch) { | 45 : hash_seed_(heap->HashSeed()), names_(StringsMatch) { |
| 46 } | 46 } |
| 47 | 47 |
| 48 | 48 |
| 49 StringsStorage::~StringsStorage() { | 49 StringsStorage::~StringsStorage() { |
| 50 for (HashMap::Entry* p = names_.Start(); | 50 for (HashMap::Entry* p = names_.Start(); |
| 51 p != NULL; | 51 p != NULL; |
| 52 p = names_.Next(p)) { | 52 p = names_.Next(p)) { |
| 53 DeleteArray(reinterpret_cast<const char*>(p->value)); | 53 DeleteArray(reinterpret_cast<const char*>(p->value)); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 | 57 |
| 58 const char* StringsStorage::GetCopy(const char* src) { | 58 const char* StringsStorage::GetCopy(const char* src) { |
| 59 int len = static_cast<int>(strlen(src)); | 59 int len = static_cast<int>(strlen(src)); |
| 60 Vector<char> dst = Vector<char>::New(len + 1); | 60 Vector<char> dst = Vector<char>::New(len + 1); |
| 61 OS::StrNCpy(dst, src, len); | 61 OS::StrNCpy(dst, src, len); |
| 62 dst[len] = '\0'; | 62 dst[len] = '\0'; |
| 63 uint32_t hash = | 63 uint32_t hash = |
| 64 StringHasher::HashSequentialString(dst.start(), len, HEAP->HashSeed()); | 64 StringHasher::HashSequentialString(dst.start(), len, hash_seed_); |
| 65 return AddOrDisposeString(dst.start(), hash); | 65 return AddOrDisposeString(dst.start(), hash); |
| 66 } | 66 } |
| 67 | 67 |
| 68 | 68 |
| 69 const char* StringsStorage::GetFormatted(const char* format, ...) { | 69 const char* StringsStorage::GetFormatted(const char* format, ...) { |
| 70 va_list args; | 70 va_list args; |
| 71 va_start(args, format); | 71 va_start(args, format); |
| 72 const char* result = GetVFormatted(format, args); | 72 const char* result = GetVFormatted(format, args); |
| 73 va_end(args); | 73 va_end(args); |
| 74 return result; | 74 return result; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 88 | 88 |
| 89 | 89 |
| 90 const char* StringsStorage::GetVFormatted(const char* format, va_list args) { | 90 const char* StringsStorage::GetVFormatted(const char* format, va_list args) { |
| 91 Vector<char> str = Vector<char>::New(1024); | 91 Vector<char> str = Vector<char>::New(1024); |
| 92 int len = OS::VSNPrintF(str, format, args); | 92 int len = OS::VSNPrintF(str, format, args); |
| 93 if (len == -1) { | 93 if (len == -1) { |
| 94 DeleteArray(str.start()); | 94 DeleteArray(str.start()); |
| 95 return format; | 95 return format; |
| 96 } | 96 } |
| 97 uint32_t hash = StringHasher::HashSequentialString( | 97 uint32_t hash = StringHasher::HashSequentialString( |
| 98 str.start(), len, HEAP->HashSeed()); | 98 str.start(), len, hash_seed_); |
| 99 return AddOrDisposeString(str.start(), hash); | 99 return AddOrDisposeString(str.start(), hash); |
| 100 } | 100 } |
| 101 | 101 |
| 102 | 102 |
| 103 const char* StringsStorage::GetName(Name* name) { | 103 const char* StringsStorage::GetName(Name* name) { |
| 104 if (name->IsString()) { | 104 if (name->IsString()) { |
| 105 String* str = String::cast(name); | 105 String* str = String::cast(name); |
| 106 int length = Min(kMaxNameSize, str->length()); | 106 int length = Min(kMaxNameSize, str->length()); |
| 107 SmartArrayPointer<char> data = | 107 SmartArrayPointer<char> data = |
| 108 str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, 0, length); | 108 str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, 0, length); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 } | 436 } |
| 437 } | 437 } |
| 438 | 438 |
| 439 | 439 |
| 440 void CodeMap::Print() { | 440 void CodeMap::Print() { |
| 441 CodeTreePrinter printer; | 441 CodeTreePrinter printer; |
| 442 tree_.ForEach(&printer); | 442 tree_.ForEach(&printer); |
| 443 } | 443 } |
| 444 | 444 |
| 445 | 445 |
| 446 CpuProfilesCollection::CpuProfilesCollection() | 446 CpuProfilesCollection::CpuProfilesCollection(Heap* heap) |
| 447 : current_profiles_semaphore_(1) { | 447 : function_and_resource_names_(heap), |
| 448 current_profiles_semaphore_(1) { |
| 448 } | 449 } |
| 449 | 450 |
| 450 | 451 |
| 451 static void DeleteCodeEntry(CodeEntry** entry_ptr) { | 452 static void DeleteCodeEntry(CodeEntry** entry_ptr) { |
| 452 delete *entry_ptr; | 453 delete *entry_ptr; |
| 453 } | 454 } |
| 454 | 455 |
| 455 | 456 |
| 456 static void DeleteCpuProfile(CpuProfile** profile_ptr) { | 457 static void DeleteCpuProfile(CpuProfile** profile_ptr) { |
| 457 delete *profile_ptr; | 458 delete *profile_ptr; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 if (no_symbolized_entries) { | 654 if (no_symbolized_entries) { |
| 654 *entry++ = EntryForVMState(sample.state); | 655 *entry++ = EntryForVMState(sample.state); |
| 655 } | 656 } |
| 656 } | 657 } |
| 657 | 658 |
| 658 profiles_->AddPathToCurrentProfiles(entries); | 659 profiles_->AddPathToCurrentProfiles(entries); |
| 659 } | 660 } |
| 660 | 661 |
| 661 | 662 |
| 662 } } // namespace v8::internal | 663 } } // namespace v8::internal |
| OLD | NEW |