Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: src/ia32/regexp-macro-assembler-ia32.cc

Issue 9854020: RegExp: Add support for table-based character class (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 void RegExpMacroAssemblerIA32::CheckNotCharacter(uint32_t c, 494 void RegExpMacroAssemblerIA32::CheckNotCharacter(uint32_t c,
495 Label* on_not_equal) { 495 Label* on_not_equal) {
496 __ cmp(current_character(), c); 496 __ cmp(current_character(), c);
497 BranchOrBacktrack(not_equal, on_not_equal); 497 BranchOrBacktrack(not_equal, on_not_equal);
498 } 498 }
499 499
500 500
501 void RegExpMacroAssemblerIA32::CheckCharacterAfterAnd(uint32_t c, 501 void RegExpMacroAssemblerIA32::CheckCharacterAfterAnd(uint32_t c,
502 uint32_t mask, 502 uint32_t mask,
503 Label* on_equal) { 503 Label* on_equal) {
504 __ mov(eax, current_character()); 504 if (c == 0) {
505 __ and_(eax, mask); 505 __ test(current_character(), Immediate(mask));
506 __ cmp(eax, c); 506 } else {
507 __ mov(eax, current_character());
508 __ and_(eax, mask);
509 __ cmp(eax, c);
510 }
507 BranchOrBacktrack(equal, on_equal); 511 BranchOrBacktrack(equal, on_equal);
508 } 512 }
509 513
510 514
511 void RegExpMacroAssemblerIA32::CheckNotCharacterAfterAnd(uint32_t c, 515 void RegExpMacroAssemblerIA32::CheckNotCharacterAfterAnd(uint32_t c,
512 uint32_t mask, 516 uint32_t mask,
513 Label* on_not_equal) { 517 Label* on_not_equal) {
514 __ mov(eax, current_character()); 518 if (c == 0) {
515 __ and_(eax, mask); 519 __ test(current_character(), Immediate(mask));
516 __ cmp(eax, c); 520 } else {
521 __ mov(eax, current_character());
522 __ and_(eax, mask);
523 __ cmp(eax, c);
524 }
517 BranchOrBacktrack(not_equal, on_not_equal); 525 BranchOrBacktrack(not_equal, on_not_equal);
518 } 526 }
519 527
520 528
521 void RegExpMacroAssemblerIA32::CheckNotCharacterAfterMinusAnd( 529 void RegExpMacroAssemblerIA32::CheckNotCharacterAfterMinusAnd(
522 uc16 c, 530 uc16 c,
523 uc16 minus, 531 uc16 minus,
524 uc16 mask, 532 uc16 mask,
525 Label* on_not_equal) { 533 Label* on_not_equal) {
526 ASSERT(minus < String::kMaxUtf16CodeUnit); 534 ASSERT(minus < String::kMaxUtf16CodeUnit);
527 __ lea(eax, Operand(current_character(), -minus)); 535 __ lea(eax, Operand(current_character(), -minus));
528 __ and_(eax, mask); 536 if (c == 0) {
529 __ cmp(eax, c); 537 __ test(eax, Immediate(mask));
538 } else {
539 __ and_(eax, mask);
540 __ cmp(eax, c);
541 }
530 BranchOrBacktrack(not_equal, on_not_equal); 542 BranchOrBacktrack(not_equal, on_not_equal);
531 } 543 }
532 544
533 545
546 void RegExpMacroAssemblerIA32::CheckCharacterInRange(
547 uc16 from,
548 uc16 to,
549 Label* on_in_range) {
550 __ lea(eax, Operand(current_character(), -from));
551 __ cmp(eax, to - from);
552 BranchOrBacktrack(below_equal, on_in_range);
553 }
554
555
556 void RegExpMacroAssemblerIA32::CheckCharacterNotInRange(
557 uc16 from,
558 uc16 to,
559 Label* on_not_in_range) {
560 __ lea(eax, Operand(current_character(), -from));
561 __ cmp(eax, to - from);
562 BranchOrBacktrack(above, on_not_in_range);
563 }
564
565
566 void RegExpMacroAssemblerIA32::CheckBitInTable(
567 Handle<ByteArray> table,
568 Label* on_bit_set) {
569 __ mov(eax, Immediate(table));
570 Register index = current_character();
571 if (mode_ != ASCII || kTableMask != String::kMaxAsciiCharCode) {
572 __ mov(ebx, current_character());
573 __ and_(ebx, kTableSize - 1);
574 index = ebx;
575 }
576 __ cmpb(FieldOperand(eax, index, times_1, ByteArray::kHeaderSize), 0);
577 BranchOrBacktrack(not_equal, on_bit_set);
578 }
579
580
534 bool RegExpMacroAssemblerIA32::CheckSpecialCharacterClass(uc16 type, 581 bool RegExpMacroAssemblerIA32::CheckSpecialCharacterClass(uc16 type,
535 Label* on_no_match) { 582 Label* on_no_match) {
536 // Range checks (c in min..max) are generally implemented by an unsigned 583 // Range checks (c in min..max) are generally implemented by an unsigned
537 // (c - min) <= (max - min) check 584 // (c - min) <= (max - min) check
538 switch (type) { 585 switch (type) {
539 case 's': 586 case 's':
540 // Match space-characters 587 // Match space-characters
541 if (mode_ == ASCII) { 588 if (mode_ == ASCII) {
542 // ASCII space characters are '\t'..'\r' and ' '. 589 // ASCII space characters are '\t'..'\r' and ' '.
543 Label success; 590 Label success;
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 } 1328 }
1282 1329
1283 1330
1284 #undef __ 1331 #undef __
1285 1332
1286 #endif // V8_INTERPRETED_REGEXP 1333 #endif // V8_INTERPRETED_REGEXP
1287 1334
1288 }} // namespace v8::internal 1335 }} // namespace v8::internal
1289 1336
1290 #endif // V8_TARGET_ARCH_IA32 1337 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698