140 static unsigned int hash(oop java_string) {
141 assert(initialized && (hash_offset > 0), "Must be initialized");
142 assert(is_instance(java_string), "must be java_string");
143 return java_string->int_field(hash_offset);
144 }
145 static int offset(oop java_string) {
146 assert(initialized, "Must be initialized");
147 assert(is_instance(java_string), "must be java_string");
148 if (offset_offset > 0) {
149 return java_string->int_field(offset_offset);
150 } else {
151 return 0;
152 }
153 }
154 static int length(oop java_string) {
155 assert(initialized, "Must be initialized");
156 assert(is_instance(java_string), "must be java_string");
157 if (count_offset > 0) {
158 return java_string->int_field(count_offset);
159 } else {
160 return ((typeArrayOop)java_string->obj_field(value_offset))->length();
161 }
162 }
163 static int utf8_length(oop java_string);
164
165 // String converters
166 static char* as_utf8_string(oop java_string);
167 static char* as_utf8_string(oop java_string, char* buf, int buflen);
168 static char* as_utf8_string(oop java_string, int start, int len);
169 static char* as_utf8_string(oop java_string, int start, int len, char* buf, int buflen);
170 static char* as_platform_dependent_str(Handle java_string, TRAPS);
171 static jchar* as_unicode_string(oop java_string, int& length, TRAPS);
172 // produce an ascii string with all other values quoted using \u####
173 static char* as_quoted_ascii(oop java_string);
174
175 // Compute the hash value for a java.lang.String object which would
176 // contain the characters passed in.
177 //
178 // As the hash value used by the String object itself, in
179 // String.hashCode(). This value is normally calculated in Java code
180 // in the String.hashCode method(), but is precomputed for String
|
140 static unsigned int hash(oop java_string) {
141 assert(initialized && (hash_offset > 0), "Must be initialized");
142 assert(is_instance(java_string), "must be java_string");
143 return java_string->int_field(hash_offset);
144 }
145 static int offset(oop java_string) {
146 assert(initialized, "Must be initialized");
147 assert(is_instance(java_string), "must be java_string");
148 if (offset_offset > 0) {
149 return java_string->int_field(offset_offset);
150 } else {
151 return 0;
152 }
153 }
154 static int length(oop java_string) {
155 assert(initialized, "Must be initialized");
156 assert(is_instance(java_string), "must be java_string");
157 if (count_offset > 0) {
158 return java_string->int_field(count_offset);
159 } else {
160 oop value = java_string->obj_field(value_offset);
161 if (ShenandoahVerifyReadsToFromSpace) {
162 value = oopDesc::bs()->read_barrier(value);
163 }
164 return ((typeArrayOop) value)->length();
165 }
166 }
167 static int utf8_length(oop java_string);
168
169 // String converters
170 static char* as_utf8_string(oop java_string);
171 static char* as_utf8_string(oop java_string, char* buf, int buflen);
172 static char* as_utf8_string(oop java_string, int start, int len);
173 static char* as_utf8_string(oop java_string, int start, int len, char* buf, int buflen);
174 static char* as_platform_dependent_str(Handle java_string, TRAPS);
175 static jchar* as_unicode_string(oop java_string, int& length, TRAPS);
176 // produce an ascii string with all other values quoted using \u####
177 static char* as_quoted_ascii(oop java_string);
178
179 // Compute the hash value for a java.lang.String object which would
180 // contain the characters passed in.
181 //
182 // As the hash value used by the String object itself, in
183 // String.hashCode(). This value is normally calculated in Java code
184 // in the String.hashCode method(), but is precomputed for String
|