1 /* |
1 /* |
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2013, 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. |
76 assert((uintptr_t(low_bound) & (card_size - 1)) == 0, "heap must start at card boundary"); |
76 assert((uintptr_t(low_bound) & (card_size - 1)) == 0, "heap must start at card boundary"); |
77 assert((uintptr_t(high_bound) & (card_size - 1)) == 0, "heap must end at card boundary"); |
77 assert((uintptr_t(high_bound) & (card_size - 1)) == 0, "heap must end at card boundary"); |
78 |
78 |
79 assert(card_size <= 512, "card_size must be less than 512"); // why? |
79 assert(card_size <= 512, "card_size must be less than 512"); // why? |
80 |
80 |
81 _covered = new MemRegion[max_covered_regions]; |
81 NEW_C_HEAP_OBJECT_ARRAY(_covered, MemRegion, max_covered_regions, mtGC, 0, AllocFailStrategy::RETURN_NULL); |
82 _committed = new MemRegion[max_covered_regions]; |
82 NEW_C_HEAP_OBJECT_ARRAY(_committed, MemRegion, max_covered_regions, mtGC, 0, AllocFailStrategy::RETURN_NULL); |
83 if (_covered == NULL || _committed == NULL) |
83 if (_covered == NULL || _committed == NULL) { |
84 vm_exit_during_initialization("couldn't alloc card table covered region set."); |
84 vm_exit_during_initialization("couldn't alloc card table covered region set."); |
85 int i; |
85 } |
86 for (i = 0; i < max_covered_regions; i++) { |
86 |
87 _covered[i].set_word_size(0); |
|
88 _committed[i].set_word_size(0); |
|
89 } |
|
90 _cur_covered_regions = 0; |
87 _cur_covered_regions = 0; |
91 |
|
92 const size_t rs_align = _page_size == (size_t) os::vm_page_size() ? 0 : |
88 const size_t rs_align = _page_size == (size_t) os::vm_page_size() ? 0 : |
93 MAX2(_page_size, (size_t) os::vm_allocation_granularity()); |
89 MAX2(_page_size, (size_t) os::vm_allocation_granularity()); |
94 ReservedSpace heap_rs(_byte_map_size, rs_align, false); |
90 ReservedSpace heap_rs(_byte_map_size, rs_align, false); |
95 |
91 |
96 MemTracker::record_virtual_memory_type((address)heap_rs.base(), mtGC); |
92 MemTracker::record_virtual_memory_type((address)heap_rs.base(), mtGC); |
132 if (_lowest_non_clean == NULL |
128 if (_lowest_non_clean == NULL |
133 || _lowest_non_clean_chunk_size == NULL |
129 || _lowest_non_clean_chunk_size == NULL |
134 || _lowest_non_clean_base_chunk_index == NULL |
130 || _lowest_non_clean_base_chunk_index == NULL |
135 || _last_LNC_resizing_collection == NULL) |
131 || _last_LNC_resizing_collection == NULL) |
136 vm_exit_during_initialization("couldn't allocate an LNC array."); |
132 vm_exit_during_initialization("couldn't allocate an LNC array."); |
137 for (i = 0; i < max_covered_regions; i++) { |
133 for (int i = 0; i < max_covered_regions; i++) { |
138 _lowest_non_clean[i] = NULL; |
134 _lowest_non_clean[i] = NULL; |
139 _lowest_non_clean_chunk_size[i] = 0; |
135 _lowest_non_clean_chunk_size[i] = 0; |
140 _last_LNC_resizing_collection[i] = -1; |
136 _last_LNC_resizing_collection[i] = -1; |
141 } |
137 } |
142 |
138 |
148 &_byte_map[0], |
144 &_byte_map[0], |
149 &_byte_map[_last_valid_index]); |
145 &_byte_map[_last_valid_index]); |
150 gclog_or_tty->print_cr(" " |
146 gclog_or_tty->print_cr(" " |
151 " byte_map_base: " INTPTR_FORMAT, |
147 " byte_map_base: " INTPTR_FORMAT, |
152 byte_map_base); |
148 byte_map_base); |
|
149 } |
|
150 } |
|
151 |
|
152 CardTableModRefBS::~CardTableModRefBS() { |
|
153 if (_covered) { |
|
154 FREE_C_HEAP_OBJECT_ARRAY(MemRegion, _covered, _max_covered_regions, mtGC); |
|
155 _covered = NULL; |
|
156 } |
|
157 if (_committed) { |
|
158 FREE_C_HEAP_OBJECT_ARRAY(MemRegion, _committed, _max_covered_regions, mtGC); |
|
159 _committed = NULL; |
|
160 } |
|
161 if (_lowest_non_clean) { |
|
162 FREE_C_HEAP_ARRAY(CardArr, _lowest_non_clean, mtGC); |
|
163 _lowest_non_clean = NULL; |
|
164 } |
|
165 if (_lowest_non_clean_chunk_size) { |
|
166 FREE_C_HEAP_ARRAY(size_t, _lowest_non_clean_chunk_size, mtGC); |
|
167 _lowest_non_clean_chunk_size = NULL; |
|
168 } |
|
169 if (_lowest_non_clean_base_chunk_index) { |
|
170 FREE_C_HEAP_ARRAY(uintptr_t, _lowest_non_clean_base_chunk_index, mtGC); |
|
171 _lowest_non_clean_base_chunk_index = NULL; |
|
172 } |
|
173 if (_last_LNC_resizing_collection) { |
|
174 FREE_C_HEAP_ARRAY(int, _last_LNC_resizing_collection, mtGC); |
|
175 _last_LNC_resizing_collection = NULL; |
153 } |
176 } |
154 } |
177 } |
155 |
178 |
156 int CardTableModRefBS::find_covering_region_by_base(HeapWord* base) { |
179 int CardTableModRefBS::find_covering_region_by_base(HeapWord* base) { |
157 int i; |
180 int i; |