OLD | NEW |
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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 LocalContext env; | 287 LocalContext env; |
288 | 288 |
289 CompileRun( | 289 CompileRun( |
290 "function A() {}\n" | 290 "function A() {}\n" |
291 "function B(x) { this.x = x; }\n" | 291 "function B(x) { this.x = x; }\n" |
292 "var a = new A();\n" | 292 "var a = new A();\n" |
293 "var b = new B(a);"); | 293 "var b = new B(a);"); |
294 const v8::HeapSnapshot* snapshot1 = | 294 const v8::HeapSnapshot* snapshot1 = |
295 v8::HeapProfiler::TakeSnapshot(v8::String::New("s1")); | 295 v8::HeapProfiler::TakeSnapshot(v8::String::New("s1")); |
296 | 296 |
297 HEAP->CollectAllGarbage(true); // Enforce compaction. | 297 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
298 | 298 |
299 const v8::HeapSnapshot* snapshot2 = | 299 const v8::HeapSnapshot* snapshot2 = |
300 v8::HeapProfiler::TakeSnapshot(v8::String::New("s2")); | 300 v8::HeapProfiler::TakeSnapshot(v8::String::New("s2")); |
301 | 301 |
302 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); | 302 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); |
303 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); | 303 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); |
304 CHECK_NE_UINT64_T(0, global1->GetId()); | 304 CHECK_NE_UINT64_T(0, global1->GetId()); |
305 CHECK_EQ_UINT64_T(global1->GetId(), global2->GetId()); | 305 CHECK_EQ_UINT64_T(global1->GetId(), global2->GetId()); |
306 const v8::HeapGraphNode* A1 = | 306 const v8::HeapGraphNode* A1 = |
307 GetProperty(global1, v8::HeapGraphEdge::kProperty, "A"); | 307 GetProperty(global1, v8::HeapGraphEdge::kProperty, "A"); |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 "Constructor4", i::V8HeapExplorer::GetConstructorName(*js_obj4))); | 938 "Constructor4", i::V8HeapExplorer::GetConstructorName(*js_obj4))); |
939 v8::Local<v8::Object> obj5 = js_global->Get(v8_str("obj5")).As<v8::Object>(); | 939 v8::Local<v8::Object> obj5 = js_global->Get(v8_str("obj5")).As<v8::Object>(); |
940 i::Handle<i::JSObject> js_obj5 = v8::Utils::OpenHandle(*obj5); | 940 i::Handle<i::JSObject> js_obj5 = v8::Utils::OpenHandle(*obj5); |
941 CHECK_EQ(0, StringCmp( | 941 CHECK_EQ(0, StringCmp( |
942 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj5))); | 942 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj5))); |
943 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>(); | 943 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>(); |
944 i::Handle<i::JSObject> js_obj6 = v8::Utils::OpenHandle(*obj6); | 944 i::Handle<i::JSObject> js_obj6 = v8::Utils::OpenHandle(*obj6); |
945 CHECK_EQ(0, StringCmp( | 945 CHECK_EQ(0, StringCmp( |
946 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6))); | 946 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6))); |
947 } | 947 } |
OLD | NEW |