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

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

Issue 1418963009: Experimental support for RegExp lookbehind. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix arm64 debug code assertion Created 5 years, 1 month 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
« no previous file with comments | « src/regexp/x64/regexp-macro-assembler-x64.cc ('k') | test/mjsunit/harmony/regexp-lookbehind.js » ('j') | no next file with comments »
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 153
154 #define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input)) 154 #define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input))
155 #define CHECK_SIMPLE(input, simple) CHECK_EQ(simple, CheckSimple(input)); 155 #define CHECK_SIMPLE(input, simple) CHECK_EQ(simple, CheckSimple(input));
156 #define CHECK_MIN_MAX(input, min, max) \ 156 #define CHECK_MIN_MAX(input, min, max) \
157 { MinMaxPair min_max = CheckMinMaxMatch(input); \ 157 { MinMaxPair min_max = CheckMinMaxMatch(input); \
158 CHECK_EQ(min, min_max.min_match); \ 158 CHECK_EQ(min, min_max.min_match); \
159 CHECK_EQ(max, min_max.max_match); \ 159 CHECK_EQ(max, min_max.max_match); \
160 } 160 }
161 161
162 TEST(Parser) { 162
163 void TestRegExpParser(bool lookbehind) {
164 FLAG_harmony_regexp_lookbehind = lookbehind;
165
163 CHECK_PARSE_ERROR("?"); 166 CHECK_PARSE_ERROR("?");
164 167
165 CheckParseEq("abc", "'abc'"); 168 CheckParseEq("abc", "'abc'");
166 CheckParseEq("", "%"); 169 CheckParseEq("", "%");
167 CheckParseEq("abc|def", "(| 'abc' 'def')"); 170 CheckParseEq("abc|def", "(| 'abc' 'def')");
168 CheckParseEq("abc|def|ghi", "(| 'abc' 'def' 'ghi')"); 171 CheckParseEq("abc|def|ghi", "(| 'abc' 'def' 'ghi')");
169 CheckParseEq("^xxx$", "(: @^i 'xxx' @$i)"); 172 CheckParseEq("^xxx$", "(: @^i 'xxx' @$i)");
170 CheckParseEq("ab\\b\\d\\bcd", "(: 'ab' @b [0-9] @b 'cd')"); 173 CheckParseEq("ab\\b\\d\\bcd", "(: 'ab' @b [0-9] @b 'cd')");
171 CheckParseEq("\\w|\\d", "(| [0-9 A-Z _ a-z] [0-9])"); 174 CheckParseEq("\\w|\\d", "(| [0-9 A-Z _ a-z] [0-9])");
172 CheckParseEq("a*", "(# 0 - g 'a')"); 175 CheckParseEq("a*", "(# 0 - g 'a')");
(...skipping 11 matching lines...) Expand all
184 CheckParseEq("xyz{1,}", "(: 'xy' (# 1 - g 'z'))"); 187 CheckParseEq("xyz{1,}", "(: 'xy' (# 1 - g 'z'))");
185 CheckParseEq("xyz{1,}?", "(: 'xy' (# 1 - n 'z'))"); 188 CheckParseEq("xyz{1,}?", "(: 'xy' (# 1 - n 'z'))");
186 CheckParseEq("a\\fb\\nc\\rd\\te\\vf", "'a\\x0cb\\x0ac\\x0dd\\x09e\\x0bf'"); 189 CheckParseEq("a\\fb\\nc\\rd\\te\\vf", "'a\\x0cb\\x0ac\\x0dd\\x09e\\x0bf'");
187 CheckParseEq("a\\nb\\bc", "(: 'a\\x0ab' @b 'c')"); 190 CheckParseEq("a\\nb\\bc", "(: 'a\\x0ab' @b 'c')");
188 CheckParseEq("(?:foo)", "'foo'"); 191 CheckParseEq("(?:foo)", "'foo'");
189 CheckParseEq("(?: foo )", "' foo '"); 192 CheckParseEq("(?: foo )", "' foo '");
190 CheckParseEq("(foo|bar|baz)", "(^ (| 'foo' 'bar' 'baz'))"); 193 CheckParseEq("(foo|bar|baz)", "(^ (| 'foo' 'bar' 'baz'))");
191 CheckParseEq("foo|(bar|baz)|quux", "(| 'foo' (^ (| 'bar' 'baz')) 'quux')"); 194 CheckParseEq("foo|(bar|baz)|quux", "(| 'foo' (^ (| 'bar' 'baz')) 'quux')");
192 CheckParseEq("foo(?=bar)baz", "(: 'foo' (-> + 'bar') 'baz')"); 195 CheckParseEq("foo(?=bar)baz", "(: 'foo' (-> + 'bar') 'baz')");
193 CheckParseEq("foo(?!bar)baz", "(: 'foo' (-> - 'bar') 'baz')"); 196 CheckParseEq("foo(?!bar)baz", "(: 'foo' (-> - 'bar') 'baz')");
197 if (lookbehind) {
198 CheckParseEq("foo(?<=bar)baz", "(: 'foo' (<- + 'bar') 'baz')");
199 CheckParseEq("foo(?<!bar)baz", "(: 'foo' (<- - 'bar') 'baz')");
200 } else {
201 CHECK_PARSE_ERROR("foo(?<=bar)baz");
202 CHECK_PARSE_ERROR("foo(?<!bar)baz");
203 }
194 CheckParseEq("()", "(^ %)"); 204 CheckParseEq("()", "(^ %)");
195 CheckParseEq("(?=)", "(-> + %)"); 205 CheckParseEq("(?=)", "(-> + %)");
196 CheckParseEq("[]", "^[\\x00-\\uffff]"); // Doesn't compile on windows 206 CheckParseEq("[]", "^[\\x00-\\uffff]"); // Doesn't compile on windows
197 CheckParseEq("[^]", "[\\x00-\\uffff]"); // \uffff isn't in codepage 1252 207 CheckParseEq("[^]", "[\\x00-\\uffff]"); // \uffff isn't in codepage 1252
198 CheckParseEq("[x]", "[x]"); 208 CheckParseEq("[x]", "[x]");
199 CheckParseEq("[xyz]", "[x y z]"); 209 CheckParseEq("[xyz]", "[x y z]");
200 CheckParseEq("[a-zA-Z0-9]", "[a-z A-Z 0-9]"); 210 CheckParseEq("[a-zA-Z0-9]", "[a-z A-Z 0-9]");
201 CheckParseEq("[-123]", "[- 1 2 3]"); 211 CheckParseEq("[-123]", "[- 1 2 3]");
202 CheckParseEq("[^123]", "^[1 2 3]"); 212 CheckParseEq("[^123]", "^[1 2 3]");
203 CheckParseEq("]", "']'"); 213 CheckParseEq("]", "']'");
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')" 270 "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')"
261 " (^ 'x') (^ 'x') (^ 'x') (^ 'x') '\\x09')"); 271 " (^ 'x') (^ 'x') (^ 'x') (^ 'x') '\\x09')");
262 CheckParseEq("(a)\\1", "(: (^ 'a') (<- 1))"); 272 CheckParseEq("(a)\\1", "(: (^ 'a') (<- 1))");
263 CheckParseEq("(a\\1)", "(^ 'a')"); 273 CheckParseEq("(a\\1)", "(^ 'a')");
264 CheckParseEq("(\\1a)", "(^ 'a')"); 274 CheckParseEq("(\\1a)", "(^ 'a')");
265 CheckParseEq("(?=a)?a", "'a'"); 275 CheckParseEq("(?=a)?a", "'a'");
266 CheckParseEq("(?=a){0,10}a", "'a'"); 276 CheckParseEq("(?=a){0,10}a", "'a'");
267 CheckParseEq("(?=a){1,10}a", "(: (-> + 'a') 'a')"); 277 CheckParseEq("(?=a){1,10}a", "(: (-> + 'a') 'a')");
268 CheckParseEq("(?=a){9,10}a", "(: (-> + 'a') 'a')"); 278 CheckParseEq("(?=a){9,10}a", "(: (-> + 'a') 'a')");
269 CheckParseEq("(?!a)?a", "'a'"); 279 CheckParseEq("(?!a)?a", "'a'");
270 CheckParseEq("\\1(a)", "(^ 'a')"); 280 CheckParseEq("\\1(a)", "(: (<- 1) (^ 'a'))");
271 CheckParseEq("(?!(a))\\1", "(: (-> - (^ 'a')) (<- 1))"); 281 CheckParseEq("(?!(a))\\1", "(: (-> - (^ 'a')) (<- 1))");
272 CheckParseEq("(?!\\1(a\\1)\\1)\\1", "(: (-> - (: (^ 'a') (<- 1))) (<- 1))"); 282 CheckParseEq("(?!\\1(a\\1)\\1)\\1",
283 "(: (-> - (: (<- 1) (^ 'a') (<- 1))) (<- 1))");
284 CheckParseEq("\\1\\2(a(?:\\1(b\\1\\2))\\2)\\1",
285 "(: (<- 1) (<- 2) (^ (: 'a' (^ 'b') (<- 2))) (<- 1))");
286 if (lookbehind) {
287 CheckParseEq("\\1\\2(a(?<=\\1(b\\1\\2))\\2)\\1",
288 "(: (<- 1) (<- 2) (^ (: 'a' (<- + (^ 'b')) (<- 2))) (<- 1))");
289 }
273 CheckParseEq("[\\0]", "[\\x00]"); 290 CheckParseEq("[\\0]", "[\\x00]");
274 CheckParseEq("[\\11]", "[\\x09]"); 291 CheckParseEq("[\\11]", "[\\x09]");
275 CheckParseEq("[\\11a]", "[\\x09 a]"); 292 CheckParseEq("[\\11a]", "[\\x09 a]");
276 CheckParseEq("[\\011]", "[\\x09]"); 293 CheckParseEq("[\\011]", "[\\x09]");
277 CheckParseEq("[\\00011]", "[\\x00 1 1]"); 294 CheckParseEq("[\\00011]", "[\\x00 1 1]");
278 CheckParseEq("[\\118]", "[\\x09 8]"); 295 CheckParseEq("[\\118]", "[\\x09 8]");
279 CheckParseEq("[\\111]", "[I]"); 296 CheckParseEq("[\\111]", "[I]");
280 CheckParseEq("[\\1111]", "[I 1]"); 297 CheckParseEq("[\\1111]", "[I 1]");
281 CheckParseEq("\\x34", "'\x34'"); 298 CheckParseEq("\\x34", "'\x34'");
282 CheckParseEq("\\x60", "'\x60'"); 299 CheckParseEq("\\x60", "'\x60'");
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 CHECK_MIN_MAX("a\\bc", 2, 2); 410 CHECK_MIN_MAX("a\\bc", 2, 2);
394 CHECK_MIN_MAX("a\\Bc", 2, 2); 411 CHECK_MIN_MAX("a\\Bc", 2, 2);
395 CHECK_MIN_MAX("a\\sc", 3, 3); 412 CHECK_MIN_MAX("a\\sc", 3, 3);
396 CHECK_MIN_MAX("a\\Sc", 3, 3); 413 CHECK_MIN_MAX("a\\Sc", 3, 3);
397 CHECK_MIN_MAX("a(?=b)c", 2, 2); 414 CHECK_MIN_MAX("a(?=b)c", 2, 2);
398 CHECK_MIN_MAX("a(?=bbb|bb)c", 2, 2); 415 CHECK_MIN_MAX("a(?=bbb|bb)c", 2, 2);
399 CHECK_MIN_MAX("a(?!bbb|bb)c", 2, 2); 416 CHECK_MIN_MAX("a(?!bbb|bb)c", 2, 2);
400 } 417 }
401 418
402 419
420 TEST(ParserWithLookbehind) {
421 TestRegExpParser(true); // Lookbehind enabled.
422 }
423
424
425 TEST(ParserWithoutLookbehind) {
426 TestRegExpParser(true); // Lookbehind enabled.
427 }
428
429
403 TEST(ParserRegression) { 430 TEST(ParserRegression) {
404 CheckParseEq("[A-Z$-][x]", "(! [A-Z $ -] [x])"); 431 CheckParseEq("[A-Z$-][x]", "(! [A-Z $ -] [x])");
405 CheckParseEq("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); 432 CheckParseEq("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')");
406 CheckParseEq("{", "'{'"); 433 CheckParseEq("{", "'{'");
407 CheckParseEq("a|", "(| 'a' %)"); 434 CheckParseEq("a|", "(| 'a' %)");
408 } 435 }
409 436
410 static void ExpectError(const char* input, 437 static void ExpectError(const char* input,
411 const char* expected) { 438 const char* expected) {
412 v8::HandleScope scope(CcTest::isolate()); 439 v8::HandleScope scope(CcTest::isolate());
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 ContextInitializer initializer; 810 ContextInitializer initializer;
784 Isolate* isolate = CcTest::i_isolate(); 811 Isolate* isolate = CcTest::i_isolate();
785 Factory* factory = isolate->factory(); 812 Factory* factory = isolate->factory();
786 Zone zone; 813 Zone zone;
787 814
788 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, 815 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1,
789 4); 816 4);
790 817
791 Label fail, backtrack; 818 Label fail, backtrack;
792 m.PushBacktrack(&fail); 819 m.PushBacktrack(&fail);
793 m.CheckNotAtStart(NULL); 820 m.CheckNotAtStart(0, NULL);
794 m.LoadCurrentCharacter(2, NULL); 821 m.LoadCurrentCharacter(2, NULL);
795 m.CheckNotCharacter('o', NULL); 822 m.CheckNotCharacter('o', NULL);
796 m.LoadCurrentCharacter(1, NULL, false); 823 m.LoadCurrentCharacter(1, NULL, false);
797 m.CheckNotCharacter('o', NULL); 824 m.CheckNotCharacter('o', NULL);
798 m.LoadCurrentCharacter(0, NULL, false); 825 m.LoadCurrentCharacter(0, NULL, false);
799 m.CheckNotCharacter('f', NULL); 826 m.CheckNotCharacter('f', NULL);
800 m.WriteCurrentPositionToRegister(0, 0); 827 m.WriteCurrentPositionToRegister(0, 0);
801 m.WriteCurrentPositionToRegister(1, 3); 828 m.WriteCurrentPositionToRegister(1, 3);
802 m.AdvanceCurrentPosition(3); 829 m.AdvanceCurrentPosition(3);
803 m.PushBacktrack(&backtrack); 830 m.PushBacktrack(&backtrack);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 ContextInitializer initializer; 877 ContextInitializer initializer;
851 Isolate* isolate = CcTest::i_isolate(); 878 Isolate* isolate = CcTest::i_isolate();
852 Factory* factory = isolate->factory(); 879 Factory* factory = isolate->factory();
853 Zone zone; 880 Zone zone;
854 881
855 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16, 882 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16,
856 4); 883 4);
857 884
858 Label fail, backtrack; 885 Label fail, backtrack;
859 m.PushBacktrack(&fail); 886 m.PushBacktrack(&fail);
860 m.CheckNotAtStart(NULL); 887 m.CheckNotAtStart(0, NULL);
861 m.LoadCurrentCharacter(2, NULL); 888 m.LoadCurrentCharacter(2, NULL);
862 m.CheckNotCharacter('o', NULL); 889 m.CheckNotCharacter('o', NULL);
863 m.LoadCurrentCharacter(1, NULL, false); 890 m.LoadCurrentCharacter(1, NULL, false);
864 m.CheckNotCharacter('o', NULL); 891 m.CheckNotCharacter('o', NULL);
865 m.LoadCurrentCharacter(0, NULL, false); 892 m.LoadCurrentCharacter(0, NULL, false);
866 m.CheckNotCharacter('f', NULL); 893 m.CheckNotCharacter('f', NULL);
867 m.WriteCurrentPositionToRegister(0, 0); 894 m.WriteCurrentPositionToRegister(0, 0);
868 m.WriteCurrentPositionToRegister(1, 3); 895 m.WriteCurrentPositionToRegister(1, 3);
869 m.AdvanceCurrentPosition(3); 896 m.AdvanceCurrentPosition(3);
870 m.PushBacktrack(&backtrack); 897 m.PushBacktrack(&backtrack);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 Factory* factory = isolate->factory(); 993 Factory* factory = isolate->factory();
967 Zone zone; 994 Zone zone;
968 995
969 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, 996 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1,
970 4); 997 4);
971 998
972 m.WriteCurrentPositionToRegister(0, 0); 999 m.WriteCurrentPositionToRegister(0, 0);
973 m.AdvanceCurrentPosition(2); 1000 m.AdvanceCurrentPosition(2);
974 m.WriteCurrentPositionToRegister(1, 0); 1001 m.WriteCurrentPositionToRegister(1, 0);
975 Label nomatch; 1002 Label nomatch;
976 m.CheckNotBackReference(0, &nomatch); 1003 m.CheckNotBackReference(0, false, &nomatch);
977 m.Fail(); 1004 m.Fail();
978 m.Bind(&nomatch); 1005 m.Bind(&nomatch);
979 m.AdvanceCurrentPosition(2); 1006 m.AdvanceCurrentPosition(2);
980 Label missing_match; 1007 Label missing_match;
981 m.CheckNotBackReference(0, &missing_match); 1008 m.CheckNotBackReference(0, false, &missing_match);
982 m.WriteCurrentPositionToRegister(2, 0); 1009 m.WriteCurrentPositionToRegister(2, 0);
983 m.Succeed(); 1010 m.Succeed();
984 m.Bind(&missing_match); 1011 m.Bind(&missing_match);
985 m.Fail(); 1012 m.Fail();
986 1013
987 Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1"); 1014 Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1");
988 Handle<Object> code_object = m.GetCode(source); 1015 Handle<Object> code_object = m.GetCode(source);
989 Handle<Code> code = Handle<Code>::cast(code_object); 1016 Handle<Code> code = Handle<Code>::cast(code_object);
990 1017
991 Handle<String> input = factory->NewStringFromStaticChars("fooofo"); 1018 Handle<String> input = factory->NewStringFromStaticChars("fooofo");
(...skipping 24 matching lines...) Expand all
1016 Factory* factory = isolate->factory(); 1043 Factory* factory = isolate->factory();
1017 Zone zone; 1044 Zone zone;
1018 1045
1019 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16, 1046 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16,
1020 4); 1047 4);
1021 1048
1022 m.WriteCurrentPositionToRegister(0, 0); 1049 m.WriteCurrentPositionToRegister(0, 0);
1023 m.AdvanceCurrentPosition(2); 1050 m.AdvanceCurrentPosition(2);
1024 m.WriteCurrentPositionToRegister(1, 0); 1051 m.WriteCurrentPositionToRegister(1, 0);
1025 Label nomatch; 1052 Label nomatch;
1026 m.CheckNotBackReference(0, &nomatch); 1053 m.CheckNotBackReference(0, false, &nomatch);
1027 m.Fail(); 1054 m.Fail();
1028 m.Bind(&nomatch); 1055 m.Bind(&nomatch);
1029 m.AdvanceCurrentPosition(2); 1056 m.AdvanceCurrentPosition(2);
1030 Label missing_match; 1057 Label missing_match;
1031 m.CheckNotBackReference(0, &missing_match); 1058 m.CheckNotBackReference(0, false, &missing_match);
1032 m.WriteCurrentPositionToRegister(2, 0); 1059 m.WriteCurrentPositionToRegister(2, 0);
1033 m.Succeed(); 1060 m.Succeed();
1034 m.Bind(&missing_match); 1061 m.Bind(&missing_match);
1035 m.Fail(); 1062 m.Fail();
1036 1063
1037 Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1"); 1064 Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1");
1038 Handle<Object> code_object = m.GetCode(source); 1065 Handle<Object> code_object = m.GetCode(source);
1039 Handle<Code> code = Handle<Code>::cast(code_object); 1066 Handle<Code> code = Handle<Code>::cast(code_object);
1040 1067
1041 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028}; 1068 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028};
(...skipping 24 matching lines...) Expand all
1066 v8::V8::Initialize(); 1093 v8::V8::Initialize();
1067 ContextInitializer initializer; 1094 ContextInitializer initializer;
1068 Isolate* isolate = CcTest::i_isolate(); 1095 Isolate* isolate = CcTest::i_isolate();
1069 Factory* factory = isolate->factory(); 1096 Factory* factory = isolate->factory();
1070 Zone zone; 1097 Zone zone;
1071 1098
1072 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, 1099 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1,
1073 0); 1100 0);
1074 1101
1075 Label not_at_start, newline, fail; 1102 Label not_at_start, newline, fail;
1076 m.CheckNotAtStart(&not_at_start); 1103 m.CheckNotAtStart(0, &not_at_start);
1077 // Check that prevchar = '\n' and current = 'f'. 1104 // Check that prevchar = '\n' and current = 'f'.
1078 m.CheckCharacter('\n', &newline); 1105 m.CheckCharacter('\n', &newline);
1079 m.Bind(&fail); 1106 m.Bind(&fail);
1080 m.Fail(); 1107 m.Fail();
1081 m.Bind(&newline); 1108 m.Bind(&newline);
1082 m.LoadCurrentCharacter(0, &fail); 1109 m.LoadCurrentCharacter(0, &fail);
1083 m.CheckNotCharacter('f', &fail); 1110 m.CheckNotCharacter('f', &fail);
1084 m.Succeed(); 1111 m.Succeed();
1085 1112
1086 m.Bind(&not_at_start); 1113 m.Bind(&not_at_start);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 1158
1132 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, 1159 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1,
1133 4); 1160 4);
1134 1161
1135 Label fail, succ; 1162 Label fail, succ;
1136 1163
1137 m.WriteCurrentPositionToRegister(0, 0); 1164 m.WriteCurrentPositionToRegister(0, 0);
1138 m.WriteCurrentPositionToRegister(2, 0); 1165 m.WriteCurrentPositionToRegister(2, 0);
1139 m.AdvanceCurrentPosition(3); 1166 m.AdvanceCurrentPosition(3);
1140 m.WriteCurrentPositionToRegister(3, 0); 1167 m.WriteCurrentPositionToRegister(3, 0);
1141 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "AbC". 1168 m.CheckNotBackReferenceIgnoreCase(2, false, &fail); // Match "AbC".
1142 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "ABC". 1169 m.CheckNotBackReferenceIgnoreCase(2, false, &fail); // Match "ABC".
1143 Label expected_fail; 1170 Label expected_fail;
1144 m.CheckNotBackReferenceIgnoreCase(2, &expected_fail); 1171 m.CheckNotBackReferenceIgnoreCase(2, false, &expected_fail);
1145 m.Bind(&fail); 1172 m.Bind(&fail);
1146 m.Fail(); 1173 m.Fail();
1147 1174
1148 m.Bind(&expected_fail); 1175 m.Bind(&expected_fail);
1149 m.AdvanceCurrentPosition(3); // Skip "xYz" 1176 m.AdvanceCurrentPosition(3); // Skip "xYz"
1150 m.CheckNotBackReferenceIgnoreCase(2, &succ); 1177 m.CheckNotBackReferenceIgnoreCase(2, false, &succ);
1151 m.Fail(); 1178 m.Fail();
1152 1179
1153 m.Bind(&succ); 1180 m.Bind(&succ);
1154 m.WriteCurrentPositionToRegister(1, 0); 1181 m.WriteCurrentPositionToRegister(1, 0);
1155 m.Succeed(); 1182 m.Succeed();
1156 1183
1157 Handle<String> source = 1184 Handle<String> source =
1158 factory->NewStringFromStaticChars("^(abc)\1\1(?!\1)...(?!\1)"); 1185 factory->NewStringFromStaticChars("^(abc)\1\1(?!\1)...(?!\1)");
1159 Handle<Object> code_object = m.GetCode(source); 1186 Handle<Object> code_object = m.GetCode(source);
1160 Handle<Code> code = Handle<Code>::cast(code_object); 1187 Handle<Code> code = Handle<Code>::cast(code_object);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, 1359 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1,
1333 2); 1360 2);
1334 1361
1335 // At least 2048, to ensure the allocated space for registers 1362 // At least 2048, to ensure the allocated space for registers
1336 // span one full page. 1363 // span one full page.
1337 const int large_number = 8000; 1364 const int large_number = 8000;
1338 m.WriteCurrentPositionToRegister(large_number, 42); 1365 m.WriteCurrentPositionToRegister(large_number, 42);
1339 m.WriteCurrentPositionToRegister(0, 0); 1366 m.WriteCurrentPositionToRegister(0, 0);
1340 m.WriteCurrentPositionToRegister(1, 1); 1367 m.WriteCurrentPositionToRegister(1, 1);
1341 Label done; 1368 Label done;
1342 m.CheckNotBackReference(0, &done); // Performs a system-stack push. 1369 m.CheckNotBackReference(0, false, &done); // Performs a system-stack push.
1343 m.Bind(&done); 1370 m.Bind(&done);
1344 m.PushRegister(large_number, RegExpMacroAssembler::kNoStackLimitCheck); 1371 m.PushRegister(large_number, RegExpMacroAssembler::kNoStackLimitCheck);
1345 m.PopRegister(1); 1372 m.PopRegister(1);
1346 m.Succeed(); 1373 m.Succeed();
1347 1374
1348 Handle<String> source = 1375 Handle<String> source =
1349 factory->NewStringFromStaticChars("<huge register space test>"); 1376 factory->NewStringFromStaticChars("<huge register space test>");
1350 Handle<Object> code_object = m.GetCode(source); 1377 Handle<Object> code_object = m.GetCode(source);
1351 Handle<Code> code = Handle<Code>::cast(code_object); 1378 Handle<Code> code = Handle<Code>::cast(code_object);
1352 1379
(...skipping 28 matching lines...) Expand all
1381 // ^f(o)o. 1408 // ^f(o)o.
1382 Label start, fail, backtrack; 1409 Label start, fail, backtrack;
1383 1410
1384 m.SetRegister(4, 42); 1411 m.SetRegister(4, 42);
1385 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck); 1412 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck);
1386 m.AdvanceRegister(4, 42); 1413 m.AdvanceRegister(4, 42);
1387 m.GoTo(&start); 1414 m.GoTo(&start);
1388 m.Fail(); 1415 m.Fail();
1389 m.Bind(&start); 1416 m.Bind(&start);
1390 m.PushBacktrack(&fail); 1417 m.PushBacktrack(&fail);
1391 m.CheckNotAtStart(NULL); 1418 m.CheckNotAtStart(0, NULL);
1392 m.LoadCurrentCharacter(0, NULL); 1419 m.LoadCurrentCharacter(0, NULL);
1393 m.CheckNotCharacter('f', NULL); 1420 m.CheckNotCharacter('f', NULL);
1394 m.LoadCurrentCharacter(1, NULL); 1421 m.LoadCurrentCharacter(1, NULL);
1395 m.CheckNotCharacter('o', NULL); 1422 m.CheckNotCharacter('o', NULL);
1396 m.LoadCurrentCharacter(2, NULL); 1423 m.LoadCurrentCharacter(2, NULL);
1397 m.CheckNotCharacter('o', NULL); 1424 m.CheckNotCharacter('o', NULL);
1398 m.WriteCurrentPositionToRegister(0, 0); 1425 m.WriteCurrentPositionToRegister(0, 0);
1399 m.WriteCurrentPositionToRegister(1, 3); 1426 m.WriteCurrentPositionToRegister(1, 3);
1400 m.WriteCurrentPositionToRegister(2, 1); 1427 m.WriteCurrentPositionToRegister(2, 1);
1401 m.WriteCurrentPositionToRegister(3, 2); 1428 m.WriteCurrentPositionToRegister(3, 2);
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 1839
1813 ZoneList<CharacterRange> first_only(4, &zone); 1840 ZoneList<CharacterRange> first_only(4, &zone);
1814 ZoneList<CharacterRange> second_only(4, &zone); 1841 ZoneList<CharacterRange> second_only(4, &zone);
1815 ZoneList<CharacterRange> both(4, &zone); 1842 ZoneList<CharacterRange> both(4, &zone);
1816 } 1843 }
1817 1844
1818 1845
1819 TEST(Graph) { 1846 TEST(Graph) {
1820 Execute("\\b\\w+\\b", false, true, true); 1847 Execute("\\b\\w+\\b", false, true, true);
1821 } 1848 }
OLDNEW
« no previous file with comments | « src/regexp/x64/regexp-macro-assembler-x64.cc ('k') | test/mjsunit/harmony/regexp-lookbehind.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698