hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp
changeset 360 21d113ecbf6a
parent 1 489c9b5090e2
child 670 ddf3e9583f2f
equal deleted inserted replaced
357:f4edb0d9f109 360:21d113ecbf6a
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    21  * have any questions.
    22  *
    22  *
    23  */
    23  */
    24 
    24 
    25 
       
    26 inline void PSScavenge::save_to_space_top_before_gc() {
    25 inline void PSScavenge::save_to_space_top_before_gc() {
    27   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
    26   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
    28   _to_space_top_before_gc = heap->young_gen()->to_space()->top();
    27   _to_space_top_before_gc = heap->young_gen()->to_space()->top();
    29 }
    28 }
    30 
    29 
    31 inline bool PSScavenge::should_scavenge(oop p) {
    30 template <class T> inline bool PSScavenge::should_scavenge(T* p) {
    32   return p == NULL ? false : PSScavenge::is_obj_in_young((HeapWord*) p);
    31   T heap_oop = oopDesc::load_heap_oop(p);
       
    32   if (oopDesc::is_null(heap_oop)) return false;
       
    33   oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
       
    34   return PSScavenge::is_obj_in_young((HeapWord*)obj);
    33 }
    35 }
    34 
    36 
    35 inline bool PSScavenge::should_scavenge(oop p, MutableSpace* to_space) {
    37 template <class T>
       
    38 inline bool PSScavenge::should_scavenge(T* p, MutableSpace* to_space) {
    36   if (should_scavenge(p)) {
    39   if (should_scavenge(p)) {
       
    40     oop obj = oopDesc::load_decode_heap_oop_not_null(p);
    37     // Skip objects copied to to_space since the scavenge started.
    41     // Skip objects copied to to_space since the scavenge started.
    38     HeapWord* const addr = (HeapWord*) p;
    42     HeapWord* const addr = (HeapWord*)obj;
    39     return addr < to_space_top_before_gc() || addr >= to_space->end();
    43     return addr < to_space_top_before_gc() || addr >= to_space->end();
    40   }
    44   }
    41   return false;
    45   return false;
    42 }
    46 }
    43 
    47 
    44 inline bool PSScavenge::should_scavenge(oop p, bool check_to_space) {
    48 template <class T>
       
    49 inline bool PSScavenge::should_scavenge(T* p, bool check_to_space) {
    45   if (check_to_space) {
    50   if (check_to_space) {
    46     ParallelScavengeHeap* heap = (ParallelScavengeHeap*) Universe::heap();
    51     ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
    47     return should_scavenge(p, heap->young_gen()->to_space());
    52     return should_scavenge(p, heap->young_gen()->to_space());
    48   }
    53   }
    49   return should_scavenge(p);
    54   return should_scavenge(p);
    50 }
    55 }
    51 
    56 
    52 // Attempt to "claim" oop at p via CAS, push the new obj if successful
    57 // Attempt to "claim" oop at p via CAS, push the new obj if successful
    53 // This version tests the oop* to make sure it is within the heap before
    58 // This version tests the oop* to make sure it is within the heap before
    54 // attempting marking.
    59 // attempting marking.
       
    60 template <class T>
    55 inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm,
    61 inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm,
    56                                                    oop*                p) {
    62                                                    T*                  p) {
    57   assert(should_scavenge(*p, true), "revisiting object?");
    63   assert(should_scavenge(p, true), "revisiting object?");
    58 
    64 
    59   oop o = *p;
    65   oop o = oopDesc::load_decode_heap_oop_not_null(p);
    60   if (o->is_forwarded()) {
    66   oop new_obj = o->is_forwarded()
    61     *p = o->forwardee();
    67         ? o->forwardee()
    62   } else {
    68         : pm->copy_to_survivor_space(o, pm->depth_first());
    63     *p = pm->copy_to_survivor_space(o, pm->depth_first());
    69   oopDesc::encode_store_heap_oop_not_null(p, new_obj);
    64   }
       
    65 
    70 
    66   // We cannot mark without test, as some code passes us pointers
    71   // We cannot mark without test, as some code passes us pointers
    67   // that are outside the heap.
    72   // that are outside the heap.
    68   if ((!PSScavenge::is_obj_in_young((HeapWord*) p)) &&
    73   if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) &&
    69       Universe::heap()->is_in_reserved(p)) {
    74       Universe::heap()->is_in_reserved(p)) {
    70     o = *p;
    75     if (PSScavenge::is_obj_in_young((HeapWord*)new_obj)) {
    71     if (PSScavenge::is_obj_in_young((HeapWord*) o)) {
    76       card_table()->inline_write_ref_field_gc(p, new_obj);
    72       card_table()->inline_write_ref_field_gc(p, o);
       
    73     }
    77     }
    74   }
    78   }
    75 }
    79 }