From 4bbe11186ffa79da62d86f804643d1dd91b89177 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Thu, 23 Jul 2026 00:19:38 +0000 Subject: [PATCH] 8388694: Refactor metaspace_pointers_do() operations for BSMAttributeEntries Reviewed-by: coleenp, matsaave --- src/hotspot/share/oops/bsmAttribute.hpp | 9 +++++---- src/hotspot/share/oops/constantPool.cpp | 10 +++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/hotspot/share/oops/bsmAttribute.hpp b/src/hotspot/share/oops/bsmAttribute.hpp index 535821d539e..25a5293119f 100644 --- a/src/hotspot/share/oops/bsmAttribute.hpp +++ b/src/hotspot/share/oops/bsmAttribute.hpp @@ -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*& offsets() { return _offsets; } - const Array* const& offsets() const { return _offsets; } - Array*& bootstrap_methods() { return _bootstrap_methods; } - const Array* const& bootstrap_methods() const { return _bootstrap_methods; } + Array* offsets() const { return _offsets; } + Array* bootstrap_methods() const { return _bootstrap_methods; } BSMAttributeEntry* entry(int bsms_attribute_index) { return reinterpret_cast(_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 diff --git a/src/hotspot/share/oops/constantPool.cpp b/src/hotspot/share/oops/constantPool.cpp index f3beb15aaee..b3ff0eb1b76 100644 --- a/src/hotspot/share/oops/constantPool.cpp +++ b/src/hotspot/share/oops/constantPool.cpp @@ -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); +}