src/share/vm/gc_implementation/g1/heapRegion.cpp

changeset 7654
36c7518fd486
parent 7647
80ac3ee51955
child 7655
8e9ede9dd2cd
equal deleted inserted replaced
7653:b6a1bf5222c5 7654:36c7518fd486
1 /* 1 /*
2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
466 assert(cur <= start, "Postcondition"); 466 assert(cur <= start, "Postcondition");
467 467
468 oop obj; 468 oop obj;
469 469
470 HeapWord* next = cur; 470 HeapWord* next = cur;
471 while (next <= start) { 471 do {
472 cur = next; 472 cur = next;
473 obj = oop(cur); 473 obj = oop(cur);
474 if (obj->klass_or_null() == NULL) { 474 if (obj->klass_or_null() == NULL) {
475 // Ran into an unparseable point. 475 // Ran into an unparseable point.
476 return cur; 476 return cur;
477 } 477 }
478 // Otherwise... 478 // Otherwise...
479 next = cur + block_size(cur); 479 next = cur + block_size(cur);
480 } 480 } while (next <= start);
481 481
482 // If we finish the above loop...We have a parseable object that 482 // If we finish the above loop...We have a parseable object that
483 // begins on or before the start of the memory region, and ends 483 // begins on or before the start of the memory region, and ends
484 // inside or spans the entire region. 484 // inside or spans the entire region.
485
486 assert(obj == oop(cur), "sanity");
487 assert(cur <= start, "Loop postcondition"); 485 assert(cur <= start, "Loop postcondition");
488 assert(obj->klass_or_null() != NULL, "Loop postcondition"); 486 assert(obj->klass_or_null() != NULL, "Loop postcondition");
489 assert((cur + block_size(cur)) > start, "Loop postcondition"); 487
490 488 do {
491 if (!g1h->is_obj_dead(obj)) {
492 obj->oop_iterate(cl, mr);
493 }
494
495 while (cur < end) {
496 obj = oop(cur); 489 obj = oop(cur);
490 assert((cur + block_size(cur)) > (HeapWord*)obj, "Loop invariant");
497 if (obj->klass_or_null() == NULL) { 491 if (obj->klass_or_null() == NULL) {
498 // Ran into an unparseable point. 492 // Ran into an unparseable point.
499 return cur; 493 return cur;
500 }; 494 }
501 495
502 // Otherwise: 496 // Advance the current pointer. "obj" still points to the object to iterate.
503 next = cur + block_size(cur); 497 cur = cur + block_size(cur);
504 498
505 if (!g1h->is_obj_dead(obj)) { 499 if (!g1h->is_obj_dead(obj)) {
506 if (next < end || !obj->is_objArray()) { 500 // Non-objArrays are sometimes marked imprecise at the object start. We
507 // This object either does not span the MemRegion 501 // always need to iterate over them in full.
508 // boundary, or if it does it's not an array. 502 // We only iterate over object arrays in full if they are completely contained
509 // Apply closure to whole object. 503 // in the memory region.
504 if (!obj->is_objArray() || (((HeapWord*)obj) >= start && cur <= end)) {
510 obj->oop_iterate(cl); 505 obj->oop_iterate(cl);
511 } else { 506 } else {
512 // This obj is an array that spans the boundary.
513 // Stop at the boundary.
514 obj->oop_iterate(cl, mr); 507 obj->oop_iterate(cl, mr);
515 } 508 }
516 } 509 }
517 cur = next; 510 } while (cur < end);
518 } 511
519 return NULL; 512 return NULL;
520 } 513 }
521 514
522 // Code roots support 515 // Code roots support
523 516

mercurial