| 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 TestCharacterClassEscapes('.', IsRegExpNewline); | 498 TestCharacterClassEscapes('.', IsRegExpNewline); |
| 499 TestCharacterClassEscapes('d', IsDigit); | 499 TestCharacterClassEscapes('d', IsDigit); |
| 500 TestCharacterClassEscapes('D', NotDigit); | 500 TestCharacterClassEscapes('D', NotDigit); |
| 501 TestCharacterClassEscapes('s', IsWhiteSpaceOrLineTerminator); | 501 TestCharacterClassEscapes('s', IsWhiteSpaceOrLineTerminator); |
| 502 TestCharacterClassEscapes('S', NotWhiteSpaceNorLineTermiantor); | 502 TestCharacterClassEscapes('S', NotWhiteSpaceNorLineTermiantor); |
| 503 TestCharacterClassEscapes('w', IsRegExpWord); | 503 TestCharacterClassEscapes('w', IsRegExpWord); |
| 504 TestCharacterClassEscapes('W', NotWord); | 504 TestCharacterClassEscapes('W', NotWord); |
| 505 } | 505 } |
| 506 | 506 |
| 507 | 507 |
| 508 static RegExpNode* Compile(const char* input, | 508 static RegExpNode* Compile(const char* input, bool multiline, bool is_one_byte, |
| 509 bool multiline, | |
| 510 bool is_ascii, | |
| 511 Zone* zone) { | 509 Zone* zone) { |
| 512 V8::Initialize(NULL); | 510 V8::Initialize(NULL); |
| 513 Isolate* isolate = CcTest::i_isolate(); | 511 Isolate* isolate = CcTest::i_isolate(); |
| 514 FlatStringReader reader(isolate, CStrVector(input)); | 512 FlatStringReader reader(isolate, CStrVector(input)); |
| 515 RegExpCompileData compile_data; | 513 RegExpCompileData compile_data; |
| 516 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline, | 514 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline, |
| 517 &compile_data, zone)) | 515 &compile_data, zone)) |
| 518 return NULL; | 516 return NULL; |
| 519 Handle<String> pattern = isolate->factory()-> | 517 Handle<String> pattern = isolate->factory()-> |
| 520 NewStringFromUtf8(CStrVector(input)).ToHandleChecked(); | 518 NewStringFromUtf8(CStrVector(input)).ToHandleChecked(); |
| 521 Handle<String> sample_subject = | 519 Handle<String> sample_subject = |
| 522 isolate->factory()->NewStringFromUtf8(CStrVector("")).ToHandleChecked(); | 520 isolate->factory()->NewStringFromUtf8(CStrVector("")).ToHandleChecked(); |
| 523 RegExpEngine::Compile(&compile_data, | 521 RegExpEngine::Compile(&compile_data, false, false, multiline, pattern, |
| 524 false, | 522 sample_subject, is_one_byte, zone); |
| 525 false, | |
| 526 multiline, | |
| 527 pattern, | |
| 528 sample_subject, | |
| 529 is_ascii, | |
| 530 zone); | |
| 531 return compile_data.node; | 523 return compile_data.node; |
| 532 } | 524 } |
| 533 | 525 |
| 534 | 526 |
| 535 static void Execute(const char* input, | 527 static void Execute(const char* input, bool multiline, bool is_one_byte, |
| 536 bool multiline, | |
| 537 bool is_ascii, | |
| 538 bool dot_output = false) { | 528 bool dot_output = false) { |
| 539 v8::HandleScope scope(CcTest::isolate()); | 529 v8::HandleScope scope(CcTest::isolate()); |
| 540 Zone zone(CcTest::i_isolate()); | 530 Zone zone(CcTest::i_isolate()); |
| 541 RegExpNode* node = Compile(input, multiline, is_ascii, &zone); | 531 RegExpNode* node = Compile(input, multiline, is_one_byte, &zone); |
| 542 USE(node); | 532 USE(node); |
| 543 #ifdef DEBUG | 533 #ifdef DEBUG |
| 544 if (dot_output) { | 534 if (dot_output) { |
| 545 RegExpEngine::DotPrint(input, node, false); | 535 RegExpEngine::DotPrint(input, node, false); |
| 546 } | 536 } |
| 547 #endif // DEBUG | 537 #endif // DEBUG |
| 548 } | 538 } |
| 549 | 539 |
| 550 | 540 |
| 551 class TestConfig { | 541 class TestConfig { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 } | 739 } |
| 750 | 740 |
| 751 | 741 |
| 752 TEST(MacroAssemblerNativeSuccess) { | 742 TEST(MacroAssemblerNativeSuccess) { |
| 753 v8::V8::Initialize(); | 743 v8::V8::Initialize(); |
| 754 ContextInitializer initializer; | 744 ContextInitializer initializer; |
| 755 Isolate* isolate = CcTest::i_isolate(); | 745 Isolate* isolate = CcTest::i_isolate(); |
| 756 Factory* factory = isolate->factory(); | 746 Factory* factory = isolate->factory(); |
| 757 Zone zone(isolate); | 747 Zone zone(isolate); |
| 758 | 748 |
| 759 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone); | 749 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 4, &zone); |
| 760 | 750 |
| 761 m.Succeed(); | 751 m.Succeed(); |
| 762 | 752 |
| 763 Handle<String> source = factory->NewStringFromStaticAscii(""); | 753 Handle<String> source = factory->NewStringFromStaticChars(""); |
| 764 Handle<Object> code_object = m.GetCode(source); | 754 Handle<Object> code_object = m.GetCode(source); |
| 765 Handle<Code> code = Handle<Code>::cast(code_object); | 755 Handle<Code> code = Handle<Code>::cast(code_object); |
| 766 | 756 |
| 767 int captures[4] = {42, 37, 87, 117}; | 757 int captures[4] = {42, 37, 87, 117}; |
| 768 Handle<String> input = factory->NewStringFromStaticAscii("foofoo"); | 758 Handle<String> input = factory->NewStringFromStaticChars("foofoo"); |
| 769 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); | 759 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
| 770 const byte* start_adr = | 760 const byte* start_adr = |
| 771 reinterpret_cast<const byte*>(seq_input->GetCharsAddress()); | 761 reinterpret_cast<const byte*>(seq_input->GetCharsAddress()); |
| 772 | 762 |
| 773 NativeRegExpMacroAssembler::Result result = | 763 NativeRegExpMacroAssembler::Result result = |
| 774 Execute(*code, | 764 Execute(*code, |
| 775 *input, | 765 *input, |
| 776 0, | 766 0, |
| 777 start_adr, | 767 start_adr, |
| 778 start_adr + seq_input->length(), | 768 start_adr + seq_input->length(), |
| 779 captures); | 769 captures); |
| 780 | 770 |
| 781 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); | 771 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 782 CHECK_EQ(-1, captures[0]); | 772 CHECK_EQ(-1, captures[0]); |
| 783 CHECK_EQ(-1, captures[1]); | 773 CHECK_EQ(-1, captures[1]); |
| 784 CHECK_EQ(-1, captures[2]); | 774 CHECK_EQ(-1, captures[2]); |
| 785 CHECK_EQ(-1, captures[3]); | 775 CHECK_EQ(-1, captures[3]); |
| 786 } | 776 } |
| 787 | 777 |
| 788 | 778 |
| 789 TEST(MacroAssemblerNativeSimple) { | 779 TEST(MacroAssemblerNativeSimple) { |
| 790 v8::V8::Initialize(); | 780 v8::V8::Initialize(); |
| 791 ContextInitializer initializer; | 781 ContextInitializer initializer; |
| 792 Isolate* isolate = CcTest::i_isolate(); | 782 Isolate* isolate = CcTest::i_isolate(); |
| 793 Factory* factory = isolate->factory(); | 783 Factory* factory = isolate->factory(); |
| 794 Zone zone(isolate); | 784 Zone zone(isolate); |
| 795 | 785 |
| 796 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone); | 786 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 4, &zone); |
| 797 | 787 |
| 798 Label fail, backtrack; | 788 Label fail, backtrack; |
| 799 m.PushBacktrack(&fail); | 789 m.PushBacktrack(&fail); |
| 800 m.CheckNotAtStart(NULL); | 790 m.CheckNotAtStart(NULL); |
| 801 m.LoadCurrentCharacter(2, NULL); | 791 m.LoadCurrentCharacter(2, NULL); |
| 802 m.CheckNotCharacter('o', NULL); | 792 m.CheckNotCharacter('o', NULL); |
| 803 m.LoadCurrentCharacter(1, NULL, false); | 793 m.LoadCurrentCharacter(1, NULL, false); |
| 804 m.CheckNotCharacter('o', NULL); | 794 m.CheckNotCharacter('o', NULL); |
| 805 m.LoadCurrentCharacter(0, NULL, false); | 795 m.LoadCurrentCharacter(0, NULL, false); |
| 806 m.CheckNotCharacter('f', NULL); | 796 m.CheckNotCharacter('f', NULL); |
| 807 m.WriteCurrentPositionToRegister(0, 0); | 797 m.WriteCurrentPositionToRegister(0, 0); |
| 808 m.WriteCurrentPositionToRegister(1, 3); | 798 m.WriteCurrentPositionToRegister(1, 3); |
| 809 m.AdvanceCurrentPosition(3); | 799 m.AdvanceCurrentPosition(3); |
| 810 m.PushBacktrack(&backtrack); | 800 m.PushBacktrack(&backtrack); |
| 811 m.Succeed(); | 801 m.Succeed(); |
| 812 m.Bind(&backtrack); | 802 m.Bind(&backtrack); |
| 813 m.Backtrack(); | 803 m.Backtrack(); |
| 814 m.Bind(&fail); | 804 m.Bind(&fail); |
| 815 m.Fail(); | 805 m.Fail(); |
| 816 | 806 |
| 817 Handle<String> source = factory->NewStringFromStaticAscii("^foo"); | 807 Handle<String> source = factory->NewStringFromStaticChars("^foo"); |
| 818 Handle<Object> code_object = m.GetCode(source); | 808 Handle<Object> code_object = m.GetCode(source); |
| 819 Handle<Code> code = Handle<Code>::cast(code_object); | 809 Handle<Code> code = Handle<Code>::cast(code_object); |
| 820 | 810 |
| 821 int captures[4] = {42, 37, 87, 117}; | 811 int captures[4] = {42, 37, 87, 117}; |
| 822 Handle<String> input = factory->NewStringFromStaticAscii("foofoo"); | 812 Handle<String> input = factory->NewStringFromStaticChars("foofoo"); |
| 823 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); | 813 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
| 824 Address start_adr = seq_input->GetCharsAddress(); | 814 Address start_adr = seq_input->GetCharsAddress(); |
| 825 | 815 |
| 826 NativeRegExpMacroAssembler::Result result = | 816 NativeRegExpMacroAssembler::Result result = |
| 827 Execute(*code, | 817 Execute(*code, |
| 828 *input, | 818 *input, |
| 829 0, | 819 0, |
| 830 start_adr, | 820 start_adr, |
| 831 start_adr + input->length(), | 821 start_adr + input->length(), |
| 832 captures); | 822 captures); |
| 833 | 823 |
| 834 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); | 824 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 835 CHECK_EQ(0, captures[0]); | 825 CHECK_EQ(0, captures[0]); |
| 836 CHECK_EQ(3, captures[1]); | 826 CHECK_EQ(3, captures[1]); |
| 837 CHECK_EQ(-1, captures[2]); | 827 CHECK_EQ(-1, captures[2]); |
| 838 CHECK_EQ(-1, captures[3]); | 828 CHECK_EQ(-1, captures[3]); |
| 839 | 829 |
| 840 input = factory->NewStringFromStaticAscii("barbarbar"); | 830 input = factory->NewStringFromStaticChars("barbarbar"); |
| 841 seq_input = Handle<SeqOneByteString>::cast(input); | 831 seq_input = Handle<SeqOneByteString>::cast(input); |
| 842 start_adr = seq_input->GetCharsAddress(); | 832 start_adr = seq_input->GetCharsAddress(); |
| 843 | 833 |
| 844 result = Execute(*code, | 834 result = Execute(*code, |
| 845 *input, | 835 *input, |
| 846 0, | 836 0, |
| 847 start_adr, | 837 start_adr, |
| 848 start_adr + input->length(), | 838 start_adr + input->length(), |
| 849 captures); | 839 captures); |
| 850 | 840 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 873 m.WriteCurrentPositionToRegister(0, 0); | 863 m.WriteCurrentPositionToRegister(0, 0); |
| 874 m.WriteCurrentPositionToRegister(1, 3); | 864 m.WriteCurrentPositionToRegister(1, 3); |
| 875 m.AdvanceCurrentPosition(3); | 865 m.AdvanceCurrentPosition(3); |
| 876 m.PushBacktrack(&backtrack); | 866 m.PushBacktrack(&backtrack); |
| 877 m.Succeed(); | 867 m.Succeed(); |
| 878 m.Bind(&backtrack); | 868 m.Bind(&backtrack); |
| 879 m.Backtrack(); | 869 m.Backtrack(); |
| 880 m.Bind(&fail); | 870 m.Bind(&fail); |
| 881 m.Fail(); | 871 m.Fail(); |
| 882 | 872 |
| 883 Handle<String> source = factory->NewStringFromStaticAscii("^foo"); | 873 Handle<String> source = factory->NewStringFromStaticChars("^foo"); |
| 884 Handle<Object> code_object = m.GetCode(source); | 874 Handle<Object> code_object = m.GetCode(source); |
| 885 Handle<Code> code = Handle<Code>::cast(code_object); | 875 Handle<Code> code = Handle<Code>::cast(code_object); |
| 886 | 876 |
| 887 int captures[4] = {42, 37, 87, 117}; | 877 int captures[4] = {42, 37, 87, 117}; |
| 888 const uc16 input_data[6] = {'f', 'o', 'o', 'f', 'o', | 878 const uc16 input_data[6] = {'f', 'o', 'o', 'f', 'o', |
| 889 static_cast<uc16>(0x2603)}; | 879 static_cast<uc16>(0x2603)}; |
| 890 Handle<String> input = factory->NewStringFromTwoByte( | 880 Handle<String> input = factory->NewStringFromTwoByte( |
| 891 Vector<const uc16>(input_data, 6)).ToHandleChecked(); | 881 Vector<const uc16>(input_data, 6)).ToHandleChecked(); |
| 892 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); | 882 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); |
| 893 Address start_adr = seq_input->GetCharsAddress(); | 883 Address start_adr = seq_input->GetCharsAddress(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 924 } | 914 } |
| 925 | 915 |
| 926 | 916 |
| 927 TEST(MacroAssemblerNativeBacktrack) { | 917 TEST(MacroAssemblerNativeBacktrack) { |
| 928 v8::V8::Initialize(); | 918 v8::V8::Initialize(); |
| 929 ContextInitializer initializer; | 919 ContextInitializer initializer; |
| 930 Isolate* isolate = CcTest::i_isolate(); | 920 Isolate* isolate = CcTest::i_isolate(); |
| 931 Factory* factory = isolate->factory(); | 921 Factory* factory = isolate->factory(); |
| 932 Zone zone(isolate); | 922 Zone zone(isolate); |
| 933 | 923 |
| 934 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone); | 924 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 0, &zone); |
| 935 | 925 |
| 936 Label fail; | 926 Label fail; |
| 937 Label backtrack; | 927 Label backtrack; |
| 938 m.LoadCurrentCharacter(10, &fail); | 928 m.LoadCurrentCharacter(10, &fail); |
| 939 m.Succeed(); | 929 m.Succeed(); |
| 940 m.Bind(&fail); | 930 m.Bind(&fail); |
| 941 m.PushBacktrack(&backtrack); | 931 m.PushBacktrack(&backtrack); |
| 942 m.LoadCurrentCharacter(10, NULL); | 932 m.LoadCurrentCharacter(10, NULL); |
| 943 m.Succeed(); | 933 m.Succeed(); |
| 944 m.Bind(&backtrack); | 934 m.Bind(&backtrack); |
| 945 m.Fail(); | 935 m.Fail(); |
| 946 | 936 |
| 947 Handle<String> source = factory->NewStringFromStaticAscii(".........."); | 937 Handle<String> source = factory->NewStringFromStaticChars(".........."); |
| 948 Handle<Object> code_object = m.GetCode(source); | 938 Handle<Object> code_object = m.GetCode(source); |
| 949 Handle<Code> code = Handle<Code>::cast(code_object); | 939 Handle<Code> code = Handle<Code>::cast(code_object); |
| 950 | 940 |
| 951 Handle<String> input = factory->NewStringFromStaticAscii("foofoo"); | 941 Handle<String> input = factory->NewStringFromStaticChars("foofoo"); |
| 952 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); | 942 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
| 953 Address start_adr = seq_input->GetCharsAddress(); | 943 Address start_adr = seq_input->GetCharsAddress(); |
| 954 | 944 |
| 955 NativeRegExpMacroAssembler::Result result = | 945 NativeRegExpMacroAssembler::Result result = |
| 956 Execute(*code, | 946 Execute(*code, |
| 957 *input, | 947 *input, |
| 958 0, | 948 0, |
| 959 start_adr, | 949 start_adr, |
| 960 start_adr + input->length(), | 950 start_adr + input->length(), |
| 961 NULL); | 951 NULL); |
| 962 | 952 |
| 963 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); | 953 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); |
| 964 } | 954 } |
| 965 | 955 |
| 966 | 956 |
| 967 TEST(MacroAssemblerNativeBackReferenceASCII) { | 957 TEST(MacroAssemblerNativeBackReferenceLATIN1) { |
| 968 v8::V8::Initialize(); | 958 v8::V8::Initialize(); |
| 969 ContextInitializer initializer; | 959 ContextInitializer initializer; |
| 970 Isolate* isolate = CcTest::i_isolate(); | 960 Isolate* isolate = CcTest::i_isolate(); |
| 971 Factory* factory = isolate->factory(); | 961 Factory* factory = isolate->factory(); |
| 972 Zone zone(isolate); | 962 Zone zone(isolate); |
| 973 | 963 |
| 974 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone); | 964 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 4, &zone); |
| 975 | 965 |
| 976 m.WriteCurrentPositionToRegister(0, 0); | 966 m.WriteCurrentPositionToRegister(0, 0); |
| 977 m.AdvanceCurrentPosition(2); | 967 m.AdvanceCurrentPosition(2); |
| 978 m.WriteCurrentPositionToRegister(1, 0); | 968 m.WriteCurrentPositionToRegister(1, 0); |
| 979 Label nomatch; | 969 Label nomatch; |
| 980 m.CheckNotBackReference(0, &nomatch); | 970 m.CheckNotBackReference(0, &nomatch); |
| 981 m.Fail(); | 971 m.Fail(); |
| 982 m.Bind(&nomatch); | 972 m.Bind(&nomatch); |
| 983 m.AdvanceCurrentPosition(2); | 973 m.AdvanceCurrentPosition(2); |
| 984 Label missing_match; | 974 Label missing_match; |
| 985 m.CheckNotBackReference(0, &missing_match); | 975 m.CheckNotBackReference(0, &missing_match); |
| 986 m.WriteCurrentPositionToRegister(2, 0); | 976 m.WriteCurrentPositionToRegister(2, 0); |
| 987 m.Succeed(); | 977 m.Succeed(); |
| 988 m.Bind(&missing_match); | 978 m.Bind(&missing_match); |
| 989 m.Fail(); | 979 m.Fail(); |
| 990 | 980 |
| 991 Handle<String> source = factory->NewStringFromStaticAscii("^(..)..\1"); | 981 Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1"); |
| 992 Handle<Object> code_object = m.GetCode(source); | 982 Handle<Object> code_object = m.GetCode(source); |
| 993 Handle<Code> code = Handle<Code>::cast(code_object); | 983 Handle<Code> code = Handle<Code>::cast(code_object); |
| 994 | 984 |
| 995 Handle<String> input = factory->NewStringFromStaticAscii("fooofo"); | 985 Handle<String> input = factory->NewStringFromStaticChars("fooofo"); |
| 996 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); | 986 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
| 997 Address start_adr = seq_input->GetCharsAddress(); | 987 Address start_adr = seq_input->GetCharsAddress(); |
| 998 | 988 |
| 999 int output[4]; | 989 int output[4]; |
| 1000 NativeRegExpMacroAssembler::Result result = | 990 NativeRegExpMacroAssembler::Result result = |
| 1001 Execute(*code, | 991 Execute(*code, |
| 1002 *input, | 992 *input, |
| 1003 0, | 993 0, |
| 1004 start_adr, | 994 start_adr, |
| 1005 start_adr + input->length(), | 995 start_adr + input->length(), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1030 m.Fail(); | 1020 m.Fail(); |
| 1031 m.Bind(&nomatch); | 1021 m.Bind(&nomatch); |
| 1032 m.AdvanceCurrentPosition(2); | 1022 m.AdvanceCurrentPosition(2); |
| 1033 Label missing_match; | 1023 Label missing_match; |
| 1034 m.CheckNotBackReference(0, &missing_match); | 1024 m.CheckNotBackReference(0, &missing_match); |
| 1035 m.WriteCurrentPositionToRegister(2, 0); | 1025 m.WriteCurrentPositionToRegister(2, 0); |
| 1036 m.Succeed(); | 1026 m.Succeed(); |
| 1037 m.Bind(&missing_match); | 1027 m.Bind(&missing_match); |
| 1038 m.Fail(); | 1028 m.Fail(); |
| 1039 | 1029 |
| 1040 Handle<String> source = factory->NewStringFromStaticAscii("^(..)..\1"); | 1030 Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1"); |
| 1041 Handle<Object> code_object = m.GetCode(source); | 1031 Handle<Object> code_object = m.GetCode(source); |
| 1042 Handle<Code> code = Handle<Code>::cast(code_object); | 1032 Handle<Code> code = Handle<Code>::cast(code_object); |
| 1043 | 1033 |
| 1044 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028}; | 1034 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028}; |
| 1045 Handle<String> input = factory->NewStringFromTwoByte( | 1035 Handle<String> input = factory->NewStringFromTwoByte( |
| 1046 Vector<const uc16>(input_data, 6)).ToHandleChecked(); | 1036 Vector<const uc16>(input_data, 6)).ToHandleChecked(); |
| 1047 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); | 1037 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); |
| 1048 Address start_adr = seq_input->GetCharsAddress(); | 1038 Address start_adr = seq_input->GetCharsAddress(); |
| 1049 | 1039 |
| 1050 int output[4]; | 1040 int output[4]; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1065 | 1055 |
| 1066 | 1056 |
| 1067 | 1057 |
| 1068 TEST(MacroAssemblernativeAtStart) { | 1058 TEST(MacroAssemblernativeAtStart) { |
| 1069 v8::V8::Initialize(); | 1059 v8::V8::Initialize(); |
| 1070 ContextInitializer initializer; | 1060 ContextInitializer initializer; |
| 1071 Isolate* isolate = CcTest::i_isolate(); | 1061 Isolate* isolate = CcTest::i_isolate(); |
| 1072 Factory* factory = isolate->factory(); | 1062 Factory* factory = isolate->factory(); |
| 1073 Zone zone(isolate); | 1063 Zone zone(isolate); |
| 1074 | 1064 |
| 1075 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone); | 1065 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 0, &zone); |
| 1076 | 1066 |
| 1077 Label not_at_start, newline, fail; | 1067 Label not_at_start, newline, fail; |
| 1078 m.CheckNotAtStart(¬_at_start); | 1068 m.CheckNotAtStart(¬_at_start); |
| 1079 // Check that prevchar = '\n' and current = 'f'. | 1069 // Check that prevchar = '\n' and current = 'f'. |
| 1080 m.CheckCharacter('\n', &newline); | 1070 m.CheckCharacter('\n', &newline); |
| 1081 m.Bind(&fail); | 1071 m.Bind(&fail); |
| 1082 m.Fail(); | 1072 m.Fail(); |
| 1083 m.Bind(&newline); | 1073 m.Bind(&newline); |
| 1084 m.LoadCurrentCharacter(0, &fail); | 1074 m.LoadCurrentCharacter(0, &fail); |
| 1085 m.CheckNotCharacter('f', &fail); | 1075 m.CheckNotCharacter('f', &fail); |
| 1086 m.Succeed(); | 1076 m.Succeed(); |
| 1087 | 1077 |
| 1088 m.Bind(¬_at_start); | 1078 m.Bind(¬_at_start); |
| 1089 // Check that prevchar = 'o' and current = 'b'. | 1079 // Check that prevchar = 'o' and current = 'b'. |
| 1090 Label prevo; | 1080 Label prevo; |
| 1091 m.CheckCharacter('o', &prevo); | 1081 m.CheckCharacter('o', &prevo); |
| 1092 m.Fail(); | 1082 m.Fail(); |
| 1093 m.Bind(&prevo); | 1083 m.Bind(&prevo); |
| 1094 m.LoadCurrentCharacter(0, &fail); | 1084 m.LoadCurrentCharacter(0, &fail); |
| 1095 m.CheckNotCharacter('b', &fail); | 1085 m.CheckNotCharacter('b', &fail); |
| 1096 m.Succeed(); | 1086 m.Succeed(); |
| 1097 | 1087 |
| 1098 Handle<String> source = factory->NewStringFromStaticAscii("(^f|ob)"); | 1088 Handle<String> source = factory->NewStringFromStaticChars("(^f|ob)"); |
| 1099 Handle<Object> code_object = m.GetCode(source); | 1089 Handle<Object> code_object = m.GetCode(source); |
| 1100 Handle<Code> code = Handle<Code>::cast(code_object); | 1090 Handle<Code> code = Handle<Code>::cast(code_object); |
| 1101 | 1091 |
| 1102 Handle<String> input = factory->NewStringFromStaticAscii("foobar"); | 1092 Handle<String> input = factory->NewStringFromStaticChars("foobar"); |
| 1103 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); | 1093 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
| 1104 Address start_adr = seq_input->GetCharsAddress(); | 1094 Address start_adr = seq_input->GetCharsAddress(); |
| 1105 | 1095 |
| 1106 NativeRegExpMacroAssembler::Result result = | 1096 NativeRegExpMacroAssembler::Result result = |
| 1107 Execute(*code, | 1097 Execute(*code, |
| 1108 *input, | 1098 *input, |
| 1109 0, | 1099 0, |
| 1110 start_adr, | 1100 start_adr, |
| 1111 start_adr + input->length(), | 1101 start_adr + input->length(), |
| 1112 NULL); | 1102 NULL); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1124 } | 1114 } |
| 1125 | 1115 |
| 1126 | 1116 |
| 1127 TEST(MacroAssemblerNativeBackRefNoCase) { | 1117 TEST(MacroAssemblerNativeBackRefNoCase) { |
| 1128 v8::V8::Initialize(); | 1118 v8::V8::Initialize(); |
| 1129 ContextInitializer initializer; | 1119 ContextInitializer initializer; |
| 1130 Isolate* isolate = CcTest::i_isolate(); | 1120 Isolate* isolate = CcTest::i_isolate(); |
| 1131 Factory* factory = isolate->factory(); | 1121 Factory* factory = isolate->factory(); |
| 1132 Zone zone(isolate); | 1122 Zone zone(isolate); |
| 1133 | 1123 |
| 1134 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone); | 1124 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 4, &zone); |
| 1135 | 1125 |
| 1136 Label fail, succ; | 1126 Label fail, succ; |
| 1137 | 1127 |
| 1138 m.WriteCurrentPositionToRegister(0, 0); | 1128 m.WriteCurrentPositionToRegister(0, 0); |
| 1139 m.WriteCurrentPositionToRegister(2, 0); | 1129 m.WriteCurrentPositionToRegister(2, 0); |
| 1140 m.AdvanceCurrentPosition(3); | 1130 m.AdvanceCurrentPosition(3); |
| 1141 m.WriteCurrentPositionToRegister(3, 0); | 1131 m.WriteCurrentPositionToRegister(3, 0); |
| 1142 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "AbC". | 1132 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "AbC". |
| 1143 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "ABC". | 1133 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "ABC". |
| 1144 Label expected_fail; | 1134 Label expected_fail; |
| 1145 m.CheckNotBackReferenceIgnoreCase(2, &expected_fail); | 1135 m.CheckNotBackReferenceIgnoreCase(2, &expected_fail); |
| 1146 m.Bind(&fail); | 1136 m.Bind(&fail); |
| 1147 m.Fail(); | 1137 m.Fail(); |
| 1148 | 1138 |
| 1149 m.Bind(&expected_fail); | 1139 m.Bind(&expected_fail); |
| 1150 m.AdvanceCurrentPosition(3); // Skip "xYz" | 1140 m.AdvanceCurrentPosition(3); // Skip "xYz" |
| 1151 m.CheckNotBackReferenceIgnoreCase(2, &succ); | 1141 m.CheckNotBackReferenceIgnoreCase(2, &succ); |
| 1152 m.Fail(); | 1142 m.Fail(); |
| 1153 | 1143 |
| 1154 m.Bind(&succ); | 1144 m.Bind(&succ); |
| 1155 m.WriteCurrentPositionToRegister(1, 0); | 1145 m.WriteCurrentPositionToRegister(1, 0); |
| 1156 m.Succeed(); | 1146 m.Succeed(); |
| 1157 | 1147 |
| 1158 Handle<String> source = | 1148 Handle<String> source = |
| 1159 factory->NewStringFromStaticAscii("^(abc)\1\1(?!\1)...(?!\1)"); | 1149 factory->NewStringFromStaticChars("^(abc)\1\1(?!\1)...(?!\1)"); |
| 1160 Handle<Object> code_object = m.GetCode(source); | 1150 Handle<Object> code_object = m.GetCode(source); |
| 1161 Handle<Code> code = Handle<Code>::cast(code_object); | 1151 Handle<Code> code = Handle<Code>::cast(code_object); |
| 1162 | 1152 |
| 1163 Handle<String> input = | 1153 Handle<String> input = factory->NewStringFromStaticChars("aBcAbCABCxYzab"); |
| 1164 factory->NewStringFromStaticAscii("aBcAbCABCxYzab"); | |
| 1165 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); | 1154 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
| 1166 Address start_adr = seq_input->GetCharsAddress(); | 1155 Address start_adr = seq_input->GetCharsAddress(); |
| 1167 | 1156 |
| 1168 int output[4]; | 1157 int output[4]; |
| 1169 NativeRegExpMacroAssembler::Result result = | 1158 NativeRegExpMacroAssembler::Result result = |
| 1170 Execute(*code, | 1159 Execute(*code, |
| 1171 *input, | 1160 *input, |
| 1172 0, | 1161 0, |
| 1173 start_adr, | 1162 start_adr, |
| 1174 start_adr + input->length(), | 1163 start_adr + input->length(), |
| 1175 output); | 1164 output); |
| 1176 | 1165 |
| 1177 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); | 1166 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 1178 CHECK_EQ(0, output[0]); | 1167 CHECK_EQ(0, output[0]); |
| 1179 CHECK_EQ(12, output[1]); | 1168 CHECK_EQ(12, output[1]); |
| 1180 CHECK_EQ(0, output[2]); | 1169 CHECK_EQ(0, output[2]); |
| 1181 CHECK_EQ(3, output[3]); | 1170 CHECK_EQ(3, output[3]); |
| 1182 } | 1171 } |
| 1183 | 1172 |
| 1184 | 1173 |
| 1185 | 1174 |
| 1186 TEST(MacroAssemblerNativeRegisters) { | 1175 TEST(MacroAssemblerNativeRegisters) { |
| 1187 v8::V8::Initialize(); | 1176 v8::V8::Initialize(); |
| 1188 ContextInitializer initializer; | 1177 ContextInitializer initializer; |
| 1189 Isolate* isolate = CcTest::i_isolate(); | 1178 Isolate* isolate = CcTest::i_isolate(); |
| 1190 Factory* factory = isolate->factory(); | 1179 Factory* factory = isolate->factory(); |
| 1191 Zone zone(isolate); | 1180 Zone zone(isolate); |
| 1192 | 1181 |
| 1193 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6, &zone); | 1182 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 6, &zone); |
| 1194 | 1183 |
| 1195 uc16 foo_chars[3] = {'f', 'o', 'o'}; | 1184 uc16 foo_chars[3] = {'f', 'o', 'o'}; |
| 1196 Vector<const uc16> foo(foo_chars, 3); | 1185 Vector<const uc16> foo(foo_chars, 3); |
| 1197 | 1186 |
| 1198 enum registers { out1, out2, out3, out4, out5, out6, sp, loop_cnt }; | 1187 enum registers { out1, out2, out3, out4, out5, out6, sp, loop_cnt }; |
| 1199 Label fail; | 1188 Label fail; |
| 1200 Label backtrack; | 1189 Label backtrack; |
| 1201 m.WriteCurrentPositionToRegister(out1, 0); // Output: [0] | 1190 m.WriteCurrentPositionToRegister(out1, 0); // Output: [0] |
| 1202 m.PushRegister(out1, RegExpMacroAssembler::kNoStackLimitCheck); | 1191 m.PushRegister(out1, RegExpMacroAssembler::kNoStackLimitCheck); |
| 1203 m.PushBacktrack(&backtrack); | 1192 m.PushBacktrack(&backtrack); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 m.GoTo(&loop3); | 1238 m.GoTo(&loop3); |
| 1250 m.Bind(&exit_loop3); | 1239 m.Bind(&exit_loop3); |
| 1251 m.PopCurrentPosition(); | 1240 m.PopCurrentPosition(); |
| 1252 m.WriteCurrentPositionToRegister(out5, 0); // [0,3,6,9,9,-1] | 1241 m.WriteCurrentPositionToRegister(out5, 0); // [0,3,6,9,9,-1] |
| 1253 | 1242 |
| 1254 m.Succeed(); | 1243 m.Succeed(); |
| 1255 | 1244 |
| 1256 m.Bind(&fail); | 1245 m.Bind(&fail); |
| 1257 m.Fail(); | 1246 m.Fail(); |
| 1258 | 1247 |
| 1259 Handle<String> source = | 1248 Handle<String> source = factory->NewStringFromStaticChars("<loop test>"); |
| 1260 factory->NewStringFromStaticAscii("<loop test>"); | |
| 1261 Handle<Object> code_object = m.GetCode(source); | 1249 Handle<Object> code_object = m.GetCode(source); |
| 1262 Handle<Code> code = Handle<Code>::cast(code_object); | 1250 Handle<Code> code = Handle<Code>::cast(code_object); |
| 1263 | 1251 |
| 1264 // String long enough for test (content doesn't matter). | 1252 // String long enough for test (content doesn't matter). |
| 1265 Handle<String> input = | 1253 Handle<String> input = factory->NewStringFromStaticChars("foofoofoofoofoo"); |
| 1266 factory->NewStringFromStaticAscii("foofoofoofoofoo"); | |
| 1267 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); | 1254 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
| 1268 Address start_adr = seq_input->GetCharsAddress(); | 1255 Address start_adr = seq_input->GetCharsAddress(); |
| 1269 | 1256 |
| 1270 int output[6]; | 1257 int output[6]; |
| 1271 NativeRegExpMacroAssembler::Result result = | 1258 NativeRegExpMacroAssembler::Result result = |
| 1272 Execute(*code, | 1259 Execute(*code, |
| 1273 *input, | 1260 *input, |
| 1274 0, | 1261 0, |
| 1275 start_adr, | 1262 start_adr, |
| 1276 start_adr + input->length(), | 1263 start_adr + input->length(), |
| 1277 output); | 1264 output); |
| 1278 | 1265 |
| 1279 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); | 1266 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 1280 CHECK_EQ(0, output[0]); | 1267 CHECK_EQ(0, output[0]); |
| 1281 CHECK_EQ(3, output[1]); | 1268 CHECK_EQ(3, output[1]); |
| 1282 CHECK_EQ(6, output[2]); | 1269 CHECK_EQ(6, output[2]); |
| 1283 CHECK_EQ(9, output[3]); | 1270 CHECK_EQ(9, output[3]); |
| 1284 CHECK_EQ(9, output[4]); | 1271 CHECK_EQ(9, output[4]); |
| 1285 CHECK_EQ(-1, output[5]); | 1272 CHECK_EQ(-1, output[5]); |
| 1286 } | 1273 } |
| 1287 | 1274 |
| 1288 | 1275 |
| 1289 TEST(MacroAssemblerStackOverflow) { | 1276 TEST(MacroAssemblerStackOverflow) { |
| 1290 v8::V8::Initialize(); | 1277 v8::V8::Initialize(); |
| 1291 ContextInitializer initializer; | 1278 ContextInitializer initializer; |
| 1292 Isolate* isolate = CcTest::i_isolate(); | 1279 Isolate* isolate = CcTest::i_isolate(); |
| 1293 Factory* factory = isolate->factory(); | 1280 Factory* factory = isolate->factory(); |
| 1294 Zone zone(isolate); | 1281 Zone zone(isolate); |
| 1295 | 1282 |
| 1296 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone); | 1283 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 0, &zone); |
| 1297 | 1284 |
| 1298 Label loop; | 1285 Label loop; |
| 1299 m.Bind(&loop); | 1286 m.Bind(&loop); |
| 1300 m.PushBacktrack(&loop); | 1287 m.PushBacktrack(&loop); |
| 1301 m.GoTo(&loop); | 1288 m.GoTo(&loop); |
| 1302 | 1289 |
| 1303 Handle<String> source = | 1290 Handle<String> source = |
| 1304 factory->NewStringFromStaticAscii("<stack overflow test>"); | 1291 factory->NewStringFromStaticChars("<stack overflow test>"); |
| 1305 Handle<Object> code_object = m.GetCode(source); | 1292 Handle<Object> code_object = m.GetCode(source); |
| 1306 Handle<Code> code = Handle<Code>::cast(code_object); | 1293 Handle<Code> code = Handle<Code>::cast(code_object); |
| 1307 | 1294 |
| 1308 // String long enough for test (content doesn't matter). | 1295 // String long enough for test (content doesn't matter). |
| 1309 Handle<String> input = | 1296 Handle<String> input = factory->NewStringFromStaticChars("dummy"); |
| 1310 factory->NewStringFromStaticAscii("dummy"); | |
| 1311 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); | 1297 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
| 1312 Address start_adr = seq_input->GetCharsAddress(); | 1298 Address start_adr = seq_input->GetCharsAddress(); |
| 1313 | 1299 |
| 1314 NativeRegExpMacroAssembler::Result result = | 1300 NativeRegExpMacroAssembler::Result result = |
| 1315 Execute(*code, | 1301 Execute(*code, |
| 1316 *input, | 1302 *input, |
| 1317 0, | 1303 0, |
| 1318 start_adr, | 1304 start_adr, |
| 1319 start_adr + input->length(), | 1305 start_adr + input->length(), |
| 1320 NULL); | 1306 NULL); |
| 1321 | 1307 |
| 1322 CHECK_EQ(NativeRegExpMacroAssembler::EXCEPTION, result); | 1308 CHECK_EQ(NativeRegExpMacroAssembler::EXCEPTION, result); |
| 1323 CHECK(isolate->has_pending_exception()); | 1309 CHECK(isolate->has_pending_exception()); |
| 1324 isolate->clear_pending_exception(); | 1310 isolate->clear_pending_exception(); |
| 1325 } | 1311 } |
| 1326 | 1312 |
| 1327 | 1313 |
| 1328 TEST(MacroAssemblerNativeLotsOfRegisters) { | 1314 TEST(MacroAssemblerNativeLotsOfRegisters) { |
| 1329 v8::V8::Initialize(); | 1315 v8::V8::Initialize(); |
| 1330 ContextInitializer initializer; | 1316 ContextInitializer initializer; |
| 1331 Isolate* isolate = CcTest::i_isolate(); | 1317 Isolate* isolate = CcTest::i_isolate(); |
| 1332 Factory* factory = isolate->factory(); | 1318 Factory* factory = isolate->factory(); |
| 1333 Zone zone(isolate); | 1319 Zone zone(isolate); |
| 1334 | 1320 |
| 1335 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2, &zone); | 1321 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 2, &zone); |
| 1336 | 1322 |
| 1337 // At least 2048, to ensure the allocated space for registers | 1323 // At least 2048, to ensure the allocated space for registers |
| 1338 // span one full page. | 1324 // span one full page. |
| 1339 const int large_number = 8000; | 1325 const int large_number = 8000; |
| 1340 m.WriteCurrentPositionToRegister(large_number, 42); | 1326 m.WriteCurrentPositionToRegister(large_number, 42); |
| 1341 m.WriteCurrentPositionToRegister(0, 0); | 1327 m.WriteCurrentPositionToRegister(0, 0); |
| 1342 m.WriteCurrentPositionToRegister(1, 1); | 1328 m.WriteCurrentPositionToRegister(1, 1); |
| 1343 Label done; | 1329 Label done; |
| 1344 m.CheckNotBackReference(0, &done); // Performs a system-stack push. | 1330 m.CheckNotBackReference(0, &done); // Performs a system-stack push. |
| 1345 m.Bind(&done); | 1331 m.Bind(&done); |
| 1346 m.PushRegister(large_number, RegExpMacroAssembler::kNoStackLimitCheck); | 1332 m.PushRegister(large_number, RegExpMacroAssembler::kNoStackLimitCheck); |
| 1347 m.PopRegister(1); | 1333 m.PopRegister(1); |
| 1348 m.Succeed(); | 1334 m.Succeed(); |
| 1349 | 1335 |
| 1350 Handle<String> source = | 1336 Handle<String> source = |
| 1351 factory->NewStringFromStaticAscii("<huge register space test>"); | 1337 factory->NewStringFromStaticChars("<huge register space test>"); |
| 1352 Handle<Object> code_object = m.GetCode(source); | 1338 Handle<Object> code_object = m.GetCode(source); |
| 1353 Handle<Code> code = Handle<Code>::cast(code_object); | 1339 Handle<Code> code = Handle<Code>::cast(code_object); |
| 1354 | 1340 |
| 1355 // String long enough for test (content doesn't matter). | 1341 // String long enough for test (content doesn't matter). |
| 1356 Handle<String> input = | 1342 Handle<String> input = factory->NewStringFromStaticChars("sample text"); |
| 1357 factory->NewStringFromStaticAscii("sample text"); | |
| 1358 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); | 1343 Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); |
| 1359 Address start_adr = seq_input->GetCharsAddress(); | 1344 Address start_adr = seq_input->GetCharsAddress(); |
| 1360 | 1345 |
| 1361 int captures[2]; | 1346 int captures[2]; |
| 1362 NativeRegExpMacroAssembler::Result result = | 1347 NativeRegExpMacroAssembler::Result result = |
| 1363 Execute(*code, | 1348 Execute(*code, |
| 1364 *input, | 1349 *input, |
| 1365 0, | 1350 0, |
| 1366 start_adr, | 1351 start_adr, |
| 1367 start_adr + input->length(), | 1352 start_adr + input->length(), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 m.ClearRegisters(2, 3); | 1394 m.ClearRegisters(2, 3); |
| 1410 m.Backtrack(); | 1395 m.Backtrack(); |
| 1411 m.Bind(&fail); | 1396 m.Bind(&fail); |
| 1412 m.PopRegister(0); | 1397 m.PopRegister(0); |
| 1413 m.Fail(); | 1398 m.Fail(); |
| 1414 | 1399 |
| 1415 Isolate* isolate = CcTest::i_isolate(); | 1400 Isolate* isolate = CcTest::i_isolate(); |
| 1416 Factory* factory = isolate->factory(); | 1401 Factory* factory = isolate->factory(); |
| 1417 HandleScope scope(isolate); | 1402 HandleScope scope(isolate); |
| 1418 | 1403 |
| 1419 Handle<String> source = factory->NewStringFromStaticAscii("^f(o)o"); | 1404 Handle<String> source = factory->NewStringFromStaticChars("^f(o)o"); |
| 1420 Handle<ByteArray> array = Handle<ByteArray>::cast(m.GetCode(source)); | 1405 Handle<ByteArray> array = Handle<ByteArray>::cast(m.GetCode(source)); |
| 1421 int captures[5]; | 1406 int captures[5]; |
| 1422 | 1407 |
| 1423 const uc16 str1[] = {'f', 'o', 'o', 'b', 'a', 'r'}; | 1408 const uc16 str1[] = {'f', 'o', 'o', 'b', 'a', 'r'}; |
| 1424 Handle<String> f1_16 = factory->NewStringFromTwoByte( | 1409 Handle<String> f1_16 = factory->NewStringFromTwoByte( |
| 1425 Vector<const uc16>(str1, 6)).ToHandleChecked(); | 1410 Vector<const uc16>(str1, 6)).ToHandleChecked(); |
| 1426 | 1411 |
| 1427 CHECK(IrregexpInterpreter::Match(isolate, array, f1_16, captures, 0)); | 1412 CHECK(IrregexpInterpreter::Match(isolate, array, f1_16, captures, 0)); |
| 1428 CHECK_EQ(0, captures[0]); | 1413 CHECK_EQ(0, captures[0]); |
| 1429 CHECK_EQ(3, captures[1]); | 1414 CHECK_EQ(3, captures[1]); |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1819 ZoneList<CharacterRange> first_only(4, &zone); | 1804 ZoneList<CharacterRange> first_only(4, &zone); |
| 1820 ZoneList<CharacterRange> second_only(4, &zone); | 1805 ZoneList<CharacterRange> second_only(4, &zone); |
| 1821 ZoneList<CharacterRange> both(4, &zone); | 1806 ZoneList<CharacterRange> both(4, &zone); |
| 1822 } | 1807 } |
| 1823 | 1808 |
| 1824 | 1809 |
| 1825 TEST(Graph) { | 1810 TEST(Graph) { |
| 1826 V8::Initialize(NULL); | 1811 V8::Initialize(NULL); |
| 1827 Execute("\\b\\w+\\b", false, true, true); | 1812 Execute("\\b\\w+\\b", false, true, true); |
| 1828 } | 1813 } |
| OLD | NEW |