Mercurial > hg > graal-jvmci-8
comparison src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp @ 6057:8f972594effc
6924259: Remove String.count/String.offset
Summary: Allow a version of String class that doesn't have count and offset fields.
Reviewed-by: never, coleenp
author | kvn |
---|---|
date | Mon, 14 May 2012 09:36:00 -0700 |
parents | 701a83c86f28 |
children | 1d7922586cf6 |
comparison
equal
deleted
inserted
replaced
6054:56d1af561395 | 6057:8f972594effc |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
236 | 236 |
237 Label Ldone; | 237 Label Ldone; |
238 | 238 |
239 Register result = dst->as_register(); | 239 Register result = dst->as_register(); |
240 { | 240 { |
241 // Get a pointer to the first character of string0 in tmp0 and get string0.count in str0 | 241 // Get a pointer to the first character of string0 in tmp0 |
242 // Get a pointer to the first character of string1 in tmp1 and get string1.count in str1 | 242 // and get string0.length() in str0 |
243 // Also, get string0.count-string1.count in o7 and get the condition code set | 243 // Get a pointer to the first character of string1 in tmp1 |
244 // and get string1.length() in str1 | |
245 // Also, get string0.length()-string1.length() in | |
246 // o7 and get the condition code set | |
244 // Note: some instructions have been hoisted for better instruction scheduling | 247 // Note: some instructions have been hoisted for better instruction scheduling |
245 | 248 |
246 Register tmp0 = L0; | 249 Register tmp0 = L0; |
247 Register tmp1 = L1; | 250 Register tmp1 = L1; |
248 Register tmp2 = L2; | 251 Register tmp2 = L2; |
249 | 252 |
250 int value_offset = java_lang_String:: value_offset_in_bytes(); // char array | 253 int value_offset = java_lang_String:: value_offset_in_bytes(); // char array |
251 int offset_offset = java_lang_String::offset_offset_in_bytes(); // first character position | 254 if (java_lang_String::has_offset_field()) { |
252 int count_offset = java_lang_String:: count_offset_in_bytes(); | 255 int offset_offset = java_lang_String::offset_offset_in_bytes(); // first character position |
253 | 256 int count_offset = java_lang_String:: count_offset_in_bytes(); |
254 __ load_heap_oop(str0, value_offset, tmp0); | 257 __ load_heap_oop(str0, value_offset, tmp0); |
255 __ ld(str0, offset_offset, tmp2); | 258 __ ld(str0, offset_offset, tmp2); |
256 __ add(tmp0, arrayOopDesc::base_offset_in_bytes(T_CHAR), tmp0); | 259 __ add(tmp0, arrayOopDesc::base_offset_in_bytes(T_CHAR), tmp0); |
257 __ ld(str0, count_offset, str0); | 260 __ ld(str0, count_offset, str0); |
258 __ sll(tmp2, exact_log2(sizeof(jchar)), tmp2); | 261 __ sll(tmp2, exact_log2(sizeof(jchar)), tmp2); |
262 } else { | |
263 __ load_heap_oop(str0, value_offset, tmp1); | |
264 __ add(tmp1, arrayOopDesc::base_offset_in_bytes(T_CHAR), tmp0); | |
265 __ ld(tmp1, arrayOopDesc::length_offset_in_bytes(), str0); | |
266 } | |
259 | 267 |
260 // str1 may be null | 268 // str1 may be null |
261 add_debug_info_for_null_check_here(info); | 269 add_debug_info_for_null_check_here(info); |
262 | 270 |
263 __ load_heap_oop(str1, value_offset, tmp1); | 271 if (java_lang_String::has_offset_field()) { |
264 __ add(tmp0, tmp2, tmp0); | 272 int offset_offset = java_lang_String::offset_offset_in_bytes(); // first character position |
265 | 273 int count_offset = java_lang_String:: count_offset_in_bytes(); |
266 __ ld(str1, offset_offset, tmp2); | 274 __ load_heap_oop(str1, value_offset, tmp1); |
267 __ add(tmp1, arrayOopDesc::base_offset_in_bytes(T_CHAR), tmp1); | 275 __ add(tmp0, tmp2, tmp0); |
268 __ ld(str1, count_offset, str1); | 276 |
269 __ sll(tmp2, exact_log2(sizeof(jchar)), tmp2); | 277 __ ld(str1, offset_offset, tmp2); |
278 __ add(tmp1, arrayOopDesc::base_offset_in_bytes(T_CHAR), tmp1); | |
279 __ ld(str1, count_offset, str1); | |
280 __ sll(tmp2, exact_log2(sizeof(jchar)), tmp2); | |
281 __ add(tmp1, tmp2, tmp1); | |
282 } else { | |
283 __ load_heap_oop(str1, value_offset, tmp2); | |
284 __ add(tmp2, arrayOopDesc::base_offset_in_bytes(T_CHAR), tmp1); | |
285 __ ld(tmp2, arrayOopDesc::length_offset_in_bytes(), str1); | |
286 } | |
270 __ subcc(str0, str1, O7); | 287 __ subcc(str0, str1, O7); |
271 __ add(tmp1, tmp2, tmp1); | |
272 } | 288 } |
273 | 289 |
274 { | 290 { |
275 // Compute the minimum of the string lengths, scale it and store it in limit | 291 // Compute the minimum of the string lengths, scale it and store it in limit |
276 Register count0 = I0; | 292 Register count0 = I0; |
300 Register limit = L3; | 316 Register limit = L3; |
301 | 317 |
302 // Shift base0 and base1 to the end of the arrays, negate limit | 318 // Shift base0 and base1 to the end of the arrays, negate limit |
303 __ add(base0, limit, base0); | 319 __ add(base0, limit, base0); |
304 __ add(base1, limit, base1); | 320 __ add(base1, limit, base1); |
305 __ neg(limit); // limit = -min{string0.count, strin1.count} | 321 __ neg(limit); // limit = -min{string0.length(), string1.length()} |
306 | 322 |
307 __ lduh(base0, limit, chr0); | 323 __ lduh(base0, limit, chr0); |
308 __ bind(Lloop); | 324 __ bind(Lloop); |
309 __ lduh(base1, limit, chr1); | 325 __ lduh(base1, limit, chr1); |
310 __ subcc(chr0, chr1, chr0); | 326 __ subcc(chr0, chr1, chr0); |