< prev index next >

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

Print this page
rev 50392 : JEP 331

*** 364,373 **** --- 364,393 ---- } } #endif HeapWord* CollectedHeap::allocate_from_tlab_slow(Klass* klass, Thread* thread, size_t size) { + HeapWord* obj = NULL; + + // In assertion mode, check that there was a sampling collector present + // in the stack. This enforces checking that no path is without a sampling + // collector. + // Only check if the sampler could actually sample something in this call path. + assert(!JvmtiExport::should_post_sampled_object_alloc() + || !JvmtiSampledObjectAllocEventCollector::object_alloc_is_safe_to_sample() + || thread->heap_sampler().sampling_collector_present(), + "Sampling collector not present."); + + if (ThreadHeapSampler::enabled()) { + // Try to allocate the sampled object from TLAB, it is possible a sample + // point was put and the TLAB still has space. + obj = thread->tlab().allocate_sampled_object(size); + + if (obj != NULL) { + return obj; + } + } // Retain tlab and allocate object in shared space if // the amount free in the tlab is too large to discard. if (thread->tlab().free() > thread->tlab().refill_waste_limit()) { thread->tlab().record_slow_allocation(size);
*** 386,396 **** // Allocate a new TLAB requesting new_tlab_size. Any size // between minimal and new_tlab_size is accepted. size_t actual_tlab_size = 0; size_t min_tlab_size = ThreadLocalAllocBuffer::compute_min_size(size); ! HeapWord* obj = Universe::heap()->allocate_new_tlab(min_tlab_size, new_tlab_size, &actual_tlab_size); if (obj == NULL) { assert(actual_tlab_size == 0, "Allocation failed, but actual size was updated. min: " SIZE_FORMAT ", desired: " SIZE_FORMAT ", actual: " SIZE_FORMAT, min_tlab_size, new_tlab_size, actual_tlab_size); return NULL; } --- 406,416 ---- // Allocate a new TLAB requesting new_tlab_size. Any size // between minimal and new_tlab_size is accepted. size_t actual_tlab_size = 0; size_t min_tlab_size = ThreadLocalAllocBuffer::compute_min_size(size); ! obj = Universe::heap()->allocate_new_tlab(min_tlab_size, new_tlab_size, &actual_tlab_size); if (obj == NULL) { assert(actual_tlab_size == 0, "Allocation failed, but actual size was updated. min: " SIZE_FORMAT ", desired: " SIZE_FORMAT ", actual: " SIZE_FORMAT, min_tlab_size, new_tlab_size, actual_tlab_size); return NULL; }
*** 410,419 **** --- 430,447 ---- // any concurrent GC thread. size_t hdr_size = oopDesc::header_size(); Copy::fill_to_words(obj + hdr_size, actual_tlab_size - hdr_size, badHeapWordVal); #endif // ASSERT } + + // Send the thread information about this allocation in case a sample is + // requested. + if (ThreadHeapSampler::enabled()) { + size_t tlab_bytes_since_last_sample = thread->tlab().bytes_since_last_sample_point(); + thread->heap_sampler().check_for_sampling(obj, size, tlab_bytes_since_last_sample); + } + thread->tlab().fill(obj, obj + size, actual_tlab_size); return obj; } size_t CollectedHeap::max_tlab_size() const {
< prev index next >