< prev index next >

src/hotspot/share/memory/oopFactory.cpp

Print this page

        

@@ -32,14 +32,19 @@
 #include "memory/resourceArea.hpp"
 #include "memory/universe.hpp"
 #include "oops/instanceKlass.hpp"
 #include "oops/instanceOop.hpp"
 #include "oops/objArrayKlass.hpp"
+#include "oops/objArrayOop.inline.hpp"
 #include "oops/objArrayOop.hpp"
 #include "oops/oop.inline.hpp"
 #include "oops/typeArrayKlass.hpp"
 #include "oops/typeArrayOop.inline.hpp"
+#include "oops/valueKlass.hpp"
+#include "oops/valueArrayKlass.hpp"
+#include "oops/valueArrayOop.inline.hpp"
+#include "oops/valueArrayOop.hpp"
 #include "runtime/handles.inline.hpp"
 #include "utilities/utf8.hpp"
 
 typeArrayOop oopFactory::new_boolArray(int length, TRAPS) {
   return TypeArrayKlass::cast(Universe::boolArrayKlassObj())->allocate(length, THREAD);

@@ -126,10 +131,43 @@
   } else {
     return InstanceKlass::cast(klass)->allocate_objArray(1, length, THREAD);
   }
 }
 
+arrayOop oopFactory::new_valueArray(Klass* klass, int length, TRAPS) {
+  assert(klass->is_value(), "Klass must be value type");
+  // Request flattened, but we might not actually get it...either way "null-free" are the aaload/aastore semantics
+  Klass* array_klass = klass->array_klass(ArrayStorageProperties::flattened_and_null_free, 1, CHECK_NULL);
+  assert(ArrayKlass::cast(array_klass)->storage_properties().is_null_free(), "Expect a null-free array class here");
+
+  arrayOop oop;
+  if (array_klass->is_valueArray_klass()) {
+    oop = (arrayOop) ValueArrayKlass::cast(array_klass)->allocate(length, THREAD);
+  } else {
+    oop = (arrayOop) ObjArrayKlass::cast(array_klass)->allocate(length, THREAD);
+  }
+  assert(oop->array_storage_properties().is_null_free(), "Bad array storage encoding");
+  return oop;
+}
+
+objArrayHandle oopFactory::copy_valueArray_to_objArray(valueArrayHandle array, TRAPS) {
+  int len = array->length();
+  ValueArrayKlass* vak = ValueArrayKlass::cast(array->klass());
+  objArrayHandle oarray = new_objArray_handle(vak->element_klass(),
+                                              array->length(), CHECK_(objArrayHandle()));
+  vak->copy_array(array(), 0, oarray(), 0, len, CHECK_(objArrayHandle()));
+  return oarray;
+}
+
+objArrayHandle  oopFactory::ensure_objArray(oop array, TRAPS) {
+  if (array != NULL && array->is_valueArray()) {
+    return copy_valueArray_to_objArray(valueArrayHandle(THREAD, valueArrayOop(array)), THREAD);
+  } else {
+    return objArrayHandle(THREAD, objArrayOop(array));
+  }
+}
+
 objArrayHandle oopFactory::new_objArray_handle(Klass* klass, int length, TRAPS) {
   objArrayOop obj = new_objArray(klass, length, CHECK_(objArrayHandle()));
   return objArrayHandle(THREAD, obj);
 }
 
< prev index next >