Mercurial > hg > graal-jvmci-8
comparison src/cpu/x86/vm/c1_LIRAssembler_x86.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 | 3576af4cb939 |
children | 6759698e3140 |
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. |
503 __ movptr (rbx, rcx); // receiver is in rcx | 503 __ movptr (rbx, rcx); // receiver is in rcx |
504 __ movptr (rax, arg1->as_register()); | 504 __ movptr (rax, arg1->as_register()); |
505 | 505 |
506 // Get addresses of first characters from both Strings | 506 // Get addresses of first characters from both Strings |
507 __ load_heap_oop(rsi, Address(rax, java_lang_String::value_offset_in_bytes())); | 507 __ load_heap_oop(rsi, Address(rax, java_lang_String::value_offset_in_bytes())); |
508 __ movptr (rcx, Address(rax, java_lang_String::offset_offset_in_bytes())); | 508 if (java_lang_String::has_offset_field()) { |
509 __ lea (rsi, Address(rsi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR))); | 509 __ movptr (rcx, Address(rax, java_lang_String::offset_offset_in_bytes())); |
510 | 510 __ movl (rax, Address(rax, java_lang_String::count_offset_in_bytes())); |
511 __ lea (rsi, Address(rsi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR))); | |
512 } else { | |
513 __ movl (rax, Address(rsi, arrayOopDesc::length_offset_in_bytes())); | |
514 __ lea (rsi, Address(rsi, arrayOopDesc::base_offset_in_bytes(T_CHAR))); | |
515 } | |
511 | 516 |
512 // rbx, may be NULL | 517 // rbx, may be NULL |
513 add_debug_info_for_null_check_here(info); | 518 add_debug_info_for_null_check_here(info); |
514 __ load_heap_oop(rdi, Address(rbx, java_lang_String::value_offset_in_bytes())); | 519 __ load_heap_oop(rdi, Address(rbx, java_lang_String::value_offset_in_bytes())); |
515 __ movptr (rcx, Address(rbx, java_lang_String::offset_offset_in_bytes())); | 520 if (java_lang_String::has_offset_field()) { |
516 __ lea (rdi, Address(rdi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR))); | 521 __ movptr (rcx, Address(rbx, java_lang_String::offset_offset_in_bytes())); |
522 __ movl (rbx, Address(rbx, java_lang_String::count_offset_in_bytes())); | |
523 __ lea (rdi, Address(rdi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR))); | |
524 } else { | |
525 __ movl (rbx, Address(rdi, arrayOopDesc::length_offset_in_bytes())); | |
526 __ lea (rdi, Address(rdi, arrayOopDesc::base_offset_in_bytes(T_CHAR))); | |
527 } | |
517 | 528 |
518 // compute minimum length (in rax) and difference of lengths (on top of stack) | 529 // compute minimum length (in rax) and difference of lengths (on top of stack) |
519 __ movl (rbx, Address(rbx, java_lang_String::count_offset_in_bytes())); | |
520 __ movl (rax, Address(rax, java_lang_String::count_offset_in_bytes())); | |
521 __ mov (rcx, rbx); | 530 __ mov (rcx, rbx); |
522 __ subptr(rbx, rax); // subtract lengths | 531 __ subptr(rbx, rax); // subtract lengths |
523 __ push (rbx); // result | 532 __ push (rbx); // result |
524 __ cmov (Assembler::lessEqual, rax, rcx); | 533 __ cmov (Assembler::lessEqual, rax, rcx); |
525 | 534 |