Skip to content

Commit 86024eb

Browse files
committed
8348426: Generate binary file for -XX:AOTMode=record -XX:AOTConfiguration=file
Reviewed-by: ccheung, asmehra, kvn, iveresov
1 parent 267d69b commit 86024eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1184
-217
lines changed

src/hotspot/share/cds/aotClassLocation.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,8 +989,14 @@ bool AOTClassLocationConfig::validate(bool has_aot_linked_classes, bool* has_ext
989989
const char* hint_msg = log_is_enabled(Info, class, path) ?
990990
"" : " (hint: enable -Xlog:class+path=info to diagnose the failure)";
991991
if (RequireSharedSpaces && !PrintSharedArchiveAndExit) {
992-
log_error(cds)("%s%s", mismatch_msg, hint_msg);
993-
MetaspaceShared::unrecoverable_loading_error();
992+
if (CDSConfig::is_dumping_final_static_archive()) {
993+
log_error(cds)("class path and/or module path are not compatible with the "
994+
"ones specified when the AOTConfiguration file was recorded%s", hint_msg);
995+
vm_exit_during_initialization("Unable to use create AOT cache.", nullptr);
996+
} else {
997+
log_error(cds)("%s%s", mismatch_msg, hint_msg);
998+
MetaspaceShared::unrecoverable_loading_error();
999+
}
9941000
} else {
9951001
log_warning(cds)("%s%s", mismatch_msg, hint_msg);
9961002
}

src/hotspot/share/cds/archiveBuilder.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,8 @@ bool ArchiveBuilder::is_excluded(Klass* klass) {
507507
return SystemDictionaryShared::is_excluded_class(ik);
508508
} else if (klass->is_objArray_klass()) {
509509
Klass* bottom = ObjArrayKlass::cast(klass)->bottom_klass();
510-
if (MetaspaceShared::is_shared_static(bottom)) {
510+
if (CDSConfig::is_dumping_dynamic_archive() && MetaspaceShared::is_shared_static(bottom)) {
511511
// The bottom class is in the static archive so it's clearly not excluded.
512-
assert(CDSConfig::is_dumping_dynamic_archive(), "sanity");
513512
return false;
514513
} else if (bottom->is_instance_klass()) {
515514
return SystemDictionaryShared::is_excluded_class(InstanceKlass::cast(bottom));
@@ -521,7 +520,7 @@ bool ArchiveBuilder::is_excluded(Klass* klass) {
521520

522521
ArchiveBuilder::FollowMode ArchiveBuilder::get_follow_mode(MetaspaceClosure::Ref *ref) {
523522
address obj = ref->obj();
524-
if (MetaspaceShared::is_in_shared_metaspace(obj)) {
523+
if (CDSConfig::is_dumping_dynamic_archive() && MetaspaceShared::is_in_shared_metaspace(obj)) {
525524
// Don't dump existing shared metadata again.
526525
return point_to_it;
527526
} else if (ref->msotype() == MetaspaceObj::MethodDataType ||

src/hotspot/share/cds/archiveUtils.hpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -255,11 +255,23 @@ class ReadClosure : public SerializeClosure {
255255
};
256256

257257
class ArchiveUtils {
258+
template <typename T> static Array<T>* archive_non_ptr_array(GrowableArray<T>* tmp_array);
259+
template <typename T> static Array<T>* archive_ptr_array(GrowableArray<T>* tmp_array);
260+
258261
public:
259262
static const uintx MAX_SHARED_DELTA = 0x7FFFFFFF;
260263
static void log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) NOT_CDS_RETURN;
261264
static bool has_aot_initialized_mirror(InstanceKlass* src_ik);
262-
template <typename T> static Array<T>* archive_array(GrowableArray<T>* tmp_array);
265+
266+
template <typename T, ENABLE_IF(!std::is_pointer<T>::value)>
267+
static Array<T>* archive_array(GrowableArray<T>* tmp_array) {
268+
return archive_non_ptr_array(tmp_array);
269+
}
270+
271+
template <typename T, ENABLE_IF(std::is_pointer<T>::value)>
272+
static Array<T>* archive_array(GrowableArray<T>* tmp_array) {
273+
return archive_ptr_array(tmp_array);
274+
}
263275

264276
// The following functions translate between a u4 offset and an address in the
265277
// the range of the mapped CDS archive (e.g., Metaspace::is_in_shared_metaspace()).

src/hotspot/share/cds/archiveUtils.inline.hpp

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
2828
#include "cds/archiveUtils.hpp"
2929

3030
#include "cds/archiveBuilder.hpp"
31+
#include "cds/cdsConfig.hpp"
32+
#include "cds/metaspaceShared.hpp"
3133
#include "oops/array.hpp"
3234
#include "utilities/bitMap.inline.hpp"
3335
#include "utilities/growableArray.hpp"
@@ -52,13 +54,40 @@ inline bool SharedDataRelocator::do_bit(size_t offset) {
5254

5355
// Returns the address of an Array<T> that's allocated in the ArchiveBuilder "buffer" space.
5456
template <typename T>
55-
Array<T>* ArchiveUtils::archive_array(GrowableArray<T>* tmp_array) {
57+
Array<T>* ArchiveUtils::archive_non_ptr_array(GrowableArray<T>* tmp_array) {
58+
ArchiveBuilder* builder = ArchiveBuilder::current();
59+
5660
Array<T>* archived_array = ArchiveBuilder::new_ro_array<T>(tmp_array->length());
5761
for (int i = 0; i < tmp_array->length(); i++) {
5862
archived_array->at_put(i, tmp_array->at(i));
59-
if (std::is_pointer<T>::value) {
63+
}
64+
65+
return archived_array;
66+
}
67+
68+
// Returns the address of an Array<T> that's allocated in the ArchiveBuilder "buffer" space.
69+
// All pointers in tmp_array must point to:
70+
// - a buffered object; or
71+
// - a source object that has been archived; or
72+
// - (only when dumping dynamic archive) an object in the static archive.
73+
template <typename T>
74+
Array<T>* ArchiveUtils::archive_ptr_array(GrowableArray<T>* tmp_array) {
75+
ArchiveBuilder* builder = ArchiveBuilder::current();
76+
const bool is_dynamic_dump = CDSConfig::is_dumping_dynamic_archive();
77+
78+
Array<T>* archived_array = ArchiveBuilder::new_ro_array<T>(tmp_array->length());
79+
for (int i = 0; i < tmp_array->length(); i++) {
80+
T ptr = tmp_array->at(i);
81+
if (!builder->is_in_buffer_space(ptr)) {
82+
if (is_dynamic_dump && MetaspaceShared::is_in_shared_metaspace(ptr)) {
83+
// We have a pointer that lives in the dynamic archive but points into
84+
// the static archive.
85+
} else {
86+
ptr = builder->get_buffered_addr(ptr);
87+
}
88+
}
89+
archived_array->at_put(i, ptr);
6090
ArchivePtrMarker::mark_pointer(archived_array->adr_at(i));
61-
}
6291
}
6392

6493
return archived_array;

0 commit comments

Comments
 (0)