--- old/src/cpu/x86/vm/templateTable_x86.cpp 2017-05-22 08:52:06.247068631 -0700 +++ new/src/cpu/x86/vm/templateTable_x86.cpp 2017-05-22 08:52:06.135069060 -0700 @@ -3927,6 +3927,7 @@ // The object is initialized before the header. If the object size is // zero, go directly to the header initialization. __ bind(initialize_object); + __ movq(rbx, rdx); // Save the size for HeapMonitoring __ decrement(rdx, sizeof(oopDesc)); __ jcc(Assembler::zero, initialize_header); @@ -3957,6 +3958,10 @@ // initialize object header only. __ bind(initialize_header); + + // Restore size for HeapMonitoring + __ movq(rdx, rbx); + if (UseBiasedLocking) { __ pop(rcx); // get saved klass back in the register. __ movptr(rbx, Address(rcx, Klass::prototype_header_offset())); @@ -3977,10 +3982,20 @@ // Trigger dtrace event for fastpath __ push(atos); __ call_VM_leaf( - CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc), rax); + CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc), + rax, rdx); __ pop(atos); } + HEAP_MONITORING(_masm, noreg, rdx, 0, rax, rcx, noreg, \ + { \ + __ push(atos); \ + __ call_VM_leaf( \ + CAST_FROM_FN_PTR(address, HeapMonitoring::object_alloc), \ + rax, rdx); \ + __ pop(atos); \ + }); + __ jmp(done); }