8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs

Relocate functions with jsr's when rewriting so not repeated after reading shared archive

Reviewed-by: twisti, jrose
This commit is contained in:
Coleen Phillimore 2013-01-02 20:28:09 -05:00
parent a5fbc1aa4d
commit 64499d9494
6 changed files with 46 additions and 61 deletions

View file

@ -47,6 +47,7 @@
#include "oops/symbol.hpp"
#include "prims/jvmtiExport.hpp"
#include "prims/jvmtiRedefineClassesTrace.hpp"
#include "prims/methodComparator.hpp"
#include "runtime/fieldDescriptor.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/javaCalls.hpp"
@ -602,7 +603,7 @@ bool InstanceKlass::link_class_impl(
}
// relocate jsrs and link methods after they are all rewritten
this_oop->relocate_and_link_methods(CHECK_false);
this_oop->link_methods(CHECK_false);
// Initialize the vtable and interface table after
// methods have been rewritten since rewrite may
@ -650,10 +651,31 @@ void InstanceKlass::rewrite_class(TRAPS) {
// Now relocate and link method entry points after class is rewritten.
// This is outside is_rewritten flag. In case of an exception, it can be
// executed more than once.
void InstanceKlass::relocate_and_link_methods(TRAPS) {
assert(is_loaded(), "must be loaded");
instanceKlassHandle this_oop(THREAD, this);
Rewriter::relocate_and_link(this_oop, CHECK);
void InstanceKlass::link_methods(TRAPS) {
int len = methods()->length();
for (int i = len-1; i >= 0; i--) {
methodHandle m(THREAD, methods()->at(i));
// Set up method entry points for compiler and interpreter .
m->link_method(m, CHECK);
// This is for JVMTI and unrelated to relocator but the last thing we do
#ifdef ASSERT
if (StressMethodComparator) {
ResourceMark rm(THREAD);
static int nmc = 0;
for (int j = i; j >= 0 && j >= i-4; j--) {
if ((++nmc % 1000) == 0) tty->print_cr("Have run MethodComparator %d times...", nmc);
bool z = MethodComparator::methods_EMCP(m(),
methods()->at(j));
if (j == i && !z) {
tty->print("MethodComparator FAIL: "); m->print(); m->print_codes();
assert(z, "method must compare equal to itself");
}
}
}
#endif //ASSERT
}
}