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

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

Issue 10383280: Remove unnecessary code for non-zero-length global regexps. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 7 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 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 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 __ movq(rbx, Operand(rbp, kRegisterOutput)); 919 __ movq(rbx, Operand(rbp, kRegisterOutput));
920 __ movq(rcx, Operand(rbp, kInputEnd)); 920 __ movq(rcx, Operand(rbp, kInputEnd));
921 __ subq(rcx, Operand(rbp, kInputStart)); 921 __ subq(rcx, Operand(rbp, kInputStart));
922 if (mode_ == UC16) { 922 if (mode_ == UC16) {
923 __ lea(rcx, Operand(rcx, rdx, times_2, 0)); 923 __ lea(rcx, Operand(rcx, rdx, times_2, 0));
924 } else { 924 } else {
925 __ addq(rcx, rdx); 925 __ addq(rcx, rdx);
926 } 926 }
927 for (int i = 0; i < num_saved_registers_; i++) { 927 for (int i = 0; i < num_saved_registers_; i++) {
928 __ movq(rax, register_location(i)); 928 __ movq(rax, register_location(i));
929 if (i == 0 && global()) { 929 if (i == 0 && global_with_zero_length_match()) {
930 // Keep capture start in rdx for the zero-length check later. 930 // Keep capture start in rdx for the zero-length check later.
931 __ movq(rdx, rax); 931 __ movq(rdx, rax);
932 } 932 }
933 __ addq(rax, rcx); // Convert to index from start, not end. 933 __ addq(rax, rcx); // Convert to index from start, not end.
934 if (mode_ == UC16) { 934 if (mode_ == UC16) {
935 __ sar(rax, Immediate(1)); // Convert byte index to character index. 935 __ sar(rax, Immediate(1)); // Convert byte index to character index.
936 } 936 }
937 __ movl(Operand(rbx, i * kIntSize), rax); 937 __ movl(Operand(rbx, i * kIntSize), rax);
938 } 938 }
939 } 939 }
(...skipping 11 matching lines...) Expand all
951 __ j(less, &exit_label_); 951 __ j(less, &exit_label_);
952 952
953 __ movq(Operand(rbp, kNumOutputRegisters), rcx); 953 __ movq(Operand(rbp, kNumOutputRegisters), rcx);
954 // Advance the location for output. 954 // Advance the location for output.
955 __ addq(Operand(rbp, kRegisterOutput), 955 __ addq(Operand(rbp, kRegisterOutput),
956 Immediate(num_saved_registers_ * kIntSize)); 956 Immediate(num_saved_registers_ * kIntSize));
957 957
958 // Prepare rax to initialize registers with its value in the next run. 958 // Prepare rax to initialize registers with its value in the next run.
959 __ movq(rax, Operand(rbp, kInputStartMinusOne)); 959 __ movq(rax, Operand(rbp, kInputStartMinusOne));
960 960
961 // Special case for zero-length matches. 961 if (global_with_zero_length_match()) {
962 // rdx: capture start index 962 // Special case for zero-length matches.
963 __ cmpq(rdi, rdx); 963 // rdx: capture start index
964 // Not a zero-length match, restart. 964 __ cmpq(rdi, rdx);
965 __ j(not_equal, &load_char_start_regexp); 965 // Not a zero-length match, restart.
966 // rdi (offset from the end) is zero if we already reached the end. 966 __ j(not_equal, &load_char_start_regexp);
967 __ testq(rdi, rdi); 967 // rdi (offset from the end) is zero if we already reached the end.
968 __ j(zero, &exit_label_, Label::kNear); 968 __ testq(rdi, rdi);
969 // Advance current position after a zero-length match. 969 __ j(zero, &exit_label_, Label::kNear);
970 if (mode_ == UC16) { 970 // Advance current position after a zero-length match.
971 __ addq(rdi, Immediate(2)); 971 if (mode_ == UC16) {
972 } else { 972 __ addq(rdi, Immediate(2));
973 __ incq(rdi); 973 } else {
974 __ incq(rdi);
975 }
974 } 976 }
977
975 __ jmp(&load_char_start_regexp); 978 __ jmp(&load_char_start_regexp);
976 } else { 979 } else {
977 __ movq(rax, Immediate(SUCCESS)); 980 __ movq(rax, Immediate(SUCCESS));
978 } 981 }
979 } 982 }
980 983
981 __ bind(&exit_label_); 984 __ bind(&exit_label_);
982 if (global()) { 985 if (global()) {
983 // Return the number of successful captures. 986 // Return the number of successful captures.
984 __ movq(rax, Operand(rbp, kSuccessfulCaptures)); 987 __ movq(rax, Operand(rbp, kSuccessfulCaptures));
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 } 1534 }
1532 } 1535 }
1533 1536
1534 #undef __ 1537 #undef __
1535 1538
1536 #endif // V8_INTERPRETED_REGEXP 1539 #endif // V8_INTERPRETED_REGEXP
1537 1540
1538 }} // namespace v8::internal 1541 }} // namespace v8::internal
1539 1542
1540 #endif // V8_TARGET_ARCH_X64 1543 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698