< prev index next >

src/share/vm/runtime/sharedRuntime.cpp

Print this page

        

@@ -36,10 +36,11 @@
 #include "compiler/disassembler.hpp"
 #include "gc/shared/gcLocker.inline.hpp"
 #include "interpreter/interpreter.hpp"
 #include "interpreter/interpreterRuntime.hpp"
 #include "logging/log.hpp"
+#include "memory/oopFactory.hpp"
 #include "memory/universe.inline.hpp"
 #include "oops/fieldStreams.hpp"
 #include "oops/objArrayKlass.inline.hpp"
 #include "oops/objArrayOop.inline.hpp"
 #include "oops/oop.inline.hpp"

@@ -2364,13 +2365,13 @@
  public:
   AdapterHandlerTable()
     : BasicHashtable<mtCode>(293, sizeof(AdapterHandlerEntry)) { }
 
   // Create a new entry suitable for insertion in the table
-  AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) {
+  AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry, Symbol* sig_extended) {
     AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable<mtCode>::new_entry(fingerprint->compute_hash());
-    entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
+    entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry, sig_extended);
     return entry;
   }
 
   // Insert an entry into the table
   void add(AdapterHandlerEntry* entry) {

@@ -2524,12 +2525,13 @@
 }
 
 AdapterHandlerEntry* AdapterHandlerLibrary::new_entry(AdapterFingerPrint* fingerprint,
                                                       address i2c_entry,
                                                       address c2i_entry,
-                                                      address c2i_unverified_entry) {
-  return _adapters->new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
+                                                      address c2i_unverified_entry,
+                                                      Symbol* sig_extended) {
+  return _adapters->new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry, sig_extended);
 }
 
 // Value type arguments are not passed by reference, instead each
 // field of the value type is passed as an argument. This helper
 // function collects the fields of the value types (including embedded

@@ -3234,23 +3236,24 @@
   ResourceMark rm;
   JavaThread* THREAD = thread;
   methodHandle callee(callee_method);
 
   int nb_slots = 0;
-  if (!callee->is_static() && callee->method_holder()->is_value()) {
+  bool has_value_receiver = !callee->is_static() && callee->method_holder()->is_value();
+  if (has_value_receiver) {
     nb_slots++;
   }
   Handle class_loader(THREAD, callee->method_holder()->class_loader());
   Handle protection_domain(THREAD, callee->method_holder()->protection_domain());
   for (SignatureStream ss(callee->signature()); !ss.at_return_type(); ss.next()) {
     if (ss.type() == T_VALUETYPE) {
       nb_slots++;
     }
   }
-  objArrayHandle array = ObjArrayKlass::cast(Universe::objectArrayKlassObj())->allocate(nb_slots, CHECK);
+  objArrayHandle array = oopFactory::new_objectArray(nb_slots, CHECK);
   int i = 0;
-  if (!callee->is_static() && callee->method_holder()->is_value()) {
+  if (has_value_receiver) {
     ValueKlass* vk = ValueKlass::cast(callee->method_holder());
     oop res = vk->allocate_instance(CHECK);
     array->obj_at_put(i, res);
     i++;
   }

@@ -3266,5 +3269,30 @@
   }
   thread->set_vm_result(array());
   thread->set_vm_result_2(callee()); // TODO: required to keep callee live?
 }
 JRT_END
+
+// Iterate of the array of heap allocated value types and apply the GC post barrier to all reference fields.
+// This is called from the C2I adapter after value type arguments were heap allocated and initialized.
+JRT_LEAF(void, SharedRuntime::apply_post_barriers(JavaThread* thread, objArrayOopDesc* array, Method* callee_method))
+{
+  assert(ValueTypePassFieldsAsArgs, "no reason to call this");
+  assert(array->is_oop(), "should be oop");
+  methodHandle callee(callee_method);
+  for (int i = 0; i < array->length(); ++i) {
+    instanceOop valueOop = (instanceOop)array->obj_at(i);
+    ValueKlass* vk = ValueKlass::cast(valueOop->klass());
+    if (vk->contains_oops()) {
+      const address dst_oop_addr = ((address) (void*) valueOop);
+      OopMapBlock* map = vk->start_of_nonstatic_oop_maps();
+      OopMapBlock* const end = map + vk->nonstatic_oop_map_count();
+      while (map != end) {
+        address doop_address = dst_oop_addr + map->offset();
+        oopDesc::bs()->write_ref_array((HeapWord*) doop_address, map->count());
+        map++;
+      }
+    }
+  }
+  thread->set_vm_result_2(callee()); // TODO: required to keep callee live?
+}
+JRT_END
< prev index next >