mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass
Change implementor to embedded instanceKlass field. Reviewed-by: sspitsyn, minqi, coleenp
This commit is contained in:
parent
50a2f8c16d
commit
4a02eb3afe
14 changed files with 183 additions and 165 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -111,7 +111,7 @@ void instanceKlassKlass::oop_follow_contents(oop obj) {
|
|||
MarkSweep::mark_and_push(ik->adr_methods_parameter_annotations());
|
||||
MarkSweep::mark_and_push(ik->adr_methods_default_annotations());
|
||||
|
||||
// We do not follow adr_implementors() here. It is followed later
|
||||
// We do not follow adr_implementor() here. It is followed later
|
||||
// in instanceKlass::follow_weak_klass_links()
|
||||
|
||||
klassKlass::oop_follow_contents(obj);
|
||||
|
@ -180,8 +180,8 @@ int instanceKlassKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
|
|||
blk->do_oop(ik->adr_host_klass());
|
||||
blk->do_oop(ik->adr_signers());
|
||||
blk->do_oop(ik->adr_inner_classes());
|
||||
for (int i = 0; i < instanceKlass::implementors_limit; i++) {
|
||||
blk->do_oop(&ik->adr_implementors()[i]);
|
||||
if (ik->is_interface()) {
|
||||
blk->do_oop(ik->adr_implementor());
|
||||
}
|
||||
blk->do_oop(ik->adr_class_annotations());
|
||||
blk->do_oop(ik->adr_fields_annotations());
|
||||
|
@ -232,9 +232,9 @@ int instanceKlassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk,
|
|||
if (mr.contains(adr)) blk->do_oop(adr);
|
||||
adr = ik->adr_inner_classes();
|
||||
if (mr.contains(adr)) blk->do_oop(adr);
|
||||
adr = ik->adr_implementors();
|
||||
for (int i = 0; i < instanceKlass::implementors_limit; i++) {
|
||||
if (mr.contains(&adr[i])) blk->do_oop(&adr[i]);
|
||||
if (ik->is_interface()) {
|
||||
adr = ik->adr_implementor();
|
||||
if (mr.contains(adr)) blk->do_oop(adr);
|
||||
}
|
||||
adr = ik->adr_class_annotations();
|
||||
if (mr.contains(adr)) blk->do_oop(adr);
|
||||
|
@ -273,8 +273,8 @@ int instanceKlassKlass::oop_adjust_pointers(oop obj) {
|
|||
MarkSweep::adjust_pointer(ik->adr_host_klass());
|
||||
MarkSweep::adjust_pointer(ik->adr_signers());
|
||||
MarkSweep::adjust_pointer(ik->adr_inner_classes());
|
||||
for (int i = 0; i < instanceKlass::implementors_limit; i++) {
|
||||
MarkSweep::adjust_pointer(&ik->adr_implementors()[i]);
|
||||
if (ik->is_interface()) {
|
||||
MarkSweep::adjust_pointer(ik->adr_implementor());
|
||||
}
|
||||
MarkSweep::adjust_pointer(ik->adr_class_annotations());
|
||||
MarkSweep::adjust_pointer(ik->adr_fields_annotations());
|
||||
|
@ -328,6 +328,9 @@ int instanceKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
|
|||
for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
|
||||
PSParallelCompact::adjust_pointer(cur_oop);
|
||||
}
|
||||
if (ik->is_interface()) {
|
||||
PSParallelCompact::adjust_pointer(ik->adr_implementor());
|
||||
}
|
||||
|
||||
OopClosure* closure = PSParallelCompact::adjust_root_pointer_closure();
|
||||
iterate_c_heap_oops(ik, closure);
|
||||
|
@ -342,11 +345,18 @@ klassOop
|
|||
instanceKlassKlass::allocate_instance_klass(Symbol* name, int vtable_len, int itable_len,
|
||||
int static_field_size,
|
||||
unsigned nonstatic_oop_map_count,
|
||||
AccessFlags access_flags,
|
||||
ReferenceType rt, TRAPS) {
|
||||
|
||||
const int nonstatic_oop_map_size =
|
||||
instanceKlass::nonstatic_oop_map_size(nonstatic_oop_map_count);
|
||||
int size = instanceKlass::object_size(align_object_offset(vtable_len) + align_object_offset(itable_len) + nonstatic_oop_map_size);
|
||||
int size = align_object_offset(vtable_len) + align_object_offset(itable_len);
|
||||
if (access_flags.is_interface()) {
|
||||
size += align_object_offset(nonstatic_oop_map_size) + (int)sizeof(klassOop)/HeapWordSize;
|
||||
} else {
|
||||
size += nonstatic_oop_map_size;
|
||||
}
|
||||
size = instanceKlass::object_size(size);
|
||||
|
||||
// Allocation
|
||||
KlassHandle h_this_klass(THREAD, as_klassOop());
|
||||
|
@ -378,6 +388,7 @@ instanceKlassKlass::allocate_instance_klass(Symbol* name, int vtable_len, int it
|
|||
ik->set_itable_length(itable_len);
|
||||
ik->set_static_field_size(static_field_size);
|
||||
ik->set_nonstatic_oop_map_size(nonstatic_oop_map_size);
|
||||
ik->set_access_flags(access_flags);
|
||||
assert(k()->size() == size, "wrong size for object");
|
||||
|
||||
ik->set_array_klasses(NULL);
|
||||
|
@ -470,16 +481,12 @@ void instanceKlassKlass::oop_print_on(oop obj, outputStream* st) {
|
|||
|
||||
if (ik->is_interface()) {
|
||||
st->print_cr(BULLET"nof implementors: %d", ik->nof_implementors());
|
||||
int print_impl = 0;
|
||||
for (int i = 0; i < instanceKlass::implementors_limit; i++) {
|
||||
if (ik->implementor(i) != NULL) {
|
||||
if (++print_impl == 1)
|
||||
st->print_cr(BULLET"implementor: ");
|
||||
st->print(" ");
|
||||
ik->implementor(i)->print_value_on(st);
|
||||
}
|
||||
if (ik->nof_implementors() == 1) {
|
||||
st->print_cr(BULLET"implementor: ");
|
||||
st->print(" ");
|
||||
ik->implementor()->print_value_on(st);
|
||||
st->cr();
|
||||
}
|
||||
if (print_impl > 0) st->cr();
|
||||
}
|
||||
|
||||
st->print(BULLET"arrays: "); ik->array_klasses()->print_value_on(st); st->cr();
|
||||
|
@ -640,16 +647,12 @@ void instanceKlassKlass::oop_verify_on(oop obj, outputStream* st) {
|
|||
}
|
||||
|
||||
// Verify implementor fields
|
||||
bool saw_null_impl = false;
|
||||
for (int i = 0; i < instanceKlass::implementors_limit; i++) {
|
||||
klassOop im = ik->implementor(i);
|
||||
if (im == NULL) { saw_null_impl = true; continue; }
|
||||
guarantee(!saw_null_impl, "non-nulls must preceded all nulls");
|
||||
klassOop im = ik->implementor();
|
||||
if (im != NULL) {
|
||||
guarantee(ik->is_interface(), "only interfaces should have implementor set");
|
||||
guarantee(i < ik->nof_implementors(), "should only have one implementor");
|
||||
guarantee(im->is_perm(), "should be in permspace");
|
||||
guarantee(im->is_klass(), "should be klass");
|
||||
guarantee(!Klass::cast(klassOop(im))->is_interface(), "implementors cannot be interfaces");
|
||||
guarantee(!Klass::cast(klassOop(im))->is_interface() || im == ik->as_klassOop(), "implementors cannot be interfaces");
|
||||
}
|
||||
|
||||
// Verify local interfaces
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue