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 "vm/object_graph.h" | 5 #include "vm/object_graph.h" |
6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
8 | 8 |
9 namespace dart { | 9 namespace dart { |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 a.SetAt(10, b); | 51 a.SetAt(10, b); |
52 b.SetAt(0, c); | 52 b.SetAt(0, c); |
53 b.SetAt(1, d); | 53 b.SetAt(1, d); |
54 a.SetAt(11, d); | 54 a.SetAt(11, d); |
55 intptr_t a_size = a.raw()->Size(); | 55 intptr_t a_size = a.raw()->Size(); |
56 intptr_t b_size = b.raw()->Size(); | 56 intptr_t b_size = b.raw()->Size(); |
57 intptr_t c_size = c.raw()->Size(); | 57 intptr_t c_size = c.raw()->Size(); |
58 intptr_t d_size = d.raw()->Size(); | 58 intptr_t d_size = d.raw()->Size(); |
59 { | 59 { |
60 // No more allocation; raw pointers ahead. | 60 // No more allocation; raw pointers ahead. |
61 NoSafepointScope no_safepoint_scope; | 61 SafepointOperationScope safepoint(thread); |
62 RawObject* b_raw = b.raw(); | 62 RawObject* b_raw = b.raw(); |
63 // Clear handles to cut unintended retained paths. | 63 // Clear handles to cut unintended retained paths. |
64 b = Array::null(); | 64 b = Array::null(); |
65 c = Array::null(); | 65 c = Array::null(); |
66 d = Array::null(); | 66 d = Array::null(); |
67 ObjectGraph graph(thread); | 67 ObjectGraph graph(thread); |
68 { | 68 { |
69 HeapIterationScope iteration_scope(true); | 69 HeapIterationScope iteration_scope(thread, true); |
70 { | 70 { |
71 // Compare count and size when 'b' is/isn't skipped. | 71 // Compare count and size when 'b' is/isn't skipped. |
72 CounterVisitor with(Object::null(), Object::null()); | 72 CounterVisitor with(Object::null(), Object::null()); |
73 graph.IterateObjectsFrom(a, &with); | 73 graph.IterateObjectsFrom(a, &with); |
74 CounterVisitor without(b_raw, a.raw()); | 74 CounterVisitor without(b_raw, a.raw()); |
75 graph.IterateObjectsFrom(a, &without); | 75 graph.IterateObjectsFrom(a, &without); |
76 // Only 'b' and 'c' were cut off. | 76 // Only 'b' and 'c' were cut off. |
77 EXPECT_EQ(2, with.count() - without.count()); | 77 EXPECT_EQ(2, with.count() - without.count()); |
78 EXPECT_EQ(b_size + c_size, with.size() - without.size()); | 78 EXPECT_EQ(b_size + c_size, with.size() - without.size()); |
79 } | 79 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 Array& expected_a = Array::Handle(); | 132 Array& expected_a = Array::Handle(); |
133 expected_a ^= path.At(4); | 133 expected_a ^= path.At(4); |
134 EXPECT(expected_c.raw() == c.raw()); | 134 EXPECT(expected_c.raw() == c.raw()); |
135 EXPECT(expected_b.raw() == a.At(10)); | 135 EXPECT(expected_b.raw() == a.At(10)); |
136 EXPECT(expected_a.raw() == a.raw()); | 136 EXPECT(expected_a.raw() == a.raw()); |
137 } | 137 } |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 } // namespace dart | 141 } // namespace dart |
OLD | NEW |