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());
    }
}
// Need to investigate, do we really want to throw OOM exception here?
HeapWord* CollectedHeap::common_permanent_mem_allocate_noinit(size_t size, TRAPS) {
  HeapWord* result = Universe::heap()->permanent_mem_allocate(size);
  if (result != NULL) {
    NOT_PRODUCT(Universe::heap()->
      check_for_non_bad_heap_word_value(result, size));
    return result;
  }
  THROW_OOP_0(Universe::out_of_memory_error_instance());
}
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;
}
HeapWord* CollectedHeap::common_mem_allocate_noinit(size_t size, bool is_noref, TRAPS) {
  // We may want to update this, is_noref objects might not be allocated in TLABs.
  HeapWord* result = NULL;
  if (UseTLAB && !Universe::jvmpi_slow_allocation()) {
    result = CollectedHeap::allocate_from_tlab(THREAD, size);
    if (result != NULL) {
      return result;
    }
  }
  result = Universe::heap()->mem_allocate(size, is_noref, false);
  if (result != NULL) {
    NOT_PRODUCT(Universe::heap()->
      check_for_non_bad_heap_word_value(result, size));
    return result;
  }
  THROW_OOP_0(Universe::out_of_memory_error_instance());
}
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());
    }
}