< prev index next >
src/hotspot/share/gc/shared/collectedHeap.cpp
Print this page
rev 49877 : [mq]: rebase
@@ -364,10 +364,27 @@
}
}
#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.
+ assert(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);
@@ -383,11 +400,11 @@
if (new_tlab_size == 0) {
return NULL;
}
// Allocate a new TLAB...
- HeapWord* obj = Universe::heap()->allocate_new_tlab(new_tlab_size);
+ 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);
@@ -403,10 +420,18 @@
// 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 >