1 /* |
1 /* |
2 * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
129 } |
129 } |
130 return bits_to_words(live_bits); |
130 return bits_to_words(live_bits); |
131 } |
131 } |
132 |
132 |
133 size_t |
133 size_t |
134 ParMarkBitMap::live_words_in_range_use_cache(ParCompactionManager* cm, HeapWord* beg_addr, oop end_obj) const |
134 ParMarkBitMap::live_words_in_range_use_cache(ParCompactionManager* cm, HeapWord* beg_addr, oop end_oop) const |
135 { |
135 { |
136 HeapWord* last_beg = cm->last_query_begin(); |
136 HeapWord* last_beg = cm->last_query_begin(); |
137 oop last_obj = cm->last_query_object(); |
137 HeapWord* last_obj = (HeapWord*)cm->last_query_object(); |
|
138 HeapWord* end_obj = (HeapWord*)end_oop; |
|
139 |
138 size_t last_ret = cm->last_query_return(); |
140 size_t last_ret = cm->last_query_return(); |
139 if (end_obj > last_obj) { |
141 if (end_obj > last_obj) { |
140 last_ret = last_ret + live_words_in_range_helper((HeapWord*)last_obj, end_obj); |
142 last_ret = last_ret + live_words_in_range_helper(last_obj, end_oop); |
141 last_obj = end_obj; |
143 last_obj = end_obj; |
142 } else if (end_obj < last_obj) { |
144 } else if (end_obj < last_obj) { |
143 // The cached value is for an object that is to the left (lower address) of the current |
145 // The cached value is for an object that is to the left (lower address) of the current |
144 // end_obj. Calculate back from that cached value. |
146 // end_obj. Calculate back from that cached value. |
145 if (pointer_delta((HeapWord*)end_obj, (HeapWord*)beg_addr) > pointer_delta((HeapWord*)last_obj, (HeapWord*)end_obj)) { |
147 if (pointer_delta(end_obj, beg_addr) > pointer_delta(last_obj, end_obj)) { |
146 last_ret = last_ret - live_words_in_range_helper((HeapWord*)end_obj, last_obj); |
148 last_ret = last_ret - live_words_in_range_helper(end_obj, (oop)last_obj); |
147 } else { |
149 } else { |
148 last_ret = live_words_in_range_helper(beg_addr, end_obj); |
150 last_ret = live_words_in_range_helper(beg_addr, end_oop); |
149 } |
151 } |
150 last_obj = end_obj; |
152 last_obj = end_obj; |
151 } |
153 } |
152 |
154 |
153 update_live_words_in_range_cache(cm, last_beg, last_obj, last_ret); |
155 update_live_words_in_range_cache(cm, last_beg, (oop)last_obj, last_ret); |
154 return last_ret; |
156 return last_ret; |
155 } |
157 } |
156 |
158 |
157 size_t |
159 size_t |
158 ParMarkBitMap::live_words_in_range(ParCompactionManager* cm, HeapWord* beg_addr, oop end_obj) const |
160 ParMarkBitMap::live_words_in_range(ParCompactionManager* cm, HeapWord* beg_addr, oop end_obj) const |