< prev index next >

src/hotspot/share/gc/g1/heapRegionManager.cpp

Print this page

        

*** 28,37 **** --- 28,38 ---- #include "gc/g1/g1ConcurrentRefine.hpp" #include "gc/g1/heapRegion.hpp" #include "gc/g1/heapRegionManager.inline.hpp" #include "gc/g1/heapRegionSet.inline.hpp" #include "gc/g1/heterogeneousHeapRegionManager.hpp" + #include "logging/logStream.hpp" #include "memory/allocation.hpp" #include "utilities/bitMap.inline.hpp" class MasterFreeRegionListChecker : public HeapRegionSetChecker { public:
*** 101,110 **** --- 102,135 ---- bool HeapRegionManager::is_available(uint region) const { return _available_map.at(region); } + HeapRegion* HeapRegionManager::allocate_free_region(HeapRegionType type, uint requested_node_index) { + G1MemoryNodeManager* mgr = G1MemoryNodeManager::mgr(); + HeapRegion* hr = NULL; + bool from_head = !type.is_young(); + + if (mgr->has_multi_nodes() && requested_node_index != G1MemoryNodeManager::AnyNodeIndex) { + // Try to allocate with requested node index. + hr = _free_list.remove_region_with_node_index(from_head, requested_node_index, NULL); + } + + if (hr == NULL) { + // If there's a single active node or we did not get a region from our requested node, + // try without requested node index. + hr = _free_list.remove_region(from_head); + } + + if (hr != NULL) { + assert(hr->next() == NULL, "Single region should not have next"); + assert(is_available(hr->hrm_index()), "Must be committed"); + } + + return hr; + } + #ifdef ASSERT bool HeapRegionManager::is_free(HeapRegion* hr) const { return _free_list.contains(hr); } #endif
*** 137,146 **** --- 162,176 ---- void HeapRegionManager::uncommit_regions(uint start, size_t num_regions) { guarantee(num_regions >= 1, "Need to specify at least one region to uncommit, tried to uncommit zero regions at %u", start); guarantee(_num_committed >= num_regions, "pre-condition"); + // Reset node index to distinguish with committed regions. + for (uint i = start; i < start + num_regions; i++) { + at(i)->set_node_index(G1MemoryNodeManager::UnknownNodeIndex); + } + // Print before uncommitting. if (G1CollectedHeap::heap()->hr_printer()->is_active()) { for (uint i = start; i < start + num_regions; i++) { HeapRegion* hr = at(i); G1CollectedHeap::heap()->hr_printer()->uncommit(hr);
*** 160,169 **** --- 190,213 ---- _cardtable_mapper->uncommit_regions(start, num_regions); _card_counts_mapper->uncommit_regions(start, num_regions); } + // Set node index of the given HeapRegion. + // If AlwaysPreTouch is enabled, set with actual node index. + // If it is disabled, set with preferred node index which is already decided. + static void set_heapregion_node_index(HeapRegion* hr) { + uint node_index; + if(AlwaysPreTouch) { + // If we already pretouched, we can check actual node index here. + node_index = G1MemoryNodeManager::mgr()->index_of_address(hr->bottom()); + } else { + node_index = G1MemoryNodeManager::mgr()->preferred_node_index_for_index(hr->hrm_index()); + } + hr->set_node_index(node_index); + } + void HeapRegionManager::make_regions_available(uint start, uint num_regions, WorkGang* pretouch_gang) { guarantee(num_regions > 0, "No point in calling this for zero regions"); commit_regions(start, num_regions, pretouch_gang); for (uint i = start; i < start + num_regions; i++) { if (_regions.get_by_index(i) == NULL) {
*** 184,193 **** --- 228,240 ---- } HeapWord* bottom = G1CollectedHeap::heap()->bottom_addr_for_region(i); MemRegion mr(bottom, bottom + HeapRegion::GrainWords); hr->initialize(mr); + // Set node index of the heap region after initialization but before inserting + // to free list. + set_heapregion_node_index(hr); insert_into_free_list(at(i)); } } MemoryUsage HeapRegionManager::get_auxiliary_data_memory_usage() const {
*** 233,242 **** --- 280,318 ---- verify_optional(); return expanded; } + uint HeapRegionManager::expand_on_preferred_node(uint preferred_index) { + uint expand_candidate = UINT_MAX; + for (uint i = 0; i < max_length(); i++) { + if (is_available(i)) { + // Already in use continue + continue; + } + // Always save the candidate so we can expand later on. + expand_candidate = i; + if (is_on_preferred_index(expand_candidate, preferred_index)) { + // We have found a candidate on the preffered node, break. + break; + } + } + + if (expand_candidate == UINT_MAX) { + // No regions left, expand failed. + return 0; + } + + make_regions_available(expand_candidate, 1, NULL); + return 1; + } + + bool HeapRegionManager::is_on_preferred_index(uint region_index, uint preferred_node_index) { + uint region_node_index = G1MemoryNodeManager::mgr()->preferred_node_index_for_index(region_index); + return region_node_index == preferred_node_index; + } + uint HeapRegionManager::find_contiguous(size_t num, bool empty_only) { uint found = 0; size_t length_found = 0; uint cur = 0;
< prev index next >