353 } 354 355 HeapWord* MemAllocator::mem_allocate(Allocation& allocation) const { 356 if (UseTLAB) { 357 HeapWord* result = allocate_inside_tlab(allocation); 358 if (result != NULL) { 359 return result; 360 } 361 } 362 363 return allocate_outside_tlab(allocation); 364 } 365 366 oop MemAllocator::allocate() const { 367 oop obj = NULL; 368 { 369 Allocation allocation(*this, &obj); 370 HeapWord* mem = mem_allocate(allocation); 371 if (mem != NULL) { 372 obj = initialize(mem); 373 } 374 } 375 return obj; 376 } 377 378 void MemAllocator::mem_clear(HeapWord* mem) const { 379 assert(mem != NULL, "cannot initialize NULL object"); 380 const size_t hs = oopDesc::header_size(); 381 assert(_word_size >= hs, "unexpected object size"); 382 oopDesc::set_klass_gap(mem, 0); 383 Copy::fill_to_aligned_words(mem + hs, _word_size - hs); 384 } 385 386 oop MemAllocator::finish(HeapWord* mem) const { 387 assert(mem != NULL, "NULL object pointer"); 388 if (UseBiasedLocking) { 389 oopDesc::set_mark_raw(mem, _klass->prototype_header()); 390 } else { 391 // May be bootstrapping 392 oopDesc::set_mark_raw(mem, markOopDesc::prototype()); | 353 } 354 355 HeapWord* MemAllocator::mem_allocate(Allocation& allocation) const { 356 if (UseTLAB) { 357 HeapWord* result = allocate_inside_tlab(allocation); 358 if (result != NULL) { 359 return result; 360 } 361 } 362 363 return allocate_outside_tlab(allocation); 364 } 365 366 oop MemAllocator::allocate() const { 367 oop obj = NULL; 368 { 369 Allocation allocation(*this, &obj); 370 HeapWord* mem = mem_allocate(allocation); 371 if (mem != NULL) { 372 obj = initialize(mem); 373 } else { 374 // Keep the unhandled oop detector happy. 375 obj = NULL; 376 } 377 } 378 return obj; 379 } 380 381 void MemAllocator::mem_clear(HeapWord* mem) const { 382 assert(mem != NULL, "cannot initialize NULL object"); 383 const size_t hs = oopDesc::header_size(); 384 assert(_word_size >= hs, "unexpected object size"); 385 oopDesc::set_klass_gap(mem, 0); 386 Copy::fill_to_aligned_words(mem + hs, _word_size - hs); 387 } 388 389 oop MemAllocator::finish(HeapWord* mem) const { 390 assert(mem != NULL, "NULL object pointer"); 391 if (UseBiasedLocking) { 392 oopDesc::set_mark_raw(mem, _klass->prototype_header()); 393 } else { 394 // May be bootstrapping 395 oopDesc::set_mark_raw(mem, markOopDesc::prototype()); |