agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7088955 Sdiff agent/src/share/classes/sun/jvm/hotspot/runtime

agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java

Print this page




 118 
 119   // VM version strings come from Abstract_VM_Version class
 120   private String       vmRelease;
 121   private String       vmInternalInfo;
 122 
 123   private Flag[] commandLineFlags;
 124   private Map flagsMap;
 125 
 126   private static Type intxType;
 127   private static Type uintxType;
 128   private static CIntegerType boolType;
 129   private Boolean sharingEnabled;
 130   private Boolean compressedOopsEnabled;
 131 
 132   // command line flags supplied to VM - see struct Flag in globals.hpp
 133   public static final class Flag {
 134      private String type;
 135      private String name;
 136      private Address addr;
 137      private String kind;

 138 
 139      private Flag(String type, String name, Address addr, String kind) {
 140         this.type = type;
 141         this.name = name;
 142         this.addr = addr;
 143         this.kind = kind;

 144      }
 145 
 146      public String getType() {
 147         return type;
 148      }
 149 
 150      public String getName() {
 151         return name;
 152      }
 153 
 154      public Address getAddress() {
 155         return addr;
 156      }
 157 
 158      public String getKind() {
 159         return kind;
 160      }
 161 




 162      public boolean isBool() {
 163         return type.equals("bool");
 164      }
 165 
 166      public boolean getBool() {
 167         if (Assert.ASSERTS_ENABLED) {
 168            Assert.that(isBool(), "not a bool flag!");
 169         }
 170         return addr.getCIntegerAt(0, boolType.getSize(), boolType.isUnsigned())
 171                != 0;
 172      }
 173 
 174      public boolean isIntx() {
 175         return type.equals("intx");
 176      }
 177 
 178      public long getIntx() {
 179         if (Assert.ASSERTS_ENABLED) {
 180            Assert.that(isIntx(), "not a intx flag!");
 181         }


 787        readCommandLineFlags();
 788     }
 789 
 790     return commandLineFlags;
 791   }
 792 
 793   public Flag getCommandLineFlag(String name) {
 794     if (flagsMap == null) {
 795       flagsMap = new HashMap();
 796       Flag[] flags = getCommandLineFlags();
 797       for (int i = 0; i < flags.length; i++) {
 798         flagsMap.put(flags[i].getName(), flags[i]);
 799       }
 800     }
 801     return (Flag) flagsMap.get(name);
 802   }
 803 
 804   private void readCommandLineFlags() {
 805     // get command line flags
 806     TypeDataBase db = getTypeDataBase();
 807     try {
 808        Type flagType = db.lookupType("Flag");
 809        int numFlags = (int) flagType.getCIntegerField("numFlags").getValue();
 810        // NOTE: last flag contains null values.
 811        commandLineFlags = new Flag[numFlags - 1];
 812 
 813        Address flagAddr = flagType.getAddressField("flags").getValue();
 814 
 815        AddressField typeFld = flagType.getAddressField("type");
 816        AddressField nameFld = flagType.getAddressField("name");
 817        AddressField addrFld = flagType.getAddressField("addr");
 818        AddressField kindFld = flagType.getAddressField("kind");

 819 
 820        long flagSize = flagType.getSize(); // sizeof(Flag)
 821 
 822        // NOTE: last flag contains null values.
 823        for (int f = 0; f < numFlags - 1; f++) {
 824           String type = CStringUtilities.getString(typeFld.getValue(flagAddr));
 825           String name = CStringUtilities.getString(nameFld.getValue(flagAddr));
 826           Address addr = addrFld.getValue(flagAddr);
 827           String kind = CStringUtilities.getString(kindFld.getValue(flagAddr));
 828           commandLineFlags[f] = new Flag(type, name, addr, kind);

 829           flagAddr = flagAddr.addOffsetTo(flagSize);
 830        }
 831 
 832        // sort flags by name
 833        Arrays.sort(commandLineFlags, new Comparator() {
 834                                         public int compare(Object o1, Object o2) {
 835                                            Flag f1 = (Flag) o1;
 836                                            Flag f2 = (Flag) o2;
 837                                            return f1.getName().compareTo(f2.getName());
 838                                         }
 839                                      });
 840     } catch (Exception exp) {
 841        // ignore. may be older version. command line flags not available.
 842     }
 843   }
 844 
 845   public String getSystemProperty(String key) {
 846     Properties props = getSystemProperties();
 847     return (props != null)? props.getProperty(key) : null;
 848   }
 849 
 850   public Properties getSystemProperties() {
 851     if (sysProps == null) {
 852        readSystemProperties();
 853     }
 854     return sysProps;
 855   }
 856 
 857   private void readSystemProperties() {
 858     final InstanceKlass systemKls = getSystemDictionary().getSystemKlass();
 859     systemKls.iterateStaticFields(new DefaultOopVisitor() {
 860         ObjectReader objReader = new ObjectReader();
 861         public void doOop(sun.jvm.hotspot.oops.OopField field, boolean isVMField) {
 862           if (field.getID().getName().equals("props")) {
 863             try {


 118 
 119   // VM version strings come from Abstract_VM_Version class
 120   private String       vmRelease;
 121   private String       vmInternalInfo;
 122 
 123   private Flag[] commandLineFlags;
 124   private Map flagsMap;
 125 
 126   private static Type intxType;
 127   private static Type uintxType;
 128   private static CIntegerType boolType;
 129   private Boolean sharingEnabled;
 130   private Boolean compressedOopsEnabled;
 131 
 132   // command line flags supplied to VM - see struct Flag in globals.hpp
 133   public static final class Flag {
 134      private String type;
 135      private String name;
 136      private Address addr;
 137      private String kind;
 138      private int origin;
 139 
 140      private Flag(String type, String name, Address addr, String kind, int origin) {
 141         this.type = type;
 142         this.name = name;
 143         this.addr = addr;
 144         this.kind = kind;
 145         this.origin = origin;
 146      }
 147 
 148      public String getType() {
 149         return type;
 150      }
 151 
 152      public String getName() {
 153         return name;
 154      }
 155 
 156      public Address getAddress() {
 157         return addr;
 158      }
 159 
 160      public String getKind() {
 161         return kind;
 162      }
 163 
 164      public int getOrigin() {
 165         return origin;
 166      }
 167 
 168      public boolean isBool() {
 169         return type.equals("bool");
 170      }
 171 
 172      public boolean getBool() {
 173         if (Assert.ASSERTS_ENABLED) {
 174            Assert.that(isBool(), "not a bool flag!");
 175         }
 176         return addr.getCIntegerAt(0, boolType.getSize(), boolType.isUnsigned())
 177                != 0;
 178      }
 179 
 180      public boolean isIntx() {
 181         return type.equals("intx");
 182      }
 183 
 184      public long getIntx() {
 185         if (Assert.ASSERTS_ENABLED) {
 186            Assert.that(isIntx(), "not a intx flag!");
 187         }


 793        readCommandLineFlags();
 794     }
 795 
 796     return commandLineFlags;
 797   }
 798 
 799   public Flag getCommandLineFlag(String name) {
 800     if (flagsMap == null) {
 801       flagsMap = new HashMap();
 802       Flag[] flags = getCommandLineFlags();
 803       for (int i = 0; i < flags.length; i++) {
 804         flagsMap.put(flags[i].getName(), flags[i]);
 805       }
 806     }
 807     return (Flag) flagsMap.get(name);
 808   }
 809 
 810   private void readCommandLineFlags() {
 811     // get command line flags
 812     TypeDataBase db = getTypeDataBase();

 813     Type flagType = db.lookupType("Flag");
 814     int numFlags = (int) flagType.getCIntegerField("numFlags").getValue();
 815     // NOTE: last flag contains null values.
 816     commandLineFlags = new Flag[numFlags - 1];
 817 
 818     Address flagAddr = flagType.getAddressField("flags").getValue();
 819 
 820     AddressField typeFld = flagType.getAddressField("type");
 821     AddressField nameFld = flagType.getAddressField("name");
 822     AddressField addrFld = flagType.getAddressField("addr");
 823     AddressField kindFld = flagType.getAddressField("kind");
 824     CIntField originFld = new CIntField(flagType.getCIntegerField("origin"), 0);
 825 
 826     long flagSize = flagType.getSize(); // sizeof(Flag)
 827 
 828     // NOTE: last flag contains null values.
 829     for (int f = 0; f < numFlags - 1; f++) {
 830       String type = CStringUtilities.getString(typeFld.getValue(flagAddr));
 831       String name = CStringUtilities.getString(nameFld.getValue(flagAddr));
 832       Address addr = addrFld.getValue(flagAddr);
 833       String kind = CStringUtilities.getString(kindFld.getValue(flagAddr));
 834       int origin = (int)originFld.getValue(flagAddr);
 835       commandLineFlags[f] = new Flag(type, name, addr, kind, origin);
 836       flagAddr = flagAddr.addOffsetTo(flagSize);
 837     }
 838 
 839     // sort flags by name
 840     Arrays.sort(commandLineFlags, new Comparator() {
 841         public int compare(Object o1, Object o2) {
 842           Flag f1 = (Flag) o1;
 843           Flag f2 = (Flag) o2;
 844           return f1.getName().compareTo(f2.getName());
 845         }
 846       });


 847   }

 848 
 849   public String getSystemProperty(String key) {
 850     Properties props = getSystemProperties();
 851     return (props != null)? props.getProperty(key) : null;
 852   }
 853 
 854   public Properties getSystemProperties() {
 855     if (sysProps == null) {
 856        readSystemProperties();
 857     }
 858     return sysProps;
 859   }
 860 
 861   private void readSystemProperties() {
 862     final InstanceKlass systemKls = getSystemDictionary().getSystemKlass();
 863     systemKls.iterateStaticFields(new DefaultOopVisitor() {
 864         ObjectReader objReader = new ObjectReader();
 865         public void doOop(sun.jvm.hotspot.oops.OopField field, boolean isVMField) {
 866           if (field.getID().getName().equals("props")) {
 867             try {
agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File