< prev index next > src/hotspot/share/memory/oopFactory.cpp
Print this page
#include "classfile/vmSymbols.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "memory/oopFactory.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+ #include "oops/flatArrayKlass.hpp"
+ #include "oops/flatArrayOop.inline.hpp"
+ #include "oops/flatArrayOop.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 "runtime/handles.inline.hpp"
} else {
return InstanceKlass::cast(klass)->allocate_objArray(1, length, THREAD);
}
}
+ arrayOop oopFactory::new_valueArray(Klass* k, int length, TRAPS) {
+ InlineKlass* klass = InlineKlass::cast(k);
+ // Request a flat array, but we might not actually get it...either way "null-free" are the aaload/aastore semantics
+ Klass* array_klass = klass->value_array_klass(CHECK_NULL);
+ assert(array_klass->is_null_free_array_klass(), "Expect a null-free array class here");
+
+ arrayOop oop;
+ if (array_klass->is_flatArray_klass()) {
+ oop = (arrayOop) FlatArrayKlass::cast(array_klass)->allocate(length, CHECK_NULL);
+ assert(oop == nullptr || oop->is_flatArray(), "sanity");
+ assert(oop == nullptr || oop->klass()->is_flatArray_klass(), "sanity");
+ } else {
+ oop = (arrayOop) ObjArrayKlass::cast(array_klass)->allocate(length, CHECK_NULL);
+ }
+ assert(oop == nullptr || oop->klass()->is_null_free_array_klass(), "sanity");
+ assert(oop == nullptr || oop->is_null_free_array(), "sanity");
+ return oop;
+ }
+
+ objArrayHandle oopFactory::copy_flatArray_to_objArray(flatArrayHandle array, TRAPS) {
+ int len = array->length();
+ FlatArrayKlass* vak = FlatArrayKlass::cast(array->klass());
+ objArrayOop oarray = new_objectArray(array->length(), CHECK_(objArrayHandle()));
+ objArrayHandle oarrayh(THREAD, oarray);
+ vak->copy_array(array(), 0, oarrayh(), 0, len, CHECK_(objArrayHandle()));
+ return oarrayh;
+ }
+
+ objArrayHandle oopFactory::ensure_objArray(oop array, TRAPS) {
+ if (array != nullptr && array->is_flatArray()) {
+ return copy_flatArray_to_objArray(flatArrayHandle(THREAD, flatArrayOop(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 >