Commit f6ddb89c authored by alph@chromium.org's avatar alph@chromium.org

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
parent 6306a52e
...@@ -107,17 +107,12 @@ const char* StringsStorage::GetName(int index) { ...@@ -107,17 +107,12 @@ const char* StringsStorage::GetName(int index) {
const char* StringsStorage::GetFunctionName(Name* name) { const char* StringsStorage::GetFunctionName(Name* name) {
return BeautifyFunctionName(GetName(name)); return GetName(name);
} }
const char* StringsStorage::GetFunctionName(const char* name) { const char* StringsStorage::GetFunctionName(const char* name) {
return BeautifyFunctionName(GetCopy(name)); return GetCopy(name);
}
const char* StringsStorage::BeautifyFunctionName(const char* name) {
return (*name == 0) ? ProfileGenerator::kAnonymousFunctionName : name;
} }
...@@ -552,8 +547,6 @@ CodeEntry* CpuProfilesCollection::NewCodeEntry( ...@@ -552,8 +547,6 @@ CodeEntry* CpuProfilesCollection::NewCodeEntry(
} }
const char* const ProfileGenerator::kAnonymousFunctionName =
"(anonymous function)";
const char* const ProfileGenerator::kProgramEntryName = const char* const ProfileGenerator::kProgramEntryName =
"(program)"; "(program)";
const char* const ProfileGenerator::kIdleEntryName = const char* const ProfileGenerator::kIdleEntryName =
......
...@@ -34,7 +34,6 @@ class StringsStorage { ...@@ -34,7 +34,6 @@ class StringsStorage {
static const int kMaxNameSize = 1024; static const int kMaxNameSize = 1024;
static bool StringsMatch(void* key1, void* key2); static bool StringsMatch(void* key1, void* key2);
const char* BeautifyFunctionName(const char* name);
const char* AddOrDisposeString(char* str, int len); const char* AddOrDisposeString(char* str, int len);
HashMap::Entry* GetEntry(const char* str, int len); HashMap::Entry* GetEntry(const char* str, int len);
...@@ -313,7 +312,6 @@ class ProfileGenerator { ...@@ -313,7 +312,6 @@ class ProfileGenerator {
CodeMap* code_map() { return &code_map_; } CodeMap* code_map() { return &code_map_; }
static const char* const kAnonymousFunctionName;
static const char* const kProgramEntryName; static const char* const kProgramEntryName;
static const char* const kIdleEntryName; static const char* const kIdleEntryName;
static const char* const kGarbageCollectorEntryName; static const char* const kGarbageCollectorEntryName;
......
...@@ -1629,15 +1629,13 @@ TEST(FunctionDetails) { ...@@ -1629,15 +1629,13 @@ TEST(FunctionDetails) {
const_cast<v8::CpuProfileNode*>(current))->Print(0); const_cast<v8::CpuProfileNode*>(current))->Print(0);
// The tree should look like this: // The tree should look like this:
// 0 (root) 0 #1 // 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 baz 19 #3 TryCatchStatement script_b:3
// 0 foo 18 #4 TryCatchStatement script_a:2 // 0 foo 18 #4 TryCatchStatement script_a:2
// 1 bar 18 #5 no reason script_a:3 // 1 bar 18 #5 no reason script_a:3
const v8::CpuProfileNode* root = profile->GetTopDownRoot(); const v8::CpuProfileNode* root = profile->GetTopDownRoot();
const v8::CpuProfileNode* script = GetChild(env->GetIsolate(), root, const v8::CpuProfileNode* script = GetChild(env->GetIsolate(), root, "");
ProfileGenerator::kAnonymousFunctionName); CheckFunctionDetails(env->GetIsolate(), script, "", "script_b",
CheckFunctionDetails(env->GetIsolate(), script,
ProfileGenerator::kAnonymousFunctionName, "script_b",
script_b->GetUnboundScript()->GetId(), 1, 1); script_b->GetUnboundScript()->GetId(), 1, 1);
const v8::CpuProfileNode* baz = GetChild(env->GetIsolate(), script, "baz"); const v8::CpuProfileNode* baz = GetChild(env->GetIsolate(), script, "baz");
CheckFunctionDetails(env->GetIsolate(), baz, "baz", "script_b", CheckFunctionDetails(env->GetIsolate(), baz, "baz", "script_b",
......
...@@ -2410,7 +2410,7 @@ TEST(ArrayGrowLeftTrim) { ...@@ -2410,7 +2410,7 @@ TEST(ArrayGrowLeftTrim) {
"for (var i = 0; i < 3; ++i)\n" "for (var i = 0; i < 3; ++i)\n"
" a.shift();\n"); " a.shift();\n");
const char* names[] = { "(anonymous function)" }; const char* names[] = {""};
AllocationTracker* tracker = AllocationTracker* tracker =
reinterpret_cast<i::HeapProfiler*>(heap_profiler)->allocation_tracker(); reinterpret_cast<i::HeapProfiler*>(heap_profiler)->allocation_tracker();
CHECK_NE(NULL, tracker); CHECK_NE(NULL, tracker);
...@@ -2445,8 +2445,7 @@ TEST(TrackHeapAllocations) { ...@@ -2445,8 +2445,7 @@ TEST(TrackHeapAllocations) {
// Print for better diagnostics in case of failure. // Print for better diagnostics in case of failure.
tracker->trace_tree()->Print(tracker); tracker->trace_tree()->Print(tracker);
const char* names[] = const char* names[] = {"", "start", "f_0_0", "f_0_1", "f_0_2"};
{ "(anonymous function)", "start", "f_0_0", "f_0_1", "f_0_2" };
AllocationTraceNode* node = AllocationTraceNode* node =
FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names)));
CHECK_NE(NULL, node); CHECK_NE(NULL, node);
...@@ -2481,7 +2480,7 @@ TEST(TrackBumpPointerAllocations) { ...@@ -2481,7 +2480,7 @@ TEST(TrackBumpPointerAllocations) {
LocalContext env; LocalContext env;
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 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. // First check that normally all allocations are recorded.
{ {
heap_profiler->StartTrackingHeapObjects(true); heap_profiler->StartTrackingHeapObjects(true);
......
...@@ -572,14 +572,14 @@ TEST(RecordStackTraceAtStartProfiling) { ...@@ -572,14 +572,14 @@ TEST(RecordStackTraceAtStartProfiling) {
const_cast<ProfileNode*>(current)->Print(0); const_cast<ProfileNode*>(current)->Print(0);
// The tree should look like this: // The tree should look like this:
// (root) // (root)
// (anonymous function) // ""
// a // a
// b // b
// c // c
// There can also be: // There can also be:
// startProfiling // startProfiling
// if the sampler managed to get a tick. // if the sampler managed to get a tick.
current = PickChild(current, "(anonymous function)"); current = PickChild(current, "");
CHECK_NE(NULL, const_cast<ProfileNode*>(current)); CHECK_NE(NULL, const_cast<ProfileNode*>(current));
current = PickChild(current, "a"); current = PickChild(current, "a");
CHECK_NE(NULL, const_cast<ProfileNode*>(current)); CHECK_NE(NULL, const_cast<ProfileNode*>(current));
...@@ -651,13 +651,13 @@ TEST(ProfileNodeScriptId) { ...@@ -651,13 +651,13 @@ TEST(ProfileNodeScriptId) {
const_cast<v8::CpuProfileNode*>(current))->Print(0); const_cast<v8::CpuProfileNode*>(current))->Print(0);
// The tree should look like this: // The tree should look like this:
// (root) // (root)
// (anonymous function) // ""
// b // b
// a // a
// There can also be: // There can also be:
// startProfiling // startProfiling
// if the sampler managed to get a tick. // if the sampler managed to get a tick.
current = PickChild(current, i::ProfileGenerator::kAnonymousFunctionName); current = PickChild(current, "");
CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current));
current = PickChild(current, "b"); current = PickChild(current, "b");
...@@ -760,10 +760,10 @@ TEST(BailoutReason) { ...@@ -760,10 +760,10 @@ TEST(BailoutReason) {
const_cast<v8::CpuProfileNode*>(current))->Print(0); const_cast<v8::CpuProfileNode*>(current))->Print(0);
// The tree should look like this: // The tree should look like this:
// (root) // (root)
// (anonymous function) // ""
// kTryFinally // kTryFinally
// kTryCatch // kTryCatch
current = PickChild(current, i::ProfileGenerator::kAnonymousFunctionName); current = PickChild(current, "");
CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current));
current = PickChild(current, "TryFinally"); current = PickChild(current, "TryFinally");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment