88 return value_offset;
89 }
90 static int hash_offset_in_bytes() {
91 assert(initialized && (hash_offset > 0), "Must be initialized");
92 return hash_offset;
93 }
94 static int coder_offset_in_bytes() {
95 assert(initialized && (coder_offset > 0), "Must be initialized");
96 return coder_offset;
97 }
98
99 static inline void set_value_raw(oop string, typeArrayOop buffer);
100 static inline void set_value(oop string, typeArrayOop buffer);
101 static inline void set_hash(oop string, unsigned int hash);
102
103 // Accessors
104 static inline typeArrayOop value(oop java_string);
105 static inline unsigned int hash(oop java_string);
106 static inline bool is_latin1(oop java_string);
107 static inline int length(oop java_string);
108 static int utf8_length(oop java_string);
109
110 // String converters
111 static char* as_utf8_string(oop java_string);
112 static char* as_utf8_string(oop java_string, char* buf, int buflen);
113 static char* as_utf8_string(oop java_string, int start, int len);
114 static char* as_utf8_string(oop java_string, int start, int len, char* buf, int buflen);
115 static char* as_platform_dependent_str(Handle java_string, TRAPS);
116 static jchar* as_unicode_string(oop java_string, int& length, TRAPS);
117 // produce an ascii string with all other values quoted using \u####
118 static char* as_quoted_ascii(oop java_string);
119
120 // Compute the hash value for a java.lang.String object which would
121 // contain the characters passed in.
122 //
123 // As the hash value used by the String object itself, in
124 // String.hashCode(). This value is normally calculated in Java code
125 // in the String.hashCode method(), but is precomputed for String
126 // objects in the shared archive file.
127 // hash P(31) from Kernighan & Ritchie
130 static unsigned int hash_code(const jchar* s, int len) {
131 unsigned int h = 0;
132 while (len-- > 0) {
133 h = 31*h + (unsigned int) *s;
134 s++;
135 }
136 return h;
137 }
138
139 static unsigned int hash_code(const jbyte* s, int len) {
140 unsigned int h = 0;
141 while (len-- > 0) {
142 h = 31*h + (((unsigned int) *s) & 0xFF);
143 s++;
144 }
145 return h;
146 }
147
148 static unsigned int hash_code(oop java_string);
149
150 static bool equals(oop java_string, jchar* chars, int len);
151 static bool equals(oop str1, oop str2);
152
153 // Conversion between '.' and '/' formats
154 static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); }
155 static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); }
156
157 // Conversion
158 static Symbol* as_symbol(oop java_string, TRAPS);
159 static Symbol* as_symbol_or_null(oop java_string);
160
161 // Testers
162 static bool is_instance(oop obj);
163 static inline bool is_instance_inlined(oop obj);
164
165 // Debugging
166 static void print(oop java_string, outputStream* st);
167 friend class JavaClasses;
168 friend class StringTable;
169 };
|
88 return value_offset;
89 }
90 static int hash_offset_in_bytes() {
91 assert(initialized && (hash_offset > 0), "Must be initialized");
92 return hash_offset;
93 }
94 static int coder_offset_in_bytes() {
95 assert(initialized && (coder_offset > 0), "Must be initialized");
96 return coder_offset;
97 }
98
99 static inline void set_value_raw(oop string, typeArrayOop buffer);
100 static inline void set_value(oop string, typeArrayOop buffer);
101 static inline void set_hash(oop string, unsigned int hash);
102
103 // Accessors
104 static inline typeArrayOop value(oop java_string);
105 static inline unsigned int hash(oop java_string);
106 static inline bool is_latin1(oop java_string);
107 static inline int length(oop java_string);
108 static inline int length(oop java_string, typeArrayOop value_array);
109 static int utf8_length(oop java_string);
110
111 // String converters
112 static char* as_utf8_string(oop java_string);
113 static char* as_utf8_string(oop java_string, char* buf, int buflen);
114 static char* as_utf8_string(oop java_string, int start, int len);
115 static char* as_utf8_string(oop java_string, int start, int len, char* buf, int buflen);
116 static char* as_platform_dependent_str(Handle java_string, TRAPS);
117 static jchar* as_unicode_string(oop java_string, int& length, TRAPS);
118 // produce an ascii string with all other values quoted using \u####
119 static char* as_quoted_ascii(oop java_string);
120
121 // Compute the hash value for a java.lang.String object which would
122 // contain the characters passed in.
123 //
124 // As the hash value used by the String object itself, in
125 // String.hashCode(). This value is normally calculated in Java code
126 // in the String.hashCode method(), but is precomputed for String
127 // objects in the shared archive file.
128 // hash P(31) from Kernighan & Ritchie
131 static unsigned int hash_code(const jchar* s, int len) {
132 unsigned int h = 0;
133 while (len-- > 0) {
134 h = 31*h + (unsigned int) *s;
135 s++;
136 }
137 return h;
138 }
139
140 static unsigned int hash_code(const jbyte* s, int len) {
141 unsigned int h = 0;
142 while (len-- > 0) {
143 h = 31*h + (((unsigned int) *s) & 0xFF);
144 s++;
145 }
146 return h;
147 }
148
149 static unsigned int hash_code(oop java_string);
150
151 static bool equals(typeArrayOop value, int length, oop java_string, jchar* chars, int len);
152 static bool equals(oop java_string, jchar* chars, int len);
153 static bool equals(oop str1, oop str2);
154
155 // Conversion between '.' and '/' formats
156 static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); }
157 static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); }
158
159 // Conversion
160 static Symbol* as_symbol(oop java_string, TRAPS);
161 static Symbol* as_symbol_or_null(oop java_string);
162
163 // Testers
164 static bool is_instance(oop obj);
165 static inline bool is_instance_inlined(oop obj);
166
167 // Debugging
168 static void print(oop java_string, outputStream* st);
169 friend class JavaClasses;
170 friend class StringTable;
171 };
|