7195867: NPG: SAJDI tests fail with sun.jvm.hotspot.types.WrongTypeException: No suitable match for type

Need to restore the vtable in metadata when we restore the type from the shared archive.

Reviewed-by: acorn, jcoomes, jmasa, jrose
This commit is contained in:
Coleen Phillimore 2012-09-05 20:08:08 -04:00
parent f3b6368c39
commit 8536f548db
6 changed files with 22 additions and 4 deletions

View File

@ -1953,7 +1953,7 @@ void SystemDictionary::initialize_preloaded_classes(TRAPS) {
// Initialize the constant pool for the Object_class
InstanceKlass* ik = InstanceKlass::cast(Object_klass());
ik->constants()->restore_unshareable_info(CHECK);
initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
} else {
initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
}

View File

@ -153,9 +153,9 @@ static void calculate_fingerprints() {
//
// Execution time:
// First virtual method call for any object of these metadata types:
// 1. object->klass->klass_part
// 2. vtable entry for that klass_part points to the jump table entries
// 3. branches to common_code with %O0/klass_part, %L0: Klass index <<8 + method index
// 1. object->klass
// 2. vtable entry for that klass points to the jump table entries
// 3. branches to common_code with %O0/klass, %L0: Klass index <<8 + method index
// 4. common_code:
// Get address of new vtbl pointer for this Klass from updated table
// Update new vtbl pointer in the Klass: future virtual calls go direct

View File

@ -152,6 +152,10 @@ void ConstantPool::initialize_resolved_references(ClassLoaderData* loader_data,
// CDS support. Create a new resolved_references array.
void ConstantPool::restore_unshareable_info(TRAPS) {
// restore the C++ vtable from the shared archive
restore_vtable();
if (SystemDictionary::Object_klass_loaded()) {
// Recreate the object array and add to ClassLoaderData.
int map_length = resolved_reference_length();

View File

@ -643,6 +643,11 @@ class ConstantPool : public Metadata {
void remove_unshareable_info();
void restore_unshareable_info(TRAPS);
bool resolve_class_constants(TRAPS);
// The ConstantPool vtable is restored by this call when the ConstantPool is
// in the shared archive. See patch_klass_vtables() in metaspaceShared.cpp for
// all the gory details. SA, dtrace and pstack helpers distinguish metadata
// by their vtable.
void restore_vtable() { guarantee(is_constantPool(), "vtable restored by this call"); }
private:
enum { _no_index_sentinel = -1, _possible_index_sentinel = -2 };

View File

@ -2165,6 +2165,8 @@ void InstanceKlass::restore_unshareable_info(TRAPS) {
for (int index2 = 0; index2 < num_methods; ++index2) {
methodHandle m(THREAD, methods->at(index2));
m()->link_method(m, CHECK);
// restore method's vtable by calling a virtual function
m->restore_vtable();
}
if (JvmtiExport::has_redefined_a_class()) {
// Reinitialize vtable because RedefineClasses may have changed some

View File

@ -168,9 +168,16 @@ class Method : public Metadata {
TRAPS);
Method() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
// The Method vtable is restored by this call when the Method is in the
// shared archive. See patch_klass_vtables() in metaspaceShared.cpp for
// all the gory details. SA, dtrace and pstack helpers distinguish metadata
// by their vtable.
void restore_vtable() { guarantee(is_method(), "vtable restored by this call"); }
bool is_method() const volatile { return true; }
// accessors for instance variables
ConstMethod* constMethod() const { return _constMethod; }
void set_constMethod(ConstMethod* xconst) { _constMethod = xconst; }