< prev index next >

src/cpu/aarch64/vm/macroAssembler_aarch64.cpp

Print this page




4812   cbz(cnt2, LENGTH_DIFF);
4813 
4814   bind(SHORT_LOOP);
4815   (this->*str1_load_chr)(result, Address(post(str1, str1_chr_size)));
4816   (this->*str2_load_chr)(cnt1, Address(post(str2, str2_chr_size)));
4817   subw(result, result, cnt1);
4818   cbnz(result, DONE);
4819   sub(cnt2, cnt2, 1);
4820   cbnz(cnt2, SHORT_LOOP);
4821 
4822   // Strings are equal up to min length.  Return the length difference.
4823   bind(LENGTH_DIFF);
4824   mov(result, tmp1);
4825 
4826   // That's it
4827   bind(DONE);
4828 
4829   BLOCK_COMMENT("} string_compare");
4830 }
4831 
























































4832 // Compare Strings or char/byte arrays.
4833 
4834 // is_string is true iff this is a string comparison.
4835 
4836 // For Strings we're passed the address of the first characters in a1
4837 // and a2 and the length in cnt1.
4838 
4839 // For byte and char arrays we're passed the arrays themselves and we
4840 // have to extract length fields and do null checks here.
4841 
4842 // elem_size is the element size in bytes: either 1 or 2.
4843 
4844 // There are two implementations.  For arrays >= 8 bytes, all
4845 // comparisons (including the final one, which may overlap) are
4846 // performed 8 bytes at a time.  For arrays < 8 bytes, we compare a
4847 // halfword, then a short, and then a byte.
4848 
4849 void MacroAssembler::arrays_equals(Register a1, Register a2,
4850                                    Register result, Register cnt1,
4851                                    int elem_size, bool is_string)




4812   cbz(cnt2, LENGTH_DIFF);
4813 
4814   bind(SHORT_LOOP);
4815   (this->*str1_load_chr)(result, Address(post(str1, str1_chr_size)));
4816   (this->*str2_load_chr)(cnt1, Address(post(str2, str2_chr_size)));
4817   subw(result, result, cnt1);
4818   cbnz(result, DONE);
4819   sub(cnt2, cnt2, 1);
4820   cbnz(cnt2, SHORT_LOOP);
4821 
4822   // Strings are equal up to min length.  Return the length difference.
4823   bind(LENGTH_DIFF);
4824   mov(result, tmp1);
4825 
4826   // That's it
4827   bind(DONE);
4828 
4829   BLOCK_COMMENT("} string_compare");
4830 }
4831 
4832 // This method checks if provided byte array contains byte with highest bit set.
4833 void MacroAssembler::has_negatives(Register ary1, Register len, Register result) {
4834     // Simple and most common case of aligned small array which is not at the
4835     // end of memory page is placed here. All other cases are in stub.
4836     Label LOOP, END, STUB, STUB_LONG, SET_RESULT, DONE;
4837     const uint64_t UPPER_BIT_MASK=0x8080808080808080;
4838     assert_different_registers(ary1, len, result);
4839 
4840     cmpw(len, 0);
4841     br(LE, SET_RESULT);
4842     cmpw(len, 4 * wordSize);
4843     br(GE, STUB_LONG); // size > 32 then go to stub
4844 
4845     int shift = 64 - exact_log2(os::vm_page_size());
4846     lsl(rscratch1, ary1, shift);
4847     mov(rscratch2, (size_t)(4 * wordSize) << shift);
4848     adds(rscratch2, rscratch1, rscratch2);  // At end of page?
4849     br(CS, STUB); // at the end of page then go to stub
4850     subs(len, len, wordSize);
4851     br(LT, END);
4852 
4853   BIND(LOOP);
4854     ldr(rscratch1, Address(post(ary1, wordSize)));
4855     tst(rscratch1, UPPER_BIT_MASK);
4856     br(NE, SET_RESULT);
4857     subs(len, len, wordSize);
4858     br(GE, LOOP);
4859     cmpw(len, -wordSize);
4860     br(EQ, SET_RESULT);
4861 
4862   BIND(END);
4863     ldr(result, Address(ary1));
4864     sub(len, zr, len, LSL, 3); // LSL 3 is to get bits from bytes
4865     lslv(result, result, len);
4866     tst(result, UPPER_BIT_MASK);
4867     b(SET_RESULT);
4868 
4869   BIND(STUB);
4870     RuntimeAddress has_neg =  RuntimeAddress(StubRoutines::aarch64::has_negatives());
4871     assert(has_neg.target() != NULL, "has_negatives stub has not been generated");
4872     trampoline_call(has_neg);
4873     b(DONE);
4874 
4875   BIND(STUB_LONG);
4876     RuntimeAddress has_neg_long =  RuntimeAddress(
4877             StubRoutines::aarch64::has_negatives_long());
4878     assert(has_neg_long.target() != NULL, "has_negatives stub has not been generated");
4879     trampoline_call(has_neg_long);
4880     b(DONE); 
4881 
4882   BIND(SET_RESULT);
4883     cset(result, NE); // set true or false
4884 
4885   BIND(DONE);
4886 }
4887 
4888 // Compare Strings or char/byte arrays.
4889 
4890 // is_string is true iff this is a string comparison.
4891 
4892 // For Strings we're passed the address of the first characters in a1
4893 // and a2 and the length in cnt1.
4894 
4895 // For byte and char arrays we're passed the arrays themselves and we
4896 // have to extract length fields and do null checks here.
4897 
4898 // elem_size is the element size in bytes: either 1 or 2.
4899 
4900 // There are two implementations.  For arrays >= 8 bytes, all
4901 // comparisons (including the final one, which may overlap) are
4902 // performed 8 bytes at a time.  For arrays < 8 bytes, we compare a
4903 // halfword, then a short, and then a byte.
4904 
4905 void MacroAssembler::arrays_equals(Register a1, Register a2,
4906                                    Register result, Register cnt1,
4907                                    int elem_size, bool is_string)


< prev index next >