src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java
changeset 53513 8c035b34248d
parent 50929 ef57cfcd22ff
child 53637 4366a1e4a021
equal deleted inserted replaced
53512:090395557398 53513:8c035b34248d
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   128   private static Type intType;
   128   private static Type intType;
   129   private static Type uintType;
   129   private static Type uintType;
   130   private static Type intxType;
   130   private static Type intxType;
   131   private static Type uintxType;
   131   private static Type uintxType;
   132   private static Type sizetType;
   132   private static Type sizetType;
       
   133   private static Type uint64tType;
   133   private static CIntegerType boolType;
   134   private static CIntegerType boolType;
   134   private Boolean sharingEnabled;
   135   private Boolean sharingEnabled;
   135   private Boolean compressedOopsEnabled;
   136   private Boolean compressedOopsEnabled;
   136   private Boolean compressedKlassPointersEnabled;
   137   private Boolean compressedKlassPointersEnabled;
   137 
   138 
   227      public long getSizet() {
   228      public long getSizet() {
   228         if (Assert.ASSERTS_ENABLED) {
   229         if (Assert.ASSERTS_ENABLED) {
   229            Assert.that(isSizet(), "not a size_t flag!");
   230            Assert.that(isSizet(), "not a size_t flag!");
   230         }
   231         }
   231         return addr.getCIntegerAt(0, sizetType.getSize(), true);
   232         return addr.getCIntegerAt(0, sizetType.getSize(), true);
       
   233      }
       
   234 
       
   235      public boolean isCcstr() {
       
   236         return type.equals("ccstr");
       
   237      }
       
   238 
       
   239      public String getCcstr() {
       
   240         if (Assert.ASSERTS_ENABLED) {
       
   241            Assert.that(isCcstr(), "not a ccstr flag!");
       
   242         }
       
   243         return CStringUtilities.getString(addr.getAddressAt(0));
       
   244      }
       
   245 
       
   246      public boolean isCcstrlist() {
       
   247         return type.equals("ccstrlist");
       
   248      }
       
   249 
       
   250      public String getCcstrlist() {
       
   251         if (Assert.ASSERTS_ENABLED) {
       
   252            Assert.that(isCcstrlist(), "not a ccstrlist flag!");
       
   253         }
       
   254         return CStringUtilities.getString(addr.getAddressAt(0));
       
   255      }
       
   256 
       
   257      public boolean isDouble() {
       
   258         return type.equals("double");
       
   259      }
       
   260 
       
   261      public double getDouble() {
       
   262         if (Assert.ASSERTS_ENABLED) {
       
   263            Assert.that(isDouble(), "not a double flag!");
       
   264         }
       
   265         return addr.getJDoubleAt(0);
       
   266      }
       
   267 
       
   268      public boolean isUint64t() {
       
   269         return type.equals("uint64_t");
       
   270      }
       
   271 
       
   272      public long getUint64t() {
       
   273         if (Assert.ASSERTS_ENABLED) {
       
   274            Assert.that(isUint64t(), "not an uint64_t flag!");
       
   275         }
       
   276         return addr.getCIntegerAt(0, uint64tType.getSize(), true);
   232      }
   277      }
   233 
   278 
   234      public String getValue() {
   279      public String getValue() {
   235         if (isBool()) {
   280         if (isBool()) {
   236            return Boolean.toString(getBool());
   281            return Boolean.toString(getBool());
   239         } else if (isUInt()) {
   284         } else if (isUInt()) {
   240            return Long.toString(getUInt());
   285            return Long.toString(getUInt());
   241         } else if (isIntx()) {
   286         } else if (isIntx()) {
   242            return Long.toString(getIntx());
   287            return Long.toString(getIntx());
   243         } else if (isUIntx()) {
   288         } else if (isUIntx()) {
   244            return Long.toString(getUIntx());
   289            return Long.toUnsignedString(getUIntx());
   245         } else if (isSizet()) {
   290         } else if (isSizet()) {
   246             return Long.toString(getSizet());
   291            return Long.toUnsignedString(getSizet());
       
   292         } else if (isCcstr()) {
       
   293            var str = getCcstr();
       
   294            if (str != null) {
       
   295                str = "\"" + str + "\"";
       
   296            }
       
   297            return str;
       
   298         } else if (isCcstrlist()) {
       
   299            var str = getCcstrlist();
       
   300            if (str != null) {
       
   301                str = "\"" + str + "\"";
       
   302            }
       
   303            return str;
       
   304         } else if (isDouble()) {
       
   305            return Double.toString(getDouble());
       
   306         } else if (isUint64t()) {
       
   307            return Long.toUnsignedString(getUint64t());
   247         } else {
   308         } else {
   248            return null;
   309            throw new WrongTypeException("Unknown type: " + type + " (" + name + ")");
   249         }
   310         }
   250      }
   311      }
   251   };
   312   };
   252 
   313 
   253   private static void checkVMVersion(String vmRelease) {
   314   private static void checkVMVersion(String vmRelease) {
   381     intType = db.lookupType("int");
   442     intType = db.lookupType("int");
   382     uintType = db.lookupType("uint");
   443     uintType = db.lookupType("uint");
   383     intxType = db.lookupType("intx");
   444     intxType = db.lookupType("intx");
   384     uintxType = db.lookupType("uintx");
   445     uintxType = db.lookupType("uintx");
   385     sizetType = db.lookupType("size_t");
   446     sizetType = db.lookupType("size_t");
       
   447     uint64tType = db.lookupType("uint64_t");
   386     boolType = (CIntegerType) db.lookupType("bool");
   448     boolType = (CIntegerType) db.lookupType("bool");
   387 
   449 
   388     minObjAlignmentInBytes = getObjectAlignmentInBytes();
   450     minObjAlignmentInBytes = getObjectAlignmentInBytes();
   389     if (minObjAlignmentInBytes == 8) {
   451     if (minObjAlignmentInBytes == 8) {
   390       logMinObjAlignmentInBytes = 3;
   452       logMinObjAlignmentInBytes = 3;