OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 BranchOrBacktrack(ne, on_not_at_start); | 228 BranchOrBacktrack(ne, on_not_at_start); |
229 } | 229 } |
230 | 230 |
231 | 231 |
232 void RegExpMacroAssemblerARM::CheckCharacterLT(uc16 limit, Label* on_less) { | 232 void RegExpMacroAssemblerARM::CheckCharacterLT(uc16 limit, Label* on_less) { |
233 __ cmp(current_character(), Operand(limit)); | 233 __ cmp(current_character(), Operand(limit)); |
234 BranchOrBacktrack(lt, on_less); | 234 BranchOrBacktrack(lt, on_less); |
235 } | 235 } |
236 | 236 |
237 | 237 |
238 void RegExpMacroAssemblerARM::CheckCharacters(Vector<const uc16> str, | |
239 int cp_offset, | |
240 Label* on_failure, | |
241 bool check_end_of_string) { | |
242 if (on_failure == NULL) { | |
243 // Instead of inlining a backtrack for each test, (re)use the global | |
244 // backtrack target. | |
245 on_failure = &backtrack_label_; | |
246 } | |
247 | |
248 if (check_end_of_string) { | |
249 // Is last character of required match inside string. | |
250 CheckPosition(cp_offset + str.length() - 1, on_failure); | |
251 } | |
252 | |
253 __ add(r0, end_of_input_address(), Operand(current_input_offset())); | |
254 if (cp_offset != 0) { | |
255 int byte_offset = cp_offset * char_size(); | |
256 __ add(r0, r0, Operand(byte_offset)); | |
257 } | |
258 | |
259 // r0 : Address of characters to match against str. | |
260 int stored_high_byte = 0; | |
261 for (int i = 0; i < str.length(); i++) { | |
262 if (mode_ == ASCII) { | |
263 __ ldrb(r1, MemOperand(r0, char_size(), PostIndex)); | |
264 ASSERT(str[i] <= String::kMaxOneByteCharCode); | |
265 __ cmp(r1, Operand(str[i])); | |
266 } else { | |
267 __ ldrh(r1, MemOperand(r0, char_size(), PostIndex)); | |
268 uc16 match_char = str[i]; | |
269 int match_high_byte = (match_char >> 8); | |
270 if (match_high_byte == 0) { | |
271 __ cmp(r1, Operand(str[i])); | |
272 } else { | |
273 if (match_high_byte != stored_high_byte) { | |
274 __ mov(r2, Operand(match_high_byte)); | |
275 stored_high_byte = match_high_byte; | |
276 } | |
277 __ add(r3, r2, Operand(match_char & 0xff)); | |
278 __ cmp(r1, r3); | |
279 } | |
280 } | |
281 BranchOrBacktrack(ne, on_failure); | |
282 } | |
283 } | |
284 | |
285 | |
286 void RegExpMacroAssemblerARM::CheckGreedyLoop(Label* on_equal) { | 238 void RegExpMacroAssemblerARM::CheckGreedyLoop(Label* on_equal) { |
287 __ ldr(r0, MemOperand(backtrack_stackpointer(), 0)); | 239 __ ldr(r0, MemOperand(backtrack_stackpointer(), 0)); |
288 __ cmp(current_input_offset(), r0); | 240 __ cmp(current_input_offset(), r0); |
289 __ add(backtrack_stackpointer(), | 241 __ add(backtrack_stackpointer(), |
290 backtrack_stackpointer(), Operand(kPointerSize), LeaveCC, eq); | 242 backtrack_stackpointer(), Operand(kPointerSize), LeaveCC, eq); |
291 BranchOrBacktrack(eq, on_equal); | 243 BranchOrBacktrack(eq, on_equal); |
292 } | 244 } |
293 | 245 |
294 | 246 |
295 void RegExpMacroAssemblerARM::CheckNotBackReferenceIgnoreCase( | 247 void RegExpMacroAssemblerARM::CheckNotBackReferenceIgnoreCase( |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 __ bind(&success); | 501 __ bind(&success); |
550 return true; | 502 return true; |
551 } | 503 } |
552 return false; | 504 return false; |
553 case 'S': | 505 case 'S': |
554 // The emitted code for generic character classes is good enough. | 506 // The emitted code for generic character classes is good enough. |
555 return false; | 507 return false; |
556 case 'd': | 508 case 'd': |
557 // Match ASCII digits ('0'..'9') | 509 // Match ASCII digits ('0'..'9') |
558 __ sub(r0, current_character(), Operand('0')); | 510 __ sub(r0, current_character(), Operand('0')); |
559 __ cmp(current_character(), Operand('9' - '0')); | 511 __ cmp(r0, Operand('9' - '0')); |
560 BranchOrBacktrack(hi, on_no_match); | 512 BranchOrBacktrack(hi, on_no_match); |
561 return true; | 513 return true; |
562 case 'D': | 514 case 'D': |
563 // Match non ASCII-digits | 515 // Match non ASCII-digits |
564 __ sub(r0, current_character(), Operand('0')); | 516 __ sub(r0, current_character(), Operand('0')); |
565 __ cmp(r0, Operand('9' - '0')); | 517 __ cmp(r0, Operand('9' - '0')); |
566 BranchOrBacktrack(ls, on_no_match); | 518 BranchOrBacktrack(ls, on_no_match); |
567 return true; | 519 return true; |
568 case '.': { | 520 case '.': { |
569 // Match non-newlines (not 0x0a('\n'), 0x0d('\r'), 0x2028 and 0x2029) | 521 // Match non-newlines (not 0x0a('\n'), 0x0d('\r'), 0x2028 and 0x2029) |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 __ ldr(pc, MemOperand(sp, stack_alignment, PostIndex)); | 1361 __ ldr(pc, MemOperand(sp, stack_alignment, PostIndex)); |
1410 } | 1362 } |
1411 | 1363 |
1412 #undef __ | 1364 #undef __ |
1413 | 1365 |
1414 #endif // V8_INTERPRETED_REGEXP | 1366 #endif // V8_INTERPRETED_REGEXP |
1415 | 1367 |
1416 }} // namespace v8::internal | 1368 }} // namespace v8::internal |
1417 | 1369 |
1418 #endif // V8_TARGET_ARCH_ARM | 1370 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |