--- old/src/cpu/x86/vm/templateTable_x86.cpp 2017-04-04 15:20:30.700090579 -0700 +++ new/src/cpu/x86/vm/templateTable_x86.cpp 2017-04-04 15:20:30.584091060 -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())); @@ -3981,6 +3986,15 @@ __ 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); \ + __ pop(atos); \ + }); + __ jmp(done); }