< prev index next >

src/hotspot/share/memory/oopFactory.cpp

Print this page




  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.hpp"
  27 #include "classfile/symbolTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "gc/shared/collectedHeap.inline.hpp"
  31 #include "memory/oopFactory.hpp"
  32 #include "memory/resourceArea.hpp"
  33 #include "memory/universe.hpp"
  34 #include "oops/instanceKlass.hpp"
  35 #include "oops/instanceOop.hpp"
  36 #include "oops/objArrayKlass.hpp"
  37 #include "oops/objArrayOop.inline.hpp"
  38 #include "oops/objArrayOop.hpp"
  39 #include "oops/oop.inline.hpp"
  40 #include "oops/typeArrayKlass.hpp"
  41 #include "oops/typeArrayOop.inline.hpp"
  42 #include "oops/valueKlass.hpp"
  43 #include "oops/valueArrayKlass.hpp"


  44 #include "runtime/handles.inline.hpp"
  45 #include "utilities/utf8.hpp"
  46 
  47 typeArrayOop oopFactory::new_boolArray(int length, TRAPS) {
  48   return TypeArrayKlass::cast(Universe::boolArrayKlassObj())->allocate(length, THREAD);
  49 }
  50 
  51 typeArrayOop oopFactory::new_charArray(int length, TRAPS) {
  52   return TypeArrayKlass::cast(Universe::charArrayKlassObj())->allocate(length, THREAD);
  53 }
  54 
  55 typeArrayOop oopFactory::new_floatArray(int length, TRAPS) {
  56   return TypeArrayKlass::cast(Universe::floatArrayKlassObj())->allocate(length, THREAD);
  57 }
  58 
  59 typeArrayOop oopFactory::new_doubleArray(int length, TRAPS) {
  60   return TypeArrayKlass::cast(Universe::doubleArrayKlassObj())->allocate(length, THREAD);
  61 }
  62 
  63 typeArrayOop oopFactory::new_byteArray(int length, TRAPS) {


 128     return ArrayKlass::cast(klass)->allocate_arrayArray(1, length, THREAD);
 129   } else {
 130     return InstanceKlass::cast(klass)->allocate_objArray(1, length, THREAD);
 131   }
 132 }
 133 
 134 arrayOop oopFactory::new_valueArray(Klass* klass, int length, TRAPS) {
 135   assert(klass->is_value(), "Klass must be value type");
 136   // Request flattened, but we might not actually get it...either way "null-free" are the aaload/aastore semantics
 137   Klass* array_klass = klass->array_klass(ArrayStorageProperties::flattened_and_null_free, 1, CHECK_NULL);
 138   assert(ArrayKlass::cast(array_klass)->storage_properties().is_null_free(), "Expect a null-free array class here");
 139 
 140   arrayOop oop;
 141   if (array_klass->is_valueArray_klass()) {
 142     oop = (arrayOop) ValueArrayKlass::cast(array_klass)->allocate(length, THREAD);
 143   } else {
 144     oop = (arrayOop) ObjArrayKlass::cast(array_klass)->allocate(length, THREAD);
 145   }
 146   assert(oop->array_storage_properties().is_null_free(), "Bad array storage encoding");
 147   return oop;

















 148 }
 149 
 150 objArrayHandle oopFactory::new_objArray_handle(Klass* klass, int length, TRAPS) {
 151   objArrayOop obj = new_objArray(klass, length, CHECK_(objArrayHandle()));
 152   return objArrayHandle(THREAD, obj);
 153 }
 154 
 155 typeArrayHandle oopFactory::new_byteArray_handle(int length, TRAPS) {
 156   typeArrayOop obj = new_byteArray(length, CHECK_(typeArrayHandle()));
 157   return typeArrayHandle(THREAD, obj);
 158 }


  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.hpp"
  27 #include "classfile/symbolTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "gc/shared/collectedHeap.inline.hpp"
  31 #include "memory/oopFactory.hpp"
  32 #include "memory/resourceArea.hpp"
  33 #include "memory/universe.hpp"
  34 #include "oops/instanceKlass.hpp"
  35 #include "oops/instanceOop.hpp"
  36 #include "oops/objArrayKlass.hpp"
  37 #include "oops/objArrayOop.inline.hpp"
  38 #include "oops/objArrayOop.hpp"
  39 #include "oops/oop.inline.hpp"
  40 #include "oops/typeArrayKlass.hpp"
  41 #include "oops/typeArrayOop.inline.hpp"
  42 #include "oops/valueKlass.hpp"
  43 #include "oops/valueArrayKlass.hpp"
  44 #include "oops/valueArrayOop.inline.hpp"
  45 #include "oops/valueArrayOop.hpp"
  46 #include "runtime/handles.inline.hpp"
  47 #include "utilities/utf8.hpp"
  48 
  49 typeArrayOop oopFactory::new_boolArray(int length, TRAPS) {
  50   return TypeArrayKlass::cast(Universe::boolArrayKlassObj())->allocate(length, THREAD);
  51 }
  52 
  53 typeArrayOop oopFactory::new_charArray(int length, TRAPS) {
  54   return TypeArrayKlass::cast(Universe::charArrayKlassObj())->allocate(length, THREAD);
  55 }
  56 
  57 typeArrayOop oopFactory::new_floatArray(int length, TRAPS) {
  58   return TypeArrayKlass::cast(Universe::floatArrayKlassObj())->allocate(length, THREAD);
  59 }
  60 
  61 typeArrayOop oopFactory::new_doubleArray(int length, TRAPS) {
  62   return TypeArrayKlass::cast(Universe::doubleArrayKlassObj())->allocate(length, THREAD);
  63 }
  64 
  65 typeArrayOop oopFactory::new_byteArray(int length, TRAPS) {


 130     return ArrayKlass::cast(klass)->allocate_arrayArray(1, length, THREAD);
 131   } else {
 132     return InstanceKlass::cast(klass)->allocate_objArray(1, length, THREAD);
 133   }
 134 }
 135 
 136 arrayOop oopFactory::new_valueArray(Klass* klass, int length, TRAPS) {
 137   assert(klass->is_value(), "Klass must be value type");
 138   // Request flattened, but we might not actually get it...either way "null-free" are the aaload/aastore semantics
 139   Klass* array_klass = klass->array_klass(ArrayStorageProperties::flattened_and_null_free, 1, CHECK_NULL);
 140   assert(ArrayKlass::cast(array_klass)->storage_properties().is_null_free(), "Expect a null-free array class here");
 141 
 142   arrayOop oop;
 143   if (array_klass->is_valueArray_klass()) {
 144     oop = (arrayOop) ValueArrayKlass::cast(array_klass)->allocate(length, THREAD);
 145   } else {
 146     oop = (arrayOop) ObjArrayKlass::cast(array_klass)->allocate(length, THREAD);
 147   }
 148   assert(oop->array_storage_properties().is_null_free(), "Bad array storage encoding");
 149   return oop;
 150 }
 151 
 152 objArrayHandle oopFactory::copy_valueArray_to_objArray(valueArrayHandle array, TRAPS) {
 153   int len = array->length();
 154   ValueArrayKlass* vak = ValueArrayKlass::cast(array->klass());
 155   objArrayHandle oarray = new_objArray_handle(vak->element_klass(),
 156                                               array->length(), CHECK_(objArrayHandle()));
 157   vak->copy_array(array(), 0, oarray(), 0, len, CHECK_(objArrayHandle()));
 158   return oarray;
 159 }
 160 
 161 objArrayHandle  oopFactory::ensure_objArray(oop array, TRAPS) {
 162   if (array != NULL && array->is_valueArray()) {
 163     return copy_valueArray_to_objArray(valueArrayHandle(THREAD, valueArrayOop(array)), THREAD);
 164   } else {
 165     return objArrayHandle(THREAD, objArrayOop(array));
 166   }
 167 }
 168 
 169 objArrayHandle oopFactory::new_objArray_handle(Klass* klass, int length, TRAPS) {
 170   objArrayOop obj = new_objArray(klass, length, CHECK_(objArrayHandle()));
 171   return objArrayHandle(THREAD, obj);
 172 }
 173 
 174 typeArrayHandle oopFactory::new_byteArray_handle(int length, TRAPS) {
 175   typeArrayOop obj = new_byteArray(length, CHECK_(typeArrayHandle()));
 176   return typeArrayHandle(THREAD, obj);
 177 }
< prev index next >