< prev index next >
src/hotspot/share/gc/shared/collectedHeap.cpp
Print this page
rev 49264 : [mq]: event-only
*** 354,363 ****
--- 354,374 ----
}
}
#endif
HeapWord* CollectedHeap::allocate_from_tlab_slow(Klass* klass, Thread* thread, size_t size) {
+ HeapWord* obj = NULL;
+
+ 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);
*** 373,383 ****
if (new_tlab_size == 0) {
return NULL;
}
// Allocate a new TLAB...
! HeapWord* obj = Universe::heap()->allocate_new_tlab(new_tlab_size);
if (obj == NULL) {
return NULL;
}
AllocTracer::send_allocation_in_new_tlab(klass, obj, new_tlab_size * HeapWordSize, size * HeapWordSize, thread);
--- 384,394 ----
if (new_tlab_size == 0) {
return NULL;
}
// Allocate a new TLAB...
! obj = Universe::heap()->allocate_new_tlab(new_tlab_size);
if (obj == NULL) {
return NULL;
}
AllocTracer::send_allocation_in_new_tlab(klass, obj, new_tlab_size * HeapWordSize, size * HeapWordSize, thread);
*** 393,402 ****
--- 404,421 ----
// any concurrent GC thread.
size_t hdr_size = oopDesc::header_size();
Copy::fill_to_words(obj + hdr_size, new_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, new_tlab_size);
return obj;
}
size_t CollectedHeap::max_tlab_size() const {
< prev index next >