Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: test/cctest/test-global-handles.cc

Issue 146213004: A64: Synchronize with r16849. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-func-name-inference.cc ('k') | test/cctest/test-global-object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 ASSERT(visitor.visited.length() == 2); 269 ASSERT(visitor.visited.length() == 2);
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 = Isolate::Current()->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();
306 USE(implicit_refs); 308 USE(implicit_refs);
307 ASSERT(implicit_refs->length() == 2); 309 ASSERT(implicit_refs->length() == 2);
308 ASSERT(implicit_refs->at(0)->parent == 310 ASSERT(implicit_refs->at(0)->parent ==
309 reinterpret_cast<HeapObject**>(g1s1.location())); 311 reinterpret_cast<HeapObject**>(g1s1.location()));
310 ASSERT(implicit_refs->at(0)->length == 2); 312 ASSERT(implicit_refs->at(0)->length == 2);
311 ASSERT(implicit_refs->at(0)->children[0] == g1c1.location()); 313 ASSERT(implicit_refs->at(0)->children[0] == g1c1.location());
312 ASSERT(implicit_refs->at(0)->children[1] == g1c2.location()); 314 ASSERT(implicit_refs->at(0)->children[1] == g1c2.location());
313 ASSERT(implicit_refs->at(1)->parent == 315 ASSERT(implicit_refs->at(1)->parent ==
314 reinterpret_cast<HeapObject**>(g2s1.location())); 316 reinterpret_cast<HeapObject**>(g2s1.location()));
315 ASSERT(implicit_refs->at(1)->length == 1); 317 ASSERT(implicit_refs->at(1)->length == 1);
316 ASSERT(implicit_refs->at(1)->children[0] == g2c1.location()); 318 ASSERT(implicit_refs->at(1)->children[0] == g2c1.location());
317 } 319 }
318 320
319 321
320 TEST(EternalHandles) { 322 TEST(EternalHandles) {
321 CcTest::InitializeVM(); 323 CcTest::InitializeVM();
322 Isolate* isolate = Isolate::Current(); 324 Isolate* isolate = CcTest::i_isolate();
323 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); 325 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
324 EternalHandles* eternal_handles = isolate->eternal_handles(); 326 EternalHandles* eternal_handles = isolate->eternal_handles();
325 327
326 // Create a number of handles that will not be on a block boundary 328 // Create a number of handles that will not be on a block boundary
327 const int kArrayLength = 2048-1; 329 const int kArrayLength = 2048-1;
328 int indices[kArrayLength]; 330 int indices[kArrayLength];
329 v8::Eternal<v8::Value> eternals[kArrayLength]; 331 v8::Eternal<v8::Value> eternals[kArrayLength];
330 332
331 CHECK_EQ(0, eternal_handles->NumberOfHandles()); 333 CHECK_EQ(0, eternal_handles->NumberOfHandles());
332 for (int i = 0; i < kArrayLength; i++) { 334 for (int i = 0; i < kArrayLength; i++) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « test/cctest/test-func-name-inference.cc ('k') | test/cctest/test-global-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698