< prev index next >

src/hotspot/share/oops/symbol.hpp

Print this page

        

*** 110,120 **** // This is an int because it needs atomic operation on the refcount. Mask length // in high half word. length is the number of UTF8 characters in the symbol volatile uint32_t _length_and_refcount; short _identity_hash; ! jbyte _body[2]; enum { // max_symbol_length must fit into the top 16 bits of _length_and_refcount max_symbol_length = (1 << 16) -1 }; --- 110,120 ---- // This is an int because it needs atomic operation on the refcount. Mask length // in high half word. length is the number of UTF8 characters in the symbol volatile uint32_t _length_and_refcount; short _identity_hash; ! u1 _body[2]; enum { // max_symbol_length must fit into the top 16 bits of _length_and_refcount max_symbol_length = (1 << 16) -1 };
*** 126,136 **** static int size(int length) { // minimum number of natural words needed to hold these bits (no non-heap version) return (int)heap_word_size(byte_size(length)); } ! void byte_at_put(int index, int value) { assert(index >=0 && index < length(), "symbol index overflow"); _body[index] = value; } Symbol(const u1* name, int length, int refcount); --- 126,136 ---- static int size(int length) { // minimum number of natural words needed to hold these bits (no non-heap version) return (int)heap_word_size(byte_size(length)); } ! void byte_at_put(int index, u1 value) { assert(index >=0 && index < length(), "symbol index overflow"); _body[index] = value; } Symbol(const u1* name, int length, int refcount);
*** 146,156 **** int length() const { return extract_length(_length_and_refcount); } public: // Low-level access (used with care, since not GC-safe) ! const jbyte* base() const { return &_body[0]; } int size() { return size(utf8_length()); } int byte_size() { return byte_size(utf8_length()); } // Symbols should be stored in the read-only region of CDS archive. --- 146,156 ---- int length() const { return extract_length(_length_and_refcount); } public: // Low-level access (used with care, since not GC-safe) ! const u1* base() const { return &_body[0]; } int size() { return size(utf8_length()); } int byte_size() { return byte_size(utf8_length()); } // Symbols should be stored in the read-only region of CDS archive.
*** 174,198 **** void decrement_refcount(); bool is_permanent() { return (refcount() == PERM_REFCOUNT); } ! int byte_at(int index) const { assert(index >=0 && index < length(), "symbol index overflow"); return base()[index]; } ! const jbyte* bytes() const { return base(); } int utf8_length() const { return length(); } // Compares the symbol with a string. bool equals(const char* str, int len) const { int l = utf8_length(); if (l != len) return false; while (l-- > 0) { ! if (str[l] != (char) byte_at(l)) return false; } assert(l == -1, "we should be at the beginning"); return true; } --- 174,212 ---- void decrement_refcount(); bool is_permanent() { return (refcount() == PERM_REFCOUNT); } ! // The byte_at() and char_at() functions return the same values but as ! // different types. Function byte_at() should be called when the unsigned ! // value of the byte is wanted. Function char_at() should be called when the ! // result is going to be used as a char, such as when comparing the result ! // to ']'. ! // ! // Note that all multi-byte chars have the sign bit set on all their bytes. ! // No single byte chars have their sign bit set. ! ! u1 byte_at(int index) const { ! assert(index >=0 && index < length(), "symbol index overflow"); ! return base()[index]; ! } ! ! char char_at(int index) const { assert(index >=0 && index < length(), "symbol index overflow"); return base()[index]; } ! const u1* bytes() const { return base(); } int utf8_length() const { return length(); } // Compares the symbol with a string. bool equals(const char* str, int len) const { int l = utf8_length(); if (l != len) return false; while (l-- > 0) { ! if (str[l] != char_at(l)) return false; } assert(l == -1, "we should be at the beginning"); return true; }
< prev index next >