< prev index next >

src/cpu/aarch64/vm/macroAssembler_aarch64.cpp

Print this page
rev 9428 : 8143219: AArch64 broken by 8141132: JEP 254: Compact Strings
Reviewed-by: kvn


4016   }
4017 }
4018 
4019 
4020 // Search for str1 in str2 and return index or -1
4021 void MacroAssembler::string_indexof(Register str2, Register str1,
4022                                     Register cnt2, Register cnt1,
4023                                     Register tmp1, Register tmp2,
4024                                     Register tmp3, Register tmp4,
4025                                     int icnt1, Register result) {
4026   Label BM, LINEARSEARCH, DONE, NOMATCH, MATCH;
4027 
4028   Register ch1 = rscratch1;
4029   Register ch2 = rscratch2;
4030   Register cnt1tmp = tmp1;
4031   Register cnt2tmp = tmp2;
4032   Register cnt1_neg = cnt1;
4033   Register cnt2_neg = cnt2;
4034   Register result_tmp = tmp4;
4035 
4036   // Note, inline_string_indexOf() generates checks:
4037   // if (substr.count > string.count) return -1;
4038   // if (substr.count == 0) return 0;
4039 
4040 // We have two strings, a source string in str2, cnt2 and a pattern string
4041 // in str1, cnt1. Find the 1st occurence of pattern in source or return -1.







4042 
4043 // For larger pattern and source we use a simplified Boyer Moore algorithm.
4044 // With a small pattern and source we use linear scan.
4045 
4046   if (icnt1 == -1) {
4047     cmp(cnt1, 256);             // Use Linear Scan if cnt1 < 8 || cnt1 >= 256
4048     ccmp(cnt1, 8, 0b0000, LO);  // Can't handle skip >= 256 because we use
4049     br(LO, LINEARSEARCH);       // a byte array.
4050     cmp(cnt1, cnt2, LSR, 2);    // Source must be 4 * pattern for BM
4051     br(HS, LINEARSEARCH);
4052   }
4053 
4054 // The Boyer Moore alogorithm is based on the description here:-
4055 //
4056 // http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm
4057 //
4058 // This describes and algorithm with 2 shift rules. The 'Bad Character' rule
4059 // and the 'Good Suffix' rule.
4060 //
4061 // These rules are essentially heuristics for how far we can shift the




4016   }
4017 }
4018 
4019 
4020 // Search for str1 in str2 and return index or -1
4021 void MacroAssembler::string_indexof(Register str2, Register str1,
4022                                     Register cnt2, Register cnt1,
4023                                     Register tmp1, Register tmp2,
4024                                     Register tmp3, Register tmp4,
4025                                     int icnt1, Register result) {
4026   Label BM, LINEARSEARCH, DONE, NOMATCH, MATCH;
4027 
4028   Register ch1 = rscratch1;
4029   Register ch2 = rscratch2;
4030   Register cnt1tmp = tmp1;
4031   Register cnt2tmp = tmp2;
4032   Register cnt1_neg = cnt1;
4033   Register cnt2_neg = cnt2;
4034   Register result_tmp = tmp4;
4035 




4036 // We have two strings, a source string in str2, cnt2 and a pattern string
4037 // in str1, cnt1. Find the 1st occurence of pattern in source or return -1.
4038 
4039   // if (substr.count > string.count) return -1;
4040   cmp(cnt1, cnt2);
4041   br(Assembler::GT, NOMATCH);
4042 
4043   // Note, inline_string_indexOf() generates checks:
4044   // if (substr.count == 0) return 0;
4045 
4046 // For larger pattern and source we use a simplified Boyer Moore algorithm.
4047 // With a small pattern and source we use linear scan.
4048 
4049   if (icnt1 == -1) {
4050     cmp(cnt1, 256);             // Use Linear Scan if cnt1 < 8 || cnt1 >= 256
4051     ccmp(cnt1, 8, 0b0000, LO);  // Can't handle skip >= 256 because we use
4052     br(LO, LINEARSEARCH);       // a byte array.
4053     cmp(cnt1, cnt2, LSR, 2);    // Source must be 4 * pattern for BM
4054     br(HS, LINEARSEARCH);
4055   }
4056 
4057 // The Boyer Moore alogorithm is based on the description here:-
4058 //
4059 // http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm
4060 //
4061 // This describes and algorithm with 2 shift rules. The 'Bad Character' rule
4062 // and the 'Good Suffix' rule.
4063 //
4064 // These rules are essentially heuristics for how far we can shift the


< prev index next >