| OLD | NEW | 
|---|
| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 227       GetProperty(global, v8::HeapGraphEdge::kProperty, "x"); | 227       GetProperty(global, v8::HeapGraphEdge::kProperty, "x"); | 
| 228   CHECK_NE(NULL, x); | 228   CHECK_NE(NULL, x); | 
| 229   const v8::HeapGraphNode* x1 = | 229   const v8::HeapGraphNode* x1 = | 
| 230       GetProperty(x, v8::HeapGraphEdge::kProperty, "a"); | 230       GetProperty(x, v8::HeapGraphEdge::kProperty, "a"); | 
| 231   CHECK_NE(NULL, x1); | 231   CHECK_NE(NULL, x1); | 
| 232   const v8::HeapGraphNode* x2 = | 232   const v8::HeapGraphNode* x2 = | 
| 233       GetProperty(x, v8::HeapGraphEdge::kProperty, "b"); | 233       GetProperty(x, v8::HeapGraphEdge::kProperty, "b"); | 
| 234   CHECK_NE(NULL, x2); | 234   CHECK_NE(NULL, x2); | 
| 235 | 235 | 
| 236   // Test sizes. | 236   // Test sizes. | 
| 237   CHECK_NE(0, x->GetSelfSize()); | 237   CHECK_NE(0, static_cast<int>(x->GetShallowSize())); | 
| 238   CHECK_NE(0, x1->GetSelfSize()); | 238   CHECK_NE(0, static_cast<int>(x1->GetShallowSize())); | 
| 239   CHECK_NE(0, x2->GetSelfSize()); | 239   CHECK_NE(0, static_cast<int>(x2->GetShallowSize())); | 
| 240 } | 240 } | 
| 241 | 241 | 
| 242 | 242 | 
| 243 TEST(BoundFunctionInSnapshot) { | 243 TEST(BoundFunctionInSnapshot) { | 
| 244   LocalContext env; | 244   LocalContext env; | 
| 245   v8::HandleScope scope(env->GetIsolate()); | 245   v8::HandleScope scope(env->GetIsolate()); | 
| 246   v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 246   v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 
| 247   CompileRun( | 247   CompileRun( | 
| 248       "function myFunction(a, b) { this.a = a; this.b = b; }\n" | 248       "function myFunction(a, b) { this.a = a; this.b = b; }\n" | 
| 249       "function AAAAA() {}\n" | 249       "function AAAAA() {}\n" | 
| (...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2060   const v8::HeapGraphNode* transition_info = | 2060   const v8::HeapGraphNode* transition_info = | 
| 2061       GetProperty(allocation_site, v8::HeapGraphEdge::kInternal, | 2061       GetProperty(allocation_site, v8::HeapGraphEdge::kInternal, | 
| 2062                   "transition_info"); | 2062                   "transition_info"); | 
| 2063   CHECK_NE(NULL, transition_info); | 2063   CHECK_NE(NULL, transition_info); | 
| 2064 | 2064 | 
| 2065   const v8::HeapGraphNode* elements = | 2065   const v8::HeapGraphNode* elements = | 
| 2066       GetProperty(transition_info, v8::HeapGraphEdge::kInternal, | 2066       GetProperty(transition_info, v8::HeapGraphEdge::kInternal, | 
| 2067                   "elements"); | 2067                   "elements"); | 
| 2068   CHECK_NE(NULL, elements); | 2068   CHECK_NE(NULL, elements); | 
| 2069   CHECK_EQ(v8::HeapGraphNode::kArray, elements->GetType()); | 2069   CHECK_EQ(v8::HeapGraphNode::kArray, elements->GetType()); | 
| 2070   CHECK_EQ(v8::internal::FixedArray::SizeFor(3), elements->GetSelfSize()); | 2070   CHECK_EQ(v8::internal::FixedArray::SizeFor(3), | 
|  | 2071            static_cast<int>(elements->GetShallowSize())); | 
| 2071 | 2072 | 
| 2072   v8::Handle<v8::Value> array_val = | 2073   v8::Handle<v8::Value> array_val = | 
| 2073       heap_profiler->FindObjectById(transition_info->GetId()); | 2074       heap_profiler->FindObjectById(transition_info->GetId()); | 
| 2074   CHECK(array_val->IsArray()); | 2075   CHECK(array_val->IsArray()); | 
| 2075   v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(array_val); | 2076   v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(array_val); | 
| 2076   // Verify the array is "a" in the code above. | 2077   // Verify the array is "a" in the code above. | 
| 2077   CHECK_EQ(3, array->Length()); | 2078   CHECK_EQ(3, array->Length()); | 
| 2078   CHECK_EQ(v8::Integer::New(isolate, 3), | 2079   CHECK_EQ(v8::Integer::New(isolate, 3), | 
| 2079            array->Get(v8::Integer::New(isolate, 0))); | 2080            array->Get(v8::Integer::New(isolate, 0))); | 
| 2080   CHECK_EQ(v8::Integer::New(isolate, 2), | 2081   CHECK_EQ(v8::Integer::New(isolate, 2), | 
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2377   CHECK_NE(NULL, arr1_obj); | 2378   CHECK_NE(NULL, arr1_obj); | 
| 2378   const v8::HeapGraphNode* arr1_buffer = | 2379   const v8::HeapGraphNode* arr1_buffer = | 
| 2379       GetProperty(arr1_obj, v8::HeapGraphEdge::kInternal, "buffer"); | 2380       GetProperty(arr1_obj, v8::HeapGraphEdge::kInternal, "buffer"); | 
| 2380   CHECK_NE(NULL, arr1_buffer); | 2381   CHECK_NE(NULL, arr1_buffer); | 
| 2381   const v8::HeapGraphNode* first_view = | 2382   const v8::HeapGraphNode* first_view = | 
| 2382       GetProperty(arr1_buffer, v8::HeapGraphEdge::kWeak, "weak_first_view"); | 2383       GetProperty(arr1_buffer, v8::HeapGraphEdge::kWeak, "weak_first_view"); | 
| 2383   CHECK_NE(NULL, first_view); | 2384   CHECK_NE(NULL, first_view); | 
| 2384   const v8::HeapGraphNode* backing_store = | 2385   const v8::HeapGraphNode* backing_store = | 
| 2385       GetProperty(arr1_buffer, v8::HeapGraphEdge::kInternal, "backing_store"); | 2386       GetProperty(arr1_buffer, v8::HeapGraphEdge::kInternal, "backing_store"); | 
| 2386   CHECK_NE(NULL, backing_store); | 2387   CHECK_NE(NULL, backing_store); | 
| 2387   CHECK_EQ(400, backing_store->GetSelfSize()); | 2388   CHECK_EQ(400, static_cast<int>(backing_store->GetShallowSize())); | 
| 2388 } | 2389 } | 
| 2389 | 2390 | 
| 2390 | 2391 | 
| 2391 static int GetRetainersCount(const v8::HeapSnapshot* snapshot, | 2392 static int GetRetainersCount(const v8::HeapSnapshot* snapshot, | 
| 2392                              const v8::HeapGraphNode* node) { | 2393                              const v8::HeapGraphNode* node) { | 
| 2393   int count = 0; | 2394   int count = 0; | 
| 2394   for (int i = 0, l = snapshot->GetNodesCount(); i < l; ++i) { | 2395   for (int i = 0, l = snapshot->GetNodesCount(); i < l; ++i) { | 
| 2395     const v8::HeapGraphNode* parent = snapshot->GetNode(i); | 2396     const v8::HeapGraphNode* parent = snapshot->GetNode(i); | 
| 2396     for (int j = 0, l2 = parent->GetChildrenCount(); j < l2; ++j) { | 2397     for (int j = 0, l2 = parent->GetChildrenCount(); j < l2; ++j) { | 
| 2397       if (parent->GetChild(j)->GetToNode() == node) { | 2398       if (parent->GetChild(j)->GetToNode() == node) { | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2453   const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); | 2454   const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); | 
| 2454   const v8::HeapGraphNode* box_node = | 2455   const v8::HeapGraphNode* box_node = | 
| 2455       GetProperty(global_node, v8::HeapGraphEdge::kElement, "0"); | 2456       GetProperty(global_node, v8::HeapGraphEdge::kElement, "0"); | 
| 2456   CHECK_NE(NULL, box_node); | 2457   CHECK_NE(NULL, box_node); | 
| 2457   v8::String::Utf8Value box_node_name(box_node->GetName()); | 2458   v8::String::Utf8Value box_node_name(box_node->GetName()); | 
| 2458   CHECK_EQ("system / Box", *box_node_name); | 2459   CHECK_EQ("system / Box", *box_node_name); | 
| 2459   const v8::HeapGraphNode* box_value = | 2460   const v8::HeapGraphNode* box_value = | 
| 2460       GetProperty(box_node, v8::HeapGraphEdge::kInternal, "value"); | 2461       GetProperty(box_node, v8::HeapGraphEdge::kInternal, "value"); | 
| 2461   CHECK_NE(NULL, box_value); | 2462   CHECK_NE(NULL, box_value); | 
| 2462 } | 2463 } | 
| OLD | NEW | 
|---|