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

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

Issue 8362028: The detailed heap snapshot generator was slightly adjusted for tracking sliced strings. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 months 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 "v8.h" 5 #include "v8.h"
6 6
7 #include "cctest.h" 7 #include "cctest.h"
8 #include "heap-profiler.h" 8 #include "heap-profiler.h"
9 #include "snapshot.h" 9 #include "snapshot.h"
10 #include "utils-inl.h" 10 #include "utils-inl.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 const v8::HeapSnapshot* snapshot = 245 const v8::HeapSnapshot* snapshot =
246 v8::HeapProfiler::TakeSnapshot(v8_str("numbers")); 246 v8::HeapProfiler::TakeSnapshot(v8_str("numbers"));
247 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 247 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
248 CHECK_EQ(NULL, GetProperty(global, v8::HeapGraphEdge::kShortcut, "a")); 248 CHECK_EQ(NULL, GetProperty(global, v8::HeapGraphEdge::kShortcut, "a"));
249 const v8::HeapGraphNode* b = 249 const v8::HeapGraphNode* b =
250 GetProperty(global, v8::HeapGraphEdge::kShortcut, "b"); 250 GetProperty(global, v8::HeapGraphEdge::kShortcut, "b");
251 CHECK_NE(NULL, b); 251 CHECK_NE(NULL, b);
252 CHECK_EQ(v8::HeapGraphNode::kHeapNumber, b->GetType()); 252 CHECK_EQ(v8::HeapGraphNode::kHeapNumber, b->GetType());
253 } 253 }
254 254
255 TEST(HeapSnapshotSlicedString) {
256 v8::HandleScope scope;
257 LocalContext env;
258 CompileRun(
259 "parent_string = \"123456789.123456789.123456789.123456789.123456789."
260 "123456789.123456789.123456789.123456789.123456789."
261 "123456789.123456789.123456789.123456789.123456789."
262 "123456789.123456789.123456789.123456789.123456789.\";"
263 "child_string = parent_string.slice(100);");
264 const v8::HeapSnapshot* snapshot =
265 v8::HeapProfiler::TakeSnapshot(v8_str("strings"));
266 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
267 const v8::HeapGraphNode* parent_string =
268 GetProperty(global, v8::HeapGraphEdge::kShortcut, "parent_string");
269 CHECK_NE(NULL, parent_string);
270 const v8::HeapGraphNode* child_string =
271 GetProperty(global, v8::HeapGraphEdge::kShortcut, "child_string");
272 CHECK_NE(NULL, child_string);
273 const v8::HeapGraphNode* parent =
274 GetProperty(child_string, v8::HeapGraphEdge::kInternal, "parent");
275 CHECK_EQ(parent_string, parent);
276 }
255 277
256 TEST(HeapSnapshotInternalReferences) { 278 TEST(HeapSnapshotInternalReferences) {
257 v8::HandleScope scope; 279 v8::HandleScope scope;
258 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 280 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
259 global_template->SetInternalFieldCount(2); 281 global_template->SetInternalFieldCount(2);
260 LocalContext env(NULL, global_template); 282 LocalContext env(NULL, global_template);
261 v8::Handle<v8::Object> global_proxy = env->Global(); 283 v8::Handle<v8::Object> global_proxy = env->Global();
262 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); 284 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
263 CHECK_EQ(2, global->InternalFieldCount()); 285 CHECK_EQ(2, global->InternalFieldCount());
264 v8::Local<v8::Object> obj = v8::Object::New(); 286 v8::Local<v8::Object> obj = v8::Object::New();
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 "Constructor4", i::V8HeapExplorer::GetConstructorName(*js_obj4))); 1016 "Constructor4", i::V8HeapExplorer::GetConstructorName(*js_obj4)));
995 v8::Local<v8::Object> obj5 = js_global->Get(v8_str("obj5")).As<v8::Object>(); 1017 v8::Local<v8::Object> obj5 = js_global->Get(v8_str("obj5")).As<v8::Object>();
996 i::Handle<i::JSObject> js_obj5 = v8::Utils::OpenHandle(*obj5); 1018 i::Handle<i::JSObject> js_obj5 = v8::Utils::OpenHandle(*obj5);
997 CHECK_EQ(0, StringCmp( 1019 CHECK_EQ(0, StringCmp(
998 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj5))); 1020 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj5)));
999 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>(); 1021 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>();
1000 i::Handle<i::JSObject> js_obj6 = v8::Utils::OpenHandle(*obj6); 1022 i::Handle<i::JSObject> js_obj6 = v8::Utils::OpenHandle(*obj6);
1001 CHECK_EQ(0, StringCmp( 1023 CHECK_EQ(0, StringCmp(
1002 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6))); 1024 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6)));
1003 } 1025 }
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