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

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

Issue 42441: Made regexp robust against changes to a string's implementation. (Closed)
Patch Set: Removed unused addition to memory.h Created 11 years, 9 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
« test/cctest/test-api.cc ('K') | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 ~ContextInitializer() { 672 ~ContextInitializer() {
673 env_->Exit(); 673 env_->Exit();
674 env_.Dispose(); 674 env_.Dispose();
675 } 675 }
676 private: 676 private:
677 v8::Persistent<v8::Context> env_; 677 v8::Persistent<v8::Context> env_;
678 v8::HandleScope scope_; 678 v8::HandleScope scope_;
679 v8::internal::StackGuard stack_guard_; 679 v8::internal::StackGuard stack_guard_;
680 }; 680 };
681 681
682 // Helper functions for calling the Execute method. 682
683 template <typename T>
684 static RegExpMacroAssemblerIA32::Result ExecuteIA32(Code* code, 683 static RegExpMacroAssemblerIA32::Result ExecuteIA32(Code* code,
685 const T** input, 684 String* input,
686 int start_offset, 685 int start_offset,
687 int end_offset, 686 const byte* input_start,
687 const byte* input_end,
688 int* captures, 688 int* captures,
689 bool at_start) { 689 bool at_start) {
690 return RegExpMacroAssemblerIA32::Execute( 690 return RegExpMacroAssemblerIA32::Execute(
691 code, 691 code,
692 reinterpret_cast<Address*>( 692 input,
693 reinterpret_cast<void*>(const_cast<T**>(input))),
694 start_offset, 693 start_offset,
695 end_offset, 694 input_start,
695 input_end,
696 captures, 696 captures,
697 at_start); 697 at_start);
698 } 698 }
699
700 template <typename T>
701 static RegExpMacroAssemblerIA32::Result ExecuteIA32(Code* code,
702 T** input,
703 int start_offset,
704 int end_offset,
705 int* captures,
706 bool at_start) {
707 return RegExpMacroAssemblerIA32::Execute(
708 code,
709 reinterpret_cast<Address*>(reinterpret_cast<void*>(input)),
710 start_offset,
711 end_offset,
712 captures,
713 at_start);
714 }
715 699
716 700
717 TEST(MacroAssemblerIA32Success) { 701 TEST(MacroAssemblerIA32Success) {
718 v8::V8::Initialize(); 702 v8::V8::Initialize();
719 ContextInitializer initializer; 703 ContextInitializer initializer;
720 704
721 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 4); 705 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 4);
722 706
723 m.Succeed(); 707 m.Succeed();
724 708
725 Handle<String> source = Factory::NewStringFromAscii(CStrVector("")); 709 Handle<String> source = Factory::NewStringFromAscii(CStrVector(""));
726 Handle<Object> code_object = m.GetCode(source); 710 Handle<Object> code_object = m.GetCode(source);
727 Handle<Code> code = Handle<Code>::cast(code_object); 711 Handle<Code> code = Handle<Code>::cast(code_object);
728 712
729 int captures[4] = {42, 37, 87, 117}; 713 int captures[4] = {42, 37, 87, 117};
730 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo")); 714 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo"));
731 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); 715 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input);
732 Address start_adr = seq_input->GetCharsAddress(); 716 const byte* start_adr =
733 int start_offset = start_adr - reinterpret_cast<Address>(*seq_input); 717 reinterpret_cast<const byte*>(seq_input->GetCharsAddress());
734 int end_offset = start_offset + seq_input->length();
735 718
736 RegExpMacroAssemblerIA32::Result result = 719 RegExpMacroAssemblerIA32::Result result =
737 ExecuteIA32(*code, 720 ExecuteIA32(*code,
738 seq_input.location(), 721 *input,
739 start_offset, 722 0,
740 end_offset, 723 start_adr,
724 start_adr + seq_input->length(),
741 captures, 725 captures,
742 true); 726 true);
743 727
744 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); 728 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
745 CHECK_EQ(-1, captures[0]); 729 CHECK_EQ(-1, captures[0]);
746 CHECK_EQ(-1, captures[1]); 730 CHECK_EQ(-1, captures[1]);
747 CHECK_EQ(-1, captures[2]); 731 CHECK_EQ(-1, captures[2]);
748 CHECK_EQ(-1, captures[3]); 732 CHECK_EQ(-1, captures[3]);
749 } 733 }
750 734
(...skipping 17 matching lines...) Expand all
768 m.Fail(); 752 m.Fail();
769 753
770 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^foo")); 754 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^foo"));
771 Handle<Object> code_object = m.GetCode(source); 755 Handle<Object> code_object = m.GetCode(source);
772 Handle<Code> code = Handle<Code>::cast(code_object); 756 Handle<Code> code = Handle<Code>::cast(code_object);
773 757
774 int captures[4] = {42, 37, 87, 117}; 758 int captures[4] = {42, 37, 87, 117};
775 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo")); 759 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo"));
776 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); 760 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input);
777 Address start_adr = seq_input->GetCharsAddress(); 761 Address start_adr = seq_input->GetCharsAddress();
778 int start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
779 int end_offset = start_offset + seq_input->length();
780 762
781 RegExpMacroAssemblerIA32::Result result = 763 RegExpMacroAssemblerIA32::Result result =
782 ExecuteIA32(*code, 764 ExecuteIA32(*code,
783 seq_input.location(), 765 *input,
784 start_offset, 766 0,
785 end_offset, 767 start_adr,
768 start_adr + input->length(),
786 captures, 769 captures,
787 true); 770 true);
788 771
789 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); 772 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
790 CHECK_EQ(0, captures[0]); 773 CHECK_EQ(0, captures[0]);
791 CHECK_EQ(3, captures[1]); 774 CHECK_EQ(3, captures[1]);
792 CHECK_EQ(-1, captures[2]); 775 CHECK_EQ(-1, captures[2]);
793 CHECK_EQ(-1, captures[3]); 776 CHECK_EQ(-1, captures[3]);
794 777
795 input = Factory::NewStringFromAscii(CStrVector("barbarbar")); 778 input = Factory::NewStringFromAscii(CStrVector("barbarbar"));
796 seq_input = Handle<SeqAsciiString>::cast(input); 779 seq_input = Handle<SeqAsciiString>::cast(input);
797 start_adr = seq_input->GetCharsAddress(); 780 start_adr = seq_input->GetCharsAddress();
798 start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
799 end_offset = start_offset + seq_input->length();
800 781
801 result = ExecuteIA32(*code, 782 result = ExecuteIA32(*code,
802 seq_input.location(), 783 *input,
803 start_offset, 784 0,
804 end_offset, 785 start_adr,
786 start_adr + input->length(),
805 captures, 787 captures,
806 true); 788 true);
807 789
808 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result); 790 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result);
809 } 791 }
810 792
811 793
812 TEST(MacroAssemblerIA32SimpleUC16) { 794 TEST(MacroAssemblerIA32SimpleUC16) {
813 v8::V8::Initialize(); 795 v8::V8::Initialize();
814 ContextInitializer initializer; 796 ContextInitializer initializer;
(...skipping 15 matching lines...) Expand all
830 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^foo")); 812 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^foo"));
831 Handle<Object> code_object = m.GetCode(source); 813 Handle<Object> code_object = m.GetCode(source);
832 Handle<Code> code = Handle<Code>::cast(code_object); 814 Handle<Code> code = Handle<Code>::cast(code_object);
833 815
834 int captures[4] = {42, 37, 87, 117}; 816 int captures[4] = {42, 37, 87, 117};
835 const uc16 input_data[6] = {'f', 'o', 'o', 'f', 'o', '\xa0'}; 817 const uc16 input_data[6] = {'f', 'o', 'o', 'f', 'o', '\xa0'};
836 Handle<String> input = 818 Handle<String> input =
837 Factory::NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); 819 Factory::NewStringFromTwoByte(Vector<const uc16>(input_data, 6));
838 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); 820 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input);
839 Address start_adr = seq_input->GetCharsAddress(); 821 Address start_adr = seq_input->GetCharsAddress();
840 int start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
841 int end_offset = start_offset + seq_input->length() * sizeof(uc16);
842 822
843 RegExpMacroAssemblerIA32::Result result = 823 RegExpMacroAssemblerIA32::Result result =
844 ExecuteIA32(*code, 824 ExecuteIA32(*code,
845 seq_input.location(), 825 *input,
846 start_offset, 826 0,
847 end_offset, 827 start_adr,
828 start_adr + input->length(),
848 captures, 829 captures,
849 true); 830 true);
850 831
851 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); 832 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
852 CHECK_EQ(0, captures[0]); 833 CHECK_EQ(0, captures[0]);
853 CHECK_EQ(3, captures[1]); 834 CHECK_EQ(3, captures[1]);
854 CHECK_EQ(-1, captures[2]); 835 CHECK_EQ(-1, captures[2]);
855 CHECK_EQ(-1, captures[3]); 836 CHECK_EQ(-1, captures[3]);
856 837
857 const uc16 input_data2[9] = {'b', 'a', 'r', 'b', 'a', 'r', 'b', 'a', '\xa0'}; 838 const uc16 input_data2[9] = {'b', 'a', 'r', 'b', 'a', 'r', 'b', 'a', '\xa0'};
858 input = Factory::NewStringFromTwoByte(Vector<const uc16>(input_data2, 9)); 839 input = Factory::NewStringFromTwoByte(Vector<const uc16>(input_data2, 9));
859 seq_input = Handle<SeqTwoByteString>::cast(input); 840 seq_input = Handle<SeqTwoByteString>::cast(input);
860 start_adr = seq_input->GetCharsAddress(); 841 start_adr = seq_input->GetCharsAddress();
861 start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
862 end_offset = start_offset + seq_input->length() * sizeof(uc16);
863 842
864 result = ExecuteIA32(*code, 843 result = ExecuteIA32(*code,
865 seq_input.location(), 844 *input,
866 start_offset, 845 0,
867 end_offset, 846 start_adr,
847 start_adr + input->length() * 2,
868 captures, 848 captures,
869 true); 849 true);
870 850
871 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result); 851 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result);
872 } 852 }
873 853
874 854
875 TEST(MacroAssemblerIA32Backtrack) { 855 TEST(MacroAssemblerIA32Backtrack) {
876 v8::V8::Initialize(); 856 v8::V8::Initialize();
877 ContextInitializer initializer; 857 ContextInitializer initializer;
(...skipping 11 matching lines...) Expand all
889 m.Bind(&backtrack); 869 m.Bind(&backtrack);
890 m.Fail(); 870 m.Fail();
891 871
892 Handle<String> source = Factory::NewStringFromAscii(CStrVector("..........")); 872 Handle<String> source = Factory::NewStringFromAscii(CStrVector(".........."));
893 Handle<Object> code_object = m.GetCode(source); 873 Handle<Object> code_object = m.GetCode(source);
894 Handle<Code> code = Handle<Code>::cast(code_object); 874 Handle<Code> code = Handle<Code>::cast(code_object);
895 875
896 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo")); 876 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo"));
897 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); 877 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input);
898 Address start_adr = seq_input->GetCharsAddress(); 878 Address start_adr = seq_input->GetCharsAddress();
899 int start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
900 int end_offset = start_offset + seq_input->length();
901 879
902 RegExpMacroAssemblerIA32::Result result = 880 RegExpMacroAssemblerIA32::Result result =
903 ExecuteIA32(*code, 881 ExecuteIA32(*code,
904 seq_input.location(), 882 *input,
905 start_offset, 883 0,
906 end_offset, 884 start_adr,
885 start_adr + input->length(),
907 NULL, 886 NULL,
908 true); 887 true);
909 888
910 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result); 889 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result);
911 } 890 }
912 891
913 892
914 TEST(MacroAssemblerIA32BackReferenceASCII) { 893 TEST(MacroAssemblerIA32BackReferenceASCII) {
915 v8::V8::Initialize(); 894 v8::V8::Initialize();
916 ContextInitializer initializer; 895 ContextInitializer initializer;
(...skipping 15 matching lines...) Expand all
932 m.Bind(&missing_match); 911 m.Bind(&missing_match);
933 m.Fail(); 912 m.Fail();
934 913
935 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^(..)..\1")); 914 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^(..)..\1"));
936 Handle<Object> code_object = m.GetCode(source); 915 Handle<Object> code_object = m.GetCode(source);
937 Handle<Code> code = Handle<Code>::cast(code_object); 916 Handle<Code> code = Handle<Code>::cast(code_object);
938 917
939 Handle<String> input = Factory::NewStringFromAscii(CStrVector("fooofo")); 918 Handle<String> input = Factory::NewStringFromAscii(CStrVector("fooofo"));
940 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); 919 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input);
941 Address start_adr = seq_input->GetCharsAddress(); 920 Address start_adr = seq_input->GetCharsAddress();
942 int start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
943 int end_offset = start_offset + seq_input->length();
944 921
945 int output[3]; 922 int output[3];
946 RegExpMacroAssemblerIA32::Result result = 923 RegExpMacroAssemblerIA32::Result result =
947 ExecuteIA32(*code, 924 ExecuteIA32(*code,
948 seq_input.location(), 925 *input,
949 start_offset, 926 0,
950 end_offset, 927 start_adr,
928 start_adr + input->length(),
951 output, 929 output,
952 true); 930 true);
953 931
954 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); 932 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
955 CHECK_EQ(0, output[0]); 933 CHECK_EQ(0, output[0]);
956 CHECK_EQ(2, output[1]); 934 CHECK_EQ(2, output[1]);
957 CHECK_EQ(6, output[2]); 935 CHECK_EQ(6, output[2]);
958 } 936 }
959 937
960 938
(...skipping 21 matching lines...) Expand all
982 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^(..)..\1")); 960 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^(..)..\1"));
983 Handle<Object> code_object = m.GetCode(source); 961 Handle<Object> code_object = m.GetCode(source);
984 Handle<Code> code = Handle<Code>::cast(code_object); 962 Handle<Code> code = Handle<Code>::cast(code_object);
985 963
986 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028}; 964 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028};
987 Handle<String> input = 965 Handle<String> input =
988 Factory::NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); 966 Factory::NewStringFromTwoByte(Vector<const uc16>(input_data, 6));
989 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); 967 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input);
990 Address start_adr = seq_input->GetCharsAddress(); 968 Address start_adr = seq_input->GetCharsAddress();
991 969
992 int start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
993 int end_offset = start_offset + seq_input->length() * sizeof(input_data[0]);
994
995 int output[3]; 970 int output[3];
996 RegExpMacroAssemblerIA32::Result result = 971 RegExpMacroAssemblerIA32::Result result =
997 ExecuteIA32(*code, 972 ExecuteIA32(*code,
998 seq_input.location(), 973 *input,
999 start_offset, 974 0,
1000 end_offset, 975 start_adr,
976 start_adr + input->length() * 2,
1001 output, 977 output,
1002 true); 978 true);
1003 979
1004 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); 980 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
1005 CHECK_EQ(0, output[0]); 981 CHECK_EQ(0, output[0]);
1006 CHECK_EQ(2, output[1]); 982 CHECK_EQ(2, output[1]);
1007 CHECK_EQ(6, output[2]); 983 CHECK_EQ(6, output[2]);
1008 } 984 }
1009 985
1010 986
(...skipping 25 matching lines...) Expand all
1036 m.CheckNotCharacter('b', &fail); 1012 m.CheckNotCharacter('b', &fail);
1037 m.Succeed(); 1013 m.Succeed();
1038 1014
1039 Handle<String> source = Factory::NewStringFromAscii(CStrVector("(^f|ob)")); 1015 Handle<String> source = Factory::NewStringFromAscii(CStrVector("(^f|ob)"));
1040 Handle<Object> code_object = m.GetCode(source); 1016 Handle<Object> code_object = m.GetCode(source);
1041 Handle<Code> code = Handle<Code>::cast(code_object); 1017 Handle<Code> code = Handle<Code>::cast(code_object);
1042 1018
1043 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foobar")); 1019 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foobar"));
1044 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); 1020 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input);
1045 Address start_adr = seq_input->GetCharsAddress(); 1021 Address start_adr = seq_input->GetCharsAddress();
1046 int start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
1047 int end_offset = start_offset + seq_input->length();
1048 1022
1049 RegExpMacroAssemblerIA32::Result result = 1023 RegExpMacroAssemblerIA32::Result result =
1050 ExecuteIA32(*code, 1024 ExecuteIA32(*code,
1051 seq_input.location(), 1025 *input,
1052 start_offset, 1026 0,
1053 end_offset, 1027 start_adr,
1028 start_adr + input->length(),
1054 NULL, 1029 NULL,
1055 true); 1030 true);
1056 1031
1057 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); 1032 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
1058 1033
1059 start_offset += 3;
1060 result = ExecuteIA32(*code, 1034 result = ExecuteIA32(*code,
1061 seq_input.location(), 1035 *input,
1062 start_offset, 1036 3,
1063 end_offset, 1037 start_adr + 3,
1038 start_adr + input->length(),
1064 NULL, 1039 NULL,
1065 false); 1040 false);
1066 1041
1067 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); 1042 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
1068 } 1043 }
1069 1044
1070 1045
1071 TEST(MacroAssemblerIA32BackRefNoCase) { 1046 TEST(MacroAssemblerIA32BackRefNoCase) {
1072 v8::V8::Initialize(); 1047 v8::V8::Initialize();
1073 ContextInitializer initializer; 1048 ContextInitializer initializer;
(...skipping 24 matching lines...) Expand all
1098 1073
1099 Handle<String> source = 1074 Handle<String> source =
1100 Factory::NewStringFromAscii(CStrVector("^(abc)\1\1(?!\1)...(?!\1)")); 1075 Factory::NewStringFromAscii(CStrVector("^(abc)\1\1(?!\1)...(?!\1)"));
1101 Handle<Object> code_object = m.GetCode(source); 1076 Handle<Object> code_object = m.GetCode(source);
1102 Handle<Code> code = Handle<Code>::cast(code_object); 1077 Handle<Code> code = Handle<Code>::cast(code_object);
1103 1078
1104 Handle<String> input = 1079 Handle<String> input =
1105 Factory::NewStringFromAscii(CStrVector("aBcAbCABCxYzab")); 1080 Factory::NewStringFromAscii(CStrVector("aBcAbCABCxYzab"));
1106 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); 1081 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input);
1107 Address start_adr = seq_input->GetCharsAddress(); 1082 Address start_adr = seq_input->GetCharsAddress();
1108 int start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
1109 int end_offset = start_offset + seq_input->length();
1110 1083
1111 int output[4]; 1084 int output[4];
1112 RegExpMacroAssemblerIA32::Result result = 1085 RegExpMacroAssemblerIA32::Result result =
1113 ExecuteIA32(*code, 1086 ExecuteIA32(*code,
1114 seq_input.location(), 1087 *input,
1115 start_offset, 1088 0,
1116 end_offset, 1089 start_adr,
1090 start_adr + input->length(),
1117 output, 1091 output,
1118 true); 1092 true);
1119 1093
1120 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); 1094 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
1121 CHECK_EQ(0, output[0]); 1095 CHECK_EQ(0, output[0]);
1122 CHECK_EQ(12, output[1]); 1096 CHECK_EQ(12, output[1]);
1123 CHECK_EQ(0, output[2]); 1097 CHECK_EQ(0, output[2]);
1124 CHECK_EQ(3, output[3]); 1098 CHECK_EQ(3, output[3]);
1125 } 1099 }
1126 1100
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 Handle<String> source = 1173 Handle<String> source =
1200 Factory::NewStringFromAscii(CStrVector("<loop test>")); 1174 Factory::NewStringFromAscii(CStrVector("<loop test>"));
1201 Handle<Object> code_object = m.GetCode(source); 1175 Handle<Object> code_object = m.GetCode(source);
1202 Handle<Code> code = Handle<Code>::cast(code_object); 1176 Handle<Code> code = Handle<Code>::cast(code_object);
1203 1177
1204 // String long enough for test (content doesn't matter). 1178 // String long enough for test (content doesn't matter).
1205 Handle<String> input = 1179 Handle<String> input =
1206 Factory::NewStringFromAscii(CStrVector("foofoofoofoofoo")); 1180 Factory::NewStringFromAscii(CStrVector("foofoofoofoofoo"));
1207 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); 1181 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input);
1208 Address start_adr = seq_input->GetCharsAddress(); 1182 Address start_adr = seq_input->GetCharsAddress();
1209 int start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
1210 int end_offset = start_offset + seq_input->length();
1211 1183
1212 int output[5]; 1184 int output[5];
1213 RegExpMacroAssemblerIA32::Result result = 1185 RegExpMacroAssemblerIA32::Result result =
1214 ExecuteIA32(*code, 1186 ExecuteIA32(*code,
1215 seq_input.location(), 1187 *input,
1216 start_offset, 1188 0,
1217 end_offset, 1189 start_adr,
1190 start_adr + input->length(),
1218 output, 1191 output,
1219 true); 1192 true);
1220 1193
1221 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); 1194 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
1222 CHECK_EQ(0, output[0]); 1195 CHECK_EQ(0, output[0]);
1223 CHECK_EQ(3, output[1]); 1196 CHECK_EQ(3, output[1]);
1224 CHECK_EQ(6, output[2]); 1197 CHECK_EQ(6, output[2]);
1225 CHECK_EQ(9, output[3]); 1198 CHECK_EQ(9, output[3]);
1226 CHECK_EQ(9, output[4]); 1199 CHECK_EQ(9, output[4]);
1227 } 1200 }
(...skipping 13 matching lines...) Expand all
1241 Handle<String> source = 1214 Handle<String> source =
1242 Factory::NewStringFromAscii(CStrVector("<stack overflow test>")); 1215 Factory::NewStringFromAscii(CStrVector("<stack overflow test>"));
1243 Handle<Object> code_object = m.GetCode(source); 1216 Handle<Object> code_object = m.GetCode(source);
1244 Handle<Code> code = Handle<Code>::cast(code_object); 1217 Handle<Code> code = Handle<Code>::cast(code_object);
1245 1218
1246 // String long enough for test (content doesn't matter). 1219 // String long enough for test (content doesn't matter).
1247 Handle<String> input = 1220 Handle<String> input =
1248 Factory::NewStringFromAscii(CStrVector("dummy")); 1221 Factory::NewStringFromAscii(CStrVector("dummy"));
1249 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); 1222 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input);
1250 Address start_adr = seq_input->GetCharsAddress(); 1223 Address start_adr = seq_input->GetCharsAddress();
1251 int start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
1252 int end_offset = start_offset + seq_input->length();
1253 1224
1254 RegExpMacroAssemblerIA32::Result result = 1225 RegExpMacroAssemblerIA32::Result result =
1255 ExecuteIA32(*code, 1226 ExecuteIA32(*code,
1256 seq_input.location(), 1227 *input,
1257 start_offset, 1228 0,
1258 end_offset, 1229 start_adr,
1230 start_adr + input->length(),
1259 NULL, 1231 NULL,
1260 true); 1232 true);
1261 1233
1262 CHECK_EQ(RegExpMacroAssemblerIA32::EXCEPTION, result); 1234 CHECK_EQ(RegExpMacroAssemblerIA32::EXCEPTION, result);
1263 CHECK(Top::has_pending_exception()); 1235 CHECK(Top::has_pending_exception());
1264 Top::clear_pending_exception(); 1236 Top::clear_pending_exception();
1265 } 1237 }
1266 1238
1267 1239
1268 TEST(MacroAssemblerIA32LotsOfRegisters) { 1240 TEST(MacroAssemblerIA32LotsOfRegisters) {
(...skipping 18 matching lines...) Expand all
1287 Handle<String> source = 1259 Handle<String> source =
1288 Factory::NewStringFromAscii(CStrVector("<huge register space test>")); 1260 Factory::NewStringFromAscii(CStrVector("<huge register space test>"));
1289 Handle<Object> code_object = m.GetCode(source); 1261 Handle<Object> code_object = m.GetCode(source);
1290 Handle<Code> code = Handle<Code>::cast(code_object); 1262 Handle<Code> code = Handle<Code>::cast(code_object);
1291 1263
1292 // String long enough for test (content doesn't matter). 1264 // String long enough for test (content doesn't matter).
1293 Handle<String> input = 1265 Handle<String> input =
1294 Factory::NewStringFromAscii(CStrVector("sample text")); 1266 Factory::NewStringFromAscii(CStrVector("sample text"));
1295 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); 1267 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input);
1296 Address start_adr = seq_input->GetCharsAddress(); 1268 Address start_adr = seq_input->GetCharsAddress();
1297 int start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
1298 int end_offset = start_offset + seq_input->length();
1299 1269
1300 int captures[2]; 1270 int captures[2];
1301 RegExpMacroAssemblerIA32::Result result = 1271 RegExpMacroAssemblerIA32::Result result =
1302 ExecuteIA32(*code, 1272 ExecuteIA32(*code,
1303 seq_input.location(), 1273 *input,
1304 start_offset, 1274 0,
1305 end_offset, 1275 start_adr,
1276 start_adr + input->length(),
1306 captures, 1277 captures,
1307 true); 1278 true);
1308 1279
1309 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); 1280 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result);
1310 CHECK_EQ(0, captures[0]); 1281 CHECK_EQ(0, captures[0]);
1311 CHECK_EQ(42, captures[1]); 1282 CHECK_EQ(42, captures[1]);
1312 1283
1313 Top::clear_pending_exception(); 1284 Top::clear_pending_exception();
1314 } 1285 }
1315 1286
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 CHECK(!InClass(i, excluded)); 1527 CHECK(!InClass(i, excluded));
1557 } 1528 }
1558 } 1529 }
1559 } 1530 }
1560 1531
1561 1532
1562 TEST(Graph) { 1533 TEST(Graph) {
1563 V8::Initialize(NULL); 1534 V8::Initialize(NULL);
1564 Execute("(?:(?:x(.))?\1)+$", false, true, true); 1535 Execute("(?:(?:x(.))?\1)+$", false, true, true);
1565 } 1536 }
OLDNEW
« test/cctest/test-api.cc ('K') | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698