Skip to content

Commit 8254311

Browse files
iklampull[bot]
authored andcommitted
8279500: Remove FileMapHeader::_heap_obj_roots
Reviewed-by: minqi, ccheung
1 parent 454c59f commit 8254311

File tree

6 files changed

+26
-28
lines changed

6 files changed

+26
-28
lines changed

src/hotspot/share/cds/filemap.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2022, 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
@@ -273,7 +273,6 @@ void FileMapHeader::populate(FileMapInfo *info, size_t core_region_alignment,
273273

274274
if (!DynamicDumpSharedSpaces) {
275275
set_shared_path_table(info->_shared_path_table);
276-
CDS_JAVA_HEAP_ONLY(_heap_obj_roots = CompressedOops::encode(HeapShared::roots());)
277276
}
278277
}
279278

@@ -2097,7 +2096,6 @@ void FileMapInfo::map_heap_regions_impl() {
20972096
/*is_open_archive=*/ true,
20982097
&open_heap_regions, &num_open_heap_regions)) {
20992098
HeapShared::set_open_regions_mapped();
2100-
HeapShared::set_roots(header()->heap_obj_roots());
21012099
}
21022100
}
21032101
}

src/hotspot/share/cds/filemap.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2022, 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
@@ -232,7 +232,6 @@ class FileMapHeader: private CDSFileMapHeaderBase {
232232
// some expensive operations.
233233
bool _use_full_module_graph; // Can we use the full archived module graph?
234234
size_t _ptrmap_size_in_bits; // Size of pointer relocation bitmap
235-
narrowOop _heap_obj_roots; // An objArray that stores all the roots of archived heap objects
236235
char* from_mapped_offset(size_t offset) const {
237236
return mapped_base_address() + offset;
238237
}
@@ -279,14 +278,12 @@ class FileMapHeader: private CDSFileMapHeaderBase {
279278
jshort app_module_paths_start_index() const { return _app_module_paths_start_index; }
280279
jshort app_class_paths_start_index() const { return _app_class_paths_start_index; }
281280
jshort num_module_paths() const { return _num_module_paths; }
282-
narrowOop heap_obj_roots() const { return _heap_obj_roots; }
283281

284282
void set_has_platform_or_app_classes(bool v) { _has_platform_or_app_classes = v; }
285283
void set_cloned_vtables(char* p) { set_as_offset(p, &_cloned_vtables_offset); }
286284
void set_serialized_data(char* p) { set_as_offset(p, &_serialized_data_offset); }
287285
void set_ptrmap_size_in_bits(size_t s) { _ptrmap_size_in_bits = s; }
288286
void set_mapped_base_address(char* p) { _mapped_base_address = p; }
289-
void set_heap_obj_roots(narrowOop r) { _heap_obj_roots = r; }
290287
void copy_base_archive_name(const char* name);
291288

292289
void set_shared_path_table(SharedPathTable table) {
@@ -413,8 +410,6 @@ class FileMapInfo : public CHeapObj<mtInternal> {
413410
void set_requested_base(char* b) { header()->set_requested_base(b); }
414411
char* requested_base_address() const { return header()->requested_base_address(); }
415412

416-
narrowOop heap_obj_roots() const { return header()->heap_obj_roots(); }
417-
418413
class DynamicArchiveHeader* dynamic_header() const {
419414
assert(!is_static(), "must be");
420415
return (DynamicArchiveHeader*)header();

src/hotspot/share/cds/heapShared.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2022, 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
@@ -128,7 +128,6 @@ const static int num_fmg_open_archive_subgraph_entry_fields =
128128
sizeof(fmg_open_archive_subgraph_entry_fields) / sizeof(ArchivableStaticFieldInfo);
129129

130130
GrowableArrayCHeap<oop, mtClassShared>* HeapShared::_pending_roots = NULL;
131-
narrowOop HeapShared::_roots_narrow;
132131
OopHandle HeapShared::_roots;
133132

134133
#ifdef ASSERT
@@ -152,7 +151,6 @@ void HeapShared::fixup_regions() {
152151
fill_failed_loaded_region();
153152
}
154153
if (is_fully_available()) {
155-
_roots = OopHandle(Universe::vm_global(), decode_from_archive(_roots_narrow));
156154
if (!MetaspaceShared::use_full_module_graph()) {
157155
// Need to remove all the archived java.lang.Module objects from HeapShared::roots().
158156
ClassLoaderDataShared::clear_archived_oops();
@@ -236,12 +234,6 @@ objArrayOop HeapShared::roots() {
236234
return roots;
237235
}
238236

239-
void HeapShared::set_roots(narrowOop roots) {
240-
assert(UseSharedSpaces, "runtime only");
241-
assert(is_fully_available(), "must be");
242-
_roots_narrow = roots;
243-
}
244-
245237
// Returns an objArray that contains all the roots of the archived objects
246238
oop HeapShared::get_root(int index, bool clear) {
247239
assert(index >= 0, "sanity");
@@ -670,7 +662,23 @@ void HeapShared::write_subgraph_info_table() {
670662
writer.dump(&_run_time_subgraph_info_table, "subgraphs");
671663
}
672664

673-
void HeapShared::serialize_subgraph_info_table_header(SerializeClosure* soc) {
665+
void HeapShared::serialize(SerializeClosure* soc) {
666+
oop roots_oop = NULL;
667+
668+
if (soc->reading()) {
669+
soc->do_oop(&roots_oop); // read from archive
670+
assert(oopDesc::is_oop_or_null(roots_oop), "is oop");
671+
// Create an OopHandle only if we have actually mapped or loaded the roots
672+
if (roots_oop != NULL) {
673+
assert(HeapShared::is_fully_available(), "must be");
674+
_roots = OopHandle(Universe::vm_global(), roots_oop);
675+
}
676+
} else {
677+
// writing
678+
roots_oop = roots();
679+
soc->do_oop(&roots_oop); // write to archive
680+
}
681+
674682
_run_time_subgraph_info_table.serialize_header(soc);
675683
}
676684

@@ -1695,7 +1703,6 @@ bool HeapShared::load_heap_regions(FileMapInfo* mapinfo) {
16951703

16961704
init_loaded_heap_relocation(loaded_regions, num_loaded_regions);
16971705
_is_loaded = true;
1698-
set_roots(mapinfo->heap_obj_roots());
16991706

17001707
return true;
17011708
}

src/hotspot/share/cds/heapShared.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2022, 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
@@ -310,7 +310,6 @@ class HeapShared: AllStatic {
310310
static SeenObjectsTable *_seen_objects_table;
311311

312312
static GrowableArrayCHeap<oop, mtClassShared>* _pending_roots;
313-
static narrowOop _roots_narrow;
314313
static OopHandle _roots;
315314

316315
static void init_seen_objects_table() {
@@ -418,7 +417,6 @@ class HeapShared: AllStatic {
418417
static oop get_root(int index, bool clear=false);
419418

420419
// Run-time only
421-
static void set_roots(narrowOop roots);
422420
static void clear_root(int index);
423421
#endif // INCLUDE_CDS_JAVA_HEAP
424422

@@ -468,7 +466,7 @@ class HeapShared: AllStatic {
468466

469467
static void init_for_dumping(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
470468
static void write_subgraph_info_table() NOT_CDS_JAVA_HEAP_RETURN;
471-
static void serialize_subgraph_info_table_header(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN;
469+
static void serialize(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN;
472470
};
473471

474472
#if INCLUDE_CDS_JAVA_HEAP

src/hotspot/share/cds/metaspaceShared.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2022, 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
@@ -384,7 +384,7 @@ void MetaspaceShared::serialize(SerializeClosure* soc) {
384384
// Dump/restore the symbol/string/subgraph_info tables
385385
SymbolTable::serialize_shared_table_header(soc);
386386
StringTable::serialize_shared_table_header(soc);
387-
HeapShared::serialize_subgraph_info_table_header(soc);
387+
HeapShared::serialize(soc);
388388
SystemDictionaryShared::serialize_dictionary_headers(soc);
389389

390390
InstanceMirrorKlass::serialize_offsets(soc);

src/hotspot/share/include/cds.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2022, 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
@@ -39,7 +39,7 @@
3939
#define CDS_ARCHIVE_MAGIC 0xf00baba2
4040
#define CDS_DYNAMIC_ARCHIVE_MAGIC 0xf00baba8
4141
#define CDS_GENERIC_HEADER_SUPPORTED_MIN_VERSION 13
42-
#define CURRENT_CDS_ARCHIVE_VERSION 13
42+
#define CURRENT_CDS_ARCHIVE_VERSION 14
4343

4444
typedef struct CDSFileMapRegion {
4545
int _crc; // CRC checksum of this region.

0 commit comments

Comments
 (0)