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

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

Issue 236303015: Remove some uses of MaybeObject methods. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | « src/runtime.cc ('k') | test/cctest/test-strings.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 = CcTest::i_isolate()->global_handles(); 89 Isolate* isolate = CcTest::i_isolate();
90 Heap* heap = CcTest::heap(); 90 GlobalHandles* global_handles = isolate->global_handles();
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(*isolate->factory()->NewFixedArray(1));
95 Handle<Object> g1s2 = 95 Handle<Object> g1s2 =
96 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); 96 global_handles->Create(*isolate->factory()->NewFixedArray(1));
97 97
98 Handle<Object> g2s1 = 98 Handle<Object> g2s1 =
99 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); 99 global_handles->Create(*isolate->factory()->NewFixedArray(1));
100 Handle<Object> g2s2 = 100 Handle<Object> g2s2 =
101 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); 101 global_handles->Create(*isolate->factory()->NewFixedArray(1));
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 = CcTest::i_isolate()->global_handles(); 184 Isolate* isolate = CcTest::i_isolate();
185 Heap* heap = CcTest::heap(); 185 GlobalHandles* global_handles = isolate->global_handles();
186 186
187 v8::HandleScope handle_scope(CcTest::isolate()); 187 v8::HandleScope handle_scope(CcTest::isolate());
188 188
189 Handle<Object> g1s1 = 189 Handle<Object> g1s1 =
190 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); 190 global_handles->Create(*isolate->factory()->NewFixedArray(1));
191 Handle<Object> g1s2 = 191 Handle<Object> g1s2 =
192 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); 192 global_handles->Create(*isolate->factory()->NewFixedArray(1));
193 193
194 Handle<Object> g2s1 = 194 Handle<Object> g2s1 =
195 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); 195 global_handles->Create(*isolate->factory()->NewFixedArray(1));
196 Handle<Object> g2s2 = 196 Handle<Object> g2s2 =
197 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); 197 global_handles->Create(*isolate->factory()->NewFixedArray(1));
198 198
199 TestRetainedObjectInfo info1; 199 TestRetainedObjectInfo info1;
200 TestRetainedObjectInfo info2; 200 TestRetainedObjectInfo info2;
201 global_handles->SetObjectGroupId(g2s1.location(), UniqueId(2)); 201 global_handles->SetObjectGroupId(g2s1.location(), UniqueId(2));
202 global_handles->SetObjectGroupId(g2s2.location(), UniqueId(2)); 202 global_handles->SetObjectGroupId(g2s2.location(), UniqueId(2));
203 global_handles->SetRetainedObjectInfo(UniqueId(2), &info2); 203 global_handles->SetRetainedObjectInfo(UniqueId(2), &info2);
204 global_handles->SetObjectGroupId(g1s1.location(), UniqueId(1)); 204 global_handles->SetObjectGroupId(g1s1.location(), UniqueId(1));
205 global_handles->SetObjectGroupId(g1s2.location(), UniqueId(1)); 205 global_handles->SetObjectGroupId(g1s2.location(), UniqueId(1));
206 global_handles->SetRetainedObjectInfo(UniqueId(1), &info1); 206 global_handles->SetRetainedObjectInfo(UniqueId(1), &info1);
207 207
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 ASSERT(visitor.visited.length() == 2); 269 ASSERT(visitor.visited.length() == 2);
270 ASSERT(visitor.visited.Contains(*g2s1.location())); 270 ASSERT(visitor.visited.Contains(*g2s1.location()));
271 ASSERT(visitor.visited.Contains(*g2s2.location())); 271 ASSERT(visitor.visited.Contains(*g2s2.location()));
272 ASSERT(info2.has_been_disposed()); 272 ASSERT(info2.has_been_disposed());
273 } 273 }
274 } 274 }
275 275
276 276
277 TEST(ImplicitReferences) { 277 TEST(ImplicitReferences) {
278 CcTest::InitializeVM(); 278 CcTest::InitializeVM();
279 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); 279 Isolate* isolate = CcTest::i_isolate();
280 Heap* heap = CcTest::heap(); 280 GlobalHandles* global_handles = isolate->global_handles();
281 281
282 v8::HandleScope handle_scope(CcTest::isolate()); 282 v8::HandleScope handle_scope(CcTest::isolate());
283 283
284 Handle<Object> g1s1 = 284 Handle<Object> g1s1 =
285 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); 285 global_handles->Create(*isolate->factory()->NewFixedArray(1));
286 Handle<Object> g1c1 = 286 Handle<Object> g1c1 =
287 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); 287 global_handles->Create(*isolate->factory()->NewFixedArray(1));
288 Handle<Object> g1c2 = 288 Handle<Object> g1c2 =
289 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); 289 global_handles->Create(*isolate->factory()->NewFixedArray(1));
290 290
291 291
292 Handle<Object> g2s1 = 292 Handle<Object> g2s1 =
293 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); 293 global_handles->Create(*isolate->factory()->NewFixedArray(1));
294 Handle<Object> g2s2 = 294 Handle<Object> g2s2 =
295 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); 295 global_handles->Create(*isolate->factory()->NewFixedArray(1));
296 Handle<Object> g2c1 = 296 Handle<Object> g2c1 =
297 global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked()); 297 global_handles->Create(*isolate->factory()->NewFixedArray(1));
298 298
299 global_handles->SetObjectGroupId(g1s1.location(), UniqueId(1)); 299 global_handles->SetObjectGroupId(g1s1.location(), UniqueId(1));
300 global_handles->SetObjectGroupId(g2s1.location(), UniqueId(2)); 300 global_handles->SetObjectGroupId(g2s1.location(), UniqueId(2));
301 global_handles->SetObjectGroupId(g2s2.location(), UniqueId(2)); 301 global_handles->SetObjectGroupId(g2s2.location(), UniqueId(2));
302 global_handles->SetReferenceFromGroup(UniqueId(1), g1c1.location()); 302 global_handles->SetReferenceFromGroup(UniqueId(1), g1c1.location());
303 global_handles->SetReferenceFromGroup(UniqueId(1), g1c2.location()); 303 global_handles->SetReferenceFromGroup(UniqueId(1), g1c2.location());
304 global_handles->SetReferenceFromGroup(UniqueId(2), g2c1.location()); 304 global_handles->SetReferenceFromGroup(UniqueId(2), g2c1.location());
305 305
306 List<ImplicitRefGroup*>* implicit_refs = 306 List<ImplicitRefGroup*>* implicit_refs =
307 global_handles->implicit_ref_groups(); 307 global_handles->implicit_ref_groups();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 { 373 {
374 HandleScope scope(isolate); 374 HandleScope scope(isolate);
375 v8::Local<v8::Object> object = v8::Object::New(v8_isolate); 375 v8::Local<v8::Object> object = v8::Object::New(v8_isolate);
376 v8::Eternal<v8::Object> eternal(v8_isolate, object); 376 v8::Eternal<v8::Object> eternal(v8_isolate, object);
377 CHECK(!eternal.IsEmpty()); 377 CHECK(!eternal.IsEmpty());
378 CHECK(object == eternal.Get(v8_isolate)); 378 CHECK(object == eternal.Get(v8_isolate));
379 } 379 }
380 380
381 CHECK_EQ(2*kArrayLength + 1, eternal_handles->NumberOfHandles()); 381 CHECK_EQ(2*kArrayLength + 1, eternal_handles->NumberOfHandles());
382 } 382 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698