From 06d46d6c0b09458bb64171ed4ee2e2c06f4e006e Mon Sep 17 00:00:00 2001 From: Jie Fu Date: Wed, 24 Mar 2021 09:30:54 +0000 Subject: [PATCH] 8264008: Incorrect metaspace statistics after JEP 387 when UseCompressedClassPointers is off Reviewed-by: stuefe --- src/hotspot/share/memory/metaspace.cpp | 6 +++--- .../TestHeapSummaryEventDefNewSerial.java | 13 ++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/hotspot/share/memory/metaspace.cpp b/src/hotspot/share/memory/metaspace.cpp index 965b395ac98..d5b46a6dc74 100644 --- a/src/hotspot/share/memory/metaspace.cpp +++ b/src/hotspot/share/memory/metaspace.cpp @@ -71,7 +71,7 @@ size_t MetaspaceUtils::used_words() { } size_t MetaspaceUtils::used_words(Metaspace::MetadataType mdtype) { - return Metaspace::is_class_space_allocation(mdtype) ? RunningCounters::used_words_class() : RunningCounters::used_words_nonclass(); + return mdtype == Metaspace::ClassType ? RunningCounters::used_words_class() : RunningCounters::used_words_nonclass(); } size_t MetaspaceUtils::reserved_words() { @@ -79,7 +79,7 @@ size_t MetaspaceUtils::reserved_words() { } size_t MetaspaceUtils::reserved_words(Metaspace::MetadataType mdtype) { - return Metaspace::is_class_space_allocation(mdtype) ? RunningCounters::reserved_words_class() : RunningCounters::reserved_words_nonclass(); + return mdtype == Metaspace::ClassType ? RunningCounters::reserved_words_class() : RunningCounters::reserved_words_nonclass(); } size_t MetaspaceUtils::committed_words() { @@ -87,7 +87,7 @@ size_t MetaspaceUtils::committed_words() { } size_t MetaspaceUtils::committed_words(Metaspace::MetadataType mdtype) { - return Metaspace::is_class_space_allocation(mdtype) ? RunningCounters::committed_words_class() : RunningCounters::committed_words_nonclass(); + return mdtype == Metaspace::ClassType ? RunningCounters::committed_words_class() : RunningCounters::committed_words_nonclass(); } void MetaspaceUtils::print_metaspace_change(const metaspace::MetaspaceSizesSnapshot& pre_meta_values) { diff --git a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java index f3e3876c52f..b46d52e46f1 100644 --- a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java +++ b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, 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 @@ -32,6 +32,17 @@ import jdk.test.lib.jfr.GCHelper; * @library /test/lib /test/jdk * @run main/othervm -XX:+UseSerialGC jdk.jfr.event.gc.heapsummary.TestHeapSummaryEventDefNewSerial */ + +/** + * @test + * @bug 8264008 + * @key jfr + * @requires vm.hasJFR & vm.bits == 64 + * @requires vm.gc == "Serial" | vm.gc == null + * @library /test/lib /test/jdk + * @run main/othervm -XX:+UseSerialGC -XX:-UseCompressedClassPointers + * jdk.jfr.event.gc.heapsummary.TestHeapSummaryEventDefNewSerial + */ public class TestHeapSummaryEventDefNewSerial { public static void main(String[] args) throws Exception { HeapSummaryEventAllGcs.test(GCHelper.gcDefNew, GCHelper.gcSerialOld);