--- old/src/hotspot/share/opto/runtime.cpp 2020-02-12 14:31:49.947522807 +0100 +++ new/src/hotspot/share/opto/runtime.cpp 2020-02-12 14:31:49.747522810 +0100 @@ -200,7 +200,13 @@ SharedRuntime::_new_instance_ctr++; // new instance requires GC #endif assert(check_compiled_frame(thread), "incorrect caller"); - + // Check if this is a larval buffer allocation (klass pointer is tagged) + bool is_larval = false; + if (is_set_nth_bit((intptr_t)klass, 0)) { + clear_nth_bit((intptr_t&)klass, 0); + assert(klass->is_value(), "must be value"); + is_larval = true; + } // These checks are cheap to make and support reflective allocation. int lh = klass->layout_helper(); if (Klass::layout_helper_needs_slow_path(lh) || !InstanceKlass::cast(klass)->is_initialized()) { @@ -214,7 +220,10 @@ if (!HAS_PENDING_EXCEPTION) { // Scavenge and allocate an instance. Handle holder(THREAD, klass->klass_holder()); // keep the klass alive - oop result = InstanceKlass::cast(klass)->allocate_instance(THREAD); + instanceOop result = InstanceKlass::cast(klass)->allocate_instance(THREAD); + if (is_larval) { + result->set_mark(result->mark().enter_larval_state()); + } thread->set_vm_result(result); // Pass oops back through thread local storage. Our apparent type to Java