Path: blob/master/test/jdk/jdk/jfr/event/compiler/TestCodeCacheConfig.java
41710 views
/*1* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package jdk.jfr.event.compiler;2425import java.util.List;2627import jdk.jfr.Recording;28import jdk.jfr.consumer.RecordedEvent;29import jdk.test.lib.Asserts;30import jdk.test.lib.jfr.EventNames;31import jdk.test.lib.jfr.Events;32import sun.hotspot.WhiteBox;3334/**35* @test TestCodeCacheConfig36* @key jfr37* @requires vm.hasJFR38* @library /test/lib39* @build sun.hotspot.WhiteBox40* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox41* @run main/othervm -Xbootclasspath/a:.42* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI43* -XX:+SegmentedCodeCache jdk.jfr.event.compiler.TestCodeCacheConfig44* @run main/othervm -Xbootclasspath/a:.45* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI46* -XX:-SegmentedCodeCache jdk.jfr.event.compiler.TestCodeCacheConfig47* @summary check "Code Cache Configuration" jfr event48*/49public class TestCodeCacheConfig {50private final static String EVENT_NAME = EventNames.CodeCacheConfiguration;5152private static final long CodeCacheExpectedSize = WhiteBox.getWhiteBox().getUintxVMFlag("ReservedCodeCacheSize");5354public static void main(String[] args) throws Exception {55Recording recording = new Recording();56recording.enable(EVENT_NAME);57recording.start();58recording.stop();5960List<RecordedEvent> events = Events.fromRecording(recording);61Events.hasEvents(events);62RecordedEvent event = events.get(0);63long initialSize = (long) event.getValue("initialSize");64long reservedSize = (long) event.getValue("reservedSize");65long nonNMethodSize = (long) event.getValue("nonNMethodSize");66long profiledSize = (long) event.getValue("profiledSize");67long nonProfiledSize = (long) event.getValue("nonProfiledSize");68long expansionSize = (long) event.getValue("expansionSize");69long minBlockLength = (long) event.getValue("minBlockLength");70long startAddress = (long) event.getValue("startAddress");71long reservedTopAddress = (long) event.getValue("reservedTopAddress");7273Asserts.assertGT(initialSize, 1024L,74"initialSize less than 1024 byte, got " + initialSize);7576Asserts.assertEQ(reservedSize, CodeCacheExpectedSize,77String.format("Unexpected reservedSize value. Expected %d but " + "got %d", CodeCacheExpectedSize, reservedSize));7879Asserts.assertLTE(nonNMethodSize, CodeCacheExpectedSize,80String.format("Unexpected nonNMethodSize value. Expected <= %d but " + "got %d", CodeCacheExpectedSize, nonNMethodSize));8182Asserts.assertLTE(profiledSize, CodeCacheExpectedSize,83String.format("Unexpected profiledSize value. Expected <= %d but " + "got %d", CodeCacheExpectedSize, profiledSize));8485Asserts.assertLTE(nonProfiledSize, CodeCacheExpectedSize,86String.format("Unexpected nonProfiledSize value. Expected <= %d but " + "got %d", CodeCacheExpectedSize, nonProfiledSize));8788Asserts.assertGTE(expansionSize, 1024L,89"expansionSize less than 1024 " + "bytes, got " + expansionSize);9091Asserts.assertGTE(minBlockLength, 1L,92"minBlockLength less than 1 byte, got " + minBlockLength);9394Asserts.assertNE(startAddress, 0L,95"startAddress null");9697Asserts.assertNE(reservedTopAddress, 0L,98"codeCacheReservedTopAddr null");99}100}101102103