diff -r 13588c901957 -r 9cf78a70fa4f src/hotspot/share/gc/shared/memAllocator.cpp --- a/src/hotspot/share/gc/shared/memAllocator.cpp Thu Oct 17 20:27:44 2019 +0100 +++ b/src/hotspot/share/gc/shared/memAllocator.cpp Thu Oct 17 20:53:35 2019 +0100 @@ -143,7 +143,6 @@ // Clear unhandled oops for memory allocation. Memory allocation might // not take out a lock if from tlab, so clear here. Thread* THREAD = _thread; - CHECK_UNHANDLED_OOPS_ONLY(THREAD->clear_unhandled_oops();) assert(!HAS_PENDING_EXCEPTION, "Should not allocate with exception pending"); debug_only(check_for_valid_allocation_state()); assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); @@ -172,14 +171,8 @@ // This is a VM policy failure, so how do we exhaustively test it? assert(!_thread->has_pending_exception(), "shouldn't be allocating with pending exception"); - if (StrictSafepointChecks) { - assert(_thread->allow_allocation(), - "Allocation done by thread for which allocation is blocked " - "by No_Allocation_Verifier!"); - // Allocation of an oop can always invoke a safepoint, - // hence, the true argument - _thread->check_for_valid_safepoint_state(true); - } + // Allocation of an oop can always invoke a safepoint. + _thread->check_for_valid_safepoint_state(); } #endif @@ -232,10 +225,10 @@ size_t size_in_bytes = _allocator._word_size * HeapWordSize; if (_allocated_outside_tlab) { - AllocTracer::send_allocation_outside_tlab(_allocator._klass, mem, size_in_bytes, _thread); + AllocTracer::send_allocation_outside_tlab(obj()->klass(), mem, size_in_bytes, _thread); } else if (_allocated_tlab_size != 0) { // TLAB was refilled - AllocTracer::send_allocation_in_new_tlab(_allocator._klass, mem, _allocated_tlab_size * HeapWordSize, + AllocTracer::send_allocation_in_new_tlab(obj()->klass(), mem, _allocated_tlab_size * HeapWordSize, size_in_bytes, _thread); } } @@ -243,7 +236,7 @@ void MemAllocator::Allocation::notify_allocation_dtrace_sampler() { if (DTraceAllocProbes) { // support for Dtrace object alloc event (no-op most of the time) - Klass* klass = _allocator._klass; + Klass* klass = obj()->klass(); size_t word_size = _allocator._word_size; if (klass != NULL && klass->name() != NULL) { SharedRuntime::dtrace_object_alloc(obj(), (int)word_size); @@ -370,6 +363,10 @@ HeapWord* mem = mem_allocate(allocation); if (mem != NULL) { obj = initialize(mem); + } else { + // The unhandled oop detector will poison local variable obj, + // so reset it to NULL if mem is NULL. + obj = NULL; } } return obj; @@ -389,7 +386,7 @@ oopDesc::set_mark_raw(mem, _klass->prototype_header()); } else { // May be bootstrapping - oopDesc::set_mark_raw(mem, markOopDesc::prototype()); + oopDesc::set_mark_raw(mem, markWord::prototype()); } // Need a release store to ensure array/class length, mark word, and // object zeroing are visible before setting the klass non-NULL, for