1.1 --- a/src/share/vm/interpreter/rewriter.cpp Mon Dec 24 11:46:38 2012 -0800 1.2 +++ b/src/share/vm/interpreter/rewriter.cpp Wed Jan 02 20:28:09 2013 -0500 1.3 @@ -27,13 +27,8 @@ 1.4 #include "interpreter/interpreter.hpp" 1.5 #include "interpreter/rewriter.hpp" 1.6 #include "memory/gcLocker.hpp" 1.7 -#include "memory/metadataFactory.hpp" 1.8 -#include "memory/oopFactory.hpp" 1.9 #include "memory/resourceArea.hpp" 1.10 #include "oops/generateOopMap.hpp" 1.11 -#include "oops/objArrayOop.hpp" 1.12 -#include "oops/oop.inline.hpp" 1.13 -#include "prims/methodComparator.hpp" 1.14 #include "prims/methodHandles.hpp" 1.15 1.16 // Computes a CPC map (new_index -> original_index) for constant pool entries 1.17 @@ -402,13 +397,6 @@ 1.18 } 1.19 1.20 1.21 -void Rewriter::rewrite(instanceKlassHandle klass, constantPoolHandle cpool, Array<Method*>* methods, TRAPS) { 1.22 - ResourceMark rm(THREAD); 1.23 - Rewriter rw(klass, cpool, methods, CHECK); 1.24 - // (That's all, folks.) 1.25 -} 1.26 - 1.27 - 1.28 Rewriter::Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, Array<Method*>* methods, TRAPS) 1.29 : _klass(klass), 1.30 _pool(cpool), 1.31 @@ -453,46 +441,25 @@ 1.32 restore_bytecodes(); 1.33 return; 1.34 } 1.35 -} 1.36 1.37 -// Relocate jsr/rets in a method. This can't be done with the rewriter 1.38 -// stage because it can throw other exceptions, leaving the bytecodes 1.39 -// pointing at constant pool cache entries. 1.40 -// Link and check jvmti dependencies while we're iterating over the methods. 1.41 -// JSR292 code calls with a different set of methods, so two entry points. 1.42 -void Rewriter::relocate_and_link(instanceKlassHandle this_oop, TRAPS) { 1.43 - relocate_and_link(this_oop, this_oop->methods(), THREAD); 1.44 -} 1.45 - 1.46 -void Rewriter::relocate_and_link(instanceKlassHandle this_oop, 1.47 - Array<Method*>* methods, TRAPS) { 1.48 - int len = methods->length(); 1.49 + // Relocate after everything, but still do this under the is_rewritten flag, 1.50 + // so methods with jsrs in custom class lists in aren't attempted to be 1.51 + // rewritten in the RO section of the shared archive. 1.52 + // Relocated bytecodes don't have to be restored, only the cp cache entries 1.53 for (int i = len-1; i >= 0; i--) { 1.54 - methodHandle m(THREAD, methods->at(i)); 1.55 + methodHandle m(THREAD, _methods->at(i)); 1.56 1.57 if (m->has_jsrs()) { 1.58 - m = rewrite_jsrs(m, CHECK); 1.59 + m = rewrite_jsrs(m, THREAD); 1.60 + // Restore bytecodes to their unrewritten state if there are exceptions 1.61 + // relocating bytecodes. If some are relocated, that is ok because that 1.62 + // doesn't affect constant pool to cpCache rewriting. 1.63 + if (HAS_PENDING_EXCEPTION) { 1.64 + restore_bytecodes(); 1.65 + return; 1.66 + } 1.67 // Method might have gotten rewritten. 1.68 methods->at_put(i, m()); 1.69 } 1.70 - 1.71 - // Set up method entry points for compiler and interpreter . 1.72 - m->link_method(m, CHECK); 1.73 - 1.74 - // This is for JVMTI and unrelated to relocator but the last thing we do 1.75 -#ifdef ASSERT 1.76 - if (StressMethodComparator) { 1.77 - static int nmc = 0; 1.78 - for (int j = i; j >= 0 && j >= i-4; j--) { 1.79 - if ((++nmc % 1000) == 0) tty->print_cr("Have run MethodComparator %d times...", nmc); 1.80 - bool z = MethodComparator::methods_EMCP(m(), 1.81 - methods->at(j)); 1.82 - if (j == i && !z) { 1.83 - tty->print("MethodComparator FAIL: "); m->print(); m->print_codes(); 1.84 - assert(z, "method must compare equal to itself"); 1.85 - } 1.86 - } 1.87 - } 1.88 -#endif //ASSERT 1.89 } 1.90 }