Thu, 12 Dec 2013 16:13:44 +0100
Merge
1.1 --- a/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp Tue Dec 10 16:18:26 2013 -0500 1.2 +++ b/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp Thu Dec 12 16:13:44 2013 +0100 1.3 @@ -27,6 +27,7 @@ 1.4 #include "gc_implementation/g1/concurrentG1RefineThread.hpp" 1.5 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" 1.6 #include "gc_implementation/g1/g1HotCardCache.hpp" 1.7 +#include "runtime/java.hpp" 1.8 1.9 ConcurrentG1Refine::ConcurrentG1Refine(G1CollectedHeap* g1h) : 1.10 _threads(NULL), _n_threads(0), 1.11 @@ -62,6 +63,10 @@ 1.12 for (int i = _n_threads - 1; i >= 0; i--) { 1.13 ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, worker_id_offset, i); 1.14 assert(t != NULL, "Conc refine should have been created"); 1.15 + if (t->osthread() == NULL) { 1.16 + vm_shutdown_during_initialization("Could not create ConcurrentG1RefineThread"); 1.17 + } 1.18 + 1.19 assert(t->cg1r() == this, "Conc refine thread should refer to this"); 1.20 _threads[i] = t; 1.21 next = t;
2.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp Tue Dec 10 16:18:26 2013 -0500 2.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp Thu Dec 12 16:13:44 2013 +0100 2.3 @@ -553,6 +553,9 @@ 2.4 _cmThread = new ConcurrentMarkThread(this); 2.5 assert(cmThread() != NULL, "CM Thread should have been created"); 2.6 assert(cmThread()->cm() != NULL, "CM Thread should refer to this cm"); 2.7 + if (_cmThread->osthread() == NULL) { 2.8 + vm_shutdown_during_initialization("Could not create ConcurrentMarkThread"); 2.9 + } 2.10 2.11 assert(CGC_lock != NULL, "Where's the CGC_lock?"); 2.12 assert(_markBitMap1.covers(heap_rs), "_markBitMap1 inconsistency");
3.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Tue Dec 10 16:18:26 2013 -0500 3.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Thu Dec 12 16:13:44 2013 +0100 3.3 @@ -2433,20 +2433,6 @@ 3.4 _gc_tracer.report_object_count_after_gc(is_alive_closure()); 3.5 } 3.6 3.7 -void PSParallelCompact::follow_klass(ParCompactionManager* cm, Klass* klass) { 3.8 - ClassLoaderData* cld = klass->class_loader_data(); 3.9 - // The actual processing of the klass is done when we 3.10 - // traverse the list of Klasses in the class loader data. 3.11 - PSParallelCompact::follow_class_loader(cm, cld); 3.12 -} 3.13 - 3.14 -void PSParallelCompact::adjust_klass(ParCompactionManager* cm, Klass* klass) { 3.15 - ClassLoaderData* cld = klass->class_loader_data(); 3.16 - // The actual processing of the klass is done when we 3.17 - // traverse the list of Klasses in the class loader data. 3.18 - PSParallelCompact::adjust_class_loader(cm, cld); 3.19 -} 3.20 - 3.21 void PSParallelCompact::follow_class_loader(ParCompactionManager* cm, 3.22 ClassLoaderData* cld) { 3.23 PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); 3.24 @@ -2455,13 +2441,6 @@ 3.25 cld->oops_do(&mark_and_push_closure, &follow_klass_closure, true); 3.26 } 3.27 3.28 -void PSParallelCompact::adjust_class_loader(ParCompactionManager* cm, 3.29 - ClassLoaderData* cld) { 3.30 - cld->oops_do(PSParallelCompact::adjust_pointer_closure(), 3.31 - PSParallelCompact::adjust_klass_closure(), 3.32 - true); 3.33 -} 3.34 - 3.35 // This should be moved to the shared markSweep code! 3.36 class PSAlwaysTrueClosure: public BoolObjectClosure { 3.37 public:
4.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp Tue Dec 10 16:18:26 2013 -0500 4.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp Thu Dec 12 16:13:44 2013 +0100 4.3 @@ -1200,13 +1200,10 @@ 4.4 T* p); 4.5 template <class T> static inline void adjust_pointer(T* p); 4.6 4.7 - static void follow_klass(ParCompactionManager* cm, Klass* klass); 4.8 - static void adjust_klass(ParCompactionManager* cm, Klass* klass); 4.9 + static inline void follow_klass(ParCompactionManager* cm, Klass* klass); 4.10 4.11 static void follow_class_loader(ParCompactionManager* cm, 4.12 ClassLoaderData* klass); 4.13 - static void adjust_class_loader(ParCompactionManager* cm, 4.14 - ClassLoaderData* klass); 4.15 4.16 // Compaction support. 4.17 // Return true if p is in the range [beg_addr, end_addr). 4.18 @@ -1380,6 +1377,11 @@ 4.19 } 4.20 } 4.21 4.22 +inline void PSParallelCompact::follow_klass(ParCompactionManager* cm, Klass* klass) { 4.23 + oop holder = klass->klass_holder(); 4.24 + PSParallelCompact::mark_and_push(cm, &holder); 4.25 +} 4.26 + 4.27 template <class T> 4.28 inline void PSParallelCompact::KeepAliveClosure::do_oop_work(T* p) { 4.29 mark_and_push(_compaction_manager, p);
5.1 --- a/src/share/vm/memory/metaspace.cpp Tue Dec 10 16:18:26 2013 -0500 5.2 +++ b/src/share/vm/memory/metaspace.cpp Thu Dec 12 16:13:44 2013 +0100 5.3 @@ -287,7 +287,7 @@ 5.4 VirtualSpace* virtual_space() const { return (VirtualSpace*) &_virtual_space; } 5.5 5.6 // Returns true if "word_size" is available in the VirtualSpace 5.7 - bool is_available(size_t word_size) { return _top + word_size <= end(); } 5.8 + bool is_available(size_t word_size) { return word_size <= pointer_delta(end(), _top, sizeof(MetaWord)); } 5.9 5.10 MetaWord* top() const { return _top; } 5.11 void inc_top(size_t word_size) { _top += word_size; } 5.12 @@ -3641,10 +3641,82 @@ 5.13 } 5.14 5.15 } 5.16 + 5.17 +#define assert_is_available_positive(word_size) \ 5.18 + assert(vsn.is_available(word_size), \ 5.19 + err_msg(#word_size ": " PTR_FORMAT " bytes were not available in " \ 5.20 + "VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \ 5.21 + (uintptr_t)(word_size * BytesPerWord), vsn.bottom(), vsn.end())); 5.22 + 5.23 +#define assert_is_available_negative(word_size) \ 5.24 + assert(!vsn.is_available(word_size), \ 5.25 + err_msg(#word_size ": " PTR_FORMAT " bytes should not be available in " \ 5.26 + "VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \ 5.27 + (uintptr_t)(word_size * BytesPerWord), vsn.bottom(), vsn.end())); 5.28 + 5.29 + static void test_is_available_positive() { 5.30 + // Reserve some memory. 5.31 + VirtualSpaceNode vsn(os::vm_allocation_granularity()); 5.32 + assert(vsn.initialize(), "Failed to setup VirtualSpaceNode"); 5.33 + 5.34 + // Commit some memory. 5.35 + size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; 5.36 + bool expanded = vsn.expand_by(commit_word_size, commit_word_size); 5.37 + assert(expanded, "Failed to commit"); 5.38 + 5.39 + // Check that is_available accepts the committed size. 5.40 + assert_is_available_positive(commit_word_size); 5.41 + 5.42 + // Check that is_available accepts half the committed size. 5.43 + size_t expand_word_size = commit_word_size / 2; 5.44 + assert_is_available_positive(expand_word_size); 5.45 + } 5.46 + 5.47 + static void test_is_available_negative() { 5.48 + // Reserve some memory. 5.49 + VirtualSpaceNode vsn(os::vm_allocation_granularity()); 5.50 + assert(vsn.initialize(), "Failed to setup VirtualSpaceNode"); 5.51 + 5.52 + // Commit some memory. 5.53 + size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; 5.54 + bool expanded = vsn.expand_by(commit_word_size, commit_word_size); 5.55 + assert(expanded, "Failed to commit"); 5.56 + 5.57 + // Check that is_available doesn't accept a too large size. 5.58 + size_t two_times_commit_word_size = commit_word_size * 2; 5.59 + assert_is_available_negative(two_times_commit_word_size); 5.60 + } 5.61 + 5.62 + static void test_is_available_overflow() { 5.63 + // Reserve some memory. 5.64 + VirtualSpaceNode vsn(os::vm_allocation_granularity()); 5.65 + assert(vsn.initialize(), "Failed to setup VirtualSpaceNode"); 5.66 + 5.67 + // Commit some memory. 5.68 + size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; 5.69 + bool expanded = vsn.expand_by(commit_word_size, commit_word_size); 5.70 + assert(expanded, "Failed to commit"); 5.71 + 5.72 + // Calculate a size that will overflow the virtual space size. 5.73 + void* virtual_space_max = (void*)(uintptr_t)-1; 5.74 + size_t bottom_to_max = pointer_delta(virtual_space_max, vsn.bottom(), 1); 5.75 + size_t overflow_size = bottom_to_max + BytesPerWord; 5.76 + size_t overflow_word_size = overflow_size / BytesPerWord; 5.77 + 5.78 + // Check that is_available can handle the overflow. 5.79 + assert_is_available_negative(overflow_word_size); 5.80 + } 5.81 + 5.82 + static void test_is_available() { 5.83 + TestVirtualSpaceNodeTest::test_is_available_positive(); 5.84 + TestVirtualSpaceNodeTest::test_is_available_negative(); 5.85 + TestVirtualSpaceNodeTest::test_is_available_overflow(); 5.86 + } 5.87 }; 5.88 5.89 void TestVirtualSpaceNode_test() { 5.90 TestVirtualSpaceNodeTest::test(); 5.91 + TestVirtualSpaceNodeTest::test_is_available(); 5.92 } 5.93 5.94 #endif
6.1 --- a/src/share/vm/oops/instanceClassLoaderKlass.cpp Tue Dec 10 16:18:26 2013 -0500 6.2 +++ b/src/share/vm/oops/instanceClassLoaderKlass.cpp Thu Dec 12 16:13:44 2013 +0100 6.3 @@ -150,10 +150,6 @@ 6.4 6.5 int InstanceClassLoaderKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { 6.6 InstanceKlass::oop_update_pointers(cm, obj); 6.7 - ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data(obj); 6.8 - if (loader_data != NULL) { 6.9 - PSParallelCompact::adjust_class_loader(cm, loader_data); 6.10 - } 6.11 return size_helper(); 6.12 } 6.13 #endif // INCLUDE_ALL_GCS
7.1 --- a/src/share/vm/oops/instanceKlass.cpp Tue Dec 10 16:18:26 2013 -0500 7.2 +++ b/src/share/vm/oops/instanceKlass.cpp Thu Dec 12 16:13:44 2013 +0100 7.3 @@ -2199,7 +2199,6 @@ 7.4 obj, \ 7.5 PSParallelCompact::adjust_pointer(p), \ 7.6 assert_is_in) 7.7 - obj->update_header(cm); 7.8 return size; 7.9 } 7.10
8.1 --- a/src/share/vm/oops/instanceMirrorKlass.cpp Tue Dec 10 16:18:26 2013 -0500 8.2 +++ b/src/share/vm/oops/instanceMirrorKlass.cpp Thu Dec 12 16:13:44 2013 +0100 8.3 @@ -155,8 +155,13 @@ 8.4 // Follow the klass field in the mirror. 8.5 Klass* klass = java_lang_Class::as_Klass(obj); 8.6 if (klass != NULL) { 8.7 - // For anonymous classes we need to handle the class loader data, 8.8 - // otherwise it won't be claimed and can be unloaded. 8.9 + // An anonymous class doesn't have its own class loader, so the call 8.10 + // to follow_klass will mark and push its java mirror instead of the 8.11 + // class loader. When handling the java mirror for an anonymous class 8.12 + // we need to make sure its class loader data is claimed, this is done 8.13 + // by calling follow_class_loader explicitly. For non-anonymous classes 8.14 + // the call to follow_class_loader is made when the class loader itself 8.15 + // is handled. 8.16 if (klass->oop_is_instance() && InstanceKlass::cast(klass)->is_anonymous()) { 8.17 MarkSweep::follow_class_loader(klass->class_loader_data()); 8.18 } else { 8.19 @@ -183,7 +188,18 @@ 8.20 // Follow the klass field in the mirror. 8.21 Klass* klass = java_lang_Class::as_Klass(obj); 8.22 if (klass != NULL) { 8.23 - PSParallelCompact::follow_klass(cm, klass); 8.24 + // An anonymous class doesn't have its own class loader, so the call 8.25 + // to follow_klass will mark and push its java mirror instead of the 8.26 + // class loader. When handling the java mirror for an anonymous class 8.27 + // we need to make sure its class loader data is claimed, this is done 8.28 + // by calling follow_class_loader explicitly. For non-anonymous classes 8.29 + // the call to follow_class_loader is made when the class loader itself 8.30 + // is handled. 8.31 + if (klass->oop_is_instance() && InstanceKlass::cast(klass)->is_anonymous()) { 8.32 + PSParallelCompact::follow_class_loader(cm, klass->class_loader_data()); 8.33 + } else { 8.34 + PSParallelCompact::follow_klass(cm, klass); 8.35 + } 8.36 } else { 8.37 // If klass is NULL then this a mirror for a primitive type. 8.38 // We don't have to follow them, since they are handled as strong 8.39 @@ -332,17 +348,6 @@ 8.40 int size = oop_size(obj); 8.41 InstanceKlass::oop_update_pointers(cm, obj); 8.42 8.43 - // Follow the klass field in the mirror. 8.44 - Klass* klass = java_lang_Class::as_Klass(obj); 8.45 - if (klass != NULL) { 8.46 - PSParallelCompact::adjust_klass(cm, klass); 8.47 - } else { 8.48 - // If klass is NULL then this a mirror for a primitive type. 8.49 - // We don't have to follow them, since they are handled as strong 8.50 - // roots in Universe::oops_do. 8.51 - assert(java_lang_Class::is_primitive(obj), "Sanity check"); 8.52 - } 8.53 - 8.54 InstanceMirrorKlass_OOP_ITERATE( \ 8.55 start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),\ 8.56 PSParallelCompact::adjust_pointer(p), \
9.1 --- a/src/share/vm/oops/objArrayKlass.cpp Tue Dec 10 16:18:26 2013 -0500 9.2 +++ b/src/share/vm/oops/objArrayKlass.cpp Thu Dec 12 16:13:44 2013 +0100 9.3 @@ -587,7 +587,6 @@ 9.4 assert (obj->is_objArray(), "obj must be obj array"); 9.5 objArrayOop a = objArrayOop(obj); 9.6 int size = a->object_size(); 9.7 - a->update_header(cm); 9.8 ObjArrayKlass_OOP_ITERATE(a, p, PSParallelCompact::adjust_pointer(p)) 9.9 return size; 9.10 }
10.1 --- a/src/share/vm/oops/oop.hpp Tue Dec 10 16:18:26 2013 -0500 10.2 +++ b/src/share/vm/oops/oop.hpp Thu Dec 12 16:13:44 2013 +0100 10.3 @@ -328,11 +328,6 @@ 10.4 // return the size of this oop. This is used by the MarkSweep collector. 10.5 int adjust_pointers(); 10.6 10.7 -#if INCLUDE_ALL_GCS 10.8 - // Parallel old 10.9 - void update_header(ParCompactionManager* cm); 10.10 -#endif // INCLUDE_ALL_GCS 10.11 - 10.12 // mark-sweep support 10.13 void follow_body(int begin, int end); 10.14
11.1 --- a/src/share/vm/oops/oop.pcgc.inline.hpp Tue Dec 10 16:18:26 2013 -0500 11.2 +++ b/src/share/vm/oops/oop.pcgc.inline.hpp Thu Dec 12 16:13:44 2013 +0100 11.3 @@ -80,8 +80,4 @@ 11.4 return forwardee(); 11.5 } 11.6 11.7 -inline void oopDesc::update_header(ParCompactionManager* cm) { 11.8 - PSParallelCompact::adjust_klass(cm, klass()); 11.9 -} 11.10 - 11.11 #endif // SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP