7991 // to do (for now) is to exit with an error. However, that may 7992 // be too draconian in some cases because the caller may be 7993 // able to recover without much harm. For such cases, we 7994 // should probably introduce a "soft_push" method which returns 7995 // an indication of success or failure with the assumption that 7996 // the caller may be able to recover from a failure; code in 7997 // the VM can then be changed, incrementally, to deal with such 7998 // failures where possible, thus, incrementally hardening the VM 7999 // in such low resource situations. 8000 void CMSCollector::preserve_mark_work(oop p, markWord m) { 8001 _preserved_oop_stack.push(p); 8002 _preserved_mark_stack.push(m); 8003 assert(m == p->mark_raw(), "Mark word changed"); 8004 assert(_preserved_oop_stack.size() == _preserved_mark_stack.size(), 8005 "bijection"); 8006 } 8007 8008 // Single threaded 8009 void CMSCollector::preserve_mark_if_necessary(oop p) { 8010 markWord m = p->mark_raw(); 8011 if (m.must_be_preserved(p)) { 8012 preserve_mark_work(p, m); 8013 } 8014 } 8015 8016 void CMSCollector::par_preserve_mark_if_necessary(oop p) { 8017 markWord m = p->mark_raw(); 8018 if (m.must_be_preserved(p)) { 8019 MutexLocker x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag); 8020 // Even though we read the mark word without holding 8021 // the lock, we are assured that it will not change 8022 // because we "own" this oop, so no other thread can 8023 // be trying to push it on the overflow list; see 8024 // the assertion in preserve_mark_work() that checks 8025 // that m == p->mark_raw(). 8026 preserve_mark_work(p, m); 8027 } 8028 } 8029 8030 // We should be able to do this multi-threaded, 8031 // a chunk of stack being a task (this is 8032 // correct because each oop only ever appears 8033 // once in the overflow list. However, it's 8034 // not very easy to completely overlap this with 8035 // other operations, so will generally not be done 8036 // until all work's been completed. Because we 8037 // expect the preserved oop stack (set) to be small, 8038 // it's probably fine to do this single-threaded. | 7991 // to do (for now) is to exit with an error. However, that may 7992 // be too draconian in some cases because the caller may be 7993 // able to recover without much harm. For such cases, we 7994 // should probably introduce a "soft_push" method which returns 7995 // an indication of success or failure with the assumption that 7996 // the caller may be able to recover from a failure; code in 7997 // the VM can then be changed, incrementally, to deal with such 7998 // failures where possible, thus, incrementally hardening the VM 7999 // in such low resource situations. 8000 void CMSCollector::preserve_mark_work(oop p, markWord m) { 8001 _preserved_oop_stack.push(p); 8002 _preserved_mark_stack.push(m); 8003 assert(m == p->mark_raw(), "Mark word changed"); 8004 assert(_preserved_oop_stack.size() == _preserved_mark_stack.size(), 8005 "bijection"); 8006 } 8007 8008 // Single threaded 8009 void CMSCollector::preserve_mark_if_necessary(oop p) { 8010 markWord m = p->mark_raw(); 8011 if (p->mark_must_be_preserved(m)) { 8012 preserve_mark_work(p, m); 8013 } 8014 } 8015 8016 void CMSCollector::par_preserve_mark_if_necessary(oop p) { 8017 markWord m = p->mark_raw(); 8018 if (p->mark_must_be_preserved(m)) { 8019 MutexLocker x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag); 8020 // Even though we read the mark word without holding 8021 // the lock, we are assured that it will not change 8022 // because we "own" this oop, so no other thread can 8023 // be trying to push it on the overflow list; see 8024 // the assertion in preserve_mark_work() that checks 8025 // that m == p->mark_raw(). 8026 preserve_mark_work(p, m); 8027 } 8028 } 8029 8030 // We should be able to do this multi-threaded, 8031 // a chunk of stack being a task (this is 8032 // correct because each oop only ever appears 8033 // once in the overflow list. However, it's 8034 // not very easy to completely overlap this with 8035 // other operations, so will generally not be done 8036 // until all work's been completed. Because we 8037 // expect the preserved oop stack (set) to be small, 8038 // it's probably fine to do this single-threaded. |