32 inline bool PreservedMarks::should_preserve_mark(oop obj, markOop m) const { 33 return m->must_be_preserved_for_promotion_failure(obj); 34 } 35 36 inline void PreservedMarks::push(oop obj, markOop m) { 37 assert(should_preserve_mark(obj, m), "pre-condition"); 38 OopAndMarkOop elem(obj, m); 39 _stack.push(elem); 40 } 41 42 inline void PreservedMarks::push_if_necessary(oop obj, markOop m) { 43 if (should_preserve_mark(obj, m)) { 44 push(obj, m); 45 } 46 } 47 48 inline void PreservedMarks::init_forwarded_mark(oop obj) { 49 obj->init_mark(); 50 } 51 52 template <class E> 53 inline void PreservedMarksSet::restore(E* executor) { 54 volatile size_t total_size = 0; 55 56 #ifdef ASSERT 57 // This is to make sure the total_size we'll calculate below is correct. 58 size_t total_size_before = 0; 59 for (uint i = 0; i < _num; i += 1) { 60 total_size_before += get(i)->size(); 61 } 62 #endif // def ASSERT 63 64 if (executor == NULL) { 65 for (uint i = 0; i < _num; i += 1) { 66 total_size += get(i)->size(); 67 get(i)->restore(); 68 } 69 } else { 70 // Right now, if the executor is not NULL we do the work in 71 // parallel. In the future we might want to do the restoration 72 // serially, if there's only a small number of marks per stack. 73 restore_internal(executor, &total_size); 74 } 75 assert_empty(); 76 77 assert(total_size == total_size_before, 78 "total_size = " SIZE_FORMAT " before = " SIZE_FORMAT, 79 total_size, total_size_before); 80 81 log_trace(gc)("Restored " SIZE_FORMAT " marks", total_size); 82 } 83 84 inline PreservedMarks::PreservedMarks() 85 : _stack(OopAndMarkOopStack::default_segment_size(), 86 // This stack should be used very infrequently so there's 87 // no point in caching stack segments (there will be a 88 // waste of space most of the time). So we set the max 89 // cache size to 0. 90 0 /* max_cache_size */) { } 91 92 #endif // SHARE_VM_GC_SHARED_PRESERVEDMARKS_INLINE_HPP | 32 inline bool PreservedMarks::should_preserve_mark(oop obj, markOop m) const { 33 return m->must_be_preserved_for_promotion_failure(obj); 34 } 35 36 inline void PreservedMarks::push(oop obj, markOop m) { 37 assert(should_preserve_mark(obj, m), "pre-condition"); 38 OopAndMarkOop elem(obj, m); 39 _stack.push(elem); 40 } 41 42 inline void PreservedMarks::push_if_necessary(oop obj, markOop m) { 43 if (should_preserve_mark(obj, m)) { 44 push(obj, m); 45 } 46 } 47 48 inline void PreservedMarks::init_forwarded_mark(oop obj) { 49 obj->init_mark(); 50 } 51 52 inline void PreservedMarksSet::restore(RestorePreservedMarksTaskExecutor* executor) { 53 volatile size_t total_size = 0; 54 55 #ifdef ASSERT 56 // This is to make sure the total_size we'll calculate below is correct. 57 size_t total_size_before = 0; 58 for (uint i = 0; i < _num; i += 1) { 59 total_size_before += get(i)->size(); 60 } 61 #endif // def ASSERT 62 63 executor->restore(this, &total_size); 64 assert_empty(); 65 66 assert(total_size == total_size_before, 67 "total_size = " SIZE_FORMAT " before = " SIZE_FORMAT, 68 total_size, total_size_before); 69 70 log_trace(gc)("Restored " SIZE_FORMAT " marks", total_size); 71 } 72 73 inline PreservedMarks::PreservedMarks() 74 : _stack(OopAndMarkOopStack::default_segment_size(), 75 // This stack should be used very infrequently so there's 76 // no point in caching stack segments (there will be a 77 // waste of space most of the time). So we set the max 78 // cache size to 0. 79 0 /* max_cache_size */) { } 80 81 #endif // SHARE_VM_GC_SHARED_PRESERVEDMARKS_INLINE_HPP |