Пример #1
0
typeArrayOop TypeArrayKlass::allocate(int length, HeapColor color, TRAPS) {
    assert(log2_element_size() >= 0, "bad scale");
    if (length >= 0) {
        if (length <= max_length()) {
            size_t size = typeArrayOopDesc::object_size(layout_helper(), length);
            KlassHandle h_k(THREAD, this);
            typeArrayOop t;
            CollectedHeap* ch = Universe::heap();
            /*
            if (size < ch->large_typearray_limit()) {
            */
            t = (typeArrayOop)CollectedHeap::array_allocate(h_k, (int)size, length,
                    color, CHECK_NULL);
            /*
            } else {
              t = (typeArrayOop)CollectedHeap::large_typearray_allocate(h_k, (int)size,
                                               length, color, CHECK_NULL);
            }
            */
            //assert(t->is_parsable(), "Don't publish unless parsable");
            return t;
        } else {
            report_java_out_of_memory("Requested array size exceeds VM limit");
            THROW_OOP_0(Universe::out_of_memory_error_array_size());
        }
    } else {
        THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
    }
}
typeArrayOop typeArrayKlass::allocate_permanent(int length, TRAPS) {
  if (length < 0) THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
  int size = typeArrayOopDesc::object_size(layout_helper(), length);
  KlassHandle h_k(THREAD, as_klassOop());
  typeArrayOop t = (typeArrayOop)
    CollectedHeap::permanent_array_allocate(h_k, size, length, CHECK_NULL);
  assert(t->is_parsable(), "Can't publish until parsable");
  return t;
}
Пример #3
0
objArrayOop arrayKlass::allocate_arrayArray(int n, int length, TRAPS) {
  if (length < 0) {
    THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
  }
  if (length > arrayOopDesc::max_array_length(T_ARRAY)) {
    THROW_OOP_0(Universe::out_of_memory_error_instance());
  }
  int size = objArrayOopDesc::object_size(length);
  klassOop k = array_klass(n+dimension(), CHECK_0);
  arrayKlassHandle ak (THREAD, k);
  objArrayOop o =
    (objArrayOop)CollectedHeap::array_allocate(ak, size, length, CHECK_0);
  // initialization to NULL not necessary, area already cleared
  return o;
}
Пример #4
0
typeArrayOop TypeArrayKlass::allocate_common(int length, bool do_zero, TRAPS) {
    assert(log2_element_size() >= 0, "bad scale");
    if (length >= 0) {
        if (length <= max_length()) {
            size_t size = typeArrayOopDesc::object_size(layout_helper(), length);
            KlassHandle h_k(THREAD, this);
            typeArrayOop t;
            CollectedHeap* ch = Universe::heap();
            if (do_zero) {
                t = (typeArrayOop)CollectedHeap::array_allocate(h_k, (int)size, length, CHECK_NULL);
            } else {
                t = (typeArrayOop)CollectedHeap::array_allocate_nozero(h_k, (int)size, length, CHECK_NULL);
            }
            return t;
        } else {
            report_java_out_of_memory("Requested array size exceeds VM limit");
            JvmtiExport::post_array_size_exhausted();
            THROW_OOP_0(Universe::out_of_memory_error_array_size());
        }
    } else {
        THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
    }
}