| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/object_graph.h" | 6 #include "vm/object_graph.h" |
| 7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
| 8 | 8 |
| 9 namespace dart { | 9 namespace dart { |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // | v | 46 // | v |
| 47 // +-->d | 47 // +-->d |
| 48 Array& a = Array::Handle(Array::New(2, Heap::kNew)); | 48 Array& a = Array::Handle(Array::New(2, Heap::kNew)); |
| 49 Array& b = Array::Handle(Array::New(2, Heap::kOld)); | 49 Array& b = Array::Handle(Array::New(2, Heap::kOld)); |
| 50 Array& c = Array::Handle(Array::New(0, Heap::kOld)); | 50 Array& c = Array::Handle(Array::New(0, Heap::kOld)); |
| 51 Array& d = Array::Handle(Array::New(0, Heap::kOld)); | 51 Array& d = Array::Handle(Array::New(0, Heap::kOld)); |
| 52 a.SetAt(0, b); | 52 a.SetAt(0, b); |
| 53 b.SetAt(0, c); | 53 b.SetAt(0, c); |
| 54 b.SetAt(1, d); | 54 b.SetAt(1, d); |
| 55 a.SetAt(1, d); | 55 a.SetAt(1, d); |
| 56 intptr_t a_size = a.raw()->Size(); |
| 56 intptr_t b_size = b.raw()->Size(); | 57 intptr_t b_size = b.raw()->Size(); |
| 57 intptr_t c_size = c.raw()->Size(); | 58 intptr_t c_size = c.raw()->Size(); |
| 59 intptr_t d_size = d.raw()->Size(); |
| 58 { | 60 { |
| 59 // No more allocation; raw pointers ahead. | 61 // No more allocation; raw pointers ahead. |
| 60 NoGCScope no_gc_scope; | 62 NoGCScope no_gc_scope; |
| 61 RawObject* b_raw = b.raw(); | 63 RawObject* b_raw = b.raw(); |
| 62 // Clear handles to cut unintended retained paths. | 64 // Clear handles to cut unintended retained paths. |
| 63 b = Array::null(); | 65 b = Array::null(); |
| 64 c = Array::null(); | 66 c = Array::null(); |
| 65 d = Array::null(); | 67 d = Array::null(); |
| 66 ObjectGraph graph(isolate); | 68 ObjectGraph graph(isolate); |
| 67 { | 69 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 79 // Like above, but iterate over the entire isolate. The counts and sizes | 81 // Like above, but iterate over the entire isolate. The counts and sizes |
| 80 // are thus larger, but the difference should still be just 'b' and 'c'. | 82 // are thus larger, but the difference should still be just 'b' and 'c'. |
| 81 Counter with(Object::null(), Object::null()); | 83 Counter with(Object::null(), Object::null()); |
| 82 graph.IterateObjects(&with); | 84 graph.IterateObjects(&with); |
| 83 Counter without(b_raw, a.raw()); | 85 Counter without(b_raw, a.raw()); |
| 84 graph.IterateObjects(&without); | 86 graph.IterateObjects(&without); |
| 85 EXPECT_EQ(2, with.count() - without.count()); | 87 EXPECT_EQ(2, with.count() - without.count()); |
| 86 EXPECT_EQ(b_size + c_size, | 88 EXPECT_EQ(b_size + c_size, |
| 87 with.size() - without.size()); | 89 with.size() - without.size()); |
| 88 } | 90 } |
| 91 EXPECT_EQ(a_size + b_size + c_size + d_size, |
| 92 graph.SizeRetainedByInstance(a)); |
| 89 } | 93 } |
| 90 } | 94 } |
| 91 | 95 |
| 92 } // namespace dart | 96 } // namespace dart |
| OLD | NEW |