1.1 --- a/src/share/vm/runtime/frame.cpp Mon Nov 26 12:31:03 2012 -0500 1.2 +++ b/src/share/vm/runtime/frame.cpp Tue Nov 27 10:13:20 2012 +0100 1.3 @@ -879,7 +879,8 @@ 1.4 } 1.5 1.6 1.7 -void frame::oops_interpreted_do(OopClosure* f, const RegisterMap* map, bool query_oop_map_cache) { 1.8 +void frame::oops_interpreted_do(OopClosure* f, CLDToOopClosure* cld_f, 1.9 + const RegisterMap* map, bool query_oop_map_cache) { 1.10 assert(is_interpreted_frame(), "Not an interpreted frame"); 1.11 assert(map != NULL, "map must be set"); 1.12 Thread *thread = Thread::current(); 1.13 @@ -906,6 +907,16 @@ 1.14 } 1.15 1.16 // process fixed part 1.17 + if (cld_f != NULL) { 1.18 + // The method pointer in the frame might be the only path to the method's 1.19 + // klass, and the klass needs to be kept alive while executing. The GCs 1.20 + // don't trace through method pointers, so typically in similar situations 1.21 + // the mirror or the class loader of the klass are installed as a GC root. 1.22 + // To minimze the overhead of doing that here, we ask the GC to pass down a 1.23 + // closure that knows how to keep klasses alive given a ClassLoaderData. 1.24 + cld_f->do_cld(m->method_holder()->class_loader_data()); 1.25 + } 1.26 + 1.27 #if !defined(PPC) || defined(ZERO) 1.28 if (m->is_native()) { 1.29 #ifdef CC_INTERP 1.30 @@ -1108,7 +1119,7 @@ 1.31 } 1.32 1.33 1.34 -void frame::oops_do_internal(OopClosure* f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache) { 1.35 +void frame::oops_do_internal(OopClosure* f, CLDToOopClosure* cld_f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache) { 1.36 #ifndef PRODUCT 1.37 // simulate GC crash here to dump java thread in error report 1.38 if (CrashGCForDumpingJavaThread) { 1.39 @@ -1117,7 +1128,7 @@ 1.40 } 1.41 #endif 1.42 if (is_interpreted_frame()) { 1.43 - oops_interpreted_do(f, map, use_interpreter_oop_map_cache); 1.44 + oops_interpreted_do(f, cld_f, map, use_interpreter_oop_map_cache); 1.45 } else if (is_entry_frame()) { 1.46 oops_entry_do(f, map); 1.47 } else if (CodeCache::contains(pc())) { 1.48 @@ -1278,7 +1289,7 @@ 1.49 } 1.50 } 1.51 COMPILER2_PRESENT(assert(DerivedPointerTable::is_empty(), "must be empty before verify");) 1.52 - oops_do_internal(&VerifyOopClosure::verify_oop, NULL, (RegisterMap*)map, false); 1.53 + oops_do_internal(&VerifyOopClosure::verify_oop, NULL, NULL, (RegisterMap*)map, false); 1.54 } 1.55 1.56