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. |
418 assert(cur <= start, "Postcondition"); |
418 assert(cur <= start, "Postcondition"); |
419 |
419 |
420 oop obj; |
420 oop obj; |
421 |
421 |
422 HeapWord* next = cur; |
422 HeapWord* next = cur; |
423 while (next <= start) { |
423 do { |
424 cur = next; |
424 cur = next; |
425 obj = oop(cur); |
425 obj = oop(cur); |
426 if (obj->klass_or_null() == NULL) { |
426 if (obj->klass_or_null() == NULL) { |
427 // Ran into an unparseable point. |
427 // Ran into an unparseable point. |
428 return cur; |
428 return cur; |
429 } |
429 } |
430 // Otherwise... |
430 // Otherwise... |
431 next = cur + block_size(cur); |
431 next = cur + block_size(cur); |
432 } |
432 } while (next <= start); |
433 |
433 |
434 // If we finish the above loop...We have a parseable object that |
434 // If we finish the above loop...We have a parseable object that |
435 // begins on or before the start of the memory region, and ends |
435 // begins on or before the start of the memory region, and ends |
436 // inside or spans the entire region. |
436 // inside or spans the entire region. |
437 |
|
438 assert(obj == oop(cur), "sanity"); |
|
439 assert(cur <= start, "Loop postcondition"); |
437 assert(cur <= start, "Loop postcondition"); |
440 assert(obj->klass_or_null() != NULL, "Loop postcondition"); |
438 assert(obj->klass_or_null() != NULL, "Loop postcondition"); |
441 assert((cur + block_size(cur)) > start, "Loop postcondition"); |
439 |
442 |
440 do { |
443 if (!g1h->is_obj_dead(obj)) { |
|
444 obj->oop_iterate(cl, mr); |
|
445 } |
|
446 |
|
447 while (cur < end) { |
|
448 obj = oop(cur); |
441 obj = oop(cur); |
|
442 assert((cur + block_size(cur)) > (HeapWord*)obj, "Loop invariant"); |
449 if (obj->klass_or_null() == NULL) { |
443 if (obj->klass_or_null() == NULL) { |
450 // Ran into an unparseable point. |
444 // Ran into an unparseable point. |
451 return cur; |
445 return cur; |
452 }; |
446 } |
453 |
447 |
454 // Otherwise: |
448 // Advance the current pointer. "obj" still points to the object to iterate. |
455 next = cur + block_size(cur); |
449 cur = cur + block_size(cur); |
456 |
450 |
457 if (!g1h->is_obj_dead(obj)) { |
451 if (!g1h->is_obj_dead(obj)) { |
458 if (next < end || !obj->is_objArray()) { |
452 // Non-objArrays are sometimes marked imprecise at the object start. We |
459 // This object either does not span the MemRegion |
453 // always need to iterate over them in full. |
460 // boundary, or if it does it's not an array. |
454 // We only iterate over object arrays in full if they are completely contained |
461 // Apply closure to whole object. |
455 // in the memory region. |
|
456 if (!obj->is_objArray() || (((HeapWord*)obj) >= start && cur <= end)) { |
462 obj->oop_iterate(cl); |
457 obj->oop_iterate(cl); |
463 } else { |
458 } else { |
464 // This obj is an array that spans the boundary. |
|
465 // Stop at the boundary. |
|
466 obj->oop_iterate(cl, mr); |
459 obj->oop_iterate(cl, mr); |
467 } |
460 } |
468 } |
461 } |
469 cur = next; |
462 } while (cur < end); |
470 } |
463 |
471 return NULL; |
464 return NULL; |
472 } |
465 } |
473 |
466 |
474 // Code roots support |
467 // Code roots support |
475 |
468 |