8249768: Move static oops and NullPointerException oops from Universe into OopStorage

Make NPE oops an objArrayOop.

Reviewed-by: dholmes, eosterlund
This commit is contained in:
Coleen Phillimore 2020-07-22 10:32:44 -04:00
parent 4d43cf9fc6
commit 2d8e74ddea
14 changed files with 241 additions and 219 deletions

@ -413,6 +413,7 @@ void TemplateTable::fast_aldc(bool wide)
// Stash null_sentinel address to get its value later
__ movptr(rarg, (uintptr_t)Universe::the_null_sentinel_addr());
__ ldr(tmp, Address(rarg));
__ resolve_oop_handle(tmp);
__ cmpoop(result, tmp);
__ br(Assembler::NE, notNull);
__ mov(result, 0); // NULL object reference

@ -462,6 +462,7 @@ void TemplateTable::fast_aldc(bool wide) {
// Stash null_sentinel address to get its value later
__ mov_slow(rarg, (uintptr_t)Universe::the_null_sentinel_addr());
__ ldr(tmp, Address(rarg));
__ resolve_oop_handle(tmp);
__ cmp(result, tmp);
__ b(notNull, ne);
__ mov(result, 0); // NULL object reference

@ -317,9 +317,10 @@ void TemplateTable::fast_aldc(bool wide) {
__ get_cache_index_at_bcp(Rscratch, 1, index_size); // Load index.
__ load_resolved_reference_at_index(R17_tos, Rscratch, &is_null);
// Convert null sentinel to NULL.
// Convert null sentinel to NULL
int simm16_rest = __ load_const_optimized(Rscratch, Universe::the_null_sentinel_addr(), R0, true);
__ ld(Rscratch, simm16_rest, Rscratch);
__ resolve_oop_handle(Rscratch);
__ cmpld(CCR0, R17_tos, Rscratch);
if (VM_Version::has_isel()) {
__ isel_0(R17_tos, CCR0, Assembler::equal);

@ -466,6 +466,7 @@ void TemplateTable::fast_aldc(bool wide) {
// Convert null sentinel to NULL.
__ load_const_optimized(Z_R1_scratch, (intptr_t)Universe::the_null_sentinel_addr());
__ resolve_oop_handle(Z_R1_scratch);
__ z_cg(Z_tos, Address(Z_R1_scratch));
__ z_brne(L_resolved);
__ clear_reg(Z_tos);

@ -448,6 +448,7 @@ void TemplateTable::fast_aldc(bool wide) {
Label notNull;
ExternalAddress null_sentinel((address)Universe::the_null_sentinel_addr());
__ movptr(tmp, null_sentinel);
__ resolve_oop_handle(tmp);
__ cmpoop(tmp, result);
__ jccb(Assembler::notEqual, notNull);
__ xorptr(result, result); // NULL object reference

@ -60,6 +60,7 @@
#include "oops/instanceRefKlass.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
#include "oops/oopHandle.inline.hpp"
#include "oops/typeArrayKlass.hpp"
#include "prims/resolvedMethodTable.hpp"
#include "runtime/arguments.hpp"
@ -106,35 +107,45 @@ PRIMITIVE_MIRRORS_DO(DEFINE_PRIMITIVE_MIRROR)
Klass* Universe::_typeArrayKlassObjs[T_LONG+1] = { NULL /*, NULL...*/ };
Klass* Universe::_objectArrayKlassObj = NULL;
oop Universe::_mirrors[T_VOID+1] = { NULL /*, NULL...*/ };
oop Universe::_main_thread_group = NULL;
oop Universe::_system_thread_group = NULL;
objArrayOop Universe::_the_empty_class_klass_array = NULL;
OopHandle Universe::_main_thread_group;
OopHandle Universe::_system_thread_group;
OopHandle Universe::_the_empty_class_array;
OopHandle Universe::_the_null_string;
OopHandle Universe::_the_min_jint_string;
OopHandle Universe::_the_null_sentinel;
// _out_of_memory_errors is an objArray
enum OutOfMemoryInstance { _oom_java_heap,
_oom_metaspace,
_oom_class_metaspace,
_oom_array_size,
_oom_gc_overhead_limit,
_oom_realloc_objects,
_oom_retry,
_oom_count };
OopHandle Universe::_out_of_memory_errors;
OopHandle Universe::_delayed_stack_overflow_error_message;
OopHandle Universe::_preallocated_out_of_memory_error_array;
volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0;
OopHandle Universe::_null_ptr_exception_instance;
OopHandle Universe::_arithmetic_exception_instance;
OopHandle Universe::_virtual_machine_error_instance;
oop Universe::_reference_pending_list = NULL;
Array<Klass*>* Universe::_the_array_interfaces_array = NULL;
oop Universe::_the_null_sentinel = NULL;
oop Universe::_the_null_string = NULL;
oop Universe::_the_min_jint_string = NULL;
LatestMethodCache* Universe::_finalizer_register_cache = NULL;
LatestMethodCache* Universe::_loader_addClass_cache = NULL;
LatestMethodCache* Universe::_throw_illegal_access_error_cache = NULL;
LatestMethodCache* Universe::_throw_no_such_method_error_cache = NULL;
LatestMethodCache* Universe::_do_stack_walk_cache = NULL;
oop Universe::_out_of_memory_error_java_heap = NULL;
oop Universe::_out_of_memory_error_metaspace = NULL;
oop Universe::_out_of_memory_error_class_metaspace = NULL;
oop Universe::_out_of_memory_error_array_size = NULL;
oop Universe::_out_of_memory_error_gc_overhead_limit = NULL;
oop Universe::_out_of_memory_error_realloc_objects = NULL;
oop Universe::_out_of_memory_error_retry = NULL;
oop Universe::_delayed_stack_overflow_error_message = NULL;
objArrayOop Universe::_preallocated_out_of_memory_error_array = NULL;
volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0;
bool Universe::_verify_in_progress = false;
long Universe::verify_flags = Universe::Verify_All;
oop Universe::_null_ptr_exception_instance = NULL;
oop Universe::_arithmetic_exception_instance = NULL;
oop Universe::_virtual_machine_error_instance = NULL;
oop Universe::_vm_exception = NULL;
oop Universe::_reference_pending_list = NULL;
Array<int>* Universe::_the_empty_int_array = NULL;
Array<u2>* Universe::_the_empty_short_array = NULL;
@ -143,8 +154,8 @@ Array<InstanceKlass*>* Universe::_the_empty_instance_klass_array = NULL;
Array<Method*>* Universe::_the_empty_method_array = NULL;
// These variables are guarded by FullGCALot_lock.
debug_only(objArrayOop Universe::_fullgc_alot_dummy_array = NULL;)
debug_only(int Universe::_fullgc_alot_dummy_next = 0;)
debug_only(OopHandle Universe::_fullgc_alot_dummy_array;)
debug_only(int Universe::_fullgc_alot_dummy_next = 0;)
// Heap
int Universe::_verify_count = 0;
@ -166,6 +177,25 @@ OopStorage* Universe::_vm_global = NULL;
CollectedHeap* Universe::_collectedHeap = NULL;
objArrayOop Universe::the_empty_class_array () {
return (objArrayOop)_the_empty_class_array.resolve();
}
oop Universe::main_thread_group() { return _main_thread_group.resolve(); }
void Universe::set_main_thread_group(oop group) { _main_thread_group = OopHandle(vm_global(), group); }
oop Universe::system_thread_group() { return _system_thread_group.resolve(); }
void Universe::set_system_thread_group(oop group) { _system_thread_group = OopHandle(vm_global(), group); }
oop Universe::the_null_string() { return _the_null_string.resolve(); }
oop Universe::the_min_jint_string() { return _the_min_jint_string.resolve(); }
oop Universe::null_ptr_exception_instance() { return _null_ptr_exception_instance.resolve(); }
oop Universe::arithmetic_exception_instance() { return _arithmetic_exception_instance.resolve(); }
oop Universe::virtual_machine_error_instance() { return _virtual_machine_error_instance.resolve(); }
oop Universe::the_null_sentinel() { return _the_null_sentinel.resolve(); }
void Universe::basic_type_classes_do(void f(Klass*)) {
for (int i = T_BOOLEAN; i < T_LONG+1; i++) {
f(_typeArrayKlassObjs[i]);
@ -185,31 +215,11 @@ void Universe::oops_do(OopClosure* f) {
PRIMITIVE_MIRRORS_DO(DO_PRIMITIVE_MIRROR);
for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
f->do_oop((oop*) &_mirrors[i]);
f->do_oop(&_mirrors[i]);
}
assert(_mirrors[0] == NULL && _mirrors[T_BOOLEAN - 1] == NULL, "checking");
f->do_oop((oop*)&_the_empty_class_klass_array);
f->do_oop((oop*)&_the_null_sentinel);
f->do_oop((oop*)&_the_null_string);
f->do_oop((oop*)&_the_min_jint_string);
f->do_oop((oop*)&_out_of_memory_error_java_heap);
f->do_oop((oop*)&_out_of_memory_error_metaspace);
f->do_oop((oop*)&_out_of_memory_error_class_metaspace);
f->do_oop((oop*)&_out_of_memory_error_array_size);
f->do_oop((oop*)&_out_of_memory_error_gc_overhead_limit);
f->do_oop((oop*)&_out_of_memory_error_realloc_objects);
f->do_oop((oop*)&_out_of_memory_error_retry);
f->do_oop((oop*)&_delayed_stack_overflow_error_message);
f->do_oop((oop*)&_preallocated_out_of_memory_error_array);
f->do_oop((oop*)&_null_ptr_exception_instance);
f->do_oop((oop*)&_arithmetic_exception_instance);
f->do_oop((oop*)&_virtual_machine_error_instance);
f->do_oop((oop*)&_main_thread_group);
f->do_oop((oop*)&_system_thread_group);
f->do_oop((oop*)&_vm_exception);
f->do_oop((oop*)&_reference_pending_list);
debug_only(f->do_oop((oop*)&_fullgc_alot_dummy_array);)
f->do_oop(&_reference_pending_list);
ThreadsSMRSupport::exiting_threads_oops_do(f);
}
@ -331,10 +341,12 @@ void Universe::genesis(TRAPS) {
SystemDictionary::initialize(CHECK);
Klass* ok = SystemDictionary::Object_klass();
// Create string constants
oop s = StringTable::intern("null", CHECK);
_the_null_string = OopHandle(vm_global(), s);
s = StringTable::intern("-2147483648", CHECK);
_the_min_jint_string = OopHandle(vm_global(), s);
_the_null_string = StringTable::intern("null", CHECK);
_the_min_jint_string = StringTable::intern("-2147483648", CHECK);
#if INCLUDE_CDS
if (UseSharedSpaces) {
@ -363,7 +375,7 @@ void Universe::genesis(TRAPS) {
{
Handle tns = java_lang_String::create_from_str("<null_sentinel>", CHECK);
_the_null_sentinel = tns();
_the_null_sentinel = OopHandle(vm_global(), tns());
}
// Maybe this could be lifted up now that object array can be initialized
@ -398,7 +410,6 @@ void Universe::genesis(TRAPS) {
// But we can't allocate directly in the old generation,
// so we allocate wherever, and hope that the first collection
// moves these objects to the bottom of the old generation.
// We can allocate directly in the permanent generation, so we do.
int size = FullGCALotDummies * 2;
objArrayOop naked_array = oopFactory::new_objArray(SystemDictionary::Object_klass(), size, CHECK);
@ -414,11 +425,11 @@ void Universe::genesis(TRAPS) {
// If we had a race to here, the other dummy_array instances
// and their elements just get dropped on the floor, which is fine.
MutexLocker ml(THREAD, FullGCALot_lock);
if (_fullgc_alot_dummy_array == NULL) {
_fullgc_alot_dummy_array = dummy_array();
if (_fullgc_alot_dummy_array.is_empty()) {
_fullgc_alot_dummy_array = OopHandle(vm_global(), dummy_array());
}
}
assert(i == _fullgc_alot_dummy_array->length(), "just checking");
assert(i == ((objArrayOop)_fullgc_alot_dummy_array.resolve())->length(), "just checking");
}
#endif
}
@ -509,9 +520,9 @@ oop Universe::reference_pending_list() {
return _reference_pending_list;
}
void Universe::set_reference_pending_list(oop list) {
void Universe::clear_reference_pending_list() {
assert_pll_ownership();
_reference_pending_list = list;
_reference_pending_list = NULL;
}
bool Universe::has_reference_pending_list() {
@ -563,6 +574,41 @@ bool Universe::on_page_boundary(void* addr) {
return is_aligned(addr, os::vm_page_size());
}
// the array of preallocated errors with backtraces
objArrayOop Universe::preallocated_out_of_memory_errors() {
return (objArrayOop)_preallocated_out_of_memory_error_array.resolve();
}
objArrayOop Universe::out_of_memory_errors() { return (objArrayOop)_out_of_memory_errors.resolve(); }
oop Universe::out_of_memory_error_java_heap() {
return gen_out_of_memory_error(out_of_memory_errors()->obj_at(_oom_java_heap));
}
oop Universe::out_of_memory_error_metaspace() {
return gen_out_of_memory_error(out_of_memory_errors()->obj_at(_oom_metaspace));
}
oop Universe::out_of_memory_error_class_metaspace() {
return gen_out_of_memory_error(out_of_memory_errors()->obj_at(_oom_class_metaspace));
}
oop Universe::out_of_memory_error_array_size() {
return gen_out_of_memory_error(out_of_memory_errors()->obj_at(_oom_array_size));
}
oop Universe::out_of_memory_error_gc_overhead_limit() {
return gen_out_of_memory_error(out_of_memory_errors()->obj_at(_oom_gc_overhead_limit));
}
oop Universe::out_of_memory_error_realloc_objects() {
return gen_out_of_memory_error(out_of_memory_errors()->obj_at(_oom_realloc_objects));
}
// Throw default _out_of_memory_error_retry object as it will never propagate out of the VM
oop Universe::out_of_memory_error_retry() { return out_of_memory_errors()->obj_at(_oom_retry); }
oop Universe::delayed_stack_overflow_error_message() { return _delayed_stack_overflow_error_message.resolve(); }
bool Universe::should_fill_in_stack_trace(Handle throwable) {
// never attempt to fill in the stack trace of preallocated errors that do not have
@ -570,13 +616,13 @@ bool Universe::should_fill_in_stack_trace(Handle throwable) {
// preallocated errors with backtrace have been consumed. Also need to avoid
// a potential loop which could happen if an out of memory occurs when attempting
// to allocate the backtrace.
return ((throwable() != Universe::_out_of_memory_error_java_heap) &&
(throwable() != Universe::_out_of_memory_error_metaspace) &&
(throwable() != Universe::_out_of_memory_error_class_metaspace) &&
(throwable() != Universe::_out_of_memory_error_array_size) &&
(throwable() != Universe::_out_of_memory_error_gc_overhead_limit) &&
(throwable() != Universe::_out_of_memory_error_realloc_objects) &&
(throwable() != Universe::_out_of_memory_error_retry));
objArrayOop preallocated_oom = out_of_memory_errors();
for (int i = 0; i < _oom_count; i++) {
if (throwable() == preallocated_oom->obj_at(i)) {
return false;
}
}
return true;
}
@ -619,6 +665,54 @@ oop Universe::gen_out_of_memory_error(oop default_err) {
}
}
// Setup preallocated OutOfMemoryError errors
void Universe::create_preallocated_out_of_memory_errors(TRAPS) {
InstanceKlass* ik = SystemDictionary::OutOfMemoryError_klass();
objArrayOop oa = oopFactory::new_objArray(ik, _oom_count, CHECK);
objArrayHandle oom_array(THREAD, oa);
for (int i = 0; i < _oom_count; i++) {
oop oom_obj = ik->allocate_instance(CHECK);
oom_array->obj_at_put(i, oom_obj);
}
_out_of_memory_errors = OopHandle(vm_global(), oom_array());
Handle msg = java_lang_String::create_from_str("Java heap space", CHECK);
java_lang_Throwable::set_message(oom_array->obj_at(_oom_java_heap), msg());
msg = java_lang_String::create_from_str("Metaspace", CHECK);
java_lang_Throwable::set_message(oom_array->obj_at(_oom_metaspace), msg());
msg = java_lang_String::create_from_str("Compressed class space", CHECK);
java_lang_Throwable::set_message(oom_array->obj_at(_oom_class_metaspace), msg());
msg = java_lang_String::create_from_str("Requested array size exceeds VM limit", CHECK);
java_lang_Throwable::set_message(oom_array->obj_at(_oom_array_size), msg());
msg = java_lang_String::create_from_str("GC overhead limit exceeded", CHECK);
java_lang_Throwable::set_message(oom_array->obj_at(_oom_gc_overhead_limit), msg());
msg = java_lang_String::create_from_str("Java heap space: failed reallocation of scalar replaced objects", CHECK);
java_lang_Throwable::set_message(oom_array->obj_at(_oom_realloc_objects), msg());
msg = java_lang_String::create_from_str("Java heap space: failed retryable allocation", CHECK);
java_lang_Throwable::set_message(oom_array->obj_at(_oom_retry), msg());
// Setup the array of errors that have preallocated backtrace
int len = (StackTraceInThrowable) ? (int)PreallocatedOutOfMemoryErrorCount : 0;
objArrayOop instance = oopFactory::new_objArray(ik, len, CHECK);
_preallocated_out_of_memory_error_array = OopHandle(vm_global(), instance);
objArrayHandle preallocated_oom_array(THREAD, instance);
for (int i=0; i<len; i++) {
oop err = ik->allocate_instance(CHECK);
Handle err_h(THREAD, err);
java_lang_Throwable::allocate_backtrace(err_h, CHECK);
preallocated_oom_array->obj_at_put(i, err_h());
}
_preallocated_out_of_memory_error_avail_count = (jint)len;
}
intptr_t Universe::_non_oop_bits = 0;
void* Universe::non_oop_word() {
@ -882,35 +976,33 @@ bool universe_post_init() {
}
HandleMark hm(THREAD);
// Setup preallocated empty java.lang.Class array
Universe::_the_empty_class_klass_array = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_false);
// Setup preallocated empty java.lang.Class array for Method reflection.
objArrayOop the_empty_class_array = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_false);
Universe::_the_empty_class_array = OopHandle(Universe::vm_global(), the_empty_class_array);
// Setup preallocated OutOfMemoryError errors
Klass* k = SystemDictionary::OutOfMemoryError_klass();
InstanceKlass* ik = InstanceKlass::cast(k);
Universe::_out_of_memory_error_java_heap = ik->allocate_instance(CHECK_false);
Universe::_out_of_memory_error_metaspace = ik->allocate_instance(CHECK_false);
Universe::_out_of_memory_error_class_metaspace = ik->allocate_instance(CHECK_false);
Universe::_out_of_memory_error_array_size = ik->allocate_instance(CHECK_false);
Universe::_out_of_memory_error_gc_overhead_limit =
ik->allocate_instance(CHECK_false);
Universe::_out_of_memory_error_realloc_objects = ik->allocate_instance(CHECK_false);
Universe::_out_of_memory_error_retry = ik->allocate_instance(CHECK_false);
Universe::create_preallocated_out_of_memory_errors(CHECK_false);
oop instance;
// Setup preallocated cause message for delayed StackOverflowError
if (StackReservedPages > 0) {
Universe::_delayed_stack_overflow_error_message =
java_lang_String::create_oop_from_str("Delayed StackOverflowError due to ReservedStackAccess annotated method", CHECK_false);
instance = java_lang_String::create_oop_from_str("Delayed StackOverflowError due to ReservedStackAccess annotated method", CHECK_false);
Universe::_delayed_stack_overflow_error_message = OopHandle(Universe::vm_global(), instance);
}
// Setup preallocated NullPointerException
// (this is currently used for a cheap & dirty solution in compiler exception handling)
k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_NullPointerException(), true, CHECK_false);
Universe::_null_ptr_exception_instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false);
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_NullPointerException(), true, CHECK_false);
instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false);
Universe::_null_ptr_exception_instance = OopHandle(Universe::vm_global(), instance);
// Setup preallocated ArithmeticException
// (this is currently used for a cheap & dirty solution in compiler exception handling)
k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_ArithmeticException(), true, CHECK_false);
Universe::_arithmetic_exception_instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false);
instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false);
Universe::_arithmetic_exception_instance = OopHandle(Universe::vm_global(), instance);
// Virtual Machine Error for when we get into a situation we can't resolve
k = SystemDictionary::VirtualMachineError_klass();
bool linked = InstanceKlass::cast(k)->link_class_or_fail(CHECK_false);
@ -918,48 +1010,12 @@ bool universe_post_init() {
tty->print_cr("Unable to link/verify VirtualMachineError class");
return false; // initialization failed
}
Universe::_virtual_machine_error_instance =
InstanceKlass::cast(k)->allocate_instance(CHECK_false);
instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false);
Universe::_virtual_machine_error_instance = OopHandle(Universe::vm_global(), instance);
Universe::_vm_exception = InstanceKlass::cast(k)->allocate_instance(CHECK_false);
Handle msg = java_lang_String::create_from_str("/ by zero", CHECK_false);
java_lang_Throwable::set_message(Universe::arithmetic_exception_instance(), msg());
Handle msg = java_lang_String::create_from_str("Java heap space", CHECK_false);
java_lang_Throwable::set_message(Universe::_out_of_memory_error_java_heap, msg());
msg = java_lang_String::create_from_str("Metaspace", CHECK_false);
java_lang_Throwable::set_message(Universe::_out_of_memory_error_metaspace, msg());
msg = java_lang_String::create_from_str("Compressed class space", CHECK_false);
java_lang_Throwable::set_message(Universe::_out_of_memory_error_class_metaspace, msg());
msg = java_lang_String::create_from_str("Requested array size exceeds VM limit", CHECK_false);
java_lang_Throwable::set_message(Universe::_out_of_memory_error_array_size, msg());
msg = java_lang_String::create_from_str("GC overhead limit exceeded", CHECK_false);
java_lang_Throwable::set_message(Universe::_out_of_memory_error_gc_overhead_limit, msg());
msg = java_lang_String::create_from_str("Java heap space: failed reallocation of scalar replaced objects", CHECK_false);
java_lang_Throwable::set_message(Universe::_out_of_memory_error_realloc_objects, msg());
msg = java_lang_String::create_from_str("Java heap space: failed retryable allocation", CHECK_false);
java_lang_Throwable::set_message(Universe::_out_of_memory_error_retry, msg());
msg = java_lang_String::create_from_str("/ by zero", CHECK_false);
java_lang_Throwable::set_message(Universe::_arithmetic_exception_instance, msg());
// Setup the array of errors that have preallocated backtrace
k = Universe::_out_of_memory_error_java_heap->klass();
assert(k->name() == vmSymbols::java_lang_OutOfMemoryError(), "should be out of memory error");
ik = InstanceKlass::cast(k);
int len = (StackTraceInThrowable) ? (int)PreallocatedOutOfMemoryErrorCount : 0;
Universe::_preallocated_out_of_memory_error_array = oopFactory::new_objArray(ik, len, CHECK_false);
for (int i=0; i<len; i++) {
oop err = ik->allocate_instance(CHECK_false);
Handle err_h = Handle(THREAD, err);
java_lang_Throwable::allocate_backtrace(err_h, CHECK_false);
Universe::preallocated_out_of_memory_errors()->obj_at_put(i, err_h());
}
Universe::_preallocated_out_of_memory_error_avail_count = (jint)len;
Universe::initialize_known_methods(CHECK_false);
@ -1225,18 +1281,16 @@ Method* LatestMethodCache::get_method() {
// Release dummy object(s) at bottom of heap
bool Universe::release_fullgc_alot_dummy() {
MutexLocker ml(FullGCALot_lock);
if (_fullgc_alot_dummy_array != NULL) {
if (_fullgc_alot_dummy_next >= _fullgc_alot_dummy_array->length()) {
objArrayOop fullgc_alot_dummy_array = (objArrayOop)_fullgc_alot_dummy_array.resolve();
if (fullgc_alot_dummy_array != NULL) {
if (_fullgc_alot_dummy_next >= fullgc_alot_dummy_array->length()) {
// No more dummies to release, release entire array instead
_fullgc_alot_dummy_array = NULL;
_fullgc_alot_dummy_array.release(Universe::vm_global());
return false;
}
// Release dummy at bottom of old generation
_fullgc_alot_dummy_array->obj_at_put(_fullgc_alot_dummy_next++, NULL);
// Release dummy at bottom of permanent generation
_fullgc_alot_dummy_array->obj_at_put(_fullgc_alot_dummy_next++, NULL);
fullgc_alot_dummy_array->obj_at_put(_fullgc_alot_dummy_next++, NULL);
}
return true;
}

@ -27,6 +27,7 @@
#include "gc/shared/verifyOption.hpp"
#include "oops/array.hpp"
#include "oops/oopHandle.hpp"
#include "runtime/handles.hpp"
#include "utilities/growableArray.hpp"
@ -106,31 +107,27 @@ class Universe: AllStatic {
static oop _short_mirror;
static oop _void_mirror;
static oop _main_thread_group; // Reference to the main thread group object
static oop _system_thread_group; // Reference to the system thread group object
static OopHandle _main_thread_group; // Reference to the main thread group object
static OopHandle _system_thread_group; // Reference to the system thread group object
static OopHandle _the_empty_class_array; // Canonicalized obj array of type java.lang.Class
static OopHandle _the_null_string; // A cache of "null" as a Java string
static OopHandle _the_min_jint_string; // A cache of "-2147483648" as a Java string
static OopHandle _the_null_sentinel; // A unique object pointer unused except as a sentinel for null.
// preallocated error objects (no backtrace)
static OopHandle _out_of_memory_errors;
// preallocated cause message for delayed StackOverflowError
static OopHandle _delayed_stack_overflow_error_message;
static objArrayOop _the_empty_class_klass_array; // Canonicalized obj array of type java.lang.Class
static oop _the_null_sentinel; // A unique object pointer unused except as a sentinel for null.
static oop _the_null_string; // A cache of "null" as a Java string
static oop _the_min_jint_string; // A cache of "-2147483648" as a Java string
static LatestMethodCache* _finalizer_register_cache; // static method for registering finalizable objects
static LatestMethodCache* _loader_addClass_cache; // method for registering loaded classes in class loader vector
static LatestMethodCache* _throw_illegal_access_error_cache; // Unsafe.throwIllegalAccessError() method
static LatestMethodCache* _throw_no_such_method_error_cache; // Unsafe.throwNoSuchMethodError() method
static LatestMethodCache* _do_stack_walk_cache; // method for stack walker callback
// preallocated error objects (no backtrace)
static oop _out_of_memory_error_java_heap;
static oop _out_of_memory_error_metaspace;
static oop _out_of_memory_error_class_metaspace;
static oop _out_of_memory_error_array_size;
static oop _out_of_memory_error_gc_overhead_limit;
static oop _out_of_memory_error_realloc_objects;
static oop _out_of_memory_error_retry;
// preallocated cause message for delayed StackOverflowError
static oop _delayed_stack_overflow_error_message;
static Array<int>* _the_empty_int_array; // Canonicalized int array
static Array<u2>* _the_empty_short_array; // Canonicalized short array
static Array<Klass*>* _the_empty_klass_array; // Canonicalized klass array
@ -140,17 +137,14 @@ class Universe: AllStatic {
static Array<Klass*>* _the_array_interfaces_array;
// array of preallocated error objects with backtrace
static objArrayOop _preallocated_out_of_memory_error_array;
static OopHandle _preallocated_out_of_memory_error_array;
// number of preallocated error objects available for use
static volatile jint _preallocated_out_of_memory_error_avail_count;
static oop _null_ptr_exception_instance; // preallocated exception object
static oop _arithmetic_exception_instance; // preallocated exception object
static oop _virtual_machine_error_instance; // preallocated exception object
// The object used as an exception dummy when exceptions are thrown for
// the vm thread.
static oop _vm_exception;
static OopHandle _null_ptr_exception_instance; // preallocated exception object
static OopHandle _arithmetic_exception_instance; // preallocated exception object
static OopHandle _virtual_machine_error_instance; // preallocated exception object
// References waiting to be transferred to the ReferenceHandler
static oop _reference_pending_list;
@ -161,8 +155,7 @@ class Universe: AllStatic {
static intptr_t _non_oop_bits;
// array of dummy objects used with +FullGCAlot
debug_only(static objArrayOop _fullgc_alot_dummy_array;)
// index of next entry to clear
debug_only(static OopHandle _fullgc_alot_dummy_array;)
debug_only(static int _fullgc_alot_dummy_next;)
// Compiler/dispatch support
@ -174,8 +167,9 @@ class Universe: AllStatic {
static bool _fully_initialized; // true after universe_init and initialize_vtables called
// the array of preallocated errors with backtraces
static objArrayOop preallocated_out_of_memory_errors() { return _preallocated_out_of_memory_error_array; }
static objArrayOop preallocated_out_of_memory_errors();
static objArrayOop out_of_memory_errors();
// generate an out of memory error; if possible using an error with preallocated backtrace;
// otherwise return the given default error.
static oop gen_out_of_memory_error(oop default_err);
@ -265,17 +259,23 @@ class Universe: AllStatic {
assert((uint)t < T_VOID+1, "range check");
return check_mirror(_mirrors[t]);
}
static oop main_thread_group() { return _main_thread_group; }
static void set_main_thread_group(oop group) { _main_thread_group = group;}
static oop main_thread_group();
static void set_main_thread_group(oop group);
static oop system_thread_group() { return _system_thread_group; }
static void set_system_thread_group(oop group) { _system_thread_group = group;}
static oop system_thread_group();
static void set_system_thread_group(oop group);
static objArrayOop the_empty_class_klass_array () { return _the_empty_class_klass_array; }
static Array<Klass*>* the_array_interfaces_array() { return _the_array_interfaces_array; }
static oop the_null_string() { return _the_null_string; }
static oop the_min_jint_string() { return _the_min_jint_string; }
static objArrayOop the_empty_class_array ();
static oop the_null_string();
static oop the_min_jint_string();
static oop null_ptr_exception_instance();
static oop arithmetic_exception_instance();
static oop virtual_machine_error_instance();
static oop vm_exception() { return virtual_machine_error_instance(); }
static Array<Klass*>* the_array_interfaces_array() { return _the_array_interfaces_array; }
static Method* finalizer_register_method() { return _finalizer_register_cache->get_method(); }
static Method* loader_addClass_method() { return _loader_addClass_cache->get_method(); }
@ -284,16 +284,13 @@ class Universe: AllStatic {
static Method* do_stack_walk_method() { return _do_stack_walk_cache->get_method(); }
static oop the_null_sentinel() { return _the_null_sentinel; }
static oop the_null_sentinel();
static address the_null_sentinel_addr() { return (address) &_the_null_sentinel; }
// Function to initialize these
static void initialize_known_methods(TRAPS);
static oop null_ptr_exception_instance() { return _null_ptr_exception_instance; }
static oop arithmetic_exception_instance() { return _arithmetic_exception_instance; }
static oop virtual_machine_error_instance() { return _virtual_machine_error_instance; }
static oop vm_exception() { return _vm_exception; }
static void create_preallocated_out_of_memory_errors(TRAPS);
// Reference pending list manipulation. Access is protected by
// Heap_lock. The getter, setter and predicate require the caller
@ -302,7 +299,7 @@ class Universe: AllStatic {
// Heap_lock, so requires the lock is locked, but not necessarily by
// the current thread.
static oop reference_pending_list();
static void set_reference_pending_list(oop list);
static void clear_reference_pending_list();
static bool has_reference_pending_list();
static oop swap_reference_pending_list(oop list);
@ -315,15 +312,16 @@ class Universe: AllStatic {
// OutOfMemoryError support. Returns an error with the required message. The returned error
// may or may not have a backtrace. If error has a backtrace then the stack trace is already
// filled in.
static oop out_of_memory_error_java_heap() { return gen_out_of_memory_error(_out_of_memory_error_java_heap); }
static oop out_of_memory_error_metaspace() { return gen_out_of_memory_error(_out_of_memory_error_metaspace); }
static oop out_of_memory_error_class_metaspace() { return gen_out_of_memory_error(_out_of_memory_error_class_metaspace); }
static oop out_of_memory_error_array_size() { return gen_out_of_memory_error(_out_of_memory_error_array_size); }
static oop out_of_memory_error_gc_overhead_limit() { return gen_out_of_memory_error(_out_of_memory_error_gc_overhead_limit); }
static oop out_of_memory_error_realloc_objects() { return gen_out_of_memory_error(_out_of_memory_error_realloc_objects); }
static oop out_of_memory_error_java_heap();
static oop out_of_memory_error_metaspace();
static oop out_of_memory_error_class_metaspace();
static oop out_of_memory_error_array_size();
static oop out_of_memory_error_gc_overhead_limit();
static oop out_of_memory_error_realloc_objects();
// Throw default _out_of_memory_error_retry object as it will never propagate out of the VM
static oop out_of_memory_error_retry() { return _out_of_memory_error_retry; }
static oop delayed_stack_overflow_error_message() { return _delayed_stack_overflow_error_message; }
static oop out_of_memory_error_retry();
static oop delayed_stack_overflow_error_message();
// The particular choice of collected heap.
static CollectedHeap* heap() { return _collectedHeap; }

@ -805,7 +805,7 @@ bool Method::needs_clinit_barrier() const {
objArrayHandle Method::resolved_checked_exceptions_impl(Method* method, TRAPS) {
int length = method->checked_exceptions_length();
if (length == 0) { // common case
return objArrayHandle(THREAD, Universe::the_empty_class_klass_array());
return objArrayHandle(THREAD, Universe::the_empty_class_array());
} else {
methodHandle h_this(THREAD, method);
objArrayOop m_oop = oopFactory::new_objArray(SystemDictionary::Class_klass(), length, CHECK_(objArrayHandle()));

@ -48,6 +48,8 @@ public:
inline oop resolve() const;
inline oop peek() const;
bool is_empty() const { return _obj == NULL; }
inline void release(OopStorage* storage);
// Used only for removing handle.

@ -3409,7 +3409,7 @@ JVM_ENTRY(jobject, JVM_GetAndClearReferencePendingList(JNIEnv* env))
MonitorLocker ml(Heap_lock);
oop ref = Universe::reference_pending_list();
if (ref != NULL) {
Universe::set_reference_pending_list(NULL);
Universe::clear_reference_pending_list();
}
return JNIHandles::make_local(THREAD, ref);
JVM_END

@ -812,8 +812,7 @@ oop Reflection::new_method(const methodHandle& method, bool for_constant_pool_ac
Handle return_type(THREAD, return_type_oop);
objArrayHandle exception_types = get_exception_types(method, CHECK_NULL);
if (exception_types.is_null()) return NULL;
assert(!exception_types.is_null(), "cannot return null");
Symbol* method_name = method->name();
oop name_oop = StringTable::intern(method_name, CHECK_NULL);
@ -859,7 +858,7 @@ oop Reflection::new_constructor(const methodHandle& method, TRAPS) {
if (parameter_types.is_null()) return NULL;
objArrayHandle exception_types = get_exception_types(method, CHECK_NULL);
if (exception_types.is_null()) return NULL;
assert(!exception_types.is_null(), "cannot return null");
const int modifiers = method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS;

@ -369,23 +369,7 @@ typedef HashtableEntry<InstanceKlass*, mtClass> KlassHashtableEntry;
/************/ \
/* Universe */ \
/************/ \
\
static_field(Universe, _mirrors[0], oop) \
static_field(Universe, _main_thread_group, oop) \
static_field(Universe, _system_thread_group, oop) \
static_field(Universe, _the_empty_class_klass_array, objArrayOop) \
static_field(Universe, _null_ptr_exception_instance, oop) \
static_field(Universe, _arithmetic_exception_instance, oop) \
static_field(Universe, _vm_exception, oop) \
static_field(Universe, _collectedHeap, CollectedHeap*) \
static_field(Universe, _base_vtable_size, int) \
static_field(Universe, _bootstrapping, bool) \
static_field(Universe, _fully_initialized, bool) \
static_field(Universe, _verify_count, int) \
static_field(Universe, _verify_oop_mask, uintptr_t) \
static_field(Universe, _verify_oop_bits, uintptr_t) \
static_field(Universe, _non_oop_bits, intptr_t) \
\
/******************/ \
/* CompressedOops */ \
/******************/ \

@ -51,8 +51,6 @@ import sun.jvm.hotspot.types.TypeDataBase;
public class Universe {
private static AddressField collectedHeapField;
private static VirtualConstructor heapConstructor;
private static sun.jvm.hotspot.types.OopField mainThreadGroupField;
private static sun.jvm.hotspot.types.OopField systemThreadGroupField;
static {
VM.registerVMInitializedObserver(new Observer() {
@ -91,9 +89,6 @@ public class Universe {
addHeapTypeIfInDB(db, ZCollectedHeap.class);
addHeapTypeIfInDB(db, ShenandoahHeap.class);
mainThreadGroupField = type.getOopField("_main_thread_group");
systemThreadGroupField = type.getOopField("_system_thread_group");
UniverseExt.initialize(heapConstructor);
}
@ -114,19 +109,6 @@ public class Universe {
return heap().isInReserved(p);
}
private Oop newOop(OopHandle handle) {
return VM.getVM().getObjectHeap().newOop(handle);
}
public Oop mainThreadGroup() {
return newOop(mainThreadGroupField.getValue());
}
public Oop systemThreadGroup() {
return newOop(systemThreadGroupField.getValue());
}
public void print() { printOn(System.out); }
public void printOn(PrintStream tty) {
heap().printOn(tty);

@ -71,9 +71,7 @@ public class ClhsdbPrintStatics {
"_number_of_threads", "_number_of_non_daemon_threads"));
expStrMap.put("printstatics Universe", List.of(
"Static fields of Universe",
"uintptr_t Universe::_verify_oop_mask",
"intptr_t Universe::_non_oop_bits",
"bool Universe::_fully_initialized"));
"Universe::_collectedHeap"));
expStrMap.put("printstatics JvmtiExport", List.of(
"Static fields of JvmtiExport",
"bool JvmtiExport::_can_access_local_variables",