< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Symbol.java

Print this page
@  rev 51710 : 8204308: SA: serviceability/sa/TestInstanceKlassSize*.java fails when running in CDS mode
|  Summary: Use longs instead of ints while computing the identity hash of klass symbols
~  Reviewed-by: coleenp, lfoltan
o  rev 50929 : 8205534: Remove SymbolTable dependency from serviceability agent
|  Reviewed-by: gziemski, poonam, jgeorge, hseigel
~


  66   Symbol(Address addr) {
  67     super(addr);
  68   }
  69 
  70   public boolean isSymbol()            { return true; }
  71 
  72   private static long baseOffset; // tells where the array part starts
  73 
  74   // Fields
  75   private static CIntegerField length;
  76 
  77   // Accessors for declared fields
  78   public long   getLength() { return          length.getValue(this.addr); }
  79 
  80   public byte getByteAt(long index) {
  81     return addr.getJByteAt(baseOffset + index);
  82   }
  83   // _identity_hash is a short
  84   private static CIntegerField idHash;
  85 
  86   public int identityHash() {
  87     long addr_value = getAddress().asLongValue();
  88     int  addr_bits = (int)(addr_value >> (VM.getVM().getLogMinObjAlignmentInBytes() + 3));

  89     int  length = (int)getLength();
  90     int  byte0 = getByteAt(0);
  91     int  byte1 = getByteAt(1);
  92     int  id_hash = (int)(0xffff & idHash.getValue(this.addr));
  93     return id_hash |
  94            ((addr_bits ^ (length << 8) ^ ((byte0 << 8) | byte1)) << 16);
  95   }
  96 
  97   public boolean equals(byte[] modUTF8Chars) {
  98     int l = (int) getLength();
  99     if (l != modUTF8Chars.length) return false;
 100     while (l-- > 0) {
 101       if (modUTF8Chars[l] != getByteAt(l)) return false;
 102     }
 103     if (Assert.ASSERTS_ENABLED) {
 104       Assert.that(l == -1, "we should be at the beginning");
 105     }
 106     return true;
 107   }
 108 
 109   public byte[] asByteArray() {
 110     int length = (int) getLength();
 111     byte [] result = new byte [length];
 112     for (int index = 0; index < length; index++) {
 113       result[index] = getByteAt(index);
 114     }




  66   Symbol(Address addr) {
  67     super(addr);
  68   }
  69 
  70   public boolean isSymbol()            { return true; }
  71 
  72   private static long baseOffset; // tells where the array part starts
  73 
  74   // Fields
  75   private static CIntegerField length;
  76 
  77   // Accessors for declared fields
  78   public long   getLength() { return          length.getValue(this.addr); }
  79 
  80   public byte getByteAt(long index) {
  81     return addr.getJByteAt(baseOffset + index);
  82   }
  83   // _identity_hash is a short
  84   private static CIntegerField idHash;
  85 
  86   public long identityHash() {
  87     long addr_value = getAddress().asLongValue();
  88     long addr_bits =
  89       (addr_value >> (VM.getVM().getLogMinObjAlignmentInBytes() + 3)) & 0xffffffffL;
  90     int  length = (int)getLength();
  91     int  byte0 = getByteAt(0);
  92     int  byte1 = getByteAt(1);
  93     long id_hash = 0xffffL & (long)idHash.getValue(this.addr);
  94     return (id_hash |
  95       ((addr_bits ^ (length << 8) ^ ((byte0 << 8) | byte1)) << 16)) & 0xffffffffL;
  96   }
  97 
  98   public boolean equals(byte[] modUTF8Chars) {
  99     int l = (int) getLength();
 100     if (l != modUTF8Chars.length) return false;
 101     while (l-- > 0) {
 102       if (modUTF8Chars[l] != getByteAt(l)) return false;
 103     }
 104     if (Assert.ASSERTS_ENABLED) {
 105       Assert.that(l == -1, "we should be at the beginning");
 106     }
 107     return true;
 108   }
 109 
 110   public byte[] asByteArray() {
 111     int length = (int) getLength();
 112     byte [] result = new byte [length];
 113     for (int index = 0; index < length; index++) {
 114       result[index] = getByteAt(index);
 115     }


< prev index next >