< prev index next >

src/hotspot/share/gc/shared/memAllocator.cpp

Print this page




 329          p2i(mem), min_tlab_size, new_tlab_size);
 330 
 331   if (ZeroTLAB) {
 332     // ..and clear it.
 333     Copy::zero_to_words(mem, allocation._allocated_tlab_size);
 334   } else {
 335     // ...and zap just allocated object.
 336 #ifdef ASSERT
 337     // Skip mangling the space corresponding to the object header to
 338     // ensure that the returned space is not considered parsable by
 339     // any concurrent GC thread.
 340     size_t hdr_size = oopDesc::header_size();
 341     Copy::fill_to_words(mem + hdr_size, allocation._allocated_tlab_size - hdr_size, badHeapWordVal);
 342 #endif // ASSERT
 343   }
 344 
 345   tlab.fill(mem, mem + _word_size, allocation._allocated_tlab_size);
 346   return mem;
 347 }
 348 
 349 HeapWord* MemAllocator::mem_allocate(Allocation& allocation) const {
 350   if (UseTLAB) {
 351     HeapWord* result = allocate_inside_tlab(allocation);
 352     if (result != NULL) {
 353       return result;
 354     }
 355   }
 356 
 357   return allocate_outside_tlab(allocation);
 358 }
 359 
 360 oop MemAllocator::allocate() const {
 361   oop obj = NULL;
 362   {
 363     Allocation allocation(*this, &obj);
 364     HeapWord* mem = mem_allocate(allocation);
 365     if (mem != NULL) {
 366       obj = initialize(mem);
 367     } else {
 368       // The unhandled oop detector will poison local variable obj,
 369       // so reset it to NULL if mem is NULL.
 370       obj = NULL;
 371     }
 372   }
 373   return obj;
 374 }
 375 
 376 void MemAllocator::mem_clear(HeapWord* mem) const {
 377   assert(mem != NULL, "cannot initialize NULL object");
 378   const size_t hs = oopDesc::header_size();
 379   assert(_word_size >= hs, "unexpected object size");
 380   oopDesc::set_klass_gap(mem, 0);
 381   Copy::fill_to_aligned_words(mem + hs, _word_size - hs);
 382 }
 383 
 384 oop MemAllocator::finish(HeapWord* mem) const {




 329          p2i(mem), min_tlab_size, new_tlab_size);
 330 
 331   if (ZeroTLAB) {
 332     // ..and clear it.
 333     Copy::zero_to_words(mem, allocation._allocated_tlab_size);
 334   } else {
 335     // ...and zap just allocated object.
 336 #ifdef ASSERT
 337     // Skip mangling the space corresponding to the object header to
 338     // ensure that the returned space is not considered parsable by
 339     // any concurrent GC thread.
 340     size_t hdr_size = oopDesc::header_size();
 341     Copy::fill_to_words(mem + hdr_size, allocation._allocated_tlab_size - hdr_size, badHeapWordVal);
 342 #endif // ASSERT
 343   }
 344 
 345   tlab.fill(mem, mem + _word_size, allocation._allocated_tlab_size);
 346   return mem;
 347 }
 348 
 349 HeapWord* MemAllocator::mem_allocate(Allocation& allocation, bool try_tlab) const {
 350   if (UseTLAB && try_tlab) {
 351     HeapWord* result = allocate_inside_tlab(allocation);
 352     if (result != NULL) {
 353       return result;
 354     }
 355   }
 356 
 357   return allocate_outside_tlab(allocation);
 358 }
 359 
 360 oop MemAllocator::allocate(bool try_tlab) const {
 361   oop obj = NULL;
 362   {
 363     Allocation allocation(*this, &obj);
 364     HeapWord* mem = mem_allocate(allocation, try_tlab);
 365     if (mem != NULL) {
 366       obj = initialize(mem);
 367     } else {
 368       // The unhandled oop detector will poison local variable obj,
 369       // so reset it to NULL if mem is NULL.
 370       obj = NULL;
 371     }
 372   }
 373   return obj;
 374 }
 375 
 376 void MemAllocator::mem_clear(HeapWord* mem) const {
 377   assert(mem != NULL, "cannot initialize NULL object");
 378   const size_t hs = oopDesc::header_size();
 379   assert(_word_size >= hs, "unexpected object size");
 380   oopDesc::set_klass_gap(mem, 0);
 381   Copy::fill_to_aligned_words(mem + hs, _word_size - hs);
 382 }
 383 
 384 oop MemAllocator::finish(HeapWord* mem) const {


< prev index next >