1 /*
 2  * Copyright (c) 2025, 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 #include "cds/aotCacheAccess.hpp"
26 #include "cds/archiveBuilder.hpp"
27 #include "cds/cdsConfig.hpp"
28 #include "cds/filemap.hpp"
29 #include "cds/heapShared.hpp"
30 #include "cds/metaspaceShared.hpp"
31 #include "classfile/stringTable.hpp"
32 #include "logging/log.hpp"
33 #include "logging/logStream.hpp"
34 #include "memory/resourceArea.hpp"
35 #include "memory/universe.hpp"
36 #include "memory/virtualspace.hpp"
37 #include "oops/instanceKlass.hpp"
38 
39 void* AOTCacheAccess::allocate_aot_code_region(size_t size) {
40   assert(CDSConfig::is_dumping_final_static_archive(), "must be");
41   return (void*)ArchiveBuilder::ac_region_alloc(size);
42 }
43 
44 size_t AOTCacheAccess::get_aot_code_region_size() {
45   assert(CDSConfig::is_using_archive(), "must be");
46   FileMapInfo* mapinfo = FileMapInfo::current_info();
47   assert(mapinfo != nullptr, "must be");
48   return mapinfo->region_at(MetaspaceShared::ac)->used_aligned();
49 }
50 
51 bool AOTCacheAccess::map_aot_code_region(ReservedSpace rs) {
52   FileMapInfo* static_mapinfo = FileMapInfo::current_info();
53   assert(UseSharedSpaces && static_mapinfo != nullptr, "must be");
54   return static_mapinfo->map_aot_code_region(rs);
55 }