src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Symbol.java
changeset 51179 516acf6956a2
parent 50929 ef57cfcd22ff
child 51531 948c62200f8c
equal deleted inserted replaced
51178:416a76fe8067 51179:516acf6956a2
    43       });
    43       });
    44   }
    44   }
    45 
    45 
    46   private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
    46   private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
    47     Type type  = db.lookupType("Symbol");
    47     Type type  = db.lookupType("Symbol");
    48     length     = type.getCIntegerField("_length");
    48     lengthAndRefcount = type.getCIntegerField("_length_and_refcount");
    49     baseOffset = type.getField("_body").getOffset();
    49     baseOffset = type.getField("_body").getOffset();
    50     idHash = type.getCIntegerField("_identity_hash");
    50     idHash = type.getCIntegerField("_identity_hash");
    51   }
    51   }
    52 
       
    53   // Format:
       
    54   //   [header]
       
    55   //   [klass ]
       
    56   //   [length] byte size of uft8 string
       
    57   //   ..body..
       
    58 
    52 
    59   public static Symbol create(Address addr) {
    53   public static Symbol create(Address addr) {
    60     if (addr == null) {
    54     if (addr == null) {
    61       return null;
    55       return null;
    62     }
    56     }
    70   public boolean isSymbol()            { return true; }
    64   public boolean isSymbol()            { return true; }
    71 
    65 
    72   private static long baseOffset; // tells where the array part starts
    66   private static long baseOffset; // tells where the array part starts
    73 
    67 
    74   // Fields
    68   // Fields
    75   private static CIntegerField length;
    69   private static CIntegerField lengthAndRefcount;
    76 
    70 
    77   // Accessors for declared fields
    71   // Accessors for declared fields
    78   public long   getLength() { return          length.getValue(this.addr); }
    72   public long getLength() {
       
    73     long i = lengthAndRefcount.getValue(this.addr);
       
    74     return (i >> 16) & 0xffff;
       
    75   }
    79 
    76 
    80   public byte getByteAt(long index) {
    77   public byte getByteAt(long index) {
    81     return addr.getJByteAt(baseOffset + index);
    78     return addr.getJByteAt(baseOffset + index);
    82   }
    79   }
    83   // _identity_hash is a short
    80   // _identity_hash is a short