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 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 Isolate::Current()->runtime_zone()); | 752 Isolate::Current()->runtime_zone()); |
753 | 753 |
754 m.Succeed(); | 754 m.Succeed(); |
755 | 755 |
756 Handle<String> source = factory->NewStringFromAscii(CStrVector("")); | 756 Handle<String> source = factory->NewStringFromAscii(CStrVector("")); |
757 Handle<Object> code_object = m.GetCode(source); | 757 Handle<Object> code_object = m.GetCode(source); |
758 Handle<Code> code = Handle<Code>::cast(code_object); | 758 Handle<Code> code = Handle<Code>::cast(code_object); |
759 | 759 |
760 int captures[4] = {42, 37, 87, 117}; | 760 int captures[4] = {42, 37, 87, 117}; |
761 Handle<String> input = factory->NewStringFromAscii(CStrVector("foofoo")); | 761 Handle<String> input = factory->NewStringFromAscii(CStrVector("foofoo")); |
762 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 762 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
763 const byte* start_adr = | 763 const byte* start_adr = |
764 reinterpret_cast<const byte*>(seq_input->GetCharsAddress()); | 764 reinterpret_cast<const byte*>(seq_input->GetCharsAddress()); |
765 | 765 |
766 NativeRegExpMacroAssembler::Result result = | 766 NativeRegExpMacroAssembler::Result result = |
767 Execute(*code, | 767 Execute(*code, |
768 *input, | 768 *input, |
769 0, | 769 0, |
770 start_adr, | 770 start_adr, |
771 start_adr + seq_input->length(), | 771 start_adr + seq_input->length(), |
772 captures); | 772 captures); |
(...skipping 25 matching lines...) Expand all Loading... |
798 m.Succeed(); | 798 m.Succeed(); |
799 m.Bind(&fail); | 799 m.Bind(&fail); |
800 m.Fail(); | 800 m.Fail(); |
801 | 801 |
802 Handle<String> source = factory->NewStringFromAscii(CStrVector("^foo")); | 802 Handle<String> source = factory->NewStringFromAscii(CStrVector("^foo")); |
803 Handle<Object> code_object = m.GetCode(source); | 803 Handle<Object> code_object = m.GetCode(source); |
804 Handle<Code> code = Handle<Code>::cast(code_object); | 804 Handle<Code> code = Handle<Code>::cast(code_object); |
805 | 805 |
806 int captures[4] = {42, 37, 87, 117}; | 806 int captures[4] = {42, 37, 87, 117}; |
807 Handle<String> input = factory->NewStringFromAscii(CStrVector("foofoo")); | 807 Handle<String> input = factory->NewStringFromAscii(CStrVector("foofoo")); |
808 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 808 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
809 Address start_adr = seq_input->GetCharsAddress(); | 809 Address start_adr = seq_input->GetCharsAddress(); |
810 | 810 |
811 NativeRegExpMacroAssembler::Result result = | 811 NativeRegExpMacroAssembler::Result result = |
812 Execute(*code, | 812 Execute(*code, |
813 *input, | 813 *input, |
814 0, | 814 0, |
815 start_adr, | 815 start_adr, |
816 start_adr + input->length(), | 816 start_adr + input->length(), |
817 captures); | 817 captures); |
818 | 818 |
819 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); | 819 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
820 CHECK_EQ(0, captures[0]); | 820 CHECK_EQ(0, captures[0]); |
821 CHECK_EQ(3, captures[1]); | 821 CHECK_EQ(3, captures[1]); |
822 CHECK_EQ(-1, captures[2]); | 822 CHECK_EQ(-1, captures[2]); |
823 CHECK_EQ(-1, captures[3]); | 823 CHECK_EQ(-1, captures[3]); |
824 | 824 |
825 input = factory->NewStringFromAscii(CStrVector("barbarbar")); | 825 input = factory->NewStringFromAscii(CStrVector("barbarbar")); |
826 seq_input = Handle<SeqAsciiString>::cast(input); | 826 seq_input = Handle<SeqOneByteString>::cast(input); |
827 start_adr = seq_input->GetCharsAddress(); | 827 start_adr = seq_input->GetCharsAddress(); |
828 | 828 |
829 result = Execute(*code, | 829 result = Execute(*code, |
830 *input, | 830 *input, |
831 0, | 831 0, |
832 start_adr, | 832 start_adr, |
833 start_adr + input->length(), | 833 start_adr + input->length(), |
834 captures); | 834 captures); |
835 | 835 |
836 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); | 836 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 m.LoadCurrentCharacter(10, NULL); | 917 m.LoadCurrentCharacter(10, NULL); |
918 m.Succeed(); | 918 m.Succeed(); |
919 m.Bind(&backtrack); | 919 m.Bind(&backtrack); |
920 m.Fail(); | 920 m.Fail(); |
921 | 921 |
922 Handle<String> source = factory->NewStringFromAscii(CStrVector("..........")); | 922 Handle<String> source = factory->NewStringFromAscii(CStrVector("..........")); |
923 Handle<Object> code_object = m.GetCode(source); | 923 Handle<Object> code_object = m.GetCode(source); |
924 Handle<Code> code = Handle<Code>::cast(code_object); | 924 Handle<Code> code = Handle<Code>::cast(code_object); |
925 | 925 |
926 Handle<String> input = factory->NewStringFromAscii(CStrVector("foofoo")); | 926 Handle<String> input = factory->NewStringFromAscii(CStrVector("foofoo")); |
927 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 927 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
928 Address start_adr = seq_input->GetCharsAddress(); | 928 Address start_adr = seq_input->GetCharsAddress(); |
929 | 929 |
930 NativeRegExpMacroAssembler::Result result = | 930 NativeRegExpMacroAssembler::Result result = |
931 Execute(*code, | 931 Execute(*code, |
932 *input, | 932 *input, |
933 0, | 933 0, |
934 start_adr, | 934 start_adr, |
935 start_adr + input->length(), | 935 start_adr + input->length(), |
936 NULL); | 936 NULL); |
937 | 937 |
(...skipping 22 matching lines...) Expand all Loading... |
960 m.WriteCurrentPositionToRegister(2, 0); | 960 m.WriteCurrentPositionToRegister(2, 0); |
961 m.Succeed(); | 961 m.Succeed(); |
962 m.Bind(&missing_match); | 962 m.Bind(&missing_match); |
963 m.Fail(); | 963 m.Fail(); |
964 | 964 |
965 Handle<String> source = factory->NewStringFromAscii(CStrVector("^(..)..\1")); | 965 Handle<String> source = factory->NewStringFromAscii(CStrVector("^(..)..\1")); |
966 Handle<Object> code_object = m.GetCode(source); | 966 Handle<Object> code_object = m.GetCode(source); |
967 Handle<Code> code = Handle<Code>::cast(code_object); | 967 Handle<Code> code = Handle<Code>::cast(code_object); |
968 | 968 |
969 Handle<String> input = factory->NewStringFromAscii(CStrVector("fooofo")); | 969 Handle<String> input = factory->NewStringFromAscii(CStrVector("fooofo")); |
970 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 970 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
971 Address start_adr = seq_input->GetCharsAddress(); | 971 Address start_adr = seq_input->GetCharsAddress(); |
972 | 972 |
973 int output[4]; | 973 int output[4]; |
974 NativeRegExpMacroAssembler::Result result = | 974 NativeRegExpMacroAssembler::Result result = |
975 Execute(*code, | 975 Execute(*code, |
976 *input, | 976 *input, |
977 0, | 977 0, |
978 start_adr, | 978 start_adr, |
979 start_adr + input->length(), | 979 start_adr + input->length(), |
980 output); | 980 output); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 m.Bind(&prevo); | 1065 m.Bind(&prevo); |
1066 m.LoadCurrentCharacter(0, &fail); | 1066 m.LoadCurrentCharacter(0, &fail); |
1067 m.CheckNotCharacter('b', &fail); | 1067 m.CheckNotCharacter('b', &fail); |
1068 m.Succeed(); | 1068 m.Succeed(); |
1069 | 1069 |
1070 Handle<String> source = factory->NewStringFromAscii(CStrVector("(^f|ob)")); | 1070 Handle<String> source = factory->NewStringFromAscii(CStrVector("(^f|ob)")); |
1071 Handle<Object> code_object = m.GetCode(source); | 1071 Handle<Object> code_object = m.GetCode(source); |
1072 Handle<Code> code = Handle<Code>::cast(code_object); | 1072 Handle<Code> code = Handle<Code>::cast(code_object); |
1073 | 1073 |
1074 Handle<String> input = factory->NewStringFromAscii(CStrVector("foobar")); | 1074 Handle<String> input = factory->NewStringFromAscii(CStrVector("foobar")); |
1075 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 1075 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
1076 Address start_adr = seq_input->GetCharsAddress(); | 1076 Address start_adr = seq_input->GetCharsAddress(); |
1077 | 1077 |
1078 NativeRegExpMacroAssembler::Result result = | 1078 NativeRegExpMacroAssembler::Result result = |
1079 Execute(*code, | 1079 Execute(*code, |
1080 *input, | 1080 *input, |
1081 0, | 1081 0, |
1082 start_adr, | 1082 start_adr, |
1083 start_adr + input->length(), | 1083 start_adr + input->length(), |
1084 NULL); | 1084 NULL); |
1085 | 1085 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 m.WriteCurrentPositionToRegister(1, 0); | 1126 m.WriteCurrentPositionToRegister(1, 0); |
1127 m.Succeed(); | 1127 m.Succeed(); |
1128 | 1128 |
1129 Handle<String> source = | 1129 Handle<String> source = |
1130 factory->NewStringFromAscii(CStrVector("^(abc)\1\1(?!\1)...(?!\1)")); | 1130 factory->NewStringFromAscii(CStrVector("^(abc)\1\1(?!\1)...(?!\1)")); |
1131 Handle<Object> code_object = m.GetCode(source); | 1131 Handle<Object> code_object = m.GetCode(source); |
1132 Handle<Code> code = Handle<Code>::cast(code_object); | 1132 Handle<Code> code = Handle<Code>::cast(code_object); |
1133 | 1133 |
1134 Handle<String> input = | 1134 Handle<String> input = |
1135 factory->NewStringFromAscii(CStrVector("aBcAbCABCxYzab")); | 1135 factory->NewStringFromAscii(CStrVector("aBcAbCABCxYzab")); |
1136 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 1136 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
1137 Address start_adr = seq_input->GetCharsAddress(); | 1137 Address start_adr = seq_input->GetCharsAddress(); |
1138 | 1138 |
1139 int output[4]; | 1139 int output[4]; |
1140 NativeRegExpMacroAssembler::Result result = | 1140 NativeRegExpMacroAssembler::Result result = |
1141 Execute(*code, | 1141 Execute(*code, |
1142 *input, | 1142 *input, |
1143 0, | 1143 0, |
1144 start_adr, | 1144 start_adr, |
1145 start_adr + input->length(), | 1145 start_adr + input->length(), |
1146 output); | 1146 output); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 m.Fail(); | 1227 m.Fail(); |
1228 | 1228 |
1229 Handle<String> source = | 1229 Handle<String> source = |
1230 factory->NewStringFromAscii(CStrVector("<loop test>")); | 1230 factory->NewStringFromAscii(CStrVector("<loop test>")); |
1231 Handle<Object> code_object = m.GetCode(source); | 1231 Handle<Object> code_object = m.GetCode(source); |
1232 Handle<Code> code = Handle<Code>::cast(code_object); | 1232 Handle<Code> code = Handle<Code>::cast(code_object); |
1233 | 1233 |
1234 // String long enough for test (content doesn't matter). | 1234 // String long enough for test (content doesn't matter). |
1235 Handle<String> input = | 1235 Handle<String> input = |
1236 factory->NewStringFromAscii(CStrVector("foofoofoofoofoo")); | 1236 factory->NewStringFromAscii(CStrVector("foofoofoofoofoo")); |
1237 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 1237 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
1238 Address start_adr = seq_input->GetCharsAddress(); | 1238 Address start_adr = seq_input->GetCharsAddress(); |
1239 | 1239 |
1240 int output[6]; | 1240 int output[6]; |
1241 NativeRegExpMacroAssembler::Result result = | 1241 NativeRegExpMacroAssembler::Result result = |
1242 Execute(*code, | 1242 Execute(*code, |
1243 *input, | 1243 *input, |
1244 0, | 1244 0, |
1245 start_adr, | 1245 start_adr, |
1246 start_adr + input->length(), | 1246 start_adr + input->length(), |
1247 output); | 1247 output); |
(...skipping 23 matching lines...) Expand all Loading... |
1271 m.GoTo(&loop); | 1271 m.GoTo(&loop); |
1272 | 1272 |
1273 Handle<String> source = | 1273 Handle<String> source = |
1274 factory->NewStringFromAscii(CStrVector("<stack overflow test>")); | 1274 factory->NewStringFromAscii(CStrVector("<stack overflow test>")); |
1275 Handle<Object> code_object = m.GetCode(source); | 1275 Handle<Object> code_object = m.GetCode(source); |
1276 Handle<Code> code = Handle<Code>::cast(code_object); | 1276 Handle<Code> code = Handle<Code>::cast(code_object); |
1277 | 1277 |
1278 // String long enough for test (content doesn't matter). | 1278 // String long enough for test (content doesn't matter). |
1279 Handle<String> input = | 1279 Handle<String> input = |
1280 factory->NewStringFromAscii(CStrVector("dummy")); | 1280 factory->NewStringFromAscii(CStrVector("dummy")); |
1281 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 1281 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
1282 Address start_adr = seq_input->GetCharsAddress(); | 1282 Address start_adr = seq_input->GetCharsAddress(); |
1283 | 1283 |
1284 NativeRegExpMacroAssembler::Result result = | 1284 NativeRegExpMacroAssembler::Result result = |
1285 Execute(*code, | 1285 Execute(*code, |
1286 *input, | 1286 *input, |
1287 0, | 1287 0, |
1288 start_adr, | 1288 start_adr, |
1289 start_adr + input->length(), | 1289 start_adr + input->length(), |
1290 NULL); | 1290 NULL); |
1291 | 1291 |
(...skipping 26 matching lines...) Expand all Loading... |
1318 m.Succeed(); | 1318 m.Succeed(); |
1319 | 1319 |
1320 Handle<String> source = | 1320 Handle<String> source = |
1321 factory->NewStringFromAscii(CStrVector("<huge register space test>")); | 1321 factory->NewStringFromAscii(CStrVector("<huge register space test>")); |
1322 Handle<Object> code_object = m.GetCode(source); | 1322 Handle<Object> code_object = m.GetCode(source); |
1323 Handle<Code> code = Handle<Code>::cast(code_object); | 1323 Handle<Code> code = Handle<Code>::cast(code_object); |
1324 | 1324 |
1325 // String long enough for test (content doesn't matter). | 1325 // String long enough for test (content doesn't matter). |
1326 Handle<String> input = | 1326 Handle<String> input = |
1327 factory->NewStringFromAscii(CStrVector("sample text")); | 1327 factory->NewStringFromAscii(CStrVector("sample text")); |
1328 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 1328 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
1329 Address start_adr = seq_input->GetCharsAddress(); | 1329 Address start_adr = seq_input->GetCharsAddress(); |
1330 | 1330 |
1331 int captures[2]; | 1331 int captures[2]; |
1332 NativeRegExpMacroAssembler::Result result = | 1332 NativeRegExpMacroAssembler::Result result = |
1333 Execute(*code, | 1333 Execute(*code, |
1334 *input, | 1334 *input, |
1335 0, | 1335 0, |
1336 start_adr, | 1336 start_adr, |
1337 start_adr + input->length(), | 1337 start_adr + input->length(), |
1338 captures); | 1338 captures); |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1802 ZoneList<CharacterRange> first_only(4, Isolate::Current()->runtime_zone()); | 1802 ZoneList<CharacterRange> first_only(4, Isolate::Current()->runtime_zone()); |
1803 ZoneList<CharacterRange> second_only(4, Isolate::Current()->runtime_zone()); | 1803 ZoneList<CharacterRange> second_only(4, Isolate::Current()->runtime_zone()); |
1804 ZoneList<CharacterRange> both(4, Isolate::Current()->runtime_zone()); | 1804 ZoneList<CharacterRange> both(4, Isolate::Current()->runtime_zone()); |
1805 } | 1805 } |
1806 | 1806 |
1807 | 1807 |
1808 TEST(Graph) { | 1808 TEST(Graph) { |
1809 V8::Initialize(NULL); | 1809 V8::Initialize(NULL); |
1810 Execute("\\b\\w+\\b", false, true, true); | 1810 Execute("\\b\\w+\\b", false, true, true); |
1811 } | 1811 } |
OLD | NEW |