diff --git a/src/hotspot/share/oops/metadata.hpp b/src/hotspot/share/oops/metadata.hpp index f5aee34c80d..ff18cef60a7 100644 --- a/src/hotspot/share/oops/metadata.hpp +++ b/src/hotspot/share/oops/metadata.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, 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 @@ -44,11 +44,10 @@ class Metadata : public MetaspaceObj { virtual bool is_method() const { return false; } virtual bool is_methodData() const { return false; } virtual bool is_constantPool() const { return false; } - virtual bool is_methodCounters() const { return false; } virtual int size() const = 0; virtual MetaspaceObj::Type type() const = 0; virtual const char* internal_name() const = 0; - virtual void metaspace_pointers_do(MetaspaceClosure* iter) {} + virtual void metaspace_pointers_do(MetaspaceClosure* iter) = 0; void print() const; void print_value() const; diff --git a/src/hotspot/share/oops/methodCounters.cpp b/src/hotspot/share/oops/methodCounters.cpp index 00096c5012c..93fd7e65c6b 100644 --- a/src/hotspot/share/oops/methodCounters.cpp +++ b/src/hotspot/share/oops/methodCounters.cpp @@ -50,12 +50,12 @@ MethodCounters::MethodCounters(const methodHandle& mh) : MethodCounters* MethodCounters::allocate_no_exception(const methodHandle& mh) { ClassLoaderData* loader_data = mh->method_holder()->class_loader_data(); - return new(loader_data, method_counters_size(), MetaspaceObj::MethodCountersType) MethodCounters(mh); + return new(loader_data, size(), MetaspaceObj::MethodCountersType) MethodCounters(mh); } MethodCounters* MethodCounters::allocate_with_exception(const methodHandle& mh, TRAPS) { ClassLoaderData* loader_data = mh->method_holder()->class_loader_data(); - return new(loader_data, method_counters_size(), MetaspaceObj::MethodCountersType, THREAD) MethodCounters(mh); + return new(loader_data, size(), MetaspaceObj::MethodCountersType, THREAD) MethodCounters(mh); } void MethodCounters::clear_counters() { @@ -70,7 +70,6 @@ void MethodCounters::clear_counters() { } void MethodCounters::print_value_on(outputStream* st) const { - assert(is_methodCounters(), "must be methodCounters"); st->print("method counters"); print_address_on(st); } diff --git a/src/hotspot/share/oops/methodCounters.hpp b/src/hotspot/share/oops/methodCounters.hpp index 80cfb159b50..bdf033a46a8 100644 --- a/src/hotspot/share/oops/methodCounters.hpp +++ b/src/hotspot/share/oops/methodCounters.hpp @@ -30,7 +30,7 @@ #include "interpreter/invocationCounter.hpp" #include "utilities/align.hpp" -class MethodCounters : public Metadata { +class MethodCounters : public MetaspaceObj { friend class VMStructs; friend class JVMCIVMStructs; private: @@ -52,19 +52,18 @@ class MethodCounters : public Metadata { MethodCounters(const methodHandle& mh); public: - virtual bool is_methodCounters() const { return true; } - static MethodCounters* allocate_no_exception(const methodHandle& mh); static MethodCounters* allocate_with_exception(const methodHandle& mh, TRAPS); + DEBUG_ONLY(bool on_stack() { return false; }) void deallocate_contents(ClassLoaderData* loader_data) {} - static int method_counters_size() { + void metaspace_pointers_do(MetaspaceClosure* it) { return; } + + static int size() { return align_up((int)sizeof(MethodCounters), wordSize) / wordSize; } - virtual int size() const { - return method_counters_size(); - } + MetaspaceObj::Type type() const { return MethodCountersType; } void clear_counters(); @@ -128,8 +127,7 @@ class MethodCounters : public Metadata { return byte_offset_of(MethodCounters, _backedge_mask); } - virtual const char* internal_name() const { return "{method counters}"; } - virtual void print_value_on(outputStream* st) const; - + const char* internal_name() const { return "{method counters}"; } + void print_value_on(outputStream* st) const; }; #endif // SHARE_OOPS_METHODCOUNTERS_HPP