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

Side by Side Diff: test/cctest/test-mark-compact.cc

Issue 505983002: HeapProfiler: remove obsolete AddImplicitReferences (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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/global-handles.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 &WeakPointerCallback); 294 &WeakPointerCallback);
295 295
296 Handle<Object> root = global_handles->Create(*g1s1); // make a root. 296 Handle<Object> root = global_handles->Create(*g1s1); // make a root.
297 297
298 // Connect group 1 and 2, make a cycle. 298 // Connect group 1 and 2, make a cycle.
299 Handle<FixedArray>::cast(g1s2)->set(0, *g2s2); 299 Handle<FixedArray>::cast(g1s2)->set(0, *g2s2);
300 Handle<FixedArray>::cast(g2s1)->set(0, *g1s1); 300 Handle<FixedArray>::cast(g2s1)->set(0, *g1s1);
301 301
302 { 302 {
303 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; 303 Object** g1_objects[] = { g1s1.location(), g1s2.location() };
304 Object** g1_children[] = { g1c1.location() };
305 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; 304 Object** g2_objects[] = { g2s1.location(), g2s2.location() };
306 Object** g2_children[] = { g2c1.location() };
307 global_handles->AddObjectGroup(g1_objects, 2, NULL); 305 global_handles->AddObjectGroup(g1_objects, 2, NULL);
308 global_handles->AddImplicitReferences( 306 global_handles->SetReference(Handle<HeapObject>::cast(g1s1).location(),
309 Handle<HeapObject>::cast(g1s1).location(), g1_children, 1); 307 g1c1.location());
310 global_handles->AddObjectGroup(g2_objects, 2, NULL); 308 global_handles->AddObjectGroup(g2_objects, 2, NULL);
311 global_handles->AddImplicitReferences( 309 global_handles->SetReference(Handle<HeapObject>::cast(g2s1).location(),
312 Handle<HeapObject>::cast(g2s1).location(), g2_children, 1); 310 g2c1.location());
313 } 311 }
314 // Do a full GC 312 // Do a full GC
315 heap->CollectGarbage(OLD_POINTER_SPACE); 313 heap->CollectGarbage(OLD_POINTER_SPACE);
316 314
317 // All object should be alive. 315 // All object should be alive.
318 CHECK_EQ(0, NumberOfWeakCalls); 316 CHECK_EQ(0, NumberOfWeakCalls);
319 317
320 // Weaken the root. 318 // Weaken the root.
321 std::pair<Handle<Object>*, int> root_and_id(&root, 1234); 319 std::pair<Handle<Object>*, int> root_and_id(&root, 1234);
322 GlobalHandles::MakeWeak(root.location(), 320 GlobalHandles::MakeWeak(root.location(),
323 reinterpret_cast<void*>(&root_and_id), 321 reinterpret_cast<void*>(&root_and_id),
324 &WeakPointerCallback); 322 &WeakPointerCallback);
325 // But make children strong roots---all the objects (except for children) 323 // But make children strong roots---all the objects (except for children)
326 // should be collectable now. 324 // should be collectable now.
327 global_handles->ClearWeakness(g1c1.location()); 325 global_handles->ClearWeakness(g1c1.location());
328 global_handles->ClearWeakness(g2c1.location()); 326 global_handles->ClearWeakness(g2c1.location());
329 327
330 // Groups are deleted, rebuild groups. 328 // Groups are deleted, rebuild groups.
331 { 329 {
332 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; 330 Object** g1_objects[] = { g1s1.location(), g1s2.location() };
333 Object** g1_children[] = { g1c1.location() };
334 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; 331 Object** g2_objects[] = { g2s1.location(), g2s2.location() };
335 Object** g2_children[] = { g2c1.location() };
336 global_handles->AddObjectGroup(g1_objects, 2, NULL); 332 global_handles->AddObjectGroup(g1_objects, 2, NULL);
337 global_handles->AddImplicitReferences( 333 global_handles->SetReference(Handle<HeapObject>::cast(g1s1).location(),
338 Handle<HeapObject>::cast(g1s1).location(), g1_children, 1); 334 g1c1.location());
339 global_handles->AddObjectGroup(g2_objects, 2, NULL); 335 global_handles->AddObjectGroup(g2_objects, 2, NULL);
340 global_handles->AddImplicitReferences( 336 global_handles->SetReference(Handle<HeapObject>::cast(g2s1).location(),
341 Handle<HeapObject>::cast(g2s1).location(), g2_children, 1); 337 g2c1.location());
342 } 338 }
343 339
344 heap->CollectGarbage(OLD_POINTER_SPACE); 340 heap->CollectGarbage(OLD_POINTER_SPACE);
345 341
346 // All objects should be gone. 5 global handles in total. 342 // All objects should be gone. 5 global handles in total.
347 CHECK_EQ(5, NumberOfWeakCalls); 343 CHECK_EQ(5, NumberOfWeakCalls);
348 344
349 // And now make children weak again and collect them. 345 // And now make children weak again and collect them.
350 GlobalHandles::MakeWeak(g1c1.location(), 346 GlobalHandles::MakeWeak(g1c1.location(),
351 reinterpret_cast<void*>(&g1c1_and_id), 347 reinterpret_cast<void*>(&g1c1_and_id),
(...skipping 30 matching lines...) Expand all
382 bool has_been_disposed_; 378 bool has_been_disposed_;
383 }; 379 };
384 380
385 381
386 TEST(EmptyObjectGroups) { 382 TEST(EmptyObjectGroups) {
387 CcTest::InitializeVM(); 383 CcTest::InitializeVM();
388 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); 384 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles();
389 385
390 v8::HandleScope handle_scope(CcTest::isolate()); 386 v8::HandleScope handle_scope(CcTest::isolate());
391 387
392 Handle<Object> object = global_handles->Create(
393 CcTest::test_heap()->AllocateFixedArray(1).ToObjectChecked());
394
395 TestRetainedObjectInfo info; 388 TestRetainedObjectInfo info;
396 global_handles->AddObjectGroup(NULL, 0, &info); 389 global_handles->AddObjectGroup(NULL, 0, &info);
397 DCHECK(info.has_been_disposed()); 390 DCHECK(info.has_been_disposed());
398
399 global_handles->AddImplicitReferences(
400 Handle<HeapObject>::cast(object).location(), NULL, 0);
401 } 391 }
402 392
403 393
404 #if defined(__has_feature) 394 #if defined(__has_feature)
405 #if __has_feature(address_sanitizer) 395 #if __has_feature(address_sanitizer)
406 #define V8_WITH_ASAN 1 396 #define V8_WITH_ASAN 1
407 #endif 397 #endif
408 #endif 398 #endif
409 399
410 400
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 486
497 487
498 TEST(RegressJoinThreadsOnIsolateDeinit) { 488 TEST(RegressJoinThreadsOnIsolateDeinit) {
499 intptr_t size_limit = ShortLivingIsolate() * 2; 489 intptr_t size_limit = ShortLivingIsolate() * 2;
500 for (int i = 0; i < 10; i++) { 490 for (int i = 0; i < 10; i++) {
501 CHECK_GT(size_limit, ShortLivingIsolate()); 491 CHECK_GT(size_limit, ShortLivingIsolate());
502 } 492 }
503 } 493 }
504 494
505 #endif // __linux__ and !USE_SIMULATOR 495 #endif // __linux__ and !USE_SIMULATOR
OLDNEW
« no previous file with comments | « src/global-handles.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698