8217845: SA should refer const values for JVMFlag from HotSpot

Reviewed-by: sspitsyn, jgeorge
This commit is contained in:
Yasumasa Suenaga 2019-02-05 14:24:29 +09:00
parent 38e316f91c
commit 67dfadfcc2
5 changed files with 74 additions and 8 deletions
src
hotspot/share/runtime
jdk.hotspot.agent/share/classes/sun/jvm/hotspot
test/hotspot/jtreg/serviceability/sa

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2019, 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
@ -2565,7 +2565,21 @@ typedef PaddedEnd<ObjectMonitor> PaddedObjectMonitor;
/****************/ \
/* VMRegImpl */ \
/****************/ \
declare_constant(VMRegImpl::stack_slot_size)
declare_constant(VMRegImpl::stack_slot_size) \
\
/******************************/ \
/* -XX flags (value origin) */ \
/******************************/ \
declare_constant(JVMFlag::DEFAULT) \
declare_constant(JVMFlag::COMMAND_LINE) \
declare_constant(JVMFlag::ENVIRON_VAR) \
declare_constant(JVMFlag::CONFIG_FILE) \
declare_constant(JVMFlag::MANAGEMENT) \
declare_constant(JVMFlag::ERGONOMIC) \
declare_constant(JVMFlag::ATTACH_ON_DEMAND) \
declare_constant(JVMFlag::INTERNAL) \
declare_constant(JVMFlag::VALUE_ORIGIN_MASK) \
declare_constant(JVMFlag::ORIG_COMMAND_LINE)
//--------------------------------------------------------------------------------
// VM_LONG_CONSTANTS

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2019, 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
@ -649,11 +649,11 @@ public class CommandProcessor {
VM.Flag flag = flags[f];
if (name == null || flag.getName().equals(name)) {
if (nonDefault && flag.getOrigin() == 0) {
if (nonDefault && (flag.getOrigin() == VM.Flags_DEFAULT)) {
// only print flags which aren't their defaults
continue;
}
out.println(flag.getName() + " = " + flag.getValue() + " " + flag.getOrigin());
out.println(flag.getName() + " = " + flag.getValue() + " " + flag.getOriginString());
printed = true;
}
}

@ -105,6 +105,17 @@ public class VM {
private int klassPtrSize;
private int oopSize;
private final int IndexSetSize;
/** -XX flags (value origin) */
public static int Flags_DEFAULT;
public static int Flags_COMMAND_LINE;
public static int Flags_ENVIRON_VAR;
public static int Flags_CONFIG_FILE;
public static int Flags_MANAGEMENT;
public static int Flags_ERGONOMIC;
public static int Flags_ATTACH_ON_DEMAND;
public static int Flags_INTERNAL;
private static int Flags_VALUE_ORIGIN_MASK;
private static int Flags_ORIG_COMMAND_LINE;
/** This is only present in a non-core build */
private CodeCache codeCache;
/** This is only present in a C1 build */
@ -163,7 +174,36 @@ public class VM {
}
public int getOrigin() {
return flags & 0xF; // XXX can we get the mask bits from somewhere?
return flags & Flags_VALUE_ORIGIN_MASK;
}
// See JVMFlag::print_origin() in HotSpot
public String getOriginString() {
var origin = flags & Flags_VALUE_ORIGIN_MASK;
if (origin == Flags_DEFAULT) {
return "default";
} else if (origin == Flags_COMMAND_LINE) {
return "command line";
} else if (origin == Flags_ENVIRON_VAR) {
return "environment";
} else if (origin == Flags_CONFIG_FILE) {
return "config file";
} else if (origin == Flags_MANAGEMENT) {
return "management";
} else if (origin == Flags_ERGONOMIC) {
String result = "";
if ((flags & Flags_ORIG_COMMAND_LINE) == Flags_ORIG_COMMAND_LINE) {
result = "command line, ";
}
return result + "ergonomic";
} else if (origin == Flags_ATTACH_ON_DEMAND) {
return "attach";
} else if (origin == Flags_INTERNAL) {
return "internal";
} else {
throw new IllegalStateException(
"Unknown flag origin " + origin + " is detected in " + name);
}
}
public boolean isBool() {
@ -436,6 +476,16 @@ public class VM {
bytesPerLong = db.lookupIntConstant("BytesPerLong").intValue();
bytesPerWord = db.lookupIntConstant("BytesPerWord").intValue();
heapWordSize = db.lookupIntConstant("HeapWordSize").intValue();
Flags_DEFAULT = db.lookupIntConstant("JVMFlag::DEFAULT").intValue();
Flags_COMMAND_LINE = db.lookupIntConstant("JVMFlag::COMMAND_LINE").intValue();
Flags_ENVIRON_VAR = db.lookupIntConstant("JVMFlag::ENVIRON_VAR").intValue();
Flags_CONFIG_FILE = db.lookupIntConstant("JVMFlag::CONFIG_FILE").intValue();
Flags_MANAGEMENT = db.lookupIntConstant("JVMFlag::MANAGEMENT").intValue();
Flags_ERGONOMIC = db.lookupIntConstant("JVMFlag::ERGONOMIC").intValue();
Flags_ATTACH_ON_DEMAND = db.lookupIntConstant("JVMFlag::ATTACH_ON_DEMAND").intValue();
Flags_INTERNAL = db.lookupIntConstant("JVMFlag::INTERNAL").intValue();
Flags_VALUE_ORIGIN_MASK = db.lookupIntConstant("JVMFlag::VALUE_ORIGIN_MASK").intValue();
Flags_ORIG_COMMAND_LINE = db.lookupIntConstant("JVMFlag::ORIG_COMMAND_LINE").intValue();
oopSize = db.lookupIntConstant("oopSize").intValue();
IndexSetSize = db.lookupIntConstant("CompactibleFreeListSpace::IndexSetSize").intValue();

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2019, 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
@ -148,7 +148,7 @@ public class JInfo extends Tool {
VM.Flag[] flags = VM.getVM().getCommandLineFlags();
System.out.print("Non-default VM flags: ");
for (VM.Flag flag : flags) {
if (flag.getOrigin() == 0) {
if (flag.getOrigin() == VM.Flags_DEFAULT) {
// only print flags which aren't their defaults
continue;
}

@ -34,6 +34,7 @@ import jtreg.SkippedException;
* @test
* @bug 8190198
* @bug 8217612
* @bug 8217845
* @summary Test clhsdb flags command
* @requires vm.hasSA
* @library /test/lib
@ -63,6 +64,7 @@ public class ClhsdbFlags {
Map<String, List<String>> expStrMap = new HashMap<>();
expStrMap.put("flags", List.of(
"command line", "ergonomic", "default",
"UnlockDiagnosticVMOptions = true",
"MaxFDLimit = false",
"MaxJavaStackTraceDepth = 1024",