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

Side by Side Diff: test/cctest/test-regexp.cc

Issue 14457: * Removed rep cmpsb everywhere in irregexp-ia32 (Closed)
Patch Set: Changes in back-reference handling Created 12 years 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
« src/assembler-ia32.h ('K') | « src/regexp-macro-assembler-ia32.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 seq_input.location(), 781 seq_input.location(),
782 start_offset, 782 start_offset,
783 end_offset, 783 end_offset,
784 NULL, 784 NULL,
785 true); 785 true);
786 786
787 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result); 787 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result);
788 } 788 }
789 789
790 790
791 TEST(MacroAssemblerIA32BackReference) { 791 TEST(MacroAssemblerIA32BackReferenceASCII) {
792 v8::V8::Initialize(); 792 v8::V8::Initialize();
793 ContextInitializer initializer; 793 ContextInitializer initializer;
794 794
795 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 3); 795 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 3);
796 796
797 m.WriteCurrentPositionToRegister(0, 0); 797 m.WriteCurrentPositionToRegister(0, 0);
798 m.AdvanceCurrentPosition(2); 798 m.AdvanceCurrentPosition(2);
799 m.WriteCurrentPositionToRegister(1, 0); 799 m.WriteCurrentPositionToRegister(1, 0);
800 Label nomatch; 800 Label nomatch;
801 m.CheckNotBackReference(0, &nomatch); 801 m.CheckNotBackReference(0, &nomatch);
(...skipping 26 matching lines...) Expand all
828 output, 828 output,
829 true); 829 true);
830 830
831 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); 831 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
832 CHECK_EQ(0, output[0]); 832 CHECK_EQ(0, output[0]);
833 CHECK_EQ(2, output[1]); 833 CHECK_EQ(2, output[1]);
834 CHECK_EQ(6, output[2]); 834 CHECK_EQ(6, output[2]);
835 } 835 }
836 836
837 837
838 TEST(MacroAssemblerIA32BackReferenceUC16) {
839 v8::V8::Initialize();
840 ContextInitializer initializer;
841
842 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::UC16, 3);
843
844 m.WriteCurrentPositionToRegister(0, 0);
845 m.AdvanceCurrentPosition(2);
846 m.WriteCurrentPositionToRegister(1, 0);
847 Label nomatch;
848 m.CheckNotBackReference(0, &nomatch);
849 m.Fail();
850 m.Bind(&nomatch);
851 m.AdvanceCurrentPosition(2);
852 Label missing_match;
853 m.CheckNotBackReference(0, &missing_match);
854 m.WriteCurrentPositionToRegister(2, 0);
855 m.Succeed();
856 m.Bind(&missing_match);
857 m.Fail();
858
859 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^(..)..\1"));
860 Handle<Object> code_object = m.GetCode(source);
861 Handle<Code> code = Handle<Code>::cast(code_object);
862
863 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028};
864 Handle<String> input =
865 Factory::NewStringFromTwoByte(Vector<const uc16>(input_data, 6));
866 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input);
867 Address start_adr = seq_input->GetCharsAddress();
868
869 int start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
870 int end_offset = start_offset + seq_input->length() * sizeof(input_data[0]);
871
872 int output[3];
873 RegExpMacroAssemblerIA32::Result result =
874 RegExpMacroAssemblerIA32::Execute(*code,
875 seq_input.location(),
876 start_offset,
877 end_offset,
878 output,
879 true);
880
881 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
882 CHECK_EQ(0, output[0]);
883 CHECK_EQ(2, output[1]);
884 CHECK_EQ(6, output[2]);
885 }
886
887
888
838 TEST(MacroAssemblerIA32AtStart) { 889 TEST(MacroAssemblerIA32AtStart) {
839 v8::V8::Initialize(); 890 v8::V8::Initialize();
840 ContextInitializer initializer; 891 ContextInitializer initializer;
841 892
842 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0); 893 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0);
843 894
844 Label not_at_start, newline, fail; 895 Label not_at_start, newline, fail;
845 m.CheckNotAtStart(&not_at_start); 896 m.CheckNotAtStart(&not_at_start);
846 // Check that prevchar = '\n' and current = 'f'. 897 // Check that prevchar = '\n' and current = 'f'.
847 m.CheckCharacter('\n', &newline); 898 m.CheckCharacter('\n', &newline);
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 CHECK(!InClass(i, excluded)); 1385 CHECK(!InClass(i, excluded));
1335 } 1386 }
1336 } 1387 }
1337 } 1388 }
1338 1389
1339 1390
1340 TEST(Graph) { 1391 TEST(Graph) {
1341 V8::Initialize(NULL); 1392 V8::Initialize(NULL);
1342 Execute("\\bboy\\b", false, true, true); 1393 Execute("\\bboy\\b", false, true, true);
1343 } 1394 }
OLDNEW
« src/assembler-ia32.h ('K') | « src/regexp-macro-assembler-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698