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

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

Issue 239243018: Heap::AllocateStringFromOneByte() and major part of its callers handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comment + some cleanup Created 6 years, 8 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 | « test/cctest/test-parsing.cc ('k') | test/cctest/test-strings.cc » ('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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 bool is_ascii, 499 bool is_ascii,
500 Zone* zone) { 500 Zone* zone) {
501 V8::Initialize(NULL); 501 V8::Initialize(NULL);
502 Isolate* isolate = CcTest::i_isolate(); 502 Isolate* isolate = CcTest::i_isolate();
503 FlatStringReader reader(isolate, CStrVector(input)); 503 FlatStringReader reader(isolate, CStrVector(input));
504 RegExpCompileData compile_data; 504 RegExpCompileData compile_data;
505 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline, 505 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline,
506 &compile_data, zone)) 506 &compile_data, zone))
507 return NULL; 507 return NULL;
508 Handle<String> pattern = isolate->factory()-> 508 Handle<String> pattern = isolate->factory()->
509 NewStringFromUtf8(CStrVector(input)); 509 NewStringFromUtf8(CStrVector(input)).ToHandleChecked();
510 Handle<String> sample_subject = 510 Handle<String> sample_subject =
511 isolate->factory()->NewStringFromUtf8(CStrVector("")); 511 isolate->factory()->NewStringFromUtf8(CStrVector("")).ToHandleChecked();
512 RegExpEngine::Compile(&compile_data, 512 RegExpEngine::Compile(&compile_data,
513 false, 513 false,
514 false, 514 false,
515 multiline, 515 multiline,
516 pattern, 516 pattern,
517 sample_subject, 517 sample_subject,
518 is_ascii, 518 is_ascii,
519 zone); 519 zone);
520 return compile_data.node; 520 return compile_data.node;
521 } 521 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 v8::V8::Initialize(); 738 v8::V8::Initialize();
739 ContextInitializer initializer; 739 ContextInitializer initializer;
740 Isolate* isolate = CcTest::i_isolate(); 740 Isolate* isolate = CcTest::i_isolate();
741 Factory* factory = isolate->factory(); 741 Factory* factory = isolate->factory();
742 Zone zone(isolate); 742 Zone zone(isolate);
743 743
744 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone); 744 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
745 745
746 m.Succeed(); 746 m.Succeed();
747 747
748 Handle<String> source = factory->NewStringFromAscii(CStrVector("")); 748 Handle<String> source = factory->NewStringFromStaticAscii("");
749 Handle<Object> code_object = m.GetCode(source); 749 Handle<Object> code_object = m.GetCode(source);
750 Handle<Code> code = Handle<Code>::cast(code_object); 750 Handle<Code> code = Handle<Code>::cast(code_object);
751 751
752 int captures[4] = {42, 37, 87, 117}; 752 int captures[4] = {42, 37, 87, 117};
753 Handle<String> input = factory->NewStringFromAscii(CStrVector("foofoo")); 753 Handle<String> input = factory->NewStringFromStaticAscii("foofoo");
754 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); 754 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
755 const byte* start_adr = 755 const byte* start_adr =
756 reinterpret_cast<const byte*>(seq_input->GetCharsAddress()); 756 reinterpret_cast<const byte*>(seq_input->GetCharsAddress());
757 757
758 NativeRegExpMacroAssembler::Result result = 758 NativeRegExpMacroAssembler::Result result =
759 Execute(*code, 759 Execute(*code,
760 *input, 760 *input,
761 0, 761 0,
762 start_adr, 762 start_adr,
763 start_adr + seq_input->length(), 763 start_adr + seq_input->length(),
(...skipping 28 matching lines...) Expand all
792 m.WriteCurrentPositionToRegister(0, 0); 792 m.WriteCurrentPositionToRegister(0, 0);
793 m.WriteCurrentPositionToRegister(1, 3); 793 m.WriteCurrentPositionToRegister(1, 3);
794 m.AdvanceCurrentPosition(3); 794 m.AdvanceCurrentPosition(3);
795 m.PushBacktrack(&backtrack); 795 m.PushBacktrack(&backtrack);
796 m.Succeed(); 796 m.Succeed();
797 m.Bind(&backtrack); 797 m.Bind(&backtrack);
798 m.Backtrack(); 798 m.Backtrack();
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->NewStringFromStaticAscii("^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->NewStringFromStaticAscii("foofoo");
808 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::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->NewStringFromStaticAscii("barbarbar");
826 seq_input = Handle<SeqOneByteString>::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
(...skipping 22 matching lines...) Expand all
858 m.WriteCurrentPositionToRegister(0, 0); 858 m.WriteCurrentPositionToRegister(0, 0);
859 m.WriteCurrentPositionToRegister(1, 3); 859 m.WriteCurrentPositionToRegister(1, 3);
860 m.AdvanceCurrentPosition(3); 860 m.AdvanceCurrentPosition(3);
861 m.PushBacktrack(&backtrack); 861 m.PushBacktrack(&backtrack);
862 m.Succeed(); 862 m.Succeed();
863 m.Bind(&backtrack); 863 m.Bind(&backtrack);
864 m.Backtrack(); 864 m.Backtrack();
865 m.Bind(&fail); 865 m.Bind(&fail);
866 m.Fail(); 866 m.Fail();
867 867
868 Handle<String> source = factory->NewStringFromAscii(CStrVector("^foo")); 868 Handle<String> source = factory->NewStringFromStaticAscii("^foo");
869 Handle<Object> code_object = m.GetCode(source); 869 Handle<Object> code_object = m.GetCode(source);
870 Handle<Code> code = Handle<Code>::cast(code_object); 870 Handle<Code> code = Handle<Code>::cast(code_object);
871 871
872 int captures[4] = {42, 37, 87, 117}; 872 int captures[4] = {42, 37, 87, 117};
873 const uc16 input_data[6] = {'f', 'o', 'o', 'f', 'o', 873 const uc16 input_data[6] = {'f', 'o', 'o', 'f', 'o',
874 static_cast<uc16>(0x2603)}; 874 static_cast<uc16>(0x2603)};
875 Handle<String> input = 875 Handle<String> input = factory->NewStringFromTwoByte(
876 factory->NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); 876 Vector<const uc16>(input_data, 6)).ToHandleChecked();
877 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); 877 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input);
878 Address start_adr = seq_input->GetCharsAddress(); 878 Address start_adr = seq_input->GetCharsAddress();
879 879
880 NativeRegExpMacroAssembler::Result result = 880 NativeRegExpMacroAssembler::Result result =
881 Execute(*code, 881 Execute(*code,
882 *input, 882 *input,
883 0, 883 0,
884 start_adr, 884 start_adr,
885 start_adr + input->length(), 885 start_adr + input->length(),
886 captures); 886 captures);
887 887
888 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); 888 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result);
889 CHECK_EQ(0, captures[0]); 889 CHECK_EQ(0, captures[0]);
890 CHECK_EQ(3, captures[1]); 890 CHECK_EQ(3, captures[1]);
891 CHECK_EQ(-1, captures[2]); 891 CHECK_EQ(-1, captures[2]);
892 CHECK_EQ(-1, captures[3]); 892 CHECK_EQ(-1, captures[3]);
893 893
894 const uc16 input_data2[9] = {'b', 'a', 'r', 'b', 'a', 'r', 'b', 'a', 894 const uc16 input_data2[9] = {'b', 'a', 'r', 'b', 'a', 'r', 'b', 'a',
895 static_cast<uc16>(0x2603)}; 895 static_cast<uc16>(0x2603)};
896 input = factory->NewStringFromTwoByte(Vector<const uc16>(input_data2, 9)); 896 input = factory->NewStringFromTwoByte(
897 Vector<const uc16>(input_data2, 9)).ToHandleChecked();
897 seq_input = Handle<SeqTwoByteString>::cast(input); 898 seq_input = Handle<SeqTwoByteString>::cast(input);
898 start_adr = seq_input->GetCharsAddress(); 899 start_adr = seq_input->GetCharsAddress();
899 900
900 result = Execute(*code, 901 result = Execute(*code,
901 *input, 902 *input,
902 0, 903 0,
903 start_adr, 904 start_adr,
904 start_adr + input->length() * 2, 905 start_adr + input->length() * 2,
905 captures); 906 captures);
906 907
(...skipping 14 matching lines...) Expand all
921 Label backtrack; 922 Label backtrack;
922 m.LoadCurrentCharacter(10, &fail); 923 m.LoadCurrentCharacter(10, &fail);
923 m.Succeed(); 924 m.Succeed();
924 m.Bind(&fail); 925 m.Bind(&fail);
925 m.PushBacktrack(&backtrack); 926 m.PushBacktrack(&backtrack);
926 m.LoadCurrentCharacter(10, NULL); 927 m.LoadCurrentCharacter(10, NULL);
927 m.Succeed(); 928 m.Succeed();
928 m.Bind(&backtrack); 929 m.Bind(&backtrack);
929 m.Fail(); 930 m.Fail();
930 931
931 Handle<String> source = factory->NewStringFromAscii(CStrVector("..........")); 932 Handle<String> source = factory->NewStringFromStaticAscii("..........");
932 Handle<Object> code_object = m.GetCode(source); 933 Handle<Object> code_object = m.GetCode(source);
933 Handle<Code> code = Handle<Code>::cast(code_object); 934 Handle<Code> code = Handle<Code>::cast(code_object);
934 935
935 Handle<String> input = factory->NewStringFromAscii(CStrVector("foofoo")); 936 Handle<String> input = factory->NewStringFromStaticAscii("foofoo");
936 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); 937 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
937 Address start_adr = seq_input->GetCharsAddress(); 938 Address start_adr = seq_input->GetCharsAddress();
938 939
939 NativeRegExpMacroAssembler::Result result = 940 NativeRegExpMacroAssembler::Result result =
940 Execute(*code, 941 Execute(*code,
941 *input, 942 *input,
942 0, 943 0,
943 start_adr, 944 start_adr,
944 start_adr + input->length(), 945 start_adr + input->length(),
945 NULL); 946 NULL);
(...skipping 19 matching lines...) Expand all
965 m.Fail(); 966 m.Fail();
966 m.Bind(&nomatch); 967 m.Bind(&nomatch);
967 m.AdvanceCurrentPosition(2); 968 m.AdvanceCurrentPosition(2);
968 Label missing_match; 969 Label missing_match;
969 m.CheckNotBackReference(0, &missing_match); 970 m.CheckNotBackReference(0, &missing_match);
970 m.WriteCurrentPositionToRegister(2, 0); 971 m.WriteCurrentPositionToRegister(2, 0);
971 m.Succeed(); 972 m.Succeed();
972 m.Bind(&missing_match); 973 m.Bind(&missing_match);
973 m.Fail(); 974 m.Fail();
974 975
975 Handle<String> source = factory->NewStringFromAscii(CStrVector("^(..)..\1")); 976 Handle<String> source = factory->NewStringFromStaticAscii("^(..)..\1");
976 Handle<Object> code_object = m.GetCode(source); 977 Handle<Object> code_object = m.GetCode(source);
977 Handle<Code> code = Handle<Code>::cast(code_object); 978 Handle<Code> code = Handle<Code>::cast(code_object);
978 979
979 Handle<String> input = factory->NewStringFromAscii(CStrVector("fooofo")); 980 Handle<String> input = factory->NewStringFromStaticAscii("fooofo");
980 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); 981 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
981 Address start_adr = seq_input->GetCharsAddress(); 982 Address start_adr = seq_input->GetCharsAddress();
982 983
983 int output[4]; 984 int output[4];
984 NativeRegExpMacroAssembler::Result result = 985 NativeRegExpMacroAssembler::Result result =
985 Execute(*code, 986 Execute(*code,
986 *input, 987 *input,
987 0, 988 0,
988 start_adr, 989 start_adr,
989 start_adr + input->length(), 990 start_adr + input->length(),
(...skipping 24 matching lines...) Expand all
1014 m.Fail(); 1015 m.Fail();
1015 m.Bind(&nomatch); 1016 m.Bind(&nomatch);
1016 m.AdvanceCurrentPosition(2); 1017 m.AdvanceCurrentPosition(2);
1017 Label missing_match; 1018 Label missing_match;
1018 m.CheckNotBackReference(0, &missing_match); 1019 m.CheckNotBackReference(0, &missing_match);
1019 m.WriteCurrentPositionToRegister(2, 0); 1020 m.WriteCurrentPositionToRegister(2, 0);
1020 m.Succeed(); 1021 m.Succeed();
1021 m.Bind(&missing_match); 1022 m.Bind(&missing_match);
1022 m.Fail(); 1023 m.Fail();
1023 1024
1024 Handle<String> source = factory->NewStringFromAscii(CStrVector("^(..)..\1")); 1025 Handle<String> source = factory->NewStringFromStaticAscii("^(..)..\1");
1025 Handle<Object> code_object = m.GetCode(source); 1026 Handle<Object> code_object = m.GetCode(source);
1026 Handle<Code> code = Handle<Code>::cast(code_object); 1027 Handle<Code> code = Handle<Code>::cast(code_object);
1027 1028
1028 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028}; 1029 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028};
1029 Handle<String> input = 1030 Handle<String> input = factory->NewStringFromTwoByte(
1030 factory->NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); 1031 Vector<const uc16>(input_data, 6)).ToHandleChecked();
1031 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); 1032 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input);
1032 Address start_adr = seq_input->GetCharsAddress(); 1033 Address start_adr = seq_input->GetCharsAddress();
1033 1034
1034 int output[4]; 1035 int output[4];
1035 NativeRegExpMacroAssembler::Result result = 1036 NativeRegExpMacroAssembler::Result result =
1036 Execute(*code, 1037 Execute(*code,
1037 *input, 1038 *input,
1038 0, 1039 0,
1039 start_adr, 1040 start_adr,
1040 start_adr + input->length() * 2, 1041 start_adr + input->length() * 2,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 m.Bind(&not_at_start); 1073 m.Bind(&not_at_start);
1073 // Check that prevchar = 'o' and current = 'b'. 1074 // Check that prevchar = 'o' and current = 'b'.
1074 Label prevo; 1075 Label prevo;
1075 m.CheckCharacter('o', &prevo); 1076 m.CheckCharacter('o', &prevo);
1076 m.Fail(); 1077 m.Fail();
1077 m.Bind(&prevo); 1078 m.Bind(&prevo);
1078 m.LoadCurrentCharacter(0, &fail); 1079 m.LoadCurrentCharacter(0, &fail);
1079 m.CheckNotCharacter('b', &fail); 1080 m.CheckNotCharacter('b', &fail);
1080 m.Succeed(); 1081 m.Succeed();
1081 1082
1082 Handle<String> source = factory->NewStringFromAscii(CStrVector("(^f|ob)")); 1083 Handle<String> source = factory->NewStringFromStaticAscii("(^f|ob)");
1083 Handle<Object> code_object = m.GetCode(source); 1084 Handle<Object> code_object = m.GetCode(source);
1084 Handle<Code> code = Handle<Code>::cast(code_object); 1085 Handle<Code> code = Handle<Code>::cast(code_object);
1085 1086
1086 Handle<String> input = factory->NewStringFromAscii(CStrVector("foobar")); 1087 Handle<String> input = factory->NewStringFromStaticAscii("foobar");
1087 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); 1088 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
1088 Address start_adr = seq_input->GetCharsAddress(); 1089 Address start_adr = seq_input->GetCharsAddress();
1089 1090
1090 NativeRegExpMacroAssembler::Result result = 1091 NativeRegExpMacroAssembler::Result result =
1091 Execute(*code, 1092 Execute(*code,
1092 *input, 1093 *input,
1093 0, 1094 0,
1094 start_adr, 1095 start_adr,
1095 start_adr + input->length(), 1096 start_adr + input->length(),
1096 NULL); 1097 NULL);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 m.Bind(&expected_fail); 1134 m.Bind(&expected_fail);
1134 m.AdvanceCurrentPosition(3); // Skip "xYz" 1135 m.AdvanceCurrentPosition(3); // Skip "xYz"
1135 m.CheckNotBackReferenceIgnoreCase(2, &succ); 1136 m.CheckNotBackReferenceIgnoreCase(2, &succ);
1136 m.Fail(); 1137 m.Fail();
1137 1138
1138 m.Bind(&succ); 1139 m.Bind(&succ);
1139 m.WriteCurrentPositionToRegister(1, 0); 1140 m.WriteCurrentPositionToRegister(1, 0);
1140 m.Succeed(); 1141 m.Succeed();
1141 1142
1142 Handle<String> source = 1143 Handle<String> source =
1143 factory->NewStringFromAscii(CStrVector("^(abc)\1\1(?!\1)...(?!\1)")); 1144 factory->NewStringFromStaticAscii("^(abc)\1\1(?!\1)...(?!\1)");
1144 Handle<Object> code_object = m.GetCode(source); 1145 Handle<Object> code_object = m.GetCode(source);
1145 Handle<Code> code = Handle<Code>::cast(code_object); 1146 Handle<Code> code = Handle<Code>::cast(code_object);
1146 1147
1147 Handle<String> input = 1148 Handle<String> input =
1148 factory->NewStringFromAscii(CStrVector("aBcAbCABCxYzab")); 1149 factory->NewStringFromStaticAscii("aBcAbCABCxYzab");
1149 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); 1150 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
1150 Address start_adr = seq_input->GetCharsAddress(); 1151 Address start_adr = seq_input->GetCharsAddress();
1151 1152
1152 int output[4]; 1153 int output[4];
1153 NativeRegExpMacroAssembler::Result result = 1154 NativeRegExpMacroAssembler::Result result =
1154 Execute(*code, 1155 Execute(*code,
1155 *input, 1156 *input,
1156 0, 1157 0,
1157 start_adr, 1158 start_adr,
1158 start_adr + input->length(), 1159 start_adr + input->length(),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 m.Bind(&exit_loop3); 1235 m.Bind(&exit_loop3);
1235 m.PopCurrentPosition(); 1236 m.PopCurrentPosition();
1236 m.WriteCurrentPositionToRegister(out5, 0); // [0,3,6,9,9,-1] 1237 m.WriteCurrentPositionToRegister(out5, 0); // [0,3,6,9,9,-1]
1237 1238
1238 m.Succeed(); 1239 m.Succeed();
1239 1240
1240 m.Bind(&fail); 1241 m.Bind(&fail);
1241 m.Fail(); 1242 m.Fail();
1242 1243
1243 Handle<String> source = 1244 Handle<String> source =
1244 factory->NewStringFromAscii(CStrVector("<loop test>")); 1245 factory->NewStringFromStaticAscii("<loop test>");
1245 Handle<Object> code_object = m.GetCode(source); 1246 Handle<Object> code_object = m.GetCode(source);
1246 Handle<Code> code = Handle<Code>::cast(code_object); 1247 Handle<Code> code = Handle<Code>::cast(code_object);
1247 1248
1248 // String long enough for test (content doesn't matter). 1249 // String long enough for test (content doesn't matter).
1249 Handle<String> input = 1250 Handle<String> input =
1250 factory->NewStringFromAscii(CStrVector("foofoofoofoofoo")); 1251 factory->NewStringFromStaticAscii("foofoofoofoofoo");
1251 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); 1252 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
1252 Address start_adr = seq_input->GetCharsAddress(); 1253 Address start_adr = seq_input->GetCharsAddress();
1253 1254
1254 int output[6]; 1255 int output[6];
1255 NativeRegExpMacroAssembler::Result result = 1256 NativeRegExpMacroAssembler::Result result =
1256 Execute(*code, 1257 Execute(*code,
1257 *input, 1258 *input,
1258 0, 1259 0,
1259 start_adr, 1260 start_adr,
1260 start_adr + input->length(), 1261 start_adr + input->length(),
(...skipping 17 matching lines...) Expand all
1278 Zone zone(isolate); 1279 Zone zone(isolate);
1279 1280
1280 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone); 1281 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
1281 1282
1282 Label loop; 1283 Label loop;
1283 m.Bind(&loop); 1284 m.Bind(&loop);
1284 m.PushBacktrack(&loop); 1285 m.PushBacktrack(&loop);
1285 m.GoTo(&loop); 1286 m.GoTo(&loop);
1286 1287
1287 Handle<String> source = 1288 Handle<String> source =
1288 factory->NewStringFromAscii(CStrVector("<stack overflow test>")); 1289 factory->NewStringFromStaticAscii("<stack overflow test>");
1289 Handle<Object> code_object = m.GetCode(source); 1290 Handle<Object> code_object = m.GetCode(source);
1290 Handle<Code> code = Handle<Code>::cast(code_object); 1291 Handle<Code> code = Handle<Code>::cast(code_object);
1291 1292
1292 // String long enough for test (content doesn't matter). 1293 // String long enough for test (content doesn't matter).
1293 Handle<String> input = 1294 Handle<String> input =
1294 factory->NewStringFromAscii(CStrVector("dummy")); 1295 factory->NewStringFromStaticAscii("dummy");
1295 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); 1296 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
1296 Address start_adr = seq_input->GetCharsAddress(); 1297 Address start_adr = seq_input->GetCharsAddress();
1297 1298
1298 NativeRegExpMacroAssembler::Result result = 1299 NativeRegExpMacroAssembler::Result result =
1299 Execute(*code, 1300 Execute(*code,
1300 *input, 1301 *input,
1301 0, 1302 0,
1302 start_adr, 1303 start_adr,
1303 start_adr + input->length(), 1304 start_adr + input->length(),
1304 NULL); 1305 NULL);
(...skipping 20 matching lines...) Expand all
1325 m.WriteCurrentPositionToRegister(0, 0); 1326 m.WriteCurrentPositionToRegister(0, 0);
1326 m.WriteCurrentPositionToRegister(1, 1); 1327 m.WriteCurrentPositionToRegister(1, 1);
1327 Label done; 1328 Label done;
1328 m.CheckNotBackReference(0, &done); // Performs a system-stack push. 1329 m.CheckNotBackReference(0, &done); // Performs a system-stack push.
1329 m.Bind(&done); 1330 m.Bind(&done);
1330 m.PushRegister(large_number, RegExpMacroAssembler::kNoStackLimitCheck); 1331 m.PushRegister(large_number, RegExpMacroAssembler::kNoStackLimitCheck);
1331 m.PopRegister(1); 1332 m.PopRegister(1);
1332 m.Succeed(); 1333 m.Succeed();
1333 1334
1334 Handle<String> source = 1335 Handle<String> source =
1335 factory->NewStringFromAscii(CStrVector("<huge register space test>")); 1336 factory->NewStringFromStaticAscii("<huge register space test>");
1336 Handle<Object> code_object = m.GetCode(source); 1337 Handle<Object> code_object = m.GetCode(source);
1337 Handle<Code> code = Handle<Code>::cast(code_object); 1338 Handle<Code> code = Handle<Code>::cast(code_object);
1338 1339
1339 // String long enough for test (content doesn't matter). 1340 // String long enough for test (content doesn't matter).
1340 Handle<String> input = 1341 Handle<String> input =
1341 factory->NewStringFromAscii(CStrVector("sample text")); 1342 factory->NewStringFromStaticAscii("sample text");
1342 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); 1343 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
1343 Address start_adr = seq_input->GetCharsAddress(); 1344 Address start_adr = seq_input->GetCharsAddress();
1344 1345
1345 int captures[2]; 1346 int captures[2];
1346 NativeRegExpMacroAssembler::Result result = 1347 NativeRegExpMacroAssembler::Result result =
1347 Execute(*code, 1348 Execute(*code,
1348 *input, 1349 *input,
1349 0, 1350 0,
1350 start_adr, 1351 start_adr,
1351 start_adr + input->length(), 1352 start_adr + input->length(),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 m.ClearRegisters(2, 3); 1394 m.ClearRegisters(2, 3);
1394 m.Backtrack(); 1395 m.Backtrack();
1395 m.Bind(&fail); 1396 m.Bind(&fail);
1396 m.PopRegister(0); 1397 m.PopRegister(0);
1397 m.Fail(); 1398 m.Fail();
1398 1399
1399 Isolate* isolate = CcTest::i_isolate(); 1400 Isolate* isolate = CcTest::i_isolate();
1400 Factory* factory = isolate->factory(); 1401 Factory* factory = isolate->factory();
1401 HandleScope scope(isolate); 1402 HandleScope scope(isolate);
1402 1403
1403 Handle<String> source = factory->NewStringFromAscii(CStrVector("^f(o)o")); 1404 Handle<String> source = factory->NewStringFromStaticAscii("^f(o)o");
1404 Handle<ByteArray> array = Handle<ByteArray>::cast(m.GetCode(source)); 1405 Handle<ByteArray> array = Handle<ByteArray>::cast(m.GetCode(source));
1405 int captures[5]; 1406 int captures[5];
1406 1407
1407 const uc16 str1[] = {'f', 'o', 'o', 'b', 'a', 'r'}; 1408 const uc16 str1[] = {'f', 'o', 'o', 'b', 'a', 'r'};
1408 Handle<String> f1_16 = 1409 Handle<String> f1_16 =
1409 factory->NewStringFromTwoByte(Vector<const uc16>(str1, 6)); 1410 factory->NewStringFromTwoByte(Vector<const uc16>(str1, 6));
1410 1411
1411 CHECK(IrregexpInterpreter::Match(isolate, array, f1_16, captures, 0)); 1412 CHECK(IrregexpInterpreter::Match(isolate, array, f1_16, captures, 0));
1412 CHECK_EQ(0, captures[0]); 1413 CHECK_EQ(0, captures[0]);
1413 CHECK_EQ(3, captures[1]); 1414 CHECK_EQ(3, captures[1]);
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 ZoneList<CharacterRange> first_only(4, &zone); 1804 ZoneList<CharacterRange> first_only(4, &zone);
1804 ZoneList<CharacterRange> second_only(4, &zone); 1805 ZoneList<CharacterRange> second_only(4, &zone);
1805 ZoneList<CharacterRange> both(4, &zone); 1806 ZoneList<CharacterRange> both(4, &zone);
1806 } 1807 }
1807 1808
1808 1809
1809 TEST(Graph) { 1810 TEST(Graph) {
1810 V8::Initialize(NULL); 1811 V8::Initialize(NULL);
1811 Execute("\\b\\w+\\b", false, true, true); 1812 Execute("\\b\\w+\\b", false, true, true);
1812 } 1813 }
OLDNEW
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698