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

Side by Side Diff: src/arm/regexp-macro-assembler-arm.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
« no previous file with comments | « no previous file | src/ia32/regexp-macro-assembler-ia32.cc » ('j') | src/regexp-macro-assembler.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 __ add(r1, r1, Operand(r2)); 789 __ add(r1, r1, Operand(r2));
790 // r1 is length of string in characters. 790 // r1 is length of string in characters.
791 791
792 ASSERT_EQ(0, num_saved_registers_ % 2); 792 ASSERT_EQ(0, num_saved_registers_ % 2);
793 // Always an even number of capture registers. This allows us to 793 // Always an even number of capture registers. This allows us to
794 // unroll the loop once to add an operation between a load of a register 794 // unroll the loop once to add an operation between a load of a register
795 // and the following use of that register. 795 // and the following use of that register.
796 for (int i = 0; i < num_saved_registers_; i += 2) { 796 for (int i = 0; i < num_saved_registers_; i += 2) {
797 __ ldr(r2, register_location(i)); 797 __ ldr(r2, register_location(i));
798 __ ldr(r3, register_location(i + 1)); 798 __ ldr(r3, register_location(i + 1));
799 if (global()) { 799 if (i == 0 && global_with_zero_length_match()) {
800 // Keep capture start in r4 for the zero-length check later. 800 // Keep capture start in r4 for the zero-length check later.
801 __ mov(r4, r2); 801 __ mov(r4, r2);
802 } 802 }
803 if (mode_ == UC16) { 803 if (mode_ == UC16) {
804 __ add(r2, r1, Operand(r2, ASR, 1)); 804 __ add(r2, r1, Operand(r2, ASR, 1));
805 __ add(r3, r1, Operand(r3, ASR, 1)); 805 __ add(r3, r1, Operand(r3, ASR, 1));
806 } else { 806 } else {
807 __ add(r2, r1, Operand(r2)); 807 __ add(r2, r1, Operand(r2));
808 __ add(r3, r1, Operand(r3)); 808 __ add(r3, r1, Operand(r3));
809 } 809 }
(...skipping 17 matching lines...) Expand all
827 __ cmp(r1, Operand(num_saved_registers_)); 827 __ cmp(r1, Operand(num_saved_registers_));
828 __ b(lt, &return_r0); 828 __ b(lt, &return_r0);
829 829
830 __ str(r1, MemOperand(frame_pointer(), kNumOutputRegisters)); 830 __ str(r1, MemOperand(frame_pointer(), kNumOutputRegisters));
831 // Advance the location for output. 831 // Advance the location for output.
832 __ add(r2, r2, Operand(num_saved_registers_ * kPointerSize)); 832 __ add(r2, r2, Operand(num_saved_registers_ * kPointerSize));
833 __ str(r2, MemOperand(frame_pointer(), kRegisterOutput)); 833 __ str(r2, MemOperand(frame_pointer(), kRegisterOutput));
834 834
835 // Prepare r0 to initialize registers with its value in the next run. 835 // Prepare r0 to initialize registers with its value in the next run.
836 __ ldr(r0, MemOperand(frame_pointer(), kInputStartMinusOne)); 836 __ ldr(r0, MemOperand(frame_pointer(), kInputStartMinusOne));
837 // Special case for zero-length matches. 837
838 // r4: capture start index 838 if (global_with_zero_length_match()) {
839 __ cmp(current_input_offset(), r4); 839 // Special case for zero-length matches.
840 // Not a zero-length match, restart. 840 // r4: capture start index
841 __ b(ne, &load_char_start_regexp); 841 __ cmp(current_input_offset(), r4);
842 // Offset from the end is zero if we already reached the end. 842 // Not a zero-length match, restart.
843 __ cmp(current_input_offset(), Operand(0)); 843 __ b(ne, &load_char_start_regexp);
844 __ b(eq, &exit_label_); 844 // Offset from the end is zero if we already reached the end.
845 // Advance current position after a zero-length match. 845 __ cmp(current_input_offset(), Operand(0));
846 __ add(current_input_offset(), 846 __ b(eq, &exit_label_);
847 current_input_offset(), 847 // Advance current position after a zero-length match.
848 Operand((mode_ == UC16) ? 2 : 1)); 848 __ add(current_input_offset(),
849 current_input_offset(),
850 Operand((mode_ == UC16) ? 2 : 1));
851 }
852
849 __ b(&load_char_start_regexp); 853 __ b(&load_char_start_regexp);
850 } else { 854 } else {
851 __ mov(r0, Operand(SUCCESS)); 855 __ mov(r0, Operand(SUCCESS));
852 } 856 }
853 } 857 }
854 858
855 // Exit and return r0 859 // Exit and return r0
856 __ bind(&exit_label_); 860 __ bind(&exit_label_);
857 if (global()) { 861 if (global()) {
858 __ ldr(r0, MemOperand(frame_pointer(), kSuccessfulCaptures)); 862 __ ldr(r0, MemOperand(frame_pointer(), kSuccessfulCaptures));
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 __ ldr(pc, MemOperand(sp, stack_alignment, PostIndex)); 1414 __ ldr(pc, MemOperand(sp, stack_alignment, PostIndex));
1411 } 1415 }
1412 1416
1413 #undef __ 1417 #undef __
1414 1418
1415 #endif // V8_INTERPRETED_REGEXP 1419 #endif // V8_INTERPRETED_REGEXP
1416 1420
1417 }} // namespace v8::internal 1421 }} // namespace v8::internal
1418 1422
1419 #endif // V8_TARGET_ARCH_ARM 1423 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/ia32/regexp-macro-assembler-ia32.cc » ('j') | src/regexp-macro-assembler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698