< prev index next >

src/hotspot/share/gc/parallel/psPromotionLAB.cpp

Print this page

 30 #include "oops/oop.inline.hpp"
 31 
 32 size_t PSPromotionLAB::filler_header_size;
 33 
 34 // This is the shared initialization code. It sets up the basic pointers,
 35 // and allows enough extra space for a filler object. We call a virtual
 36 // method, "lab_is_valid()" to handle the different asserts the old/young
 37 // labs require.
 38 void PSPromotionLAB::initialize(MemRegion lab) {
 39   assert(lab_is_valid(lab), "Sanity");
 40 
 41   HeapWord* bottom = lab.start();
 42   HeapWord* end    = lab.end();
 43 
 44   set_bottom(bottom);
 45   set_end(end);
 46   set_top(bottom);
 47 
 48   // Initialize after VM starts up because header_size depends on compressed
 49   // oops.
 50   filler_header_size = align_object_size(typeArrayOopDesc::header_size(T_INT));
 51 
 52   // We can be initialized to a zero size!
 53   if (free() > 0) {
 54     if (ZapUnusedHeapArea) {
 55       debug_only(Copy::fill_to_words(top(), free()/HeapWordSize, badHeapWord));
 56     }
 57 
 58     // NOTE! We need to allow space for a filler object.
 59     assert(lab.word_size() >= filler_header_size, "lab is too small");
 60     end = end - filler_header_size;
 61     set_end(end);
 62 
 63     _state = needs_flush;
 64   } else {
 65     _state = zero_size;
 66   }
 67 
 68   assert(this->top() <= this->end(), "pointers out of order");
 69 }
 70 
 71 // Fill all remaining lab space with an unreachable object.
 72 // The goal is to leave a contiguous parseable span of objects.
 73 void PSPromotionLAB::flush() {
 74   assert(_state != flushed, "Attempt to flush PLAB twice");
 75   assert(top() <= end(), "pointers out of order");
 76 
 77   // If we were initialized to a zero sized lab, there is
 78   // nothing to flush
 79   if (_state == zero_size)
 80     return;
 81 
 82   // PLAB's never allocate the last aligned_header_size
 83   // so they can always fill with an array.
 84   HeapWord* tlab_end = end() + filler_header_size;
 85   typeArrayOop filler_oop = (typeArrayOop) cast_to_oop(top());
 86   filler_oop->set_mark(markWord::prototype());
 87   filler_oop->set_klass(Universe::intArrayKlassObj());
 88   const size_t array_length =
 89     pointer_delta(tlab_end, top()) - typeArrayOopDesc::header_size(T_INT);
 90   assert( (array_length * (HeapWordSize/sizeof(jint))) < (size_t)max_jint, "array too big in PSPromotionLAB");
 91   filler_oop->set_length((int)(array_length * (HeapWordSize/sizeof(jint))));




 92 
 93 #ifdef ASSERT
 94   // Note that we actually DO NOT want to use the aligned header size!
 95   HeapWord* elt_words = cast_from_oop<HeapWord*>(filler_oop) + typeArrayOopDesc::header_size(T_INT);
 96   Copy::fill_to_words(elt_words, array_length, 0xDEAABABE);

 97 #endif
 98 
 99   set_bottom(NULL);
100   set_end(NULL);
101   set_top(NULL);
102 
103   _state = flushed;
104 }
105 
106 bool PSPromotionLAB::unallocate_object(HeapWord* obj, size_t obj_size) {
107   assert(ParallelScavengeHeap::heap()->is_in(obj), "Object outside heap");
108 
109   if (contains(obj)) {
110     HeapWord* object_end = obj + obj_size;
111     assert(object_end == top(), "Not matching last allocation");
112 
113     set_top(obj);
114     return true;
115   }
116 

 30 #include "oops/oop.inline.hpp"
 31 
 32 size_t PSPromotionLAB::filler_header_size;
 33 
 34 // This is the shared initialization code. It sets up the basic pointers,
 35 // and allows enough extra space for a filler object. We call a virtual
 36 // method, "lab_is_valid()" to handle the different asserts the old/young
 37 // labs require.
 38 void PSPromotionLAB::initialize(MemRegion lab) {
 39   assert(lab_is_valid(lab), "Sanity");
 40 
 41   HeapWord* bottom = lab.start();
 42   HeapWord* end    = lab.end();
 43 
 44   set_bottom(bottom);
 45   set_end(end);
 46   set_top(bottom);
 47 
 48   // Initialize after VM starts up because header_size depends on compressed
 49   // oops.
 50   filler_header_size = align_object_size((arrayOopDesc::base_offset_in_bytes(T_INT) + BytesPerWord) / BytesPerWord);
 51 
 52   // We can be initialized to a zero size!
 53   if (free() > 0) {
 54     if (ZapUnusedHeapArea) {
 55       debug_only(Copy::fill_to_words(top(), free()/HeapWordSize, badHeapWord));
 56     }
 57 
 58     // NOTE! We need to allow space for a filler object.
 59     assert(lab.word_size() >= filler_header_size, "lab is too small");
 60     end = end - filler_header_size;
 61     set_end(end);
 62 
 63     _state = needs_flush;
 64   } else {
 65     _state = zero_size;
 66   }
 67 
 68   assert(this->top() <= this->end(), "pointers out of order");
 69 }
 70 
 71 // Fill all remaining lab space with an unreachable object.
 72 // The goal is to leave a contiguous parseable span of objects.
 73 void PSPromotionLAB::flush() {
 74   assert(_state != flushed, "Attempt to flush PLAB twice");
 75   assert(top() <= end(), "pointers out of order");
 76 
 77   // If we were initialized to a zero sized lab, there is
 78   // nothing to flush
 79   if (_state == zero_size)
 80     return;
 81 
 82   // PLAB's never allocate the last aligned_header_size
 83   // so they can always fill with an array.
 84   HeapWord* tlab_end = end() + filler_header_size;
 85   typeArrayOop filler_oop = (typeArrayOop) cast_to_oop(top());
 86   if (UseCompactObjectHeaders) {
 87     filler_oop->set_mark(Universe::intArrayKlassObj()->prototype_header());
 88   } else {
 89     filler_oop->set_mark(markWord::prototype());
 90     filler_oop->set_klass(Universe::intArrayKlassObj());
 91   }
 92   int header_size = arrayOopDesc::base_offset_in_bytes(T_INT);
 93   const size_t array_length_bytes = pointer_delta(tlab_end, top(), 1) - header_size;
 94   assert((array_length_bytes / sizeof(jint)) < (size_t)max_jint, "array too big in PSPromotionLAB");
 95   filler_oop->set_length((int)(array_length_bytes / sizeof(jint)));
 96 
 97 #ifdef ASSERT
 98   // Note that we actually DO NOT want to use the aligned header size!
 99   const size_t array_length_words = pointer_delta(tlab_end, top()) - heap_word_size(header_size);
100   HeapWord* elt_words = cast_from_oop<HeapWord*>(filler_oop) + heap_word_size(header_size);
101   Copy::fill_to_words(elt_words, array_length_words, 0xDEAABABE);
102 #endif
103 
104   set_bottom(NULL);
105   set_end(NULL);
106   set_top(NULL);
107 
108   _state = flushed;
109 }
110 
111 bool PSPromotionLAB::unallocate_object(HeapWord* obj, size_t obj_size) {
112   assert(ParallelScavengeHeap::heap()->is_in(obj), "Object outside heap");
113 
114   if (contains(obj)) {
115     HeapWord* object_end = obj + obj_size;
116     assert(object_end == top(), "Not matching last allocation");
117 
118     set_top(obj);
119     return true;
120   }
121 
< prev index next >