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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 for (Object** o = start; o != end; ++o) | 79 for (Object** o = start; o != end; ++o) |
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 = Isolate::Current()->global_handles(); | 89 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); |
90 | 90 |
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()); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 ASSERT(visitor.visited.length() == 2); | 174 ASSERT(visitor.visited.length() == 2); |
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 = Isolate::Current()->global_handles(); | 184 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); |
185 | 185 |
186 v8::HandleScope handle_scope(CcTest::isolate()); | 186 v8::HandleScope handle_scope(CcTest::isolate()); |
187 | 187 |
188 Handle<Object> g1s1 = | 188 Handle<Object> g1s1 = |
189 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 189 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); |
190 Handle<Object> g1s2 = | 190 Handle<Object> g1s2 = |
191 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 191 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); |
192 | 192 |
193 Handle<Object> g2s1 = | 193 Handle<Object> g2s1 = |
194 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 194 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 ASSERT(visitor.visited.length() == 2); | 268 ASSERT(visitor.visited.length() == 2); |
269 ASSERT(visitor.visited.Contains(*g2s1.location())); | 269 ASSERT(visitor.visited.Contains(*g2s1.location())); |
270 ASSERT(visitor.visited.Contains(*g2s2.location())); | 270 ASSERT(visitor.visited.Contains(*g2s2.location())); |
271 ASSERT(info2.has_been_disposed()); | 271 ASSERT(info2.has_been_disposed()); |
272 } | 272 } |
273 } | 273 } |
274 | 274 |
275 | 275 |
276 TEST(ImplicitReferences) { | 276 TEST(ImplicitReferences) { |
277 CcTest::InitializeVM(); | 277 CcTest::InitializeVM(); |
278 GlobalHandles* global_handles = Isolate::Current()->global_handles(); | 278 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); |
279 | 279 |
280 v8::HandleScope handle_scope(CcTest::isolate()); | 280 v8::HandleScope handle_scope(CcTest::isolate()); |
281 | 281 |
282 Handle<Object> g1s1 = | 282 Handle<Object> g1s1 = |
283 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 283 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); |
284 Handle<Object> g1c1 = | 284 Handle<Object> g1c1 = |
285 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 285 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); |
286 Handle<Object> g1c2 = | 286 Handle<Object> g1c2 = |
287 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 287 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); |
288 | 288 |
(...skipping 23 matching lines...) Expand all Loading... |
312 ASSERT(implicit_refs->at(0)->children[1] == g1c2.location()); | 312 ASSERT(implicit_refs->at(0)->children[1] == g1c2.location()); |
313 ASSERT(implicit_refs->at(1)->parent == | 313 ASSERT(implicit_refs->at(1)->parent == |
314 reinterpret_cast<HeapObject**>(g2s1.location())); | 314 reinterpret_cast<HeapObject**>(g2s1.location())); |
315 ASSERT(implicit_refs->at(1)->length == 1); | 315 ASSERT(implicit_refs->at(1)->length == 1); |
316 ASSERT(implicit_refs->at(1)->children[0] == g2c1.location()); | 316 ASSERT(implicit_refs->at(1)->children[0] == g2c1.location()); |
317 } | 317 } |
318 | 318 |
319 | 319 |
320 TEST(EternalHandles) { | 320 TEST(EternalHandles) { |
321 CcTest::InitializeVM(); | 321 CcTest::InitializeVM(); |
322 Isolate* isolate = Isolate::Current(); | 322 Isolate* isolate = CcTest::i_isolate(); |
323 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); | 323 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); |
324 EternalHandles* eternal_handles = isolate->eternal_handles(); | 324 EternalHandles* eternal_handles = isolate->eternal_handles(); |
325 | 325 |
326 // Create a number of handles that will not be on a block boundary | 326 // Create a number of handles that will not be on a block boundary |
327 const int kArrayLength = 2048-1; | 327 const int kArrayLength = 2048-1; |
328 int indices[kArrayLength]; | 328 int indices[kArrayLength]; |
329 v8::Eternal<v8::Value> eternals[kArrayLength]; | 329 v8::Eternal<v8::Value> eternals[kArrayLength]; |
330 | 330 |
331 CHECK_EQ(0, eternal_handles->NumberOfHandles()); | 331 CHECK_EQ(0, eternal_handles->NumberOfHandles()); |
332 for (int i = 0; i < kArrayLength; i++) { | 332 for (int i = 0; i < kArrayLength; i++) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 { | 369 { |
370 HandleScope scope(isolate); | 370 HandleScope scope(isolate); |
371 v8::Local<v8::Object> object = v8::Object::New(); | 371 v8::Local<v8::Object> object = v8::Object::New(); |
372 v8::Eternal<v8::Object> eternal(v8_isolate, object); | 372 v8::Eternal<v8::Object> eternal(v8_isolate, object); |
373 CHECK(!eternal.IsEmpty()); | 373 CHECK(!eternal.IsEmpty()); |
374 CHECK(object == eternal.Get(v8_isolate)); | 374 CHECK(object == eternal.Get(v8_isolate)); |
375 } | 375 } |
376 | 376 |
377 CHECK_EQ(2*kArrayLength + 1, eternal_handles->NumberOfHandles()); | 377 CHECK_EQ(2*kArrayLength + 1, eternal_handles->NumberOfHandles()); |
378 } | 378 } |
OLD | NEW |