hotspot/src/share/vm/oops/symbol.hpp
changeset 34666 1c7168ea0034
parent 33468 b82c87453d2d
child 35898 ddc274f0052f
equal deleted inserted replaced
34665:9fdcc78b5398 34666:1c7168ea0034
   146   const jbyte* base() const { return &_body[0]; }
   146   const jbyte* base() const { return &_body[0]; }
   147 
   147 
   148   int size()                { return size(utf8_length()); }
   148   int size()                { return size(utf8_length()); }
   149 
   149 
   150   // Returns the largest size symbol we can safely hold.
   150   // Returns the largest size symbol we can safely hold.
   151   static int max_length()   { return max_symbol_length; }
   151   static int max_length() { return max_symbol_length; }
   152   unsigned identity_hash() {
   152   unsigned identity_hash() const {
   153     unsigned addr_bits = (unsigned)((uintptr_t)this >> (LogMinObjAlignmentInBytes + 3));
   153     unsigned addr_bits = (unsigned)((uintptr_t)this >> (LogMinObjAlignmentInBytes + 3));
   154     return ((unsigned)_identity_hash & 0xffff) |
   154     return ((unsigned)_identity_hash & 0xffff) |
   155            ((addr_bits ^ (_length << 8) ^ (( _body[0] << 8) | _body[1])) << 16);
   155            ((addr_bits ^ (_length << 8) ^ (( _body[0] << 8) | _body[1])) << 16);
   156   }
   156   }
   157 
   157 
   195     return index_of_at(i, str, (int) strlen(str));
   195     return index_of_at(i, str, (int) strlen(str));
   196   }
   196   }
   197 
   197 
   198   // Three-way compare for sorting; returns -1/0/1 if receiver is </==/> than arg
   198   // Three-way compare for sorting; returns -1/0/1 if receiver is </==/> than arg
   199   // note that the ordering is not alfabetical
   199   // note that the ordering is not alfabetical
   200   inline int fast_compare(Symbol* other) const;
   200   inline int fast_compare(const Symbol* other) const;
   201 
   201 
   202   // Returns receiver converted to null-terminated UTF-8 string; string is
   202   // Returns receiver converted to null-terminated UTF-8 string; string is
   203   // allocated in resource area, or in the char buffer provided by caller.
   203   // allocated in resource area, or in the char buffer provided by caller.
   204   char* as_C_string() const;
   204   char* as_C_string() const;
   205   char* as_C_string(char* buf, int size) const;
   205   char* as_C_string(char* buf, int size) const;
   244 
   244 
   245 // Note: this comparison is used for vtable sorting only; it doesn't matter
   245 // Note: this comparison is used for vtable sorting only; it doesn't matter
   246 // what order it defines, as long as it is a total, time-invariant order
   246 // what order it defines, as long as it is a total, time-invariant order
   247 // Since Symbol*s are in C_HEAP, their relative order in memory never changes,
   247 // Since Symbol*s are in C_HEAP, their relative order in memory never changes,
   248 // so use address comparison for speed
   248 // so use address comparison for speed
   249 int Symbol::fast_compare(Symbol* other) const {
   249 int Symbol::fast_compare(const Symbol* other) const {
   250  return (((uintptr_t)this < (uintptr_t)other) ? -1
   250  return (((uintptr_t)this < (uintptr_t)other) ? -1
   251    : ((uintptr_t)this == (uintptr_t) other) ? 0 : 1);
   251    : ((uintptr_t)this == (uintptr_t) other) ? 0 : 1);
   252 }
   252 }
   253 #endif // SHARE_VM_OOPS_SYMBOL_HPP
   253 #endif // SHARE_VM_OOPS_SYMBOL_HPP