69 stats->add_undo_wasted(_undo_wasted);
70 stats->add_unused(unused);
71
72 // Since we have flushed the stats we need to clear the _allocated and _wasted
73 // fields in case somebody retains an instance of this over GCs. Not doing so
74 // will artifically inflate the values in the statistics.
75 _allocated = 0;
76 _wasted = 0;
77 _undo_wasted = 0;
78 }
79
80 void PLAB::retire() {
81 _wasted += retire_internal();
82 }
83
84 size_t PLAB::retire_internal() {
85 size_t result = 0;
86 if (_top < _hard_end) {
87 assert(pointer_delta(_hard_end, _top) >= (size_t)(oopDesc::header_size() + Universe::heap()->oop_extra_words()),
88 "better have enough space left to fill with dummy");
89 HeapWord* obj = Universe::heap()->tlab_post_allocation_setup(_top);
90 CollectedHeap::fill_with_object(obj, _hard_end);
91 result += invalidate();
92 }
93 return result;
94 }
95
96 void PLAB::add_undo_waste(HeapWord* obj, size_t word_sz) {
97 HeapWord* head_obj = Universe::heap()->tlab_post_allocation_setup(obj);
98 CollectedHeap::fill_with_object(head_obj, word_sz - (head_obj - obj));
99 _undo_wasted += word_sz;
100 }
101
102 void PLAB::undo_last_allocation(HeapWord* obj, size_t word_sz) {
103 assert(pointer_delta(_top, _bottom) >= word_sz, "Bad undo");
104 assert(pointer_delta(_top, obj) == word_sz, "Bad undo");
105 _top = obj;
106 }
107
108 void PLAB::undo_allocation(HeapWord* obj, size_t word_sz) {
109 // Is the alloc in the current alloc buffer?
110 if (contains(obj)) {
111 assert(contains(obj + word_sz - 1),
112 "should contain whole object");
113 undo_last_allocation(obj, word_sz);
114 } else {
115 add_undo_waste(obj, word_sz);
116 }
117 }
118
|
69 stats->add_undo_wasted(_undo_wasted);
70 stats->add_unused(unused);
71
72 // Since we have flushed the stats we need to clear the _allocated and _wasted
73 // fields in case somebody retains an instance of this over GCs. Not doing so
74 // will artifically inflate the values in the statistics.
75 _allocated = 0;
76 _wasted = 0;
77 _undo_wasted = 0;
78 }
79
80 void PLAB::retire() {
81 _wasted += retire_internal();
82 }
83
84 size_t PLAB::retire_internal() {
85 size_t result = 0;
86 if (_top < _hard_end) {
87 assert(pointer_delta(_hard_end, _top) >= (size_t)(oopDesc::header_size() + Universe::heap()->oop_extra_words()),
88 "better have enough space left to fill with dummy");
89 Universe::heap()->fill_with_dummy_object(_top, _hard_end, false);
90 result += invalidate();
91 }
92 return result;
93 }
94
95 void PLAB::add_undo_waste(HeapWord* obj, size_t word_sz) {
96 Universe::heap()->fill_with_dummy_object(obj, obj + word_sz, false);
97 _undo_wasted += word_sz;
98 }
99
100 void PLAB::undo_last_allocation(HeapWord* obj, size_t word_sz) {
101 assert(pointer_delta(_top, _bottom) >= word_sz, "Bad undo");
102 assert(pointer_delta(_top, obj) == word_sz, "Bad undo");
103 _top = obj;
104 }
105
106 void PLAB::undo_allocation(HeapWord* obj, size_t word_sz) {
107 // Is the alloc in the current alloc buffer?
108 if (contains(obj)) {
109 assert(contains(obj + word_sz - 1),
110 "should contain whole object");
111 undo_last_allocation(obj, word_sz);
112 } else {
113 add_undo_waste(obj, word_sz);
114 }
115 }
116
|