1 //
2 // Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
3 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 //
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
7 // published by the Free Software Foundation.
8 //
9 // This code is distributed in the hope that it will be useful, but WITHOUT
10 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 // version 2 for more details (a copy is included in the LICENSE file that
13 // accompanied this code).
14 //
15 // You should have received a copy of the GNU General Public License version
16 // 2 along with this work; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 // or visit www.oracle.com if you need additional information or have any
21 // questions.
22 //
2979 __ lduh(str1_reg, limit_reg, chr1_reg);
2980 __ bind(Lloop);
2981 // __ lduh(str1_reg, limit_reg, chr1_reg); // hoisted
2982 __ lduh(str2_reg, limit_reg, chr2_reg);
2983 __ subcc(chr1_reg, chr2_reg, chr1_reg);
2984 __ br(Assembler::notZero, false, Assembler::pt, Ldone);
2985 assert(chr1_reg == result_reg, "result must be pre-placed");
2986 __ delayed()->inccc(limit_reg, sizeof(jchar));
2987 // annul LDUH if branch is not taken to prevent access past end of string
2988 __ br(Assembler::notZero, true, Assembler::pt, Lloop);
2989 __ delayed()->lduh(str1_reg, limit_reg, chr1_reg); // hoisted
2990
2991 // If strings are equal up to min length, return the length difference.
2992 __ mov(O7, result_reg);
2993
2994 // Otherwise, return the difference between the first mismatched chars.
2995 __ bind(Ldone);
2996 %}
2997
2998 enc_class enc_String_Equals(o0RegP str1, o1RegP str2, g3RegI cnt, notemp_iRegI result) %{
2999 Label Lword_loop, Lpost_word, Lchar, Lchar_loop, Ldone;
3000 MacroAssembler _masm(&cbuf);
3001
3002 Register str1_reg = reg_to_register_object($str1$$reg);
3003 Register str2_reg = reg_to_register_object($str2$$reg);
3004 Register cnt_reg = reg_to_register_object($cnt$$reg);
3005 Register tmp1_reg = O7;
3006 Register result_reg = reg_to_register_object($result$$reg);
3007
3008 assert(result_reg != str1_reg &&
3009 result_reg != str2_reg &&
3010 result_reg != cnt_reg &&
3011 result_reg != tmp1_reg ,
3012 "need different registers");
3013
3014 __ cmp(str1_reg, str2_reg); //same char[] ?
3015 __ brx(Assembler::equal, true, Assembler::pn, Ldone);
3016 __ delayed()->add(G0, 1, result_reg);
3017
3018 __ cmp_zero_and_br(Assembler::zero, cnt_reg, Ldone, true, Assembler::pn);
3019 __ delayed()->add(G0, 1, result_reg); // count == 0
|
1 //
2 // Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
3 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 //
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
7 // published by the Free Software Foundation.
8 //
9 // This code is distributed in the hope that it will be useful, but WITHOUT
10 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 // version 2 for more details (a copy is included in the LICENSE file that
13 // accompanied this code).
14 //
15 // You should have received a copy of the GNU General Public License version
16 // 2 along with this work; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 // or visit www.oracle.com if you need additional information or have any
21 // questions.
22 //
2979 __ lduh(str1_reg, limit_reg, chr1_reg);
2980 __ bind(Lloop);
2981 // __ lduh(str1_reg, limit_reg, chr1_reg); // hoisted
2982 __ lduh(str2_reg, limit_reg, chr2_reg);
2983 __ subcc(chr1_reg, chr2_reg, chr1_reg);
2984 __ br(Assembler::notZero, false, Assembler::pt, Ldone);
2985 assert(chr1_reg == result_reg, "result must be pre-placed");
2986 __ delayed()->inccc(limit_reg, sizeof(jchar));
2987 // annul LDUH if branch is not taken to prevent access past end of string
2988 __ br(Assembler::notZero, true, Assembler::pt, Lloop);
2989 __ delayed()->lduh(str1_reg, limit_reg, chr1_reg); // hoisted
2990
2991 // If strings are equal up to min length, return the length difference.
2992 __ mov(O7, result_reg);
2993
2994 // Otherwise, return the difference between the first mismatched chars.
2995 __ bind(Ldone);
2996 %}
2997
2998 enc_class enc_String_Equals(o0RegP str1, o1RegP str2, g3RegI cnt, notemp_iRegI result) %{
2999 Label Lchar, Lchar_loop, Ldone;
3000 MacroAssembler _masm(&cbuf);
3001
3002 Register str1_reg = reg_to_register_object($str1$$reg);
3003 Register str2_reg = reg_to_register_object($str2$$reg);
3004 Register cnt_reg = reg_to_register_object($cnt$$reg);
3005 Register tmp1_reg = O7;
3006 Register result_reg = reg_to_register_object($result$$reg);
3007
3008 assert(result_reg != str1_reg &&
3009 result_reg != str2_reg &&
3010 result_reg != cnt_reg &&
3011 result_reg != tmp1_reg ,
3012 "need different registers");
3013
3014 __ cmp(str1_reg, str2_reg); //same char[] ?
3015 __ brx(Assembler::equal, true, Assembler::pn, Ldone);
3016 __ delayed()->add(G0, 1, result_reg);
3017
3018 __ cmp_zero_and_br(Assembler::zero, cnt_reg, Ldone, true, Assembler::pn);
3019 __ delayed()->add(G0, 1, result_reg); // count == 0
|