< prev index next >

src/share/vm/gc/shared/collectedHeap.inline.hpp

Print this page




 251   debug_only(check_for_valid_allocation_state());
 252   assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
 253   assert(size >= 0, "int won't convert to size_t");
 254   HeapWord* obj = common_mem_allocate_noinit(klass, size, CHECK_NULL);
 255   ((oop)obj)->set_klass_gap(0);
 256   post_allocation_setup_array(klass, obj, length);
 257 #ifndef PRODUCT
 258   const size_t hs = oopDesc::header_size()+1;
 259   Universe::heap()->check_for_non_bad_heap_word_value(obj+hs, size-hs);
 260 #endif
 261   return (oop)obj;
 262 }
 263 
 264 inline HeapWord* CollectedHeap::align_allocation_or_fail(HeapWord* addr,
 265                                                          HeapWord* end,
 266                                                          unsigned short alignment_in_bytes) {
 267   if (alignment_in_bytes <= ObjectAlignmentInBytes) {
 268     return addr;
 269   }
 270 
 271   assert(is_ptr_aligned(addr, HeapWordSize),
 272          "Address " PTR_FORMAT " is not properly aligned.", p2i(addr));
 273   assert(is_size_aligned(alignment_in_bytes, HeapWordSize),
 274          "Alignment size %u is incorrect.", alignment_in_bytes);
 275 
 276   HeapWord* new_addr = align_ptr_up(addr, alignment_in_bytes);
 277   size_t padding = pointer_delta(new_addr, addr);
 278 
 279   if (padding == 0) {
 280     return addr;
 281   }
 282 
 283   if (padding < CollectedHeap::min_fill_size()) {
 284     padding += alignment_in_bytes / HeapWordSize;
 285     assert(padding >= CollectedHeap::min_fill_size(),
 286            "alignment_in_bytes %u is expect to be larger "
 287            "than the minimum object size", alignment_in_bytes);
 288     new_addr = addr + padding;
 289   }
 290 
 291   assert(new_addr > addr, "Unexpected arithmetic overflow "
 292          PTR_FORMAT " not greater than " PTR_FORMAT, p2i(new_addr), p2i(addr));
 293   if(new_addr < end) {
 294     CollectedHeap::fill_with_object(addr, padding);
 295     return new_addr;
 296   } else {




 251   debug_only(check_for_valid_allocation_state());
 252   assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
 253   assert(size >= 0, "int won't convert to size_t");
 254   HeapWord* obj = common_mem_allocate_noinit(klass, size, CHECK_NULL);
 255   ((oop)obj)->set_klass_gap(0);
 256   post_allocation_setup_array(klass, obj, length);
 257 #ifndef PRODUCT
 258   const size_t hs = oopDesc::header_size()+1;
 259   Universe::heap()->check_for_non_bad_heap_word_value(obj+hs, size-hs);
 260 #endif
 261   return (oop)obj;
 262 }
 263 
 264 inline HeapWord* CollectedHeap::align_allocation_or_fail(HeapWord* addr,
 265                                                          HeapWord* end,
 266                                                          unsigned short alignment_in_bytes) {
 267   if (alignment_in_bytes <= ObjectAlignmentInBytes) {
 268     return addr;
 269   }
 270 
 271   assert(is_aligned(addr, HeapWordSize),
 272          "Address " PTR_FORMAT " is not properly aligned.", p2i(addr));
 273   assert(is_aligned(alignment_in_bytes, HeapWordSize),
 274          "Alignment size %u is incorrect.", alignment_in_bytes);
 275 
 276   HeapWord* new_addr = align_up(addr, alignment_in_bytes);
 277   size_t padding = pointer_delta(new_addr, addr);
 278 
 279   if (padding == 0) {
 280     return addr;
 281   }
 282 
 283   if (padding < CollectedHeap::min_fill_size()) {
 284     padding += alignment_in_bytes / HeapWordSize;
 285     assert(padding >= CollectedHeap::min_fill_size(),
 286            "alignment_in_bytes %u is expect to be larger "
 287            "than the minimum object size", alignment_in_bytes);
 288     new_addr = addr + padding;
 289   }
 290 
 291   assert(new_addr > addr, "Unexpected arithmetic overflow "
 292          PTR_FORMAT " not greater than " PTR_FORMAT, p2i(new_addr), p2i(addr));
 293   if(new_addr < end) {
 294     CollectedHeap::fill_with_object(addr, padding);
 295     return new_addr;
 296   } else {


< prev index next >