8388694: Refactor metaspace_pointers_do() operations for BSMAttributeEntries

Reviewed-by: coleenp, matsaave
This commit is contained in:
Ioi Lam 2026-07-23 00:19:38 +00:00
parent 303b84d4bc
commit 4bbe11186f
2 changed files with 12 additions and 7 deletions

View File

@ -30,6 +30,7 @@
#include "utilities/globalDefinitions.hpp"
class ClassLoaderData;
class MetaspaceClosure;
class BSMAttributeEntry {
friend class ConstantPool;
@ -130,10 +131,8 @@ public:
return _offsets == nullptr && _bootstrap_methods == nullptr;
}
Array<u4>*& offsets() { return _offsets; }
const Array<u4>* const& offsets() const { return _offsets; }
Array<u2>*& bootstrap_methods() { return _bootstrap_methods; }
const Array<u2>* const& bootstrap_methods() const { return _bootstrap_methods; }
Array<u4>* offsets() const { return _offsets; }
Array<u2>* bootstrap_methods() const { return _bootstrap_methods; }
BSMAttributeEntry* entry(int bsms_attribute_index) {
return reinterpret_cast<BSMAttributeEntry*>(_bootstrap_methods->adr_at(_offsets->at(bsms_attribute_index)));
@ -164,6 +163,8 @@ public:
void end_extension(InsertionIterator& iter, ClassLoaderData* loader_data, TRAPS);
// Append all of the BSMAEs in other into this.
void append(const BSMAttributeEntries& other, ClassLoaderData* loader_data, TRAPS);
void metaspace_pointers_do(MetaspaceClosure* it);
};
#endif // SHARE_OOPS_BSMATTRIBUTE_HPP

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -152,9 +152,8 @@ void ConstantPool::metaspace_pointers_do(MetaspaceClosure* it) {
it->push(&_tags, MetaspaceClosure::_writable);
it->push(&_cache);
it->push(&_pool_holder);
it->push(&bsm_entries().offsets());
it->push(&bsm_entries().bootstrap_methods());
it->push(&_resolved_klasses, MetaspaceClosure::_writable);
bsm_entries().metaspace_pointers_do(it);
for (int i = 0; i < length(); i++) {
// The only MSO's embedded in the CP entries are Symbols:
@ -2424,3 +2423,8 @@ void BSMAttributeEntries::end_extension(InsertionIterator& iter, ClassLoaderData
_offsets = new_offsets;
_bootstrap_methods = new_array;
}
void BSMAttributeEntries::metaspace_pointers_do(MetaspaceClosure* it) {
it->push(&_offsets);
it->push(&_bootstrap_methods);
}