< prev index next >

src/share/vm/gc/shared/collectedHeap.inline.hpp

Print this page

        

*** 31,40 **** --- 31,41 ---- #include "gc/shared/threadLocalAllocBuffer.inline.hpp" #include "memory/universe.hpp" #include "oops/arrayOop.hpp" #include "oops/oop.inline.hpp" #include "prims/jvmtiExport.hpp" + #include "runtime/heapMonitoring.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/thread.inline.hpp" #include "services/lowMemoryDetector.hpp" #include "utilities/copy.hpp"
*** 79,88 **** --- 80,107 ---- // support for Dtrace object alloc event (no-op most of the time) if (klass() != NULL && klass()->name() != NULL) { SharedRuntime::dtrace_object_alloc(obj, size); } } + + if (HeapMonitor) { + // support for object alloc event (no-op most of the time) + if (klass() != NULL && klass()->name() != NULL) { + Thread *base_thread = Thread::current(); + if (base_thread->is_Java_thread()) { + JavaThread *thread = (JavaThread *) base_thread; + size_t *bytes_until_sample = thread->bytes_until_sample(); + size_t size_in_bytes = ((size_t) size) << LogHeapWordSize; + assert(size > 0, "positive size"); + if (*bytes_until_sample < size_in_bytes) { + HeapMonitoring::object_alloc_do_sample(thread, obj); + } else { + *bytes_until_sample -= size_in_bytes; + } + } + } + } } void CollectedHeap::post_allocation_setup_obj(KlassHandle klass, HeapWord* obj_ptr, int size) {
< prev index next >