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

Side by Side Diff: test/cctest/test-heap-profiler.cc

Issue 52643002: HeapProfiler: provide human readable names for code objects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: style fix Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2170 2170
2171 const char* names[] = 2171 const char* names[] =
2172 { "(anonymous function)", "start", "f_0_0", "f_0_1", "f_0_2" }; 2172 { "(anonymous function)", "start", "f_0_0", "f_0_1", "f_0_2" };
2173 AllocationTraceNode* node = 2173 AllocationTraceNode* node =
2174 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); 2174 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names)));
2175 CHECK_NE(NULL, node); 2175 CHECK_NE(NULL, node);
2176 CHECK_GE(node->allocation_count(), 100); 2176 CHECK_GE(node->allocation_count(), 100);
2177 CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); 2177 CHECK_GE(node->allocation_size(), 4 * node->allocation_count());
2178 heap_profiler->StopRecordingHeapAllocations(); 2178 heap_profiler->StopRecordingHeapAllocations();
2179 } 2179 }
2180
2181
2182 static const v8::HeapGraphNode* GetNodeByPath(const v8::HeapSnapshot* snapshot,
2183 const char* path[],
2184 int depth) {
2185 const v8::HeapGraphNode* node = snapshot->GetRoot();
2186 for (int current_depth = 0; current_depth < depth; ++current_depth) {
2187 int i, count = node->GetChildrenCount();
2188 for (i = 0; i < count; ++i) {
2189 const v8::HeapGraphEdge* edge = node->GetChild(i);
2190 const v8::HeapGraphNode* to_node = edge->GetToNode();
2191 v8::String::Utf8Value edge_name(edge->GetName());
2192 v8::String::Utf8Value node_name(to_node->GetName());
2193 i::EmbeddedVector<char, 100> name;
2194 i::OS::SNPrintF(name, "%s::%s", *edge_name, *node_name);
2195 if (strstr(name.start(), path[current_depth])) {
2196 node = to_node;
2197 break;
2198 }
2199 }
2200 if (i == count) return NULL;
2201 }
2202 return node;
2203 }
2204
2205
2206 TEST(CheckCodeNames) {
2207 LocalContext env;
2208 v8::HandleScope scope(env->GetIsolate());
2209 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
2210 CompileRun("var a = 1.1;");
2211 const v8::HeapSnapshot* snapshot =
2212 heap_profiler->TakeHeapSnapshot(v8_str("CheckCodeNames"));
2213 CHECK(ValidateSnapshot(snapshot));
2214
2215 const char* stub_path[] = {
2216 "::(GC roots)",
2217 "::(Strong roots)",
2218 "code_stubs::",
2219 "::(ArraySingleArgumentConstructorStub code)"
2220 };
2221 const v8::HeapGraphNode* node = GetNodeByPath(snapshot,
2222 stub_path, ARRAY_SIZE(stub_path));
2223 CHECK_NE(NULL, node);
2224
2225 const char* builtin_path[] = {
2226 "::(GC roots)",
2227 "::(Builtins)",
2228 "::(KeyedLoadIC_Generic code)"
2229 };
2230 node = GetNodeByPath(snapshot, builtin_path, ARRAY_SIZE(builtin_path));
2231 CHECK_NE(NULL, node);
2232 }
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698