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 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 __ mov(ecx, Operand(ebp, kInputEnd)); | 850 __ mov(ecx, Operand(ebp, kInputEnd)); |
851 __ mov(edx, Operand(ebp, kStartIndex)); | 851 __ mov(edx, Operand(ebp, kStartIndex)); |
852 __ sub(ecx, Operand(ebp, kInputStart)); | 852 __ sub(ecx, Operand(ebp, kInputStart)); |
853 if (mode_ == UC16) { | 853 if (mode_ == UC16) { |
854 __ lea(ecx, Operand(ecx, edx, times_2, 0)); | 854 __ lea(ecx, Operand(ecx, edx, times_2, 0)); |
855 } else { | 855 } else { |
856 __ add(ecx, edx); | 856 __ add(ecx, edx); |
857 } | 857 } |
858 for (int i = 0; i < num_saved_registers_; i++) { | 858 for (int i = 0; i < num_saved_registers_; i++) { |
859 __ mov(eax, register_location(i)); | 859 __ mov(eax, register_location(i)); |
860 if (i == 0 && global()) { | 860 if (i == 0 && global_with_zero_length_match()) { |
861 // Keep capture start in edx for the zero-length check later. | 861 // Keep capture start in edx for the zero-length check later. |
862 __ mov(edx, eax); | 862 __ mov(edx, eax); |
863 } | 863 } |
864 // Convert to index from start of string, not end. | 864 // Convert to index from start of string, not end. |
865 __ add(eax, ecx); | 865 __ add(eax, ecx); |
866 if (mode_ == UC16) { | 866 if (mode_ == UC16) { |
867 __ sar(eax, 1); // Convert byte index to character index. | 867 __ sar(eax, 1); // Convert byte index to character index. |
868 } | 868 } |
869 __ mov(Operand(ebx, i * kPointerSize), eax); | 869 __ mov(Operand(ebx, i * kPointerSize), eax); |
870 } | 870 } |
(...skipping 12 matching lines...) Expand all Loading... |
883 __ j(less, &exit_label_); | 883 __ j(less, &exit_label_); |
884 | 884 |
885 __ mov(Operand(ebp, kNumOutputRegisters), ecx); | 885 __ mov(Operand(ebp, kNumOutputRegisters), ecx); |
886 // Advance the location for output. | 886 // Advance the location for output. |
887 __ add(Operand(ebp, kRegisterOutput), | 887 __ add(Operand(ebp, kRegisterOutput), |
888 Immediate(num_saved_registers_ * kPointerSize)); | 888 Immediate(num_saved_registers_ * kPointerSize)); |
889 | 889 |
890 // Prepare eax to initialize registers with its value in the next run. | 890 // Prepare eax to initialize registers with its value in the next run. |
891 __ mov(eax, Operand(ebp, kInputStartMinusOne)); | 891 __ mov(eax, Operand(ebp, kInputStartMinusOne)); |
892 | 892 |
893 // Special case for zero-length matches. | 893 if (global_with_zero_length_match()) { |
894 // edx: capture start index | 894 // Special case for zero-length matches. |
895 __ cmp(edi, edx); | 895 // edx: capture start index |
896 // Not a zero-length match, restart. | 896 __ cmp(edi, edx); |
897 __ j(not_equal, &load_char_start_regexp); | 897 // Not a zero-length match, restart. |
898 // edi (offset from the end) is zero if we already reached the end. | 898 __ j(not_equal, &load_char_start_regexp); |
899 __ test(edi, edi); | 899 // edi (offset from the end) is zero if we already reached the end. |
900 __ j(zero, &exit_label_, Label::kNear); | 900 __ test(edi, edi); |
901 // Advance current position after a zero-length match. | 901 __ j(zero, &exit_label_, Label::kNear); |
902 if (mode_ == UC16) { | 902 // Advance current position after a zero-length match. |
903 __ add(edi, Immediate(2)); | 903 if (mode_ == UC16) { |
904 } else { | 904 __ add(edi, Immediate(2)); |
905 __ inc(edi); | 905 } else { |
| 906 __ inc(edi); |
| 907 } |
906 } | 908 } |
| 909 |
907 __ jmp(&load_char_start_regexp); | 910 __ jmp(&load_char_start_regexp); |
908 } else { | 911 } else { |
909 __ mov(eax, Immediate(SUCCESS)); | 912 __ mov(eax, Immediate(SUCCESS)); |
910 } | 913 } |
911 } | 914 } |
912 | 915 |
913 __ bind(&exit_label_); | 916 __ bind(&exit_label_); |
914 if (global()) { | 917 if (global()) { |
915 // Return the number of successful captures. | 918 // Return the number of successful captures. |
916 __ mov(eax, Operand(ebp, kSuccessfulCaptures)); | 919 __ mov(eax, Operand(ebp, kSuccessfulCaptures)); |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 } | 1401 } |
1399 | 1402 |
1400 | 1403 |
1401 #undef __ | 1404 #undef __ |
1402 | 1405 |
1403 #endif // V8_INTERPRETED_REGEXP | 1406 #endif // V8_INTERPRETED_REGEXP |
1404 | 1407 |
1405 }} // namespace v8::internal | 1408 }} // namespace v8::internal |
1406 | 1409 |
1407 #endif // V8_TARGET_ARCH_IA32 | 1410 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |