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

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

Issue 14007008: New GC APIs, try 2. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: code review (yurys) Created 7 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
« no previous file with comments | « test/cctest/test-heap-profiler.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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 { 361 {
362 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; 362 Object** g1_objects[] = { g1s1.location(), g1s2.location() };
363 Object** g1_children[] = { g1c1.location() }; 363 Object** g1_children[] = { g1c1.location() };
364 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; 364 Object** g2_objects[] = { g2s1.location(), g2s2.location() };
365 Object** g2_children[] = { g2c1.location() }; 365 Object** g2_children[] = { g2c1.location() };
366 global_handles->AddObjectGroup(g1_objects, 2, NULL); 366 global_handles->AddObjectGroup(g1_objects, 2, NULL);
367 global_handles->AddImplicitReferences( 367 global_handles->AddImplicitReferences(
368 Handle<HeapObject>::cast(g1s1).location(), g1_children, 1); 368 Handle<HeapObject>::cast(g1s1).location(), g1_children, 1);
369 global_handles->AddObjectGroup(g2_objects, 2, NULL); 369 global_handles->AddObjectGroup(g2_objects, 2, NULL);
370 global_handles->AddImplicitReferences( 370 global_handles->AddImplicitReferences(
371 Handle<HeapObject>::cast(g2s2).location(), g2_children, 1); 371 Handle<HeapObject>::cast(g2s1).location(), g2_children, 1);
372 } 372 }
373 // Do a full GC 373 // Do a full GC
374 HEAP->CollectGarbage(OLD_POINTER_SPACE); 374 HEAP->CollectGarbage(OLD_POINTER_SPACE);
375 375
376 // All object should be alive. 376 // All object should be alive.
377 CHECK_EQ(0, NumberOfWeakCalls); 377 CHECK_EQ(0, NumberOfWeakCalls);
378 378
379 // Weaken the root. 379 // Weaken the root.
380 global_handles->MakeWeak(root.location(), 380 global_handles->MakeWeak(root.location(),
381 reinterpret_cast<void*>(1234), 381 reinterpret_cast<void*>(1234),
382 NULL, 382 NULL,
383 &WeakPointerCallback); 383 &WeakPointerCallback);
384 // But make children strong roots---all the objects (except for children) 384 // But make children strong roots---all the objects (except for children)
385 // should be collectable now. 385 // should be collectable now.
386 global_handles->ClearWeakness(g1c1.location()); 386 global_handles->ClearWeakness(g1c1.location());
387 global_handles->ClearWeakness(g2c1.location()); 387 global_handles->ClearWeakness(g2c1.location());
388 388
389 // Groups are deleted, rebuild groups. 389 // Groups are deleted, rebuild groups.
390 { 390 {
391 Object** g1_objects[] = { g1s1.location(), g1s2.location() }; 391 Object** g1_objects[] = { g1s1.location(), g1s2.location() };
392 Object** g1_children[] = { g1c1.location() }; 392 Object** g1_children[] = { g1c1.location() };
393 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; 393 Object** g2_objects[] = { g2s1.location(), g2s2.location() };
394 Object** g2_children[] = { g2c1.location() }; 394 Object** g2_children[] = { g2c1.location() };
395 global_handles->AddObjectGroup(g1_objects, 2, NULL); 395 global_handles->AddObjectGroup(g1_objects, 2, NULL);
396 global_handles->AddImplicitReferences( 396 global_handles->AddImplicitReferences(
397 Handle<HeapObject>::cast(g1s1).location(), g1_children, 1); 397 Handle<HeapObject>::cast(g1s1).location(), g1_children, 1);
398 global_handles->AddObjectGroup(g2_objects, 2, NULL); 398 global_handles->AddObjectGroup(g2_objects, 2, NULL);
399 global_handles->AddImplicitReferences( 399 global_handles->AddImplicitReferences(
400 Handle<HeapObject>::cast(g2s2).location(), g2_children, 1); 400 Handle<HeapObject>::cast(g2s1).location(), g2_children, 1);
401 } 401 }
402 402
403 HEAP->CollectGarbage(OLD_POINTER_SPACE); 403 HEAP->CollectGarbage(OLD_POINTER_SPACE);
404 404
405 // All objects should be gone. 5 global handles in total. 405 // All objects should be gone. 5 global handles in total.
406 CHECK_EQ(5, NumberOfWeakCalls); 406 CHECK_EQ(5, NumberOfWeakCalls);
407 407
408 // And now make children weak again and collect them. 408 // And now make children weak again and collect them.
409 global_handles->MakeWeak(g1c1.location(), 409 global_handles->MakeWeak(g1c1.location(),
410 reinterpret_cast<void*>(1234), 410 reinterpret_cast<void*>(1234),
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 if (v8::internal::Snapshot::IsEnabled()) { 558 if (v8::internal::Snapshot::IsEnabled()) {
559 CHECK_LE(delta, 2900 * 1024); 559 CHECK_LE(delta, 2900 * 1024);
560 } else { 560 } else {
561 CHECK_LE(delta, 3400 * 1024); 561 CHECK_LE(delta, 3400 * 1024);
562 } 562 }
563 } 563 }
564 } 564 }
565 } 565 }
566 566
567 #endif // __linux__ and !USE_SIMULATOR 567 #endif // __linux__ and !USE_SIMULATOR
OLDNEW
« no previous file with comments | « test/cctest/test-heap-profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698