< prev index next >

src/share/vm/gc_interface/collectedHeap.inline.hpp

Print this page




 219   return (oop)obj;
 220 }
 221 
 222 oop CollectedHeap::array_allocate_nozero(KlassHandle klass,
 223                                          int size,
 224                                          int length,
 225                                          TRAPS) {
 226   debug_only(check_for_valid_allocation_state());
 227   assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
 228   assert(size >= 0, "int won't convert to size_t");
 229   HeapWord* obj = common_mem_allocate_noinit(klass, size, CHECK_NULL);
 230   ((oop)obj)->set_klass_gap(0);
 231   post_allocation_setup_array(klass, obj, length);
 232 #ifndef PRODUCT
 233   const size_t hs = oopDesc::header_size()+1;
 234   Universe::heap()->check_for_non_bad_heap_word_value(obj+hs, size-hs);
 235 #endif
 236   return (oop)obj;
 237 }
 238 
 239 inline void CollectedHeap::oop_iterate_no_header(OopClosure* cl) {
 240   NoHeaderExtendedOopClosure no_header_cl(cl);
 241   oop_iterate(&no_header_cl);
 242 }
 243 
 244 
 245 inline HeapWord* CollectedHeap::align_allocation_or_fail(HeapWord* addr,
 246                                                          HeapWord* end,
 247                                                          unsigned short alignment_in_bytes) {
 248   if (alignment_in_bytes <= ObjectAlignmentInBytes) {
 249     return addr;
 250   }
 251 
 252   assert(is_ptr_aligned(addr, HeapWordSize),
 253     err_msg("Address " PTR_FORMAT " is not properly aligned.", p2i(addr)));
 254   assert(is_size_aligned(alignment_in_bytes, HeapWordSize),
 255     err_msg("Alignment size %u is incorrect.", alignment_in_bytes));
 256 
 257   HeapWord* new_addr = (HeapWord*) align_pointer_up(addr, alignment_in_bytes);
 258   size_t padding = pointer_delta(new_addr, addr);
 259 
 260   if (padding == 0) {
 261     return addr;
 262   }
 263 
 264   if (padding < CollectedHeap::min_fill_size()) {




 219   return (oop)obj;
 220 }
 221 
 222 oop CollectedHeap::array_allocate_nozero(KlassHandle klass,
 223                                          int size,
 224                                          int length,
 225                                          TRAPS) {
 226   debug_only(check_for_valid_allocation_state());
 227   assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
 228   assert(size >= 0, "int won't convert to size_t");
 229   HeapWord* obj = common_mem_allocate_noinit(klass, size, CHECK_NULL);
 230   ((oop)obj)->set_klass_gap(0);
 231   post_allocation_setup_array(klass, obj, length);
 232 #ifndef PRODUCT
 233   const size_t hs = oopDesc::header_size()+1;
 234   Universe::heap()->check_for_non_bad_heap_word_value(obj+hs, size-hs);
 235 #endif
 236   return (oop)obj;
 237 }
 238 






 239 inline HeapWord* CollectedHeap::align_allocation_or_fail(HeapWord* addr,
 240                                                          HeapWord* end,
 241                                                          unsigned short alignment_in_bytes) {
 242   if (alignment_in_bytes <= ObjectAlignmentInBytes) {
 243     return addr;
 244   }
 245 
 246   assert(is_ptr_aligned(addr, HeapWordSize),
 247     err_msg("Address " PTR_FORMAT " is not properly aligned.", p2i(addr)));
 248   assert(is_size_aligned(alignment_in_bytes, HeapWordSize),
 249     err_msg("Alignment size %u is incorrect.", alignment_in_bytes));
 250 
 251   HeapWord* new_addr = (HeapWord*) align_pointer_up(addr, alignment_in_bytes);
 252   size_t padding = pointer_delta(new_addr, addr);
 253 
 254   if (padding == 0) {
 255     return addr;
 256   }
 257 
 258   if (padding < CollectedHeap::min_fill_size()) {


< prev index next >