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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 CheckParseEq("(x)(x)(x)\\4*", | 263 CheckParseEq("(x)(x)(x)\\4*", |
254 "(: (^ 'x') (^ 'x') (^ 'x')" | 264 "(: (^ 'x') (^ 'x') (^ 'x')" |
255 " (# 0 - g '\\x04'))"); | 265 " (# 0 - g '\\x04'))"); |
256 CheckParseEq("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\10", | 266 CheckParseEq("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\10", |
257 "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')" | 267 "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')" |
258 " (^ 'x') (^ 'x') (^ 'x') (^ 'x') (<- 10))"); | 268 " (^ 'x') (^ 'x') (^ 'x') (^ 'x') (<- 10))"); |
259 CheckParseEq("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\11", | 269 CheckParseEq("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\11", |
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' (<- 1)))"); |
264 CheckParseEq("(\\1a)", "(^ 'a')"); | 274 CheckParseEq("(\\1a)", "(^ (: (<- 1) '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))) (<- 1))"); |
273 CheckParseEq("[\\0]", "[\\x00]"); | 284 CheckParseEq("[\\0]", "[\\x00]"); |
274 CheckParseEq("[\\11]", "[\\x09]"); | 285 CheckParseEq("[\\11]", "[\\x09]"); |
275 CheckParseEq("[\\11a]", "[\\x09 a]"); | 286 CheckParseEq("[\\11a]", "[\\x09 a]"); |
276 CheckParseEq("[\\011]", "[\\x09]"); | 287 CheckParseEq("[\\011]", "[\\x09]"); |
277 CheckParseEq("[\\00011]", "[\\x00 1 1]"); | 288 CheckParseEq("[\\00011]", "[\\x00 1 1]"); |
278 CheckParseEq("[\\118]", "[\\x09 8]"); | 289 CheckParseEq("[\\118]", "[\\x09 8]"); |
279 CheckParseEq("[\\111]", "[I]"); | 290 CheckParseEq("[\\111]", "[I]"); |
280 CheckParseEq("[\\1111]", "[I 1]"); | 291 CheckParseEq("[\\1111]", "[I 1]"); |
281 CheckParseEq("\\x34", "'\x34'"); | 292 CheckParseEq("\\x34", "'\x34'"); |
282 CheckParseEq("\\x60", "'\x60'"); | 293 CheckParseEq("\\x60", "'\x60'"); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 CHECK_MIN_MAX("a\\bc", 2, 2); | 404 CHECK_MIN_MAX("a\\bc", 2, 2); |
394 CHECK_MIN_MAX("a\\Bc", 2, 2); | 405 CHECK_MIN_MAX("a\\Bc", 2, 2); |
395 CHECK_MIN_MAX("a\\sc", 3, 3); | 406 CHECK_MIN_MAX("a\\sc", 3, 3); |
396 CHECK_MIN_MAX("a\\Sc", 3, 3); | 407 CHECK_MIN_MAX("a\\Sc", 3, 3); |
397 CHECK_MIN_MAX("a(?=b)c", 2, 2); | 408 CHECK_MIN_MAX("a(?=b)c", 2, 2); |
398 CHECK_MIN_MAX("a(?=bbb|bb)c", 2, 2); | 409 CHECK_MIN_MAX("a(?=bbb|bb)c", 2, 2); |
399 CHECK_MIN_MAX("a(?!bbb|bb)c", 2, 2); | 410 CHECK_MIN_MAX("a(?!bbb|bb)c", 2, 2); |
400 } | 411 } |
401 | 412 |
402 | 413 |
| 414 TEST(ParserWithLookbehind) { |
| 415 TestRegExpParser(true); // Lookbehind enabled. |
| 416 } |
| 417 |
| 418 |
| 419 TEST(ParserWithoutLookbehind) { |
| 420 TestRegExpParser(true); // Lookbehind enabled. |
| 421 } |
| 422 |
| 423 |
403 TEST(ParserRegression) { | 424 TEST(ParserRegression) { |
404 CheckParseEq("[A-Z$-][x]", "(! [A-Z $ -] [x])"); | 425 CheckParseEq("[A-Z$-][x]", "(! [A-Z $ -] [x])"); |
405 CheckParseEq("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); | 426 CheckParseEq("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); |
406 CheckParseEq("{", "'{'"); | 427 CheckParseEq("{", "'{'"); |
407 CheckParseEq("a|", "(| 'a' %)"); | 428 CheckParseEq("a|", "(| 'a' %)"); |
408 } | 429 } |
409 | 430 |
410 static void ExpectError(const char* input, | 431 static void ExpectError(const char* input, |
411 const char* expected) { | 432 const char* expected) { |
412 v8::HandleScope scope(CcTest::isolate()); | 433 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 ContextInitializer initializer; | 804 ContextInitializer initializer; |
784 Isolate* isolate = CcTest::i_isolate(); | 805 Isolate* isolate = CcTest::i_isolate(); |
785 Factory* factory = isolate->factory(); | 806 Factory* factory = isolate->factory(); |
786 Zone zone; | 807 Zone zone; |
787 | 808 |
788 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 809 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
789 4); | 810 4); |
790 | 811 |
791 Label fail, backtrack; | 812 Label fail, backtrack; |
792 m.PushBacktrack(&fail); | 813 m.PushBacktrack(&fail); |
793 m.CheckNotAtStart(NULL); | 814 m.CheckNotAtStart(0, NULL); |
794 m.LoadCurrentCharacter(2, NULL); | 815 m.LoadCurrentCharacter(2, NULL); |
795 m.CheckNotCharacter('o', NULL); | 816 m.CheckNotCharacter('o', NULL); |
796 m.LoadCurrentCharacter(1, NULL, false); | 817 m.LoadCurrentCharacter(1, NULL, false); |
797 m.CheckNotCharacter('o', NULL); | 818 m.CheckNotCharacter('o', NULL); |
798 m.LoadCurrentCharacter(0, NULL, false); | 819 m.LoadCurrentCharacter(0, NULL, false); |
799 m.CheckNotCharacter('f', NULL); | 820 m.CheckNotCharacter('f', NULL); |
800 m.WriteCurrentPositionToRegister(0, 0); | 821 m.WriteCurrentPositionToRegister(0, 0); |
801 m.WriteCurrentPositionToRegister(1, 3); | 822 m.WriteCurrentPositionToRegister(1, 3); |
802 m.AdvanceCurrentPosition(3); | 823 m.AdvanceCurrentPosition(3); |
803 m.PushBacktrack(&backtrack); | 824 m.PushBacktrack(&backtrack); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 ContextInitializer initializer; | 871 ContextInitializer initializer; |
851 Isolate* isolate = CcTest::i_isolate(); | 872 Isolate* isolate = CcTest::i_isolate(); |
852 Factory* factory = isolate->factory(); | 873 Factory* factory = isolate->factory(); |
853 Zone zone; | 874 Zone zone; |
854 | 875 |
855 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16, | 876 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16, |
856 4); | 877 4); |
857 | 878 |
858 Label fail, backtrack; | 879 Label fail, backtrack; |
859 m.PushBacktrack(&fail); | 880 m.PushBacktrack(&fail); |
860 m.CheckNotAtStart(NULL); | 881 m.CheckNotAtStart(0, NULL); |
861 m.LoadCurrentCharacter(2, NULL); | 882 m.LoadCurrentCharacter(2, NULL); |
862 m.CheckNotCharacter('o', NULL); | 883 m.CheckNotCharacter('o', NULL); |
863 m.LoadCurrentCharacter(1, NULL, false); | 884 m.LoadCurrentCharacter(1, NULL, false); |
864 m.CheckNotCharacter('o', NULL); | 885 m.CheckNotCharacter('o', NULL); |
865 m.LoadCurrentCharacter(0, NULL, false); | 886 m.LoadCurrentCharacter(0, NULL, false); |
866 m.CheckNotCharacter('f', NULL); | 887 m.CheckNotCharacter('f', NULL); |
867 m.WriteCurrentPositionToRegister(0, 0); | 888 m.WriteCurrentPositionToRegister(0, 0); |
868 m.WriteCurrentPositionToRegister(1, 3); | 889 m.WriteCurrentPositionToRegister(1, 3); |
869 m.AdvanceCurrentPosition(3); | 890 m.AdvanceCurrentPosition(3); |
870 m.PushBacktrack(&backtrack); | 891 m.PushBacktrack(&backtrack); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 Factory* factory = isolate->factory(); | 987 Factory* factory = isolate->factory(); |
967 Zone zone; | 988 Zone zone; |
968 | 989 |
969 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 990 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
970 4); | 991 4); |
971 | 992 |
972 m.WriteCurrentPositionToRegister(0, 0); | 993 m.WriteCurrentPositionToRegister(0, 0); |
973 m.AdvanceCurrentPosition(2); | 994 m.AdvanceCurrentPosition(2); |
974 m.WriteCurrentPositionToRegister(1, 0); | 995 m.WriteCurrentPositionToRegister(1, 0); |
975 Label nomatch; | 996 Label nomatch; |
976 m.CheckNotBackReference(0, &nomatch); | 997 m.CheckNotBackReference(0, false, &nomatch); |
977 m.Fail(); | 998 m.Fail(); |
978 m.Bind(&nomatch); | 999 m.Bind(&nomatch); |
979 m.AdvanceCurrentPosition(2); | 1000 m.AdvanceCurrentPosition(2); |
980 Label missing_match; | 1001 Label missing_match; |
981 m.CheckNotBackReference(0, &missing_match); | 1002 m.CheckNotBackReference(0, false, &missing_match); |
982 m.WriteCurrentPositionToRegister(2, 0); | 1003 m.WriteCurrentPositionToRegister(2, 0); |
983 m.Succeed(); | 1004 m.Succeed(); |
984 m.Bind(&missing_match); | 1005 m.Bind(&missing_match); |
985 m.Fail(); | 1006 m.Fail(); |
986 | 1007 |
987 Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1"); | 1008 Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1"); |
988 Handle<Object> code_object = m.GetCode(source); | 1009 Handle<Object> code_object = m.GetCode(source); |
989 Handle<Code> code = Handle<Code>::cast(code_object); | 1010 Handle<Code> code = Handle<Code>::cast(code_object); |
990 | 1011 |
991 Handle<String> input = factory->NewStringFromStaticChars("fooofo"); | 1012 Handle<String> input = factory->NewStringFromStaticChars("fooofo"); |
(...skipping 24 matching lines...) Expand all Loading... |
1016 Factory* factory = isolate->factory(); | 1037 Factory* factory = isolate->factory(); |
1017 Zone zone; | 1038 Zone zone; |
1018 | 1039 |
1019 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16, | 1040 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::UC16, |
1020 4); | 1041 4); |
1021 | 1042 |
1022 m.WriteCurrentPositionToRegister(0, 0); | 1043 m.WriteCurrentPositionToRegister(0, 0); |
1023 m.AdvanceCurrentPosition(2); | 1044 m.AdvanceCurrentPosition(2); |
1024 m.WriteCurrentPositionToRegister(1, 0); | 1045 m.WriteCurrentPositionToRegister(1, 0); |
1025 Label nomatch; | 1046 Label nomatch; |
1026 m.CheckNotBackReference(0, &nomatch); | 1047 m.CheckNotBackReference(0, false, &nomatch); |
1027 m.Fail(); | 1048 m.Fail(); |
1028 m.Bind(&nomatch); | 1049 m.Bind(&nomatch); |
1029 m.AdvanceCurrentPosition(2); | 1050 m.AdvanceCurrentPosition(2); |
1030 Label missing_match; | 1051 Label missing_match; |
1031 m.CheckNotBackReference(0, &missing_match); | 1052 m.CheckNotBackReference(0, false, &missing_match); |
1032 m.WriteCurrentPositionToRegister(2, 0); | 1053 m.WriteCurrentPositionToRegister(2, 0); |
1033 m.Succeed(); | 1054 m.Succeed(); |
1034 m.Bind(&missing_match); | 1055 m.Bind(&missing_match); |
1035 m.Fail(); | 1056 m.Fail(); |
1036 | 1057 |
1037 Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1"); | 1058 Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1"); |
1038 Handle<Object> code_object = m.GetCode(source); | 1059 Handle<Object> code_object = m.GetCode(source); |
1039 Handle<Code> code = Handle<Code>::cast(code_object); | 1060 Handle<Code> code = Handle<Code>::cast(code_object); |
1040 | 1061 |
1041 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028}; | 1062 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028}; |
(...skipping 24 matching lines...) Expand all Loading... |
1066 v8::V8::Initialize(); | 1087 v8::V8::Initialize(); |
1067 ContextInitializer initializer; | 1088 ContextInitializer initializer; |
1068 Isolate* isolate = CcTest::i_isolate(); | 1089 Isolate* isolate = CcTest::i_isolate(); |
1069 Factory* factory = isolate->factory(); | 1090 Factory* factory = isolate->factory(); |
1070 Zone zone; | 1091 Zone zone; |
1071 | 1092 |
1072 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1093 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
1073 0); | 1094 0); |
1074 | 1095 |
1075 Label not_at_start, newline, fail; | 1096 Label not_at_start, newline, fail; |
1076 m.CheckNotAtStart(¬_at_start); | 1097 m.CheckNotAtStart(0, ¬_at_start); |
1077 // Check that prevchar = '\n' and current = 'f'. | 1098 // Check that prevchar = '\n' and current = 'f'. |
1078 m.CheckCharacter('\n', &newline); | 1099 m.CheckCharacter('\n', &newline); |
1079 m.Bind(&fail); | 1100 m.Bind(&fail); |
1080 m.Fail(); | 1101 m.Fail(); |
1081 m.Bind(&newline); | 1102 m.Bind(&newline); |
1082 m.LoadCurrentCharacter(0, &fail); | 1103 m.LoadCurrentCharacter(0, &fail); |
1083 m.CheckNotCharacter('f', &fail); | 1104 m.CheckNotCharacter('f', &fail); |
1084 m.Succeed(); | 1105 m.Succeed(); |
1085 | 1106 |
1086 m.Bind(¬_at_start); | 1107 m.Bind(¬_at_start); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 | 1152 |
1132 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1153 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
1133 4); | 1154 4); |
1134 | 1155 |
1135 Label fail, succ; | 1156 Label fail, succ; |
1136 | 1157 |
1137 m.WriteCurrentPositionToRegister(0, 0); | 1158 m.WriteCurrentPositionToRegister(0, 0); |
1138 m.WriteCurrentPositionToRegister(2, 0); | 1159 m.WriteCurrentPositionToRegister(2, 0); |
1139 m.AdvanceCurrentPosition(3); | 1160 m.AdvanceCurrentPosition(3); |
1140 m.WriteCurrentPositionToRegister(3, 0); | 1161 m.WriteCurrentPositionToRegister(3, 0); |
1141 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "AbC". | 1162 m.CheckNotBackReferenceIgnoreCase(2, false, &fail); // Match "AbC". |
1142 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "ABC". | 1163 m.CheckNotBackReferenceIgnoreCase(2, false, &fail); // Match "ABC". |
1143 Label expected_fail; | 1164 Label expected_fail; |
1144 m.CheckNotBackReferenceIgnoreCase(2, &expected_fail); | 1165 m.CheckNotBackReferenceIgnoreCase(2, false, &expected_fail); |
1145 m.Bind(&fail); | 1166 m.Bind(&fail); |
1146 m.Fail(); | 1167 m.Fail(); |
1147 | 1168 |
1148 m.Bind(&expected_fail); | 1169 m.Bind(&expected_fail); |
1149 m.AdvanceCurrentPosition(3); // Skip "xYz" | 1170 m.AdvanceCurrentPosition(3); // Skip "xYz" |
1150 m.CheckNotBackReferenceIgnoreCase(2, &succ); | 1171 m.CheckNotBackReferenceIgnoreCase(2, false, &succ); |
1151 m.Fail(); | 1172 m.Fail(); |
1152 | 1173 |
1153 m.Bind(&succ); | 1174 m.Bind(&succ); |
1154 m.WriteCurrentPositionToRegister(1, 0); | 1175 m.WriteCurrentPositionToRegister(1, 0); |
1155 m.Succeed(); | 1176 m.Succeed(); |
1156 | 1177 |
1157 Handle<String> source = | 1178 Handle<String> source = |
1158 factory->NewStringFromStaticChars("^(abc)\1\1(?!\1)...(?!\1)"); | 1179 factory->NewStringFromStaticChars("^(abc)\1\1(?!\1)...(?!\1)"); |
1159 Handle<Object> code_object = m.GetCode(source); | 1180 Handle<Object> code_object = m.GetCode(source); |
1160 Handle<Code> code = Handle<Code>::cast(code_object); | 1181 Handle<Code> code = Handle<Code>::cast(code_object); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, | 1353 ArchRegExpMacroAssembler m(isolate, &zone, NativeRegExpMacroAssembler::LATIN1, |
1333 2); | 1354 2); |
1334 | 1355 |
1335 // At least 2048, to ensure the allocated space for registers | 1356 // At least 2048, to ensure the allocated space for registers |
1336 // span one full page. | 1357 // span one full page. |
1337 const int large_number = 8000; | 1358 const int large_number = 8000; |
1338 m.WriteCurrentPositionToRegister(large_number, 42); | 1359 m.WriteCurrentPositionToRegister(large_number, 42); |
1339 m.WriteCurrentPositionToRegister(0, 0); | 1360 m.WriteCurrentPositionToRegister(0, 0); |
1340 m.WriteCurrentPositionToRegister(1, 1); | 1361 m.WriteCurrentPositionToRegister(1, 1); |
1341 Label done; | 1362 Label done; |
1342 m.CheckNotBackReference(0, &done); // Performs a system-stack push. | 1363 m.CheckNotBackReference(0, false, &done); // Performs a system-stack push. |
1343 m.Bind(&done); | 1364 m.Bind(&done); |
1344 m.PushRegister(large_number, RegExpMacroAssembler::kNoStackLimitCheck); | 1365 m.PushRegister(large_number, RegExpMacroAssembler::kNoStackLimitCheck); |
1345 m.PopRegister(1); | 1366 m.PopRegister(1); |
1346 m.Succeed(); | 1367 m.Succeed(); |
1347 | 1368 |
1348 Handle<String> source = | 1369 Handle<String> source = |
1349 factory->NewStringFromStaticChars("<huge register space test>"); | 1370 factory->NewStringFromStaticChars("<huge register space test>"); |
1350 Handle<Object> code_object = m.GetCode(source); | 1371 Handle<Object> code_object = m.GetCode(source); |
1351 Handle<Code> code = Handle<Code>::cast(code_object); | 1372 Handle<Code> code = Handle<Code>::cast(code_object); |
1352 | 1373 |
(...skipping 28 matching lines...) Expand all Loading... |
1381 // ^f(o)o. | 1402 // ^f(o)o. |
1382 Label start, fail, backtrack; | 1403 Label start, fail, backtrack; |
1383 | 1404 |
1384 m.SetRegister(4, 42); | 1405 m.SetRegister(4, 42); |
1385 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck); | 1406 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck); |
1386 m.AdvanceRegister(4, 42); | 1407 m.AdvanceRegister(4, 42); |
1387 m.GoTo(&start); | 1408 m.GoTo(&start); |
1388 m.Fail(); | 1409 m.Fail(); |
1389 m.Bind(&start); | 1410 m.Bind(&start); |
1390 m.PushBacktrack(&fail); | 1411 m.PushBacktrack(&fail); |
1391 m.CheckNotAtStart(NULL); | 1412 m.CheckNotAtStart(0, NULL); |
1392 m.LoadCurrentCharacter(0, NULL); | 1413 m.LoadCurrentCharacter(0, NULL); |
1393 m.CheckNotCharacter('f', NULL); | 1414 m.CheckNotCharacter('f', NULL); |
1394 m.LoadCurrentCharacter(1, NULL); | 1415 m.LoadCurrentCharacter(1, NULL); |
1395 m.CheckNotCharacter('o', NULL); | 1416 m.CheckNotCharacter('o', NULL); |
1396 m.LoadCurrentCharacter(2, NULL); | 1417 m.LoadCurrentCharacter(2, NULL); |
1397 m.CheckNotCharacter('o', NULL); | 1418 m.CheckNotCharacter('o', NULL); |
1398 m.WriteCurrentPositionToRegister(0, 0); | 1419 m.WriteCurrentPositionToRegister(0, 0); |
1399 m.WriteCurrentPositionToRegister(1, 3); | 1420 m.WriteCurrentPositionToRegister(1, 3); |
1400 m.WriteCurrentPositionToRegister(2, 1); | 1421 m.WriteCurrentPositionToRegister(2, 1); |
1401 m.WriteCurrentPositionToRegister(3, 2); | 1422 m.WriteCurrentPositionToRegister(3, 2); |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1812 | 1833 |
1813 ZoneList<CharacterRange> first_only(4, &zone); | 1834 ZoneList<CharacterRange> first_only(4, &zone); |
1814 ZoneList<CharacterRange> second_only(4, &zone); | 1835 ZoneList<CharacterRange> second_only(4, &zone); |
1815 ZoneList<CharacterRange> both(4, &zone); | 1836 ZoneList<CharacterRange> both(4, &zone); |
1816 } | 1837 } |
1817 | 1838 |
1818 | 1839 |
1819 TEST(Graph) { | 1840 TEST(Graph) { |
1820 Execute("\\b\\w+\\b", false, true, true); | 1841 Execute("\\b\\w+\\b", false, true, true); |
1821 } | 1842 } |
OLD | NEW |