OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 __ bind(&stack_ok); | 704 __ bind(&stack_ok); |
705 | 705 |
706 // Allocate space on stack for registers. | 706 // Allocate space on stack for registers. |
707 __ subq(rsp, Immediate(num_registers_ * kPointerSize)); | 707 __ subq(rsp, Immediate(num_registers_ * kPointerSize)); |
708 // Load string length. | 708 // Load string length. |
709 __ movq(rsi, Operand(rbp, kInputEnd)); | 709 __ movq(rsi, Operand(rbp, kInputEnd)); |
710 // Load input position. | 710 // Load input position. |
711 __ movq(rdi, Operand(rbp, kInputStart)); | 711 __ movq(rdi, Operand(rbp, kInputStart)); |
712 // Set up rdi to be negative offset from string end. | 712 // Set up rdi to be negative offset from string end. |
713 __ subq(rdi, rsi); | 713 __ subq(rdi, rsi); |
714 // Set rax to address of char before start of input | 714 // Set rax to address of char before start of the string |
715 // (effectively string position -1). | 715 // (effectively string position -1). |
716 __ lea(rax, Operand(rdi, -char_size())); | 716 __ movq(rbx, Operand(rbp, kStartIndex)); |
| 717 __ neg(rbx); |
| 718 if (mode_ == UC16) { |
| 719 __ lea(rax, Operand(rdi, rbx, times_2, -char_size())); |
| 720 } else { |
| 721 __ lea(rax, Operand(rdi, rbx, times_1, -char_size())); |
| 722 } |
717 // Store this value in a local variable, for use when clearing | 723 // Store this value in a local variable, for use when clearing |
718 // position registers. | 724 // position registers. |
719 __ movq(Operand(rbp, kInputStartMinusOne), rax); | 725 __ movq(Operand(rbp, kInputStartMinusOne), rax); |
720 | 726 |
721 // Determine whether the start index is zero, that is at the start of the | 727 // Determine whether the start index is zero, that is at the start of the |
722 // string, and store that value in a local variable. | 728 // string, and store that value in a local variable. |
723 __ movq(rbx, Operand(rbp, kStartIndex)); | 729 __ movq(rbx, Operand(rbp, kStartIndex)); |
724 __ xor_(rcx, rcx); // setcc only operates on cl (lower byte of rcx). | 730 __ xor_(rcx, rcx); // setcc only operates on cl (lower byte of rcx). |
725 __ testq(rbx, rbx); | 731 __ testq(rbx, rbx); |
726 __ setcc(zero, rcx); // 1 if 0 (start of string), 0 if positive. | 732 __ setcc(zero, rcx); // 1 if 0 (start of string), 0 if positive. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 __ movq(current_character(), Immediate('\n')); | 769 __ movq(current_character(), Immediate('\n')); |
764 __ jmp(&start_label_); | 770 __ jmp(&start_label_); |
765 | 771 |
766 | 772 |
767 // Exit code: | 773 // Exit code: |
768 if (success_label_.is_linked()) { | 774 if (success_label_.is_linked()) { |
769 // Save captures when successful. | 775 // Save captures when successful. |
770 __ bind(&success_label_); | 776 __ bind(&success_label_); |
771 if (num_saved_registers_ > 0) { | 777 if (num_saved_registers_ > 0) { |
772 // copy captures to output | 778 // copy captures to output |
| 779 __ movq(rdx, Operand(rbp, kStartIndex)); |
773 __ movq(rbx, Operand(rbp, kRegisterOutput)); | 780 __ movq(rbx, Operand(rbp, kRegisterOutput)); |
774 __ movq(rcx, Operand(rbp, kInputEnd)); | 781 __ movq(rcx, Operand(rbp, kInputEnd)); |
775 __ subq(rcx, Operand(rbp, kInputStart)); | 782 __ subq(rcx, Operand(rbp, kInputStart)); |
| 783 if (mode_ == UC16) { |
| 784 __ lea(rcx, Operand(rcx, rdx, times_2, 0)); |
| 785 } else { |
| 786 __ addq(rcx, rdx); |
| 787 } |
776 for (int i = 0; i < num_saved_registers_; i++) { | 788 for (int i = 0; i < num_saved_registers_; i++) { |
777 __ movq(rax, register_location(i)); | 789 __ movq(rax, register_location(i)); |
778 __ addq(rax, rcx); // Convert to index from start, not end. | 790 __ addq(rax, rcx); // Convert to index from start, not end. |
779 if (mode_ == UC16) { | 791 if (mode_ == UC16) { |
780 __ sar(rax, Immediate(1)); // Convert byte index to character index. | 792 __ sar(rax, Immediate(1)); // Convert byte index to character index. |
781 } | 793 } |
782 __ movl(Operand(rbx, i * kIntSize), rax); | 794 __ movl(Operand(rbx, i * kIntSize), rax); |
783 } | 795 } |
784 } | 796 } |
785 __ movq(rax, Immediate(SUCCESS)); | 797 __ movq(rax, Immediate(SUCCESS)); |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 Operand(rsi, rdi, times_1, cp_offset * sizeof(uc16))); | 1306 Operand(rsi, rdi, times_1, cp_offset * sizeof(uc16))); |
1295 } | 1307 } |
1296 } | 1308 } |
1297 } | 1309 } |
1298 | 1310 |
1299 #undef __ | 1311 #undef __ |
1300 | 1312 |
1301 #endif // V8_NATIVE_REGEXP | 1313 #endif // V8_NATIVE_REGEXP |
1302 | 1314 |
1303 }} // namespace v8::internal | 1315 }} // namespace v8::internal |
OLD | NEW |