Skip to content

Commit 5ccc962

Browse files
committed
8308342: Remove MetaspaceClosure::Ref::keep_after_pushing()
Reviewed-by: ccheung
1 parent a0f4a94 commit 5ccc962

File tree

4 files changed

+17
-43
lines changed

4 files changed

+17
-43
lines changed

src/hotspot/share/cds/archiveBuilder.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void ArchiveBuilder::SourceObjList::remember_embedded_pointer(SourceObjInfo* src
9292
// To mark the f->ptr pointer on 64-bit platform, this function is called with
9393
// src_info()->obj() == 0x100
9494
// ref->addr() == 0x108
95-
address src_obj = src_info->obj();
95+
address src_obj = src_info->source_addr();
9696
address* field_addr = ref->addr();
9797
assert(src_info->ptrmap_start() < _total_bytes, "sanity");
9898
assert(src_info->ptrmap_end() <= _total_bytes, "sanity");
@@ -176,8 +176,6 @@ ArchiveBuilder::~ArchiveBuilder() {
176176
assert(_current == this, "must be");
177177
_current = nullptr;
178178

179-
clean_up_src_obj_table();
180-
181179
for (int i = 0; i < _symbols->length(); i++) {
182180
_symbols->at(i)->decrement_refcount();
183181
}
@@ -427,7 +425,6 @@ bool ArchiveBuilder::gather_one_source_obj(MetaspaceClosure::Ref* enclosing_ref,
427425
if (src_obj == nullptr) {
428426
return false;
429427
}
430-
ref->set_keep_after_pushing();
431428
remember_embedded_pointer_in_gathered_obj(enclosing_ref, ref);
432429

433430
FollowMode follow_mode = get_follow_mode(ref);
@@ -589,15 +586,14 @@ void ArchiveBuilder::make_shallow_copies(DumpRegion *dump_region,
589586
}
590587

591588
void ArchiveBuilder::make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* src_info) {
592-
MetaspaceClosure::Ref* ref = src_info->ref();
593-
address src = ref->obj();
589+
address src = src_info->source_addr();
594590
int bytes = src_info->size_in_bytes();
595591
char* dest;
596592
char* oldtop;
597593
char* newtop;
598594

599595
oldtop = dump_region->top();
600-
if (ref->msotype() == MetaspaceObj::ClassType) {
596+
if (src_info->msotype() == MetaspaceObj::ClassType) {
601597
// Save a pointer immediate in front of an InstanceKlass, so
602598
// we can do a quick lookup from InstanceKlass* -> RunTimeClassInfo*
603599
// without building another hashtable. See RunTimeClassInfo::get_for()
@@ -621,7 +617,7 @@ void ArchiveBuilder::make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* s
621617
}
622618
}
623619

624-
intptr_t* archived_vtable = CppVtables::get_archived_vtable(ref->msotype(), (address)dest);
620+
intptr_t* archived_vtable = CppVtables::get_archived_vtable(src_info->msotype(), (address)dest);
625621
if (archived_vtable != nullptr) {
626622
*(address*)dest = (address)archived_vtable;
627623
ArchivePtrMarker::mark_pointer((address*)dest);
@@ -630,7 +626,7 @@ void ArchiveBuilder::make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* s
630626
log_trace(cds)("Copy: " PTR_FORMAT " ==> " PTR_FORMAT " %d", p2i(src), p2i(dest), bytes);
631627
src_info->set_buffered_addr((address)dest);
632628

633-
_alloc_stats.record(ref->msotype(), int(newtop - oldtop), src_info->read_only());
629+
_alloc_stats.record(src_info->msotype(), int(newtop - oldtop), src_info->read_only());
634630
}
635631

636632
// This is used by code that hand-assemble data structures, such as the LambdaProxyClassKey, that are
@@ -1097,11 +1093,6 @@ void ArchiveBuilder::print_stats() {
10971093
_alloc_stats.print_stats(int(_ro_region.used()), int(_rw_region.used()));
10981094
}
10991095

1100-
void ArchiveBuilder::clean_up_src_obj_table() {
1101-
SrcObjTableCleaner cleaner;
1102-
_src_obj_table.iterate(&cleaner);
1103-
}
1104-
11051096
void ArchiveBuilder::write_archive(FileMapInfo* mapinfo, ArchiveHeapInfo* heap_info) {
11061097
// Make sure NUM_CDS_REGIONS (exported in cds.h) agrees with
11071098
// MetaspaceShared::n_regions (internal to hotspot).

src/hotspot/share/cds/archiveBuilder.hpp

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,17 @@ class ArchiveBuilder : public StackObj {
123123

124124
private:
125125
class SourceObjInfo {
126-
MetaspaceClosure::Ref* _ref; // The object that's copied into the buffer
127126
uintx _ptrmap_start; // The bit-offset of the start of this object (inclusive)
128127
uintx _ptrmap_end; // The bit-offset of the end of this object (exclusive)
129128
bool _read_only;
130129
FollowMode _follow_mode;
131130
int _size_in_bytes;
132131
MetaspaceObj::Type _msotype;
133-
address _source_addr; // The value of the source object (_ref->obj()) when this
134-
// SourceObjInfo was created. Note that _ref->obj() may change
135-
// later if _ref is relocated.
136-
address _buffered_addr; // The copy of _ref->obj() insider the buffer.
132+
address _source_addr; // The source object to be copied.
133+
address _buffered_addr; // The copy of this object insider the buffer.
137134
public:
138135
SourceObjInfo(MetaspaceClosure::Ref* ref, bool read_only, FollowMode follow_mode) :
139-
_ref(ref), _ptrmap_start(0), _ptrmap_end(0), _read_only(read_only), _follow_mode(follow_mode),
136+
_ptrmap_start(0), _ptrmap_end(0), _read_only(read_only), _follow_mode(follow_mode),
140137
_size_in_bytes(ref->size() * BytesPerWord), _msotype(ref->msotype()),
141138
_source_addr(ref->obj()) {
142139
if (follow_mode == point_to_it) {
@@ -147,7 +144,6 @@ class ArchiveBuilder : public StackObj {
147144
}
148145

149146
bool should_copy() const { return _follow_mode == make_a_copy; }
150-
MetaspaceClosure::Ref* ref() const { return _ref; }
151147
void set_buffered_addr(address addr) {
152148
assert(should_copy(), "must be");
153149
assert(_buffered_addr == nullptr, "cannot be copied twice");
@@ -161,11 +157,13 @@ class ArchiveBuilder : public StackObj {
161157
bool read_only() const { return _read_only; }
162158
int size_in_bytes() const { return _size_in_bytes; }
163159
address source_addr() const { return _source_addr; }
164-
address buffered_addr() const { return _buffered_addr; }
160+
address buffered_addr() const {
161+
if (_follow_mode != set_to_null) {
162+
assert(_buffered_addr != nullptr, "must be initialized");
163+
}
164+
return _buffered_addr;
165+
}
165166
MetaspaceObj::Type msotype() const { return _msotype; }
166-
167-
// convenience accessor
168-
address obj() const { return ref()->obj(); }
169167
};
170168

171169
class SourceObjList {
@@ -187,14 +185,6 @@ class ArchiveBuilder : public StackObj {
187185
SourceObjInfo* at(int i) const { return objs()->at(i); }
188186
};
189187

190-
class SrcObjTableCleaner {
191-
public:
192-
bool do_entry(address key, const SourceObjInfo& value) {
193-
delete value.ref();
194-
return true;
195-
}
196-
};
197-
198188
class CDSMapLogger;
199189

200190
static const int INITIAL_TABLE_SIZE = 15889;

src/hotspot/share/memory/metaspaceClosure.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ void MetaspaceClosure::Ref::update(address new_loc) const {
3535
void MetaspaceClosure::push_impl(MetaspaceClosure::Ref* ref) {
3636
if (_nest_level < MAX_NEST_LEVEL) {
3737
do_push(ref);
38-
if (!ref->keep_after_pushing()) {
39-
delete ref;
40-
}
38+
delete ref;
4139
} else {
4240
do_pending_ref(ref);
4341
ref->set_next(_pending_refs);
@@ -80,9 +78,7 @@ void MetaspaceClosure::finish() {
8078
Ref* ref = _pending_refs;
8179
_pending_refs = _pending_refs->next();
8280
do_push(ref);
83-
if (!ref->keep_after_pushing()) {
84-
delete ref;
85-
}
81+
delete ref;
8682
}
8783
}
8884

src/hotspot/share/memory/metaspaceClosure.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,13 @@ class MetaspaceClosure {
106106
// [2] All Array<T> dimensions are statically declared.
107107
class Ref : public CHeapObj<mtMetaspace> {
108108
Writability _writability;
109-
bool _keep_after_pushing;
110109
Ref* _next;
111110
void* _user_data;
112111
NONCOPYABLE(Ref);
113112

114113
protected:
115114
virtual void** mpp() const = 0;
116-
Ref(Writability w) : _writability(w), _keep_after_pushing(false), _next(nullptr), _user_data(nullptr) {}
115+
Ref(Writability w) : _writability(w), _next(nullptr), _user_data(nullptr) {}
117116
public:
118117
virtual bool not_null() const = 0;
119118
virtual int size() const = 0;
@@ -134,8 +133,6 @@ class MetaspaceClosure {
134133
void update(address new_loc) const;
135134

136135
Writability writability() const { return _writability; };
137-
void set_keep_after_pushing() { _keep_after_pushing = true; }
138-
bool keep_after_pushing() { return _keep_after_pushing; }
139136
void set_user_data(void* data) { _user_data = data; }
140137
void* user_data() { return _user_data; }
141138
void set_next(Ref* n) { _next = n; }

0 commit comments

Comments
 (0)