OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 visited.Add(*o); | 80 visited.Add(*o); |
81 } | 81 } |
82 | 82 |
83 List<Object*> visited; | 83 List<Object*> visited; |
84 }; | 84 }; |
85 | 85 |
86 | 86 |
87 TEST(IterateObjectGroupsOldApi) { | 87 TEST(IterateObjectGroupsOldApi) { |
88 CcTest::InitializeVM(); | 88 CcTest::InitializeVM(); |
89 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); | 89 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); |
90 | 90 Heap* heap = CcTest::heap(); |
91 v8::HandleScope handle_scope(CcTest::isolate()); | 91 v8::HandleScope handle_scope(CcTest::isolate()); |
92 | 92 |
93 Handle<Object> g1s1 = | 93 Handle<Object> g1s1 = |
94 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 94 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); |
95 Handle<Object> g1s2 = | 95 Handle<Object> g1s2 = |
96 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 96 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); |
97 | 97 |
98 Handle<Object> g2s1 = | 98 Handle<Object> g2s1 = |
99 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 99 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); |
100 Handle<Object> g2s2 = | 100 Handle<Object> g2s2 = |
101 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 101 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); |
102 | 102 |
103 TestRetainedObjectInfo info1; | 103 TestRetainedObjectInfo info1; |
104 TestRetainedObjectInfo info2; | 104 TestRetainedObjectInfo info2; |
105 { | 105 { |
106 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; | 106 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; |
107 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; | 107 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; |
108 | 108 |
109 global_handles->AddObjectGroup(g1_objects, 2, &info1); | 109 global_handles->AddObjectGroup(g1_objects, 2, &info1); |
110 global_handles->AddObjectGroup(g2_objects, 2, &info2); | 110 global_handles->AddObjectGroup(g2_objects, 2, &info2); |
111 } | 111 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 ASSERT(visitor.visited.Contains(*g2s1.location())); | 175 ASSERT(visitor.visited.Contains(*g2s1.location())); |
176 ASSERT(visitor.visited.Contains(*g2s2.location())); | 176 ASSERT(visitor.visited.Contains(*g2s2.location())); |
177 ASSERT(info2.has_been_disposed()); | 177 ASSERT(info2.has_been_disposed()); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 | 181 |
182 TEST(IterateObjectGroups) { | 182 TEST(IterateObjectGroups) { |
183 CcTest::InitializeVM(); | 183 CcTest::InitializeVM(); |
184 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); | 184 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); |
| 185 Heap* heap = CcTest::heap(); |
185 | 186 |
186 v8::HandleScope handle_scope(CcTest::isolate()); | 187 v8::HandleScope handle_scope(CcTest::isolate()); |
187 | 188 |
188 Handle<Object> g1s1 = | 189 Handle<Object> g1s1 = |
189 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 190 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); |
190 Handle<Object> g1s2 = | 191 Handle<Object> g1s2 = |
191 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 192 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); |
192 | 193 |
193 Handle<Object> g2s1 = | 194 Handle<Object> g2s1 = |
194 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 195 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); |
195 Handle<Object> g2s2 = | 196 Handle<Object> g2s2 = |
196 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 197 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); |
197 | 198 |
198 TestRetainedObjectInfo info1; | 199 TestRetainedObjectInfo info1; |
199 TestRetainedObjectInfo info2; | 200 TestRetainedObjectInfo info2; |
200 global_handles->SetObjectGroupId(g2s1.location(), UniqueId(2)); | 201 global_handles->SetObjectGroupId(g2s1.location(), UniqueId(2)); |
201 global_handles->SetObjectGroupId(g2s2.location(), UniqueId(2)); | 202 global_handles->SetObjectGroupId(g2s2.location(), UniqueId(2)); |
202 global_handles->SetRetainedObjectInfo(UniqueId(2), &info2); | 203 global_handles->SetRetainedObjectInfo(UniqueId(2), &info2); |
203 global_handles->SetObjectGroupId(g1s1.location(), UniqueId(1)); | 204 global_handles->SetObjectGroupId(g1s1.location(), UniqueId(1)); |
204 global_handles->SetObjectGroupId(g1s2.location(), UniqueId(1)); | 205 global_handles->SetObjectGroupId(g1s2.location(), UniqueId(1)); |
205 global_handles->SetRetainedObjectInfo(UniqueId(1), &info1); | 206 global_handles->SetRetainedObjectInfo(UniqueId(1), &info1); |
206 | 207 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 ASSERT(visitor.visited.Contains(*g2s1.location())); | 270 ASSERT(visitor.visited.Contains(*g2s1.location())); |
270 ASSERT(visitor.visited.Contains(*g2s2.location())); | 271 ASSERT(visitor.visited.Contains(*g2s2.location())); |
271 ASSERT(info2.has_been_disposed()); | 272 ASSERT(info2.has_been_disposed()); |
272 } | 273 } |
273 } | 274 } |
274 | 275 |
275 | 276 |
276 TEST(ImplicitReferences) { | 277 TEST(ImplicitReferences) { |
277 CcTest::InitializeVM(); | 278 CcTest::InitializeVM(); |
278 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); | 279 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); |
| 280 Heap* heap = CcTest::heap(); |
279 | 281 |
280 v8::HandleScope handle_scope(CcTest::isolate()); | 282 v8::HandleScope handle_scope(CcTest::isolate()); |
281 | 283 |
282 Handle<Object> g1s1 = | 284 Handle<Object> g1s1 = |
283 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 285 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); |
284 Handle<Object> g1c1 = | 286 Handle<Object> g1c1 = |
285 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 287 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); |
286 Handle<Object> g1c2 = | 288 Handle<Object> g1c2 = |
287 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 289 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); |
288 | 290 |
289 | 291 |
290 Handle<Object> g2s1 = | 292 Handle<Object> g2s1 = |
291 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 293 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); |
292 Handle<Object> g2s2 = | 294 Handle<Object> g2s2 = |
293 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 295 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); |
294 Handle<Object> g2c1 = | 296 Handle<Object> g2c1 = |
295 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 297 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); |
296 | 298 |
297 global_handles->SetObjectGroupId(g1s1.location(), UniqueId(1)); | 299 global_handles->SetObjectGroupId(g1s1.location(), UniqueId(1)); |
298 global_handles->SetObjectGroupId(g2s1.location(), UniqueId(2)); | 300 global_handles->SetObjectGroupId(g2s1.location(), UniqueId(2)); |
299 global_handles->SetObjectGroupId(g2s2.location(), UniqueId(2)); | 301 global_handles->SetObjectGroupId(g2s2.location(), UniqueId(2)); |
300 global_handles->SetReferenceFromGroup(UniqueId(1), g1c1.location()); | 302 global_handles->SetReferenceFromGroup(UniqueId(1), g1c1.location()); |
301 global_handles->SetReferenceFromGroup(UniqueId(1), g1c2.location()); | 303 global_handles->SetReferenceFromGroup(UniqueId(1), g1c2.location()); |
302 global_handles->SetReferenceFromGroup(UniqueId(2), g2c1.location()); | 304 global_handles->SetReferenceFromGroup(UniqueId(2), g2c1.location()); |
303 | 305 |
304 List<ImplicitRefGroup*>* implicit_refs = | 306 List<ImplicitRefGroup*>* implicit_refs = |
305 global_handles->implicit_ref_groups(); | 307 global_handles->implicit_ref_groups(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 { | 371 { |
370 HandleScope scope(isolate); | 372 HandleScope scope(isolate); |
371 v8::Local<v8::Object> object = v8::Object::New(); | 373 v8::Local<v8::Object> object = v8::Object::New(); |
372 v8::Eternal<v8::Object> eternal(v8_isolate, object); | 374 v8::Eternal<v8::Object> eternal(v8_isolate, object); |
373 CHECK(!eternal.IsEmpty()); | 375 CHECK(!eternal.IsEmpty()); |
374 CHECK(object == eternal.Get(v8_isolate)); | 376 CHECK(object == eternal.Get(v8_isolate)); |
375 } | 377 } |
376 | 378 |
377 CHECK_EQ(2*kArrayLength + 1, eternal_handles->NumberOfHandles()); | 379 CHECK_EQ(2*kArrayLength + 1, eternal_handles->NumberOfHandles()); |
378 } | 380 } |
OLD | NEW |