1 /* 2 * Copyright (c) 2019, 2020, Oracle and/or its affiliates. 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 #ifndef SHARE_MEMORY_ARCHIVEUTILS_INLINE_HPP 26 #define SHARE_MEMORY_ARCHIVEUTILS_INLINE_HPP 27 28 #include "memory/archiveUtils.hpp" 29 #include "utilities/bitMap.inline.hpp" 30 31 template <bool COMPACTING> 32 inline bool SharedDataRelocator<COMPACTING>::do_bit(size_t offset) { 33 address* p = _patch_base + offset; 34 assert(_patch_base <= p && p < _patch_end, "must be"); 35 36 address old_ptr = *p; 37 assert(_valid_old_base <= old_ptr && old_ptr < _valid_old_end, "must be"); 38 39 if (COMPACTING) { 40 // Start-up performance: use a template parameter to elide this block for run-time archive 41 // relocation. 42 assert(Arguments::is_dumping_archive(), "Don't do this during run-time archive loading!"); 43 if (old_ptr == NULL) { 44 _ptrmap->clear_bit(offset); 45 DEBUG_ONLY(log_trace(cds, reloc)("Clearing pointer [" PTR_FORMAT "] -> NULL @ " SIZE_FORMAT_W(9), p2i(p), offset)); 46 return true; 47 } else { 48 _max_non_null_offset = offset; 49 } 50 } else { 51 assert(old_ptr != NULL, "bits for NULL pointers should have been cleaned at dump time"); 52 } 53 54 address new_ptr = old_ptr + _delta; 55 assert(new_ptr != NULL, "don't point to the bottom of the archive"); // See ArchivePtrMarker::mark_pointer(). 56 assert(_valid_new_base <= new_ptr && new_ptr < _valid_new_end, "must be"); 57 58 DEBUG_ONLY(log_trace(cds, reloc)("Patch2: @%8d [" PTR_FORMAT "] " PTR_FORMAT " -> " PTR_FORMAT, 59 (int)offset, p2i(p), p2i(old_ptr), p2i(new_ptr))); 60 *p = new_ptr; 61 return true; // keep iterating 62 } 63 64 #endif // SHARE_MEMORY_ARCHIVEUTILS_INLINE_HPP