src/share/vm/oops/symbol.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/oops

src/share/vm/oops/symbol.hpp

Print this page




 206     return as_C_string_flexible_buffer(t, buf, size);
 207   }
 208 
 209   jchar* as_unicode(int& length) const;
 210 
 211   // Treating this symbol as a class name, returns the Java name for the class.
 212   // String is allocated in resource area if buffer is not provided.
 213   // See Klass::external_name()
 214   const char* as_klass_external_name() const;
 215   const char* as_klass_external_name(char* buf, int size) const;
 216 
 217   // Printing
 218   void print_symbol_on(outputStream* st = NULL) const;
 219   void print_on(outputStream* st) const;         // First level print
 220   void print_value_on(outputStream* st) const;   // Second level print.
 221 
 222   // printing on default output stream
 223   void print()         { print_on(tty);       }
 224   void print_value()   { print_value_on(tty); }
 225 






















 226 #ifndef PRODUCT
 227   // Empty constructor to create a dummy symbol object on stack
 228   // only for getting its vtable pointer.
 229   Symbol() { }
 230 
 231   static int _total_count;
 232 #endif
 233 };
 234 
 235 // Note: this comparison is used for vtable sorting only; it doesn't matter
 236 // what order it defines, as long as it is a total, time-invariant order
 237 // Since Symbol*s are in C_HEAP, their relative order in memory never changes,
 238 // so use address comparison for speed
 239 int Symbol::fast_compare(Symbol* other) const {
 240  return (((uintptr_t)this < (uintptr_t)other) ? -1
 241    : ((uintptr_t)this == (uintptr_t) other) ? 0 : 1);
 242 }
 243 #endif // SHARE_VM_OOPS_SYMBOL_HPP


 206     return as_C_string_flexible_buffer(t, buf, size);
 207   }
 208 
 209   jchar* as_unicode(int& length) const;
 210 
 211   // Treating this symbol as a class name, returns the Java name for the class.
 212   // String is allocated in resource area if buffer is not provided.
 213   // See Klass::external_name()
 214   const char* as_klass_external_name() const;
 215   const char* as_klass_external_name(char* buf, int size) const;
 216 
 217   // Printing
 218   void print_symbol_on(outputStream* st = NULL) const;
 219   void print_on(outputStream* st) const;         // First level print
 220   void print_value_on(outputStream* st) const;   // Second level print.
 221 
 222   // printing on default output stream
 223   void print()         { print_on(tty);       }
 224   void print_value()   { print_value_on(tty); }
 225 
 226   // Allows two distinct Symbol objects to be considered equal as long as
 227   // they contain the same string. However, no two Symbol objects stored in the same
 228   // SymbolTable would contain the same string. Therefore, if two distinct Symbol
 229   // objects contain the same string, they must belong to different SymbolTables.
 230   inline bool equals(const Symbol* other) const {
 231     if (this && other) {
 232       int len = this->utf8_length();
 233       if (len != other->utf8_length()) {
 234         return false;
 235       }
 236       if (this->_identity_hash != other->_identity_hash) {
 237         return false;
 238       }
 239       return (strncmp((const char*)(this->base()), (const char*)(other->base()), len) == 0);
 240     } else {
 241       return (this == other);
 242     }
 243   }
 244   inline bool not_equals(const Symbol* other) const {
 245     return !(this->equals(other));
 246   }
 247 
 248 #ifndef PRODUCT
 249   // Empty constructor to create a dummy symbol object on stack
 250   // only for getting its vtable pointer.
 251   Symbol() { }
 252 
 253   static int _total_count;
 254 #endif
 255 };
 256 
 257 // Note: this comparison is used for vtable sorting only; it doesn't matter
 258 // what order it defines, as long as it is a total, time-invariant order
 259 // Since Symbol*s are in C_HEAP, their relative order in memory never changes,
 260 // so use address comparison for speed
 261 int Symbol::fast_compare(Symbol* other) const {
 262  return (((uintptr_t)this < (uintptr_t)other) ? -1
 263    : ((uintptr_t)this == (uintptr_t) other) ? 0 : 1);
 264 }
 265 #endif // SHARE_VM_OOPS_SYMBOL_HPP
src/share/vm/oops/symbol.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File