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) {
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 =
......
......@@ -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;
......
......@@ -1629,15 +1629,13 @@ TEST(FunctionDetails) {
const_cast<v8::CpuProfileNode*>(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",
......
......@@ -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<i::HeapProfiler*>(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<const char*>(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);
......
......@@ -572,14 +572,14 @@ TEST(RecordStackTraceAtStartProfiling) {
const_cast<ProfileNode*>(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<ProfileNode*>(current));
current = PickChild(current, "a");
CHECK_NE(NULL, const_cast<ProfileNode*>(current));
......@@ -651,13 +651,13 @@ TEST(ProfileNodeScriptId) {
const_cast<v8::CpuProfileNode*>(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<v8::CpuProfileNode*>(current));
current = PickChild(current, "b");
......@@ -760,10 +760,10 @@ TEST(BailoutReason) {
const_cast<v8::CpuProfileNode*>(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<v8::CpuProfileNode*>(current));
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