1 /* 2 * Copyright (c) 2021, Red Hat, Inc. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc/shared/slidingForwarding.hpp" 27 28 #ifdef _LP64 29 HeapWord* const SlidingForwarding::UNUSED_BASE = reinterpret_cast<HeapWord*>(0x1); 30 #endif 31 32 SlidingForwarding::SlidingForwarding(MemRegion heap) 33 #ifdef _LP64 34 : _heap_start(heap.start()), 35 _num_regions(((heap.end() - heap.start()) >> NUM_COMPRESSED_BITS) + 1), 36 _region_size_words_shift(NUM_COMPRESSED_BITS), 37 _target_base_table(NEW_C_HEAP_ARRAY(HeapWord*, _num_regions * 2, mtGC)) { 38 assert(_region_size_words_shift <= NUM_COMPRESSED_BITS, "regions must not be larger than maximum addressing bits allow"); 39 #else 40 { 41 #endif 42 } 43 44 SlidingForwarding::SlidingForwarding(MemRegion heap, size_t region_size_words_shift) 45 #ifdef _LP64 46 : _heap_start(heap.start()), 47 _num_regions(((heap.end() - heap.start()) >> region_size_words_shift) + 1), 48 _region_size_words_shift(region_size_words_shift), 49 _target_base_table(NEW_C_HEAP_ARRAY(HeapWord*, _num_regions * (ONE << NUM_REGION_BITS), mtGC)) { 50 assert(region_size_words_shift <= NUM_COMPRESSED_BITS, "regions must not be larger than maximum addressing bits allow"); 51 #else 52 { 53 #endif 54 } 55 56 SlidingForwarding::~SlidingForwarding() { 57 #ifdef _LP64 58 FREE_C_HEAP_ARRAY(HeapWord*, _target_base_table); 59 #endif 60 } 61 62 void SlidingForwarding::clear() { 63 #ifdef _LP64 64 size_t max = _num_regions * (ONE << NUM_REGION_BITS); 65 for (size_t i = 0; i < max; i++) { 66 _target_base_table[i] = UNUSED_BASE; 67 } 68 #endif 69 }