< prev index next >

src/hotspot/share/opto/runtime.cpp

Print this page

        

@@ -198,11 +198,17 @@
   JRT_BLOCK;
 #ifndef PRODUCT
   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()) {
     Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
     klass->check_valid_for_instantiation(false, THREAD);

@@ -212,11 +218,14 @@
   }
 
   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
     // is that we return an oop, but we can block on exit from this routine and
     // a GC can trash the oop in C's return register.  The generated stub will
< prev index next >