--- a/src/share/vm/ci/ciObject.hpp Thu May 26 20:19:48 2011 -0700+++ b/src/share/vm/ci/ciObject.hpp Fri May 27 23:55:49 2011 -0700@@ -108,7 +108,7 @@ int hash(); // Tells if this oop has an encoding as a constant.- // True if is_scavengable is false.+ // True if is_perm is true. // Also true if ScavengeRootsInCode is non-zero. // If it does not have an encoding, the compiler is responsible for // making other arrangements for dealing with the oop.@@ -116,7 +116,7 @@ bool can_be_constant(); // Tells if this oop should be made a constant.- // True if is_scavengable is false or ScavengeRootsInCode > 1.+ // True if is_perm is true or ScavengeRootsInCode > 1. bool should_be_constant(); // Is this object guaranteed to be in the permanent part of the heap?

--- a/src/share/vm/oops/instanceKlass.cpp Thu May 26 20:19:48 2011 -0700+++ b/src/share/vm/oops/instanceKlass.cpp Fri May 27 23:55:49 2011 -0700@@ -335,6 +335,9 @@ this_oop->rewrite_class(CHECK_false); }+ // relocate jsrs and link methods after they are all rewritten+ this_oop->relocate_and_link_methods(CHECK_false);+ // Initialize the vtable and interface table after // methods have been rewritten since rewrite may // fabricate new methodOops.@@ -365,17 +368,8 @@ // Rewrite the byte codes of all of the methods of a class.-// Three cases:-// During the link of a newly loaded class.-// During the preloading of classes to be written to the shared spaces.-// - Rewrite the methods and update the method entry points.-//-// During the link of a class in the shared spaces.-// - The methods were already rewritten, update the metho entry points.-// // The rewriter must be called exactly once. Rewriting must happen after // verification but before the first method of the class is executed.- void instanceKlass::rewrite_class(TRAPS) { assert(is_loaded(), "must be loaded"); instanceKlassHandle this_oop(THREAD, this->as_klassOop());@@ -383,10 +377,19 @@ assert(this_oop()->is_shared(), "rewriting an unshared class?"); return; }- Rewriter::rewrite(this_oop, CHECK); // No exception can happen here+ Rewriter::rewrite(this_oop, CHECK); this_oop->set_rewritten(); }+// 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->as_klassOop());+ Rewriter::relocate_and_link(this_oop, CHECK);+}+ void instanceKlass::initialize_impl(instanceKlassHandle this_oop, TRAPS) { // Make sure klass is linked (verified) before initialization

--- a/src/share/vm/oops/methodOop.cpp Thu May 26 20:19:48 2011 -0700+++ b/src/share/vm/oops/methodOop.cpp Fri May 27 23:55:49 2011 -0700@@ -693,7 +693,10 @@ // Called when the method_holder is getting linked. Setup entrypoints so the method // is ready to be called from interpreter, compiler, and vtables. void methodOopDesc::link_method(methodHandle h_method, TRAPS) {- assert(_i2i_entry == NULL, "should only be called once");+ // If the code cache is full, we may reenter this function for the+ // leftover methods that weren't linked.+ if (_i2i_entry != NULL) return;+ assert(_adapter == NULL, "init'd to NULL" ); assert( _code == NULL, "nothing compiled yet" );@@ -717,7 +720,7 @@ // called from the vtable. We need adapters on such methods that get loaded // later. Ditto for mega-morphic itable calls. If this proves to be a // problem we'll make these lazily later.- (void) make_adapters(h_method, CHECK);+ if (UseCompiler) (void) make_adapters(h_method, CHECK); // ONLY USE the h_method now as make_adapter may have blocked