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

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

Issue 1114001: Refactoring of RegExp interface to better support calling several times in a row. (Closed)
Patch Set: Fix type that snuck into the commit. Created 10 years, 9 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
OLDNEW
1 // Copyright 2008-2009 the V8 project authors. All rights reserved. 1 // Copyright 2008-2009 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 __ mov(eax, EXCEPTION); 646 __ mov(eax, EXCEPTION);
647 __ jmp(&exit_label_); 647 __ jmp(&exit_label_);
648 648
649 __ bind(&stack_limit_hit); 649 __ bind(&stack_limit_hit);
650 CallCheckStackGuardState(ebx); 650 CallCheckStackGuardState(ebx);
651 __ or_(eax, Operand(eax)); 651 __ or_(eax, Operand(eax));
652 // If returned value is non-zero, we exit with the returned value as result. 652 // If returned value is non-zero, we exit with the returned value as result.
653 __ j(not_zero, &exit_label_); 653 __ j(not_zero, &exit_label_);
654 654
655 __ bind(&stack_ok); 655 __ bind(&stack_ok);
656 // Load start index for later use.
657 __ mov(ebx, Operand(ebp, kStartIndex));
656 658
657 // Allocate space on stack for registers. 659 // Allocate space on stack for registers.
658 __ sub(Operand(esp), Immediate(num_registers_ * kPointerSize)); 660 __ sub(Operand(esp), Immediate(num_registers_ * kPointerSize));
659 // Load string length. 661 // Load string length.
660 __ mov(esi, Operand(ebp, kInputEnd)); 662 __ mov(esi, Operand(ebp, kInputEnd));
661 // Load input position. 663 // Load input position.
662 __ mov(edi, Operand(ebp, kInputStart)); 664 __ mov(edi, Operand(ebp, kInputStart));
663 // Set up edi to be negative offset from string end. 665 // Set up edi to be negative offset from string end.
664 __ sub(edi, Operand(esi)); 666 __ sub(edi, Operand(esi));
665 // Set eax to address of char before start of input 667
668 // Set eax to address of char before start of the string.
666 // (effectively string position -1). 669 // (effectively string position -1).
667 __ lea(eax, Operand(edi, -char_size())); 670 __ neg(ebx);
671 if (mode_ == UC16) {
672 __ lea(eax, Operand(edi, ebx, times_2, -char_size()));
673 } else {
674 __ lea(eax, Operand(edi, ebx, times_1, -char_size()));
675 }
668 // Store this value in a local variable, for use when clearing 676 // Store this value in a local variable, for use when clearing
669 // position registers. 677 // position registers.
670 __ mov(Operand(ebp, kInputStartMinusOne), eax); 678 __ mov(Operand(ebp, kInputStartMinusOne), eax);
671 679
672 // Determine whether the start index is zero, that is at the start of the 680 // Determine whether the start index is zero, that is at the start of the
673 // string, and store that value in a local variable. 681 // string, and store that value in a local variable.
674 __ mov(ebx, Operand(ebp, kStartIndex));
675 __ xor_(Operand(ecx), ecx); // setcc only operates on cl (lower byte of ecx). 682 __ xor_(Operand(ecx), ecx); // setcc only operates on cl (lower byte of ecx).
683 // Register ebx still holds -stringIndex.
676 __ test(ebx, Operand(ebx)); 684 __ test(ebx, Operand(ebx));
677 __ setcc(zero, ecx); // 1 if 0 (start of string), 0 if positive. 685 __ setcc(zero, ecx); // 1 if 0 (start of string), 0 if positive.
678 __ mov(Operand(ebp, kAtStart), ecx); 686 __ mov(Operand(ebp, kAtStart), ecx);
679 687
680 if (num_saved_registers_ > 0) { // Always is, if generated from a regexp. 688 if (num_saved_registers_ > 0) { // Always is, if generated from a regexp.
681 // Fill saved registers with initial value = start offset - 1 689 // Fill saved registers with initial value = start offset - 1
682 // Fill in stack push order, to avoid accessing across an unwritten 690 // Fill in stack push order, to avoid accessing across an unwritten
683 // page (a problem on Windows). 691 // page (a problem on Windows).
684 __ mov(ecx, kRegisterZero); 692 __ mov(ecx, kRegisterZero);
685 Label init_loop; 693 Label init_loop;
(...skipping 28 matching lines...) Expand all
714 722
715 723
716 // Exit code: 724 // Exit code:
717 if (success_label_.is_linked()) { 725 if (success_label_.is_linked()) {
718 // Save captures when successful. 726 // Save captures when successful.
719 __ bind(&success_label_); 727 __ bind(&success_label_);
720 if (num_saved_registers_ > 0) { 728 if (num_saved_registers_ > 0) {
721 // copy captures to output 729 // copy captures to output
722 __ mov(ebx, Operand(ebp, kRegisterOutput)); 730 __ mov(ebx, Operand(ebp, kRegisterOutput));
723 __ mov(ecx, Operand(ebp, kInputEnd)); 731 __ mov(ecx, Operand(ebp, kInputEnd));
732 __ mov(edx, Operand(ebp, kStartIndex));
724 __ sub(ecx, Operand(ebp, kInputStart)); 733 __ sub(ecx, Operand(ebp, kInputStart));
734 if (mode_ == UC16) {
735 __ lea(ecx, Operand(ecx, edx, times_2, 0));
736 } else {
737 __ add(ecx, Operand(edx));
738 }
725 for (int i = 0; i < num_saved_registers_; i++) { 739 for (int i = 0; i < num_saved_registers_; i++) {
726 __ mov(eax, register_location(i)); 740 __ mov(eax, register_location(i));
727 __ add(eax, Operand(ecx)); // Convert to index from start, not end. 741 // Convert to index from start of string, not end.
742 __ add(eax, Operand(ecx));
728 if (mode_ == UC16) { 743 if (mode_ == UC16) {
729 __ sar(eax, 1); // Convert byte index to character index. 744 __ sar(eax, 1); // Convert byte index to character index.
730 } 745 }
731 __ mov(Operand(ebx, i * kPointerSize), eax); 746 __ mov(Operand(ebx, i * kPointerSize), eax);
732 } 747 }
733 } 748 }
734 __ mov(eax, Immediate(SUCCESS)); 749 __ mov(eax, Immediate(SUCCESS));
735 } 750 }
736 // Exit and return eax 751 // Exit and return eax
737 __ bind(&exit_label_); 752 __ bind(&exit_label_);
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 } 1191 }
1177 } 1192 }
1178 } 1193 }
1179 1194
1180 1195
1181 #undef __ 1196 #undef __
1182 1197
1183 #endif // V8_NATIVE_REGEXP 1198 #endif // V8_NATIVE_REGEXP
1184 1199
1185 }} // namespace v8::internal 1200 }} // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698