538 _span(cmsGen->reserved()._union(permGen->reserved())), |
538 _span(cmsGen->reserved()._union(permGen->reserved())), |
539 // Construct the is_alive_closure with _span & markBitMap |
539 // Construct the is_alive_closure with _span & markBitMap |
540 _is_alive_closure(_span, &_markBitMap), |
540 _is_alive_closure(_span, &_markBitMap), |
541 _restart_addr(NULL), |
541 _restart_addr(NULL), |
542 _overflow_list(NULL), |
542 _overflow_list(NULL), |
543 _preserved_oop_stack(NULL), |
|
544 _preserved_mark_stack(NULL), |
|
545 _stats(cmsGen), |
543 _stats(cmsGen), |
546 _eden_chunk_array(NULL), // may be set in ctor body |
544 _eden_chunk_array(NULL), // may be set in ctor body |
547 _eden_chunk_capacity(0), // -- ditto -- |
545 _eden_chunk_capacity(0), // -- ditto -- |
548 _eden_chunk_index(0), // -- ditto -- |
546 _eden_chunk_index(0), // -- ditto -- |
549 _survivor_plab_array(NULL), // -- ditto -- |
547 _survivor_plab_array(NULL), // -- ditto -- |
8905 // the caller may be able to recover from a failure; code in |
8903 // the caller may be able to recover from a failure; code in |
8906 // the VM can then be changed, incrementally, to deal with such |
8904 // the VM can then be changed, incrementally, to deal with such |
8907 // failures where possible, thus, incrementally hardening the VM |
8905 // failures where possible, thus, incrementally hardening the VM |
8908 // in such low resource situations. |
8906 // in such low resource situations. |
8909 void CMSCollector::preserve_mark_work(oop p, markOop m) { |
8907 void CMSCollector::preserve_mark_work(oop p, markOop m) { |
8910 if (_preserved_oop_stack == NULL) { |
8908 _preserved_oop_stack.push(p); |
8911 assert(_preserved_mark_stack == NULL, |
8909 _preserved_mark_stack.push(m); |
8912 "bijection with preserved_oop_stack"); |
|
8913 // Allocate the stacks |
|
8914 _preserved_oop_stack = new (ResourceObj::C_HEAP) |
|
8915 GrowableArray<oop>(PreserveMarkStackSize, true); |
|
8916 _preserved_mark_stack = new (ResourceObj::C_HEAP) |
|
8917 GrowableArray<markOop>(PreserveMarkStackSize, true); |
|
8918 if (_preserved_oop_stack == NULL || _preserved_mark_stack == NULL) { |
|
8919 vm_exit_out_of_memory(2* PreserveMarkStackSize * sizeof(oop) /* punt */, |
|
8920 "Preserved Mark/Oop Stack for CMS (C-heap)"); |
|
8921 } |
|
8922 } |
|
8923 _preserved_oop_stack->push(p); |
|
8924 _preserved_mark_stack->push(m); |
|
8925 assert(m == p->mark(), "Mark word changed"); |
8910 assert(m == p->mark(), "Mark word changed"); |
8926 assert(_preserved_oop_stack->length() == _preserved_mark_stack->length(), |
8911 assert(_preserved_oop_stack.size() == _preserved_mark_stack.size(), |
8927 "bijection"); |
8912 "bijection"); |
8928 } |
8913 } |
8929 |
8914 |
8930 // Single threaded |
8915 // Single threaded |
8931 void CMSCollector::preserve_mark_if_necessary(oop p) { |
8916 void CMSCollector::preserve_mark_if_necessary(oop p) { |
8963 // need for this in the future. Stack overflow should |
8948 // need for this in the future. Stack overflow should |
8964 // be so rare in practice and, when it happens, its |
8949 // be so rare in practice and, when it happens, its |
8965 // effect on performance so great that this will |
8950 // effect on performance so great that this will |
8966 // likely just be in the noise anyway. |
8951 // likely just be in the noise anyway. |
8967 void CMSCollector::restore_preserved_marks_if_any() { |
8952 void CMSCollector::restore_preserved_marks_if_any() { |
8968 if (_preserved_oop_stack == NULL) { |
|
8969 assert(_preserved_mark_stack == NULL, |
|
8970 "bijection with preserved_oop_stack"); |
|
8971 return; |
|
8972 } |
|
8973 |
|
8974 assert(SafepointSynchronize::is_at_safepoint(), |
8953 assert(SafepointSynchronize::is_at_safepoint(), |
8975 "world should be stopped"); |
8954 "world should be stopped"); |
8976 assert(Thread::current()->is_ConcurrentGC_thread() || |
8955 assert(Thread::current()->is_ConcurrentGC_thread() || |
8977 Thread::current()->is_VM_thread(), |
8956 Thread::current()->is_VM_thread(), |
8978 "should be single-threaded"); |
8957 "should be single-threaded"); |
8979 |
8958 assert(_preserved_oop_stack.size() == _preserved_mark_stack.size(), |
8980 int length = _preserved_oop_stack->length(); |
8959 "bijection"); |
8981 assert(_preserved_mark_stack->length() == length, "bijection"); |
8960 |
8982 for (int i = 0; i < length; i++) { |
8961 while (!_preserved_oop_stack.is_empty()) { |
8983 oop p = _preserved_oop_stack->at(i); |
8962 oop p = _preserved_oop_stack.pop(); |
8984 assert(p->is_oop(), "Should be an oop"); |
8963 assert(p->is_oop(), "Should be an oop"); |
8985 assert(_span.contains(p), "oop should be in _span"); |
8964 assert(_span.contains(p), "oop should be in _span"); |
8986 assert(p->mark() == markOopDesc::prototype(), |
8965 assert(p->mark() == markOopDesc::prototype(), |
8987 "Set when taken from overflow list"); |
8966 "Set when taken from overflow list"); |
8988 markOop m = _preserved_mark_stack->at(i); |
8967 markOop m = _preserved_mark_stack.pop(); |
8989 p->set_mark(m); |
8968 p->set_mark(m); |
8990 } |
8969 } |
8991 _preserved_mark_stack->clear(); |
8970 assert(_preserved_mark_stack.is_empty() && _preserved_oop_stack.is_empty(), |
8992 _preserved_oop_stack->clear(); |
|
8993 assert(_preserved_mark_stack->is_empty() && |
|
8994 _preserved_oop_stack->is_empty(), |
|
8995 "stacks were cleared above"); |
8971 "stacks were cleared above"); |
8996 } |
8972 } |
8997 |
8973 |
8998 #ifndef PRODUCT |
8974 #ifndef PRODUCT |
8999 bool CMSCollector::no_preserved_marks() const { |
8975 bool CMSCollector::no_preserved_marks() const { |
9000 return ( ( _preserved_mark_stack == NULL |
8976 return _preserved_mark_stack.is_empty() && _preserved_oop_stack.is_empty(); |
9001 && _preserved_oop_stack == NULL) |
|
9002 || ( _preserved_mark_stack->is_empty() |
|
9003 && _preserved_oop_stack->is_empty())); |
|
9004 } |
8977 } |
9005 #endif |
8978 #endif |
9006 |
8979 |
9007 CMSAdaptiveSizePolicy* ASConcurrentMarkSweepGeneration::cms_size_policy() const |
8980 CMSAdaptiveSizePolicy* ASConcurrentMarkSweepGeneration::cms_size_policy() const |
9008 { |
8981 { |