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

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

Issue 11415203: Introduce callback for resolving global object name while taking heap snapshot (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years 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/profile-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 // 2 //
3 // Tests for heap profiler 3 // Tests for heap profiler
4 4
5 #include <ctype.h> 5 #include <ctype.h>
6 6
7 #include "v8.h" 7 #include "v8.h"
8 8
9 #include "cctest.h" 9 #include "cctest.h"
10 #include "hashmap.h" 10 #include "hashmap.h"
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 const_cast<v8::HeapSnapshot*>(s2)->Delete(); 1220 const_cast<v8::HeapSnapshot*>(s2)->Delete();
1221 CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount()); 1221 CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount());
1222 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid2)); 1222 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid2));
1223 CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3)); 1223 CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3));
1224 const_cast<v8::HeapSnapshot*>(s3)->Delete(); 1224 const_cast<v8::HeapSnapshot*>(s3)->Delete();
1225 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); 1225 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
1226 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid3)); 1226 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid3));
1227 } 1227 }
1228 1228
1229 1229
1230 class NameResolver : public v8::HeapProfiler::ObjectNameResolver {
1231 public:
1232 virtual const char* GetName(v8::Handle<v8::Object> object) {
1233 return "Global object name";
1234 }
1235 };
1236
1237 TEST(GlobalObjectName) {
1238 v8::HandleScope scope;
1239 LocalContext env;
1240
1241 CompileRun("document = { URL:\"abcdefgh\" };");
1242
1243 NameResolver name_resolver;
1244 const v8::HeapSnapshot* snapshot =
1245 v8::HeapProfiler::TakeSnapshot(v8_str("document"),
1246 v8::HeapSnapshot::kFull,
1247 NULL,
1248 &name_resolver);
1249 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1250 CHECK_NE(NULL, global);
1251 CHECK_EQ("Object / Global object name" ,
1252 const_cast<i::HeapEntry*>(
1253 reinterpret_cast<const i::HeapEntry*>(global))->name());
1254 }
1255
1256
1230 TEST(DocumentURL) { 1257 TEST(DocumentURL) {
1231 v8::HandleScope scope; 1258 v8::HandleScope scope;
1232 LocalContext env; 1259 LocalContext env;
1233 1260
1234 CompileRun("document = { URL:\"abcdefgh\" };"); 1261 CompileRun("document = { URL:\"abcdefgh\" };");
1235 1262
1236 const v8::HeapSnapshot* snapshot = 1263 const v8::HeapSnapshot* snapshot =
1237 v8::HeapProfiler::TakeSnapshot(v8_str("document")); 1264 v8::HeapProfiler::TakeSnapshot(v8_str("document"));
1238 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 1265 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1239 CHECK_NE(NULL, global); 1266 CHECK_NE(NULL, global);
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 const v8::HeapGraphNode* map = 1700 const v8::HeapGraphNode* map =
1674 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "map"); 1701 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "map");
1675 CHECK_NE(NULL, map); 1702 CHECK_NE(NULL, map);
1676 const v8::HeapGraphNode* own_descriptors = GetProperty( 1703 const v8::HeapGraphNode* own_descriptors = GetProperty(
1677 map, v8::HeapGraphEdge::kInternal, "descriptors"); 1704 map, v8::HeapGraphEdge::kInternal, "descriptors");
1678 CHECK_NE(NULL, own_descriptors); 1705 CHECK_NE(NULL, own_descriptors);
1679 const v8::HeapGraphNode* own_transitions = GetProperty( 1706 const v8::HeapGraphNode* own_transitions = GetProperty(
1680 map, v8::HeapGraphEdge::kInternal, "transitions"); 1707 map, v8::HeapGraphEdge::kInternal, "transitions");
1681 CHECK_EQ(NULL, own_transitions); 1708 CHECK_EQ(NULL, own_transitions);
1682 } 1709 }
OLDNEW
« no previous file with comments | « src/profile-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698