From f6ddb89cd3c8d274dfc03f90812ab272d52b45c3 Mon Sep 17 00:00:00 2001 From: "alph@chromium.org" Date: Tue, 5 Aug 2014 07:08:39 +0000 Subject: [PATCH] Move anonymous function name beautifying out of v8. R=yangguo@chromium.org, yurys@chromium.org Review URL: https://codereview.chromium.org/425223004 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22842 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/profile-generator.cc | 11 ++--------- src/profile-generator.h | 2 -- test/cctest/test-cpu-profiler.cc | 8 +++----- test/cctest/test-heap-profiler.cc | 7 +++---- test/cctest/test-profile-generator.cc | 12 ++++++------ 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/profile-generator.cc b/src/profile-generator.cc index 06a9ee1..6017f12 100644 --- a/src/profile-generator.cc +++ b/src/profile-generator.cc @@ -107,17 +107,12 @@ const char* StringsStorage::GetName(int index) { const char* StringsStorage::GetFunctionName(Name* name) { - return BeautifyFunctionName(GetName(name)); + return GetName(name); } const char* StringsStorage::GetFunctionName(const char* name) { - return BeautifyFunctionName(GetCopy(name)); -} - - -const char* StringsStorage::BeautifyFunctionName(const char* name) { - return (*name == 0) ? ProfileGenerator::kAnonymousFunctionName : name; + return GetCopy(name); } @@ -552,8 +547,6 @@ CodeEntry* CpuProfilesCollection::NewCodeEntry( } -const char* const ProfileGenerator::kAnonymousFunctionName = - "(anonymous function)"; const char* const ProfileGenerator::kProgramEntryName = "(program)"; const char* const ProfileGenerator::kIdleEntryName = diff --git a/src/profile-generator.h b/src/profile-generator.h index 1fb2a46..5ebb92b 100644 --- a/src/profile-generator.h +++ b/src/profile-generator.h @@ -34,7 +34,6 @@ class StringsStorage { static const int kMaxNameSize = 1024; static bool StringsMatch(void* key1, void* key2); - const char* BeautifyFunctionName(const char* name); const char* AddOrDisposeString(char* str, int len); HashMap::Entry* GetEntry(const char* str, int len); @@ -313,7 +312,6 @@ class ProfileGenerator { CodeMap* code_map() { return &code_map_; } - static const char* const kAnonymousFunctionName; static const char* const kProgramEntryName; static const char* const kIdleEntryName; static const char* const kGarbageCollectorEntryName; diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc index a3e7b8d..6051c3f 100644 --- a/test/cctest/test-cpu-profiler.cc +++ b/test/cctest/test-cpu-profiler.cc @@ -1629,15 +1629,13 @@ TEST(FunctionDetails) { const_cast(current))->Print(0); // The tree should look like this: // 0 (root) 0 #1 - // 0 (anonymous function) 19 #2 no reason script_b:1 + // 0 "" 19 #2 no reason script_b:1 // 0 baz 19 #3 TryCatchStatement script_b:3 // 0 foo 18 #4 TryCatchStatement script_a:2 // 1 bar 18 #5 no reason script_a:3 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); - const v8::CpuProfileNode* script = GetChild(env->GetIsolate(), root, - ProfileGenerator::kAnonymousFunctionName); - CheckFunctionDetails(env->GetIsolate(), script, - ProfileGenerator::kAnonymousFunctionName, "script_b", + const v8::CpuProfileNode* script = GetChild(env->GetIsolate(), root, ""); + CheckFunctionDetails(env->GetIsolate(), script, "", "script_b", script_b->GetUnboundScript()->GetId(), 1, 1); const v8::CpuProfileNode* baz = GetChild(env->GetIsolate(), script, "baz"); CheckFunctionDetails(env->GetIsolate(), baz, "baz", "script_b", diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc index 8925f39..d6268c9 100644 --- a/test/cctest/test-heap-profiler.cc +++ b/test/cctest/test-heap-profiler.cc @@ -2410,7 +2410,7 @@ TEST(ArrayGrowLeftTrim) { "for (var i = 0; i < 3; ++i)\n" " a.shift();\n"); - const char* names[] = { "(anonymous function)" }; + const char* names[] = {""}; AllocationTracker* tracker = reinterpret_cast(heap_profiler)->allocation_tracker(); CHECK_NE(NULL, tracker); @@ -2445,8 +2445,7 @@ TEST(TrackHeapAllocations) { // Print for better diagnostics in case of failure. tracker->trace_tree()->Print(tracker); - const char* names[] = - { "(anonymous function)", "start", "f_0_0", "f_0_1", "f_0_2" }; + const char* names[] = {"", "start", "f_0_0", "f_0_1", "f_0_2"}; AllocationTraceNode* node = FindNode(tracker, Vector(names, ARRAY_SIZE(names))); CHECK_NE(NULL, node); @@ -2481,7 +2480,7 @@ TEST(TrackBumpPointerAllocations) { LocalContext env; v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); - const char* names[] = { "(anonymous function)", "start", "f_0", "f_1" }; + const char* names[] = {"", "start", "f_0", "f_1"}; // First check that normally all allocations are recorded. { heap_profiler->StartTrackingHeapObjects(true); diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc index fd590f3..7578b35 100644 --- a/test/cctest/test-profile-generator.cc +++ b/test/cctest/test-profile-generator.cc @@ -572,14 +572,14 @@ TEST(RecordStackTraceAtStartProfiling) { const_cast(current)->Print(0); // The tree should look like this: // (root) - // (anonymous function) + // "" // a // b // c // There can also be: // startProfiling // if the sampler managed to get a tick. - current = PickChild(current, "(anonymous function)"); + current = PickChild(current, ""); CHECK_NE(NULL, const_cast(current)); current = PickChild(current, "a"); CHECK_NE(NULL, const_cast(current)); @@ -651,13 +651,13 @@ TEST(ProfileNodeScriptId) { const_cast(current))->Print(0); // The tree should look like this: // (root) - // (anonymous function) + // "" // b // a // There can also be: // startProfiling // if the sampler managed to get a tick. - current = PickChild(current, i::ProfileGenerator::kAnonymousFunctionName); + current = PickChild(current, ""); CHECK_NE(NULL, const_cast(current)); current = PickChild(current, "b"); @@ -760,10 +760,10 @@ TEST(BailoutReason) { const_cast(current))->Print(0); // The tree should look like this: // (root) - // (anonymous function) + // "" // kTryFinally // kTryCatch - current = PickChild(current, i::ProfileGenerator::kAnonymousFunctionName); + current = PickChild(current, ""); CHECK_NE(NULL, const_cast(current)); current = PickChild(current, "TryFinally"); -- 2.7.4