| OLD | NEW |
| 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 24 matching lines...) Expand all Loading... |
| 35 #include "zone-inl.h" | 35 #include "zone-inl.h" |
| 36 #include "parser.h" | 36 #include "parser.h" |
| 37 #include "ast.h" | 37 #include "ast.h" |
| 38 #include "jsregexp.h" | 38 #include "jsregexp.h" |
| 39 #include "regexp-macro-assembler.h" | 39 #include "regexp-macro-assembler.h" |
| 40 #include "regexp-macro-assembler-irregexp.h" | 40 #include "regexp-macro-assembler-irregexp.h" |
| 41 #ifdef V8_TARGET_ARCH_ARM | 41 #ifdef V8_TARGET_ARCH_ARM |
| 42 #include "arm/regexp-macro-assembler-arm.h" | 42 #include "arm/regexp-macro-assembler-arm.h" |
| 43 #endif | 43 #endif |
| 44 #ifdef V8_TARGET_ARCH_X64 | 44 #ifdef V8_TARGET_ARCH_X64 |
| 45 // No X64-implementation yet. | 45 #include "x64/macro-assembler-x64.h" |
| 46 #include "x64/regexp-macro-assembler-x64.h" |
| 46 #endif | 47 #endif |
| 47 #ifdef V8_TARGET_ARCH_IA32 | 48 #ifdef V8_TARGET_ARCH_IA32 |
| 48 #include "ia32/macro-assembler-ia32.h" | 49 #include "ia32/macro-assembler-ia32.h" |
| 49 #include "ia32/regexp-macro-assembler-ia32.h" | 50 #include "ia32/regexp-macro-assembler-ia32.h" |
| 50 #endif | 51 #endif |
| 51 #include "interpreter-irregexp.h" | 52 #include "interpreter-irregexp.h" |
| 52 | 53 |
| 53 | 54 |
| 54 using namespace v8::internal; | 55 using namespace v8::internal; |
| 55 | 56 |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 CHECK_EQ(84, captures[4]); | 656 CHECK_EQ(84, captures[4]); |
| 656 | 657 |
| 657 const uc16 str2[] = {'b', 'a', 'r', 'f', 'o', 'o'}; | 658 const uc16 str2[] = {'b', 'a', 'r', 'f', 'o', 'o'}; |
| 658 Handle<String> f2_16 = | 659 Handle<String> f2_16 = |
| 659 Factory::NewStringFromTwoByte(Vector<const uc16>(str2, 6)); | 660 Factory::NewStringFromTwoByte(Vector<const uc16>(str2, 6)); |
| 660 | 661 |
| 661 CHECK(!IrregexpInterpreter::Match(array, f2_16, captures, 0)); | 662 CHECK(!IrregexpInterpreter::Match(array, f2_16, captures, 0)); |
| 662 CHECK_EQ(42, captures[0]); | 663 CHECK_EQ(42, captures[0]); |
| 663 } | 664 } |
| 664 | 665 |
| 665 #ifdef V8_TARGET_ARCH_IA32 // IA32 Native Regexp only tests. | |
| 666 #ifdef V8_NATIVE_REGEXP | 666 #ifdef V8_NATIVE_REGEXP |
| 667 | 667 |
| 668 #ifdef V8_TARGET_ARCH_IA32 |
| 669 typedef RegExpMacroAssemblerIA32 ArchRegExpMacroAssembler; |
| 670 #endif |
| 671 #ifdef V8_TARGET_ARCH_X64 |
| 672 typedef RegExpMacroAssemblerX64 ArchRegExpMacroAssembler; |
| 673 #endif |
| 674 |
| 668 class ContextInitializer { | 675 class ContextInitializer { |
| 669 public: | 676 public: |
| 670 ContextInitializer() : env_(), scope_(), stack_guard_() { | 677 ContextInitializer() |
| 678 : env_(), scope_(), zone_(DELETE_ON_EXIT), stack_guard_() { |
| 671 env_ = v8::Context::New(); | 679 env_ = v8::Context::New(); |
| 672 env_->Enter(); | 680 env_->Enter(); |
| 673 } | 681 } |
| 674 ~ContextInitializer() { | 682 ~ContextInitializer() { |
| 675 env_->Exit(); | 683 env_->Exit(); |
| 676 env_.Dispose(); | 684 env_.Dispose(); |
| 677 } | 685 } |
| 678 private: | 686 private: |
| 679 v8::Persistent<v8::Context> env_; | 687 v8::Persistent<v8::Context> env_; |
| 680 v8::HandleScope scope_; | 688 v8::HandleScope scope_; |
| 689 v8::internal::ZoneScope zone_; |
| 681 v8::internal::StackGuard stack_guard_; | 690 v8::internal::StackGuard stack_guard_; |
| 682 }; | 691 }; |
| 683 | 692 |
| 684 | 693 |
| 685 static RegExpMacroAssemblerIA32::Result ExecuteIA32(Code* code, | 694 static ArchRegExpMacroAssembler::Result Execute(Code* code, |
| 686 String* input, | 695 String* input, |
| 687 int start_offset, | 696 int start_offset, |
| 688 const byte* input_start, | 697 const byte* input_start, |
| 689 const byte* input_end, | 698 const byte* input_end, |
| 690 int* captures, | 699 int* captures, |
| 691 bool at_start) { | 700 bool at_start) { |
| 692 return RegExpMacroAssemblerIA32::Execute( | 701 return NativeRegExpMacroAssembler::Execute( |
| 693 code, | 702 code, |
| 694 input, | 703 input, |
| 695 start_offset, | 704 start_offset, |
| 696 input_start, | 705 input_start, |
| 697 input_end, | 706 input_end, |
| 698 captures, | 707 captures, |
| 699 at_start); | 708 at_start); |
| 700 } | 709 } |
| 701 | 710 |
| 702 | 711 |
| 703 TEST(MacroAssemblerIA32Success) { | 712 TEST(MacroAssemblerNativeSuccess) { |
| 704 v8::V8::Initialize(); | 713 v8::V8::Initialize(); |
| 705 ContextInitializer initializer; | 714 ContextInitializer initializer; |
| 706 | 715 |
| 707 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 4); | 716 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4); |
| 708 | 717 |
| 709 m.Succeed(); | 718 m.Succeed(); |
| 710 | 719 |
| 711 Handle<String> source = Factory::NewStringFromAscii(CStrVector("")); | 720 Handle<String> source = Factory::NewStringFromAscii(CStrVector("")); |
| 712 Handle<Object> code_object = m.GetCode(source); | 721 Handle<Object> code_object = m.GetCode(source); |
| 713 Handle<Code> code = Handle<Code>::cast(code_object); | 722 Handle<Code> code = Handle<Code>::cast(code_object); |
| 714 | 723 |
| 715 int captures[4] = {42, 37, 87, 117}; | 724 int captures[4] = {42, 37, 87, 117}; |
| 716 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo")); | 725 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo")); |
| 717 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 726 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); |
| 718 const byte* start_adr = | 727 const byte* start_adr = |
| 719 reinterpret_cast<const byte*>(seq_input->GetCharsAddress()); | 728 reinterpret_cast<const byte*>(seq_input->GetCharsAddress()); |
| 720 | 729 |
| 721 RegExpMacroAssemblerIA32::Result result = | 730 NativeRegExpMacroAssembler::Result result = |
| 722 ExecuteIA32(*code, | 731 Execute(*code, |
| 723 *input, | 732 *input, |
| 724 0, | 733 0, |
| 725 start_adr, | 734 start_adr, |
| 726 start_adr + seq_input->length(), | 735 start_adr + seq_input->length(), |
| 727 captures, | 736 captures, |
| 728 true); | 737 true); |
| 729 | 738 |
| 730 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 739 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 731 CHECK_EQ(-1, captures[0]); | 740 CHECK_EQ(-1, captures[0]); |
| 732 CHECK_EQ(-1, captures[1]); | 741 CHECK_EQ(-1, captures[1]); |
| 733 CHECK_EQ(-1, captures[2]); | 742 CHECK_EQ(-1, captures[2]); |
| 734 CHECK_EQ(-1, captures[3]); | 743 CHECK_EQ(-1, captures[3]); |
| 735 } | 744 } |
| 736 | 745 |
| 737 | 746 |
| 738 TEST(MacroAssemblerIA32Simple) { | 747 TEST(MacroAssemblerNativeSimple) { |
| 739 v8::V8::Initialize(); | 748 v8::V8::Initialize(); |
| 740 ContextInitializer initializer; | 749 ContextInitializer initializer; |
| 741 | 750 |
| 742 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 4); | 751 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4); |
| 743 | 752 |
| 744 uc16 foo_chars[3] = {'f', 'o', 'o'}; | 753 uc16 foo_chars[3] = {'f', 'o', 'o'}; |
| 745 Vector<const uc16> foo(foo_chars, 3); | 754 Vector<const uc16> foo(foo_chars, 3); |
| 746 | 755 |
| 747 Label fail; | 756 Label fail; |
| 748 m.CheckCharacters(foo, 0, &fail, true); | 757 m.CheckCharacters(foo, 0, &fail, true); |
| 749 m.WriteCurrentPositionToRegister(0, 0); | 758 m.WriteCurrentPositionToRegister(0, 0); |
| 750 m.AdvanceCurrentPosition(3); | 759 m.AdvanceCurrentPosition(3); |
| 751 m.WriteCurrentPositionToRegister(1, 0); | 760 m.WriteCurrentPositionToRegister(1, 0); |
| 752 m.Succeed(); | 761 m.Succeed(); |
| 753 m.Bind(&fail); | 762 m.Bind(&fail); |
| 754 m.Fail(); | 763 m.Fail(); |
| 755 | 764 |
| 756 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^foo")); | 765 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^foo")); |
| 757 Handle<Object> code_object = m.GetCode(source); | 766 Handle<Object> code_object = m.GetCode(source); |
| 758 Handle<Code> code = Handle<Code>::cast(code_object); | 767 Handle<Code> code = Handle<Code>::cast(code_object); |
| 759 | 768 |
| 760 int captures[4] = {42, 37, 87, 117}; | 769 int captures[4] = {42, 37, 87, 117}; |
| 761 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo")); | 770 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo")); |
| 762 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 771 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); |
| 763 Address start_adr = seq_input->GetCharsAddress(); | 772 Address start_adr = seq_input->GetCharsAddress(); |
| 764 | 773 |
| 765 RegExpMacroAssemblerIA32::Result result = | 774 NativeRegExpMacroAssembler::Result result = |
| 766 ExecuteIA32(*code, | 775 Execute(*code, |
| 767 *input, | 776 *input, |
| 768 0, | 777 0, |
| 769 start_adr, | 778 start_adr, |
| 770 start_adr + input->length(), | 779 start_adr + input->length(), |
| 771 captures, | 780 captures, |
| 772 true); | 781 true); |
| 773 | 782 |
| 774 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 783 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 775 CHECK_EQ(0, captures[0]); | 784 CHECK_EQ(0, captures[0]); |
| 776 CHECK_EQ(3, captures[1]); | 785 CHECK_EQ(3, captures[1]); |
| 777 CHECK_EQ(-1, captures[2]); | 786 CHECK_EQ(-1, captures[2]); |
| 778 CHECK_EQ(-1, captures[3]); | 787 CHECK_EQ(-1, captures[3]); |
| 779 | 788 |
| 780 input = Factory::NewStringFromAscii(CStrVector("barbarbar")); | 789 input = Factory::NewStringFromAscii(CStrVector("barbarbar")); |
| 781 seq_input = Handle<SeqAsciiString>::cast(input); | 790 seq_input = Handle<SeqAsciiString>::cast(input); |
| 782 start_adr = seq_input->GetCharsAddress(); | 791 start_adr = seq_input->GetCharsAddress(); |
| 783 | 792 |
| 784 result = ExecuteIA32(*code, | 793 result = Execute(*code, |
| 785 *input, | 794 *input, |
| 786 0, | 795 0, |
| 787 start_adr, | 796 start_adr, |
| 788 start_adr + input->length(), | 797 start_adr + input->length(), |
| 789 captures, | 798 captures, |
| 790 true); | 799 true); |
| 791 | 800 |
| 792 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result); | 801 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); |
| 793 } | 802 } |
| 794 | 803 |
| 795 | 804 |
| 796 TEST(MacroAssemblerIA32SimpleUC16) { | 805 TEST(MacroAssemblerNativeSimpleUC16) { |
| 797 v8::V8::Initialize(); | 806 v8::V8::Initialize(); |
| 798 ContextInitializer initializer; | 807 ContextInitializer initializer; |
| 799 | 808 |
| 800 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::UC16, 4); | 809 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4); |
| 801 | 810 |
| 802 uc16 foo_chars[3] = {'f', 'o', 'o'}; | 811 uc16 foo_chars[3] = {'f', 'o', 'o'}; |
| 803 Vector<const uc16> foo(foo_chars, 3); | 812 Vector<const uc16> foo(foo_chars, 3); |
| 804 | 813 |
| 805 Label fail; | 814 Label fail; |
| 806 m.CheckCharacters(foo, 0, &fail, true); | 815 m.CheckCharacters(foo, 0, &fail, true); |
| 807 m.WriteCurrentPositionToRegister(0, 0); | 816 m.WriteCurrentPositionToRegister(0, 0); |
| 808 m.AdvanceCurrentPosition(3); | 817 m.AdvanceCurrentPosition(3); |
| 809 m.WriteCurrentPositionToRegister(1, 0); | 818 m.WriteCurrentPositionToRegister(1, 0); |
| 810 m.Succeed(); | 819 m.Succeed(); |
| 811 m.Bind(&fail); | 820 m.Bind(&fail); |
| 812 m.Fail(); | 821 m.Fail(); |
| 813 | 822 |
| 814 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^foo")); | 823 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^foo")); |
| 815 Handle<Object> code_object = m.GetCode(source); | 824 Handle<Object> code_object = m.GetCode(source); |
| 816 Handle<Code> code = Handle<Code>::cast(code_object); | 825 Handle<Code> code = Handle<Code>::cast(code_object); |
| 817 | 826 |
| 818 int captures[4] = {42, 37, 87, 117}; | 827 int captures[4] = {42, 37, 87, 117}; |
| 819 const uc16 input_data[6] = {'f', 'o', 'o', 'f', 'o', '\xa0'}; | 828 const uc16 input_data[6] = {'f', 'o', 'o', 'f', 'o', '\xa0'}; |
| 820 Handle<String> input = | 829 Handle<String> input = |
| 821 Factory::NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); | 830 Factory::NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); |
| 822 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); | 831 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); |
| 823 Address start_adr = seq_input->GetCharsAddress(); | 832 Address start_adr = seq_input->GetCharsAddress(); |
| 824 | 833 |
| 825 RegExpMacroAssemblerIA32::Result result = | 834 NativeRegExpMacroAssembler::Result result = |
| 826 ExecuteIA32(*code, | 835 Execute(*code, |
| 827 *input, | 836 *input, |
| 828 0, | 837 0, |
| 829 start_adr, | 838 start_adr, |
| 830 start_adr + input->length(), | 839 start_adr + input->length(), |
| 831 captures, | 840 captures, |
| 832 true); | 841 true); |
| 833 | 842 |
| 834 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 843 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 835 CHECK_EQ(0, captures[0]); | 844 CHECK_EQ(0, captures[0]); |
| 836 CHECK_EQ(3, captures[1]); | 845 CHECK_EQ(3, captures[1]); |
| 837 CHECK_EQ(-1, captures[2]); | 846 CHECK_EQ(-1, captures[2]); |
| 838 CHECK_EQ(-1, captures[3]); | 847 CHECK_EQ(-1, captures[3]); |
| 839 | 848 |
| 840 const uc16 input_data2[9] = {'b', 'a', 'r', 'b', 'a', 'r', 'b', 'a', '\xa0'}; | 849 const uc16 input_data2[9] = {'b', 'a', 'r', 'b', 'a', 'r', 'b', 'a', '\xa0'}; |
| 841 input = Factory::NewStringFromTwoByte(Vector<const uc16>(input_data2, 9)); | 850 input = Factory::NewStringFromTwoByte(Vector<const uc16>(input_data2, 9)); |
| 842 seq_input = Handle<SeqTwoByteString>::cast(input); | 851 seq_input = Handle<SeqTwoByteString>::cast(input); |
| 843 start_adr = seq_input->GetCharsAddress(); | 852 start_adr = seq_input->GetCharsAddress(); |
| 844 | 853 |
| 845 result = ExecuteIA32(*code, | 854 result = Execute(*code, |
| 846 *input, | 855 *input, |
| 847 0, | 856 0, |
| 848 start_adr, | 857 start_adr, |
| 849 start_adr + input->length() * 2, | 858 start_adr + input->length() * 2, |
| 850 captures, | 859 captures, |
| 851 true); | 860 true); |
| 852 | 861 |
| 853 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result); | 862 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); |
| 854 } | 863 } |
| 855 | 864 |
| 856 | 865 |
| 857 TEST(MacroAssemblerIA32Backtrack) { | 866 TEST(MacroAssemblerNativeBacktrack) { |
| 858 v8::V8::Initialize(); | 867 v8::V8::Initialize(); |
| 859 ContextInitializer initializer; | 868 ContextInitializer initializer; |
| 860 | 869 |
| 861 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0); | 870 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0); |
| 862 | 871 |
| 863 Label fail; | 872 Label fail; |
| 864 Label backtrack; | 873 Label backtrack; |
| 865 m.LoadCurrentCharacter(10, &fail); | 874 m.LoadCurrentCharacter(10, &fail); |
| 866 m.Succeed(); | 875 m.Succeed(); |
| 867 m.Bind(&fail); | 876 m.Bind(&fail); |
| 868 m.PushBacktrack(&backtrack); | 877 m.PushBacktrack(&backtrack); |
| 869 m.LoadCurrentCharacter(10, NULL); | 878 m.LoadCurrentCharacter(10, NULL); |
| 870 m.Succeed(); | 879 m.Succeed(); |
| 871 m.Bind(&backtrack); | 880 m.Bind(&backtrack); |
| 872 m.Fail(); | 881 m.Fail(); |
| 873 | 882 |
| 874 Handle<String> source = Factory::NewStringFromAscii(CStrVector("..........")); | 883 Handle<String> source = Factory::NewStringFromAscii(CStrVector("..........")); |
| 875 Handle<Object> code_object = m.GetCode(source); | 884 Handle<Object> code_object = m.GetCode(source); |
| 876 Handle<Code> code = Handle<Code>::cast(code_object); | 885 Handle<Code> code = Handle<Code>::cast(code_object); |
| 877 | 886 |
| 878 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo")); | 887 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo")); |
| 879 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 888 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); |
| 880 Address start_adr = seq_input->GetCharsAddress(); | 889 Address start_adr = seq_input->GetCharsAddress(); |
| 881 | 890 |
| 882 RegExpMacroAssemblerIA32::Result result = | 891 NativeRegExpMacroAssembler::Result result = |
| 883 ExecuteIA32(*code, | 892 Execute(*code, |
| 884 *input, | 893 *input, |
| 885 0, | 894 0, |
| 886 start_adr, | 895 start_adr, |
| 887 start_adr + input->length(), | 896 start_adr + input->length(), |
| 888 NULL, | 897 NULL, |
| 889 true); | 898 true); |
| 890 | 899 |
| 891 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result); | 900 CHECK_EQ(NativeRegExpMacroAssembler::FAILURE, result); |
| 892 } | 901 } |
| 893 | 902 |
| 894 | 903 |
| 895 TEST(MacroAssemblerIA32BackReferenceASCII) { | 904 TEST(MacroAssemblerNativeBackReferenceASCII) { |
| 896 v8::V8::Initialize(); | 905 v8::V8::Initialize(); |
| 897 ContextInitializer initializer; | 906 ContextInitializer initializer; |
| 898 | 907 |
| 899 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 3); | 908 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 3); |
| 900 | 909 |
| 901 m.WriteCurrentPositionToRegister(0, 0); | 910 m.WriteCurrentPositionToRegister(0, 0); |
| 902 m.AdvanceCurrentPosition(2); | 911 m.AdvanceCurrentPosition(2); |
| 903 m.WriteCurrentPositionToRegister(1, 0); | 912 m.WriteCurrentPositionToRegister(1, 0); |
| 904 Label nomatch; | 913 Label nomatch; |
| 905 m.CheckNotBackReference(0, &nomatch); | 914 m.CheckNotBackReference(0, &nomatch); |
| 906 m.Fail(); | 915 m.Fail(); |
| 907 m.Bind(&nomatch); | 916 m.Bind(&nomatch); |
| 908 m.AdvanceCurrentPosition(2); | 917 m.AdvanceCurrentPosition(2); |
| 909 Label missing_match; | 918 Label missing_match; |
| 910 m.CheckNotBackReference(0, &missing_match); | 919 m.CheckNotBackReference(0, &missing_match); |
| 911 m.WriteCurrentPositionToRegister(2, 0); | 920 m.WriteCurrentPositionToRegister(2, 0); |
| 912 m.Succeed(); | 921 m.Succeed(); |
| 913 m.Bind(&missing_match); | 922 m.Bind(&missing_match); |
| 914 m.Fail(); | 923 m.Fail(); |
| 915 | 924 |
| 916 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^(..)..\1")); | 925 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^(..)..\1")); |
| 917 Handle<Object> code_object = m.GetCode(source); | 926 Handle<Object> code_object = m.GetCode(source); |
| 918 Handle<Code> code = Handle<Code>::cast(code_object); | 927 Handle<Code> code = Handle<Code>::cast(code_object); |
| 919 | 928 |
| 920 Handle<String> input = Factory::NewStringFromAscii(CStrVector("fooofo")); | 929 Handle<String> input = Factory::NewStringFromAscii(CStrVector("fooofo")); |
| 921 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 930 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); |
| 922 Address start_adr = seq_input->GetCharsAddress(); | 931 Address start_adr = seq_input->GetCharsAddress(); |
| 923 | 932 |
| 924 int output[3]; | 933 int output[3]; |
| 925 RegExpMacroAssemblerIA32::Result result = | 934 NativeRegExpMacroAssembler::Result result = |
| 926 ExecuteIA32(*code, | 935 Execute(*code, |
| 927 *input, | 936 *input, |
| 928 0, | 937 0, |
| 929 start_adr, | 938 start_adr, |
| 930 start_adr + input->length(), | 939 start_adr + input->length(), |
| 931 output, | 940 output, |
| 932 true); | 941 true); |
| 933 | 942 |
| 934 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 943 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 935 CHECK_EQ(0, output[0]); | 944 CHECK_EQ(0, output[0]); |
| 936 CHECK_EQ(2, output[1]); | 945 CHECK_EQ(2, output[1]); |
| 937 CHECK_EQ(6, output[2]); | 946 CHECK_EQ(6, output[2]); |
| 938 } | 947 } |
| 939 | 948 |
| 940 | 949 |
| 941 TEST(MacroAssemblerIA32BackReferenceUC16) { | 950 TEST(MacroAssemblerNativeBackReferenceUC16) { |
| 942 v8::V8::Initialize(); | 951 v8::V8::Initialize(); |
| 943 ContextInitializer initializer; | 952 ContextInitializer initializer; |
| 944 | 953 |
| 945 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::UC16, 3); | 954 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 3); |
| 946 | 955 |
| 947 m.WriteCurrentPositionToRegister(0, 0); | 956 m.WriteCurrentPositionToRegister(0, 0); |
| 948 m.AdvanceCurrentPosition(2); | 957 m.AdvanceCurrentPosition(2); |
| 949 m.WriteCurrentPositionToRegister(1, 0); | 958 m.WriteCurrentPositionToRegister(1, 0); |
| 950 Label nomatch; | 959 Label nomatch; |
| 951 m.CheckNotBackReference(0, &nomatch); | 960 m.CheckNotBackReference(0, &nomatch); |
| 952 m.Fail(); | 961 m.Fail(); |
| 953 m.Bind(&nomatch); | 962 m.Bind(&nomatch); |
| 954 m.AdvanceCurrentPosition(2); | 963 m.AdvanceCurrentPosition(2); |
| 955 Label missing_match; | 964 Label missing_match; |
| 956 m.CheckNotBackReference(0, &missing_match); | 965 m.CheckNotBackReference(0, &missing_match); |
| 957 m.WriteCurrentPositionToRegister(2, 0); | 966 m.WriteCurrentPositionToRegister(2, 0); |
| 958 m.Succeed(); | 967 m.Succeed(); |
| 959 m.Bind(&missing_match); | 968 m.Bind(&missing_match); |
| 960 m.Fail(); | 969 m.Fail(); |
| 961 | 970 |
| 962 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^(..)..\1")); | 971 Handle<String> source = Factory::NewStringFromAscii(CStrVector("^(..)..\1")); |
| 963 Handle<Object> code_object = m.GetCode(source); | 972 Handle<Object> code_object = m.GetCode(source); |
| 964 Handle<Code> code = Handle<Code>::cast(code_object); | 973 Handle<Code> code = Handle<Code>::cast(code_object); |
| 965 | 974 |
| 966 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028}; | 975 const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028}; |
| 967 Handle<String> input = | 976 Handle<String> input = |
| 968 Factory::NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); | 977 Factory::NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); |
| 969 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); | 978 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); |
| 970 Address start_adr = seq_input->GetCharsAddress(); | 979 Address start_adr = seq_input->GetCharsAddress(); |
| 971 | 980 |
| 972 int output[3]; | 981 int output[3]; |
| 973 RegExpMacroAssemblerIA32::Result result = | 982 NativeRegExpMacroAssembler::Result result = |
| 974 ExecuteIA32(*code, | 983 Execute(*code, |
| 975 *input, | 984 *input, |
| 976 0, | 985 0, |
| 977 start_adr, | 986 start_adr, |
| 978 start_adr + input->length() * 2, | 987 start_adr + input->length() * 2, |
| 979 output, | 988 output, |
| 980 true); | 989 true); |
| 981 | 990 |
| 982 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 991 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 983 CHECK_EQ(0, output[0]); | 992 CHECK_EQ(0, output[0]); |
| 984 CHECK_EQ(2, output[1]); | 993 CHECK_EQ(2, output[1]); |
| 985 CHECK_EQ(6, output[2]); | 994 CHECK_EQ(6, output[2]); |
| 986 } | 995 } |
| 987 | 996 |
| 988 | 997 |
| 989 | 998 |
| 990 TEST(MacroAssemblerIA32AtStart) { | 999 TEST(MacroAssemblernativeAtStart) { |
| 991 v8::V8::Initialize(); | 1000 v8::V8::Initialize(); |
| 992 ContextInitializer initializer; | 1001 ContextInitializer initializer; |
| 993 | 1002 |
| 994 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0); | 1003 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0); |
| 995 | 1004 |
| 996 Label not_at_start, newline, fail; | 1005 Label not_at_start, newline, fail; |
| 997 m.CheckNotAtStart(¬_at_start); | 1006 m.CheckNotAtStart(¬_at_start); |
| 998 // Check that prevchar = '\n' and current = 'f'. | 1007 // Check that prevchar = '\n' and current = 'f'. |
| 999 m.CheckCharacter('\n', &newline); | 1008 m.CheckCharacter('\n', &newline); |
| 1000 m.Bind(&fail); | 1009 m.Bind(&fail); |
| 1001 m.Fail(); | 1010 m.Fail(); |
| 1002 m.Bind(&newline); | 1011 m.Bind(&newline); |
| 1003 m.LoadCurrentCharacter(0, &fail); | 1012 m.LoadCurrentCharacter(0, &fail); |
| 1004 m.CheckNotCharacter('f', &fail); | 1013 m.CheckNotCharacter('f', &fail); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1015 m.Succeed(); | 1024 m.Succeed(); |
| 1016 | 1025 |
| 1017 Handle<String> source = Factory::NewStringFromAscii(CStrVector("(^f|ob)")); | 1026 Handle<String> source = Factory::NewStringFromAscii(CStrVector("(^f|ob)")); |
| 1018 Handle<Object> code_object = m.GetCode(source); | 1027 Handle<Object> code_object = m.GetCode(source); |
| 1019 Handle<Code> code = Handle<Code>::cast(code_object); | 1028 Handle<Code> code = Handle<Code>::cast(code_object); |
| 1020 | 1029 |
| 1021 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foobar")); | 1030 Handle<String> input = Factory::NewStringFromAscii(CStrVector("foobar")); |
| 1022 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 1031 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); |
| 1023 Address start_adr = seq_input->GetCharsAddress(); | 1032 Address start_adr = seq_input->GetCharsAddress(); |
| 1024 | 1033 |
| 1025 RegExpMacroAssemblerIA32::Result result = | 1034 NativeRegExpMacroAssembler::Result result = |
| 1026 ExecuteIA32(*code, | 1035 Execute(*code, |
| 1027 *input, | 1036 *input, |
| 1028 0, | 1037 0, |
| 1029 start_adr, | 1038 start_adr, |
| 1030 start_adr + input->length(), | 1039 start_adr + input->length(), |
| 1031 NULL, | 1040 NULL, |
| 1032 true); | 1041 true); |
| 1033 | 1042 |
| 1034 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 1043 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 1035 | 1044 |
| 1036 result = ExecuteIA32(*code, | 1045 result = Execute(*code, |
| 1037 *input, | 1046 *input, |
| 1038 3, | 1047 3, |
| 1039 start_adr + 3, | 1048 start_adr + 3, |
| 1040 start_adr + input->length(), | 1049 start_adr + input->length(), |
| 1041 NULL, | 1050 NULL, |
| 1042 false); | 1051 false); |
| 1043 | 1052 |
| 1044 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 1053 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 1045 } | 1054 } |
| 1046 | 1055 |
| 1047 | 1056 |
| 1048 TEST(MacroAssemblerIA32BackRefNoCase) { | 1057 TEST(MacroAssemblerNativeBackRefNoCase) { |
| 1049 v8::V8::Initialize(); | 1058 v8::V8::Initialize(); |
| 1050 ContextInitializer initializer; | 1059 ContextInitializer initializer; |
| 1051 | 1060 |
| 1052 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 4); | 1061 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4); |
| 1053 | 1062 |
| 1054 Label fail, succ; | 1063 Label fail, succ; |
| 1055 | 1064 |
| 1056 m.WriteCurrentPositionToRegister(0, 0); | 1065 m.WriteCurrentPositionToRegister(0, 0); |
| 1057 m.WriteCurrentPositionToRegister(2, 0); | 1066 m.WriteCurrentPositionToRegister(2, 0); |
| 1058 m.AdvanceCurrentPosition(3); | 1067 m.AdvanceCurrentPosition(3); |
| 1059 m.WriteCurrentPositionToRegister(3, 0); | 1068 m.WriteCurrentPositionToRegister(3, 0); |
| 1060 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "AbC". | 1069 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "AbC". |
| 1061 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "ABC". | 1070 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "ABC". |
| 1062 Label expected_fail; | 1071 Label expected_fail; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1077 Factory::NewStringFromAscii(CStrVector("^(abc)\1\1(?!\1)...(?!\1)")); | 1086 Factory::NewStringFromAscii(CStrVector("^(abc)\1\1(?!\1)...(?!\1)")); |
| 1078 Handle<Object> code_object = m.GetCode(source); | 1087 Handle<Object> code_object = m.GetCode(source); |
| 1079 Handle<Code> code = Handle<Code>::cast(code_object); | 1088 Handle<Code> code = Handle<Code>::cast(code_object); |
| 1080 | 1089 |
| 1081 Handle<String> input = | 1090 Handle<String> input = |
| 1082 Factory::NewStringFromAscii(CStrVector("aBcAbCABCxYzab")); | 1091 Factory::NewStringFromAscii(CStrVector("aBcAbCABCxYzab")); |
| 1083 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 1092 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); |
| 1084 Address start_adr = seq_input->GetCharsAddress(); | 1093 Address start_adr = seq_input->GetCharsAddress(); |
| 1085 | 1094 |
| 1086 int output[4]; | 1095 int output[4]; |
| 1087 RegExpMacroAssemblerIA32::Result result = | 1096 NativeRegExpMacroAssembler::Result result = |
| 1088 ExecuteIA32(*code, | 1097 Execute(*code, |
| 1089 *input, | 1098 *input, |
| 1090 0, | 1099 0, |
| 1091 start_adr, | 1100 start_adr, |
| 1092 start_adr + input->length(), | 1101 start_adr + input->length(), |
| 1093 output, | 1102 output, |
| 1094 true); | 1103 true); |
| 1095 | 1104 |
| 1096 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 1105 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 1097 CHECK_EQ(0, output[0]); | 1106 CHECK_EQ(0, output[0]); |
| 1098 CHECK_EQ(12, output[1]); | 1107 CHECK_EQ(12, output[1]); |
| 1099 CHECK_EQ(0, output[2]); | 1108 CHECK_EQ(0, output[2]); |
| 1100 CHECK_EQ(3, output[3]); | 1109 CHECK_EQ(3, output[3]); |
| 1101 } | 1110 } |
| 1102 | 1111 |
| 1103 | 1112 |
| 1104 | 1113 |
| 1105 TEST(MacroAssemblerIA32Registers) { | 1114 TEST(MacroAssemblerNativeRegisters) { |
| 1106 v8::V8::Initialize(); | 1115 v8::V8::Initialize(); |
| 1107 ContextInitializer initializer; | 1116 ContextInitializer initializer; |
| 1108 | 1117 |
| 1109 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 5); | 1118 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 5); |
| 1110 | 1119 |
| 1111 uc16 foo_chars[3] = {'f', 'o', 'o'}; | 1120 uc16 foo_chars[3] = {'f', 'o', 'o'}; |
| 1112 Vector<const uc16> foo(foo_chars, 3); | 1121 Vector<const uc16> foo(foo_chars, 3); |
| 1113 | 1122 |
| 1114 enum registers { out1, out2, out3, out4, out5, sp, loop_cnt }; | 1123 enum registers { out1, out2, out3, out4, out5, sp, loop_cnt }; |
| 1115 Label fail; | 1124 Label fail; |
| 1116 Label backtrack; | 1125 Label backtrack; |
| 1117 m.WriteCurrentPositionToRegister(out1, 0); // Output: [0] | 1126 m.WriteCurrentPositionToRegister(out1, 0); // Output: [0] |
| 1118 m.PushRegister(out1, RegExpMacroAssembler::kNoStackLimitCheck); | 1127 m.PushRegister(out1, RegExpMacroAssembler::kNoStackLimitCheck); |
| 1119 m.PushBacktrack(&backtrack); | 1128 m.PushBacktrack(&backtrack); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 Handle<Object> code_object = m.GetCode(source); | 1186 Handle<Object> code_object = m.GetCode(source); |
| 1178 Handle<Code> code = Handle<Code>::cast(code_object); | 1187 Handle<Code> code = Handle<Code>::cast(code_object); |
| 1179 | 1188 |
| 1180 // String long enough for test (content doesn't matter). | 1189 // String long enough for test (content doesn't matter). |
| 1181 Handle<String> input = | 1190 Handle<String> input = |
| 1182 Factory::NewStringFromAscii(CStrVector("foofoofoofoofoo")); | 1191 Factory::NewStringFromAscii(CStrVector("foofoofoofoofoo")); |
| 1183 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 1192 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); |
| 1184 Address start_adr = seq_input->GetCharsAddress(); | 1193 Address start_adr = seq_input->GetCharsAddress(); |
| 1185 | 1194 |
| 1186 int output[5]; | 1195 int output[5]; |
| 1187 RegExpMacroAssemblerIA32::Result result = | 1196 NativeRegExpMacroAssembler::Result result = |
| 1188 ExecuteIA32(*code, | 1197 Execute(*code, |
| 1189 *input, | 1198 *input, |
| 1190 0, | 1199 0, |
| 1191 start_adr, | 1200 start_adr, |
| 1192 start_adr + input->length(), | 1201 start_adr + input->length(), |
| 1193 output, | 1202 output, |
| 1194 true); | 1203 true); |
| 1195 | 1204 |
| 1196 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 1205 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 1197 CHECK_EQ(0, output[0]); | 1206 CHECK_EQ(0, output[0]); |
| 1198 CHECK_EQ(3, output[1]); | 1207 CHECK_EQ(3, output[1]); |
| 1199 CHECK_EQ(6, output[2]); | 1208 CHECK_EQ(6, output[2]); |
| 1200 CHECK_EQ(9, output[3]); | 1209 CHECK_EQ(9, output[3]); |
| 1201 CHECK_EQ(9, output[4]); | 1210 CHECK_EQ(9, output[4]); |
| 1202 } | 1211 } |
| 1203 | 1212 |
| 1204 | 1213 |
| 1205 TEST(MacroAssemblerIA32StackOverflow) { | 1214 TEST(MacroAssemblerStackOverflow) { |
| 1206 v8::V8::Initialize(); | 1215 v8::V8::Initialize(); |
| 1207 ContextInitializer initializer; | 1216 ContextInitializer initializer; |
| 1208 | 1217 |
| 1209 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0); | 1218 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0); |
| 1210 | 1219 |
| 1211 Label loop; | 1220 Label loop; |
| 1212 m.Bind(&loop); | 1221 m.Bind(&loop); |
| 1213 m.PushBacktrack(&loop); | 1222 m.PushBacktrack(&loop); |
| 1214 m.GoTo(&loop); | 1223 m.GoTo(&loop); |
| 1215 | 1224 |
| 1216 Handle<String> source = | 1225 Handle<String> source = |
| 1217 Factory::NewStringFromAscii(CStrVector("<stack overflow test>")); | 1226 Factory::NewStringFromAscii(CStrVector("<stack overflow test>")); |
| 1218 Handle<Object> code_object = m.GetCode(source); | 1227 Handle<Object> code_object = m.GetCode(source); |
| 1219 Handle<Code> code = Handle<Code>::cast(code_object); | 1228 Handle<Code> code = Handle<Code>::cast(code_object); |
| 1220 | 1229 |
| 1221 // String long enough for test (content doesn't matter). | 1230 // String long enough for test (content doesn't matter). |
| 1222 Handle<String> input = | 1231 Handle<String> input = |
| 1223 Factory::NewStringFromAscii(CStrVector("dummy")); | 1232 Factory::NewStringFromAscii(CStrVector("dummy")); |
| 1224 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 1233 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); |
| 1225 Address start_adr = seq_input->GetCharsAddress(); | 1234 Address start_adr = seq_input->GetCharsAddress(); |
| 1226 | 1235 |
| 1227 RegExpMacroAssemblerIA32::Result result = | 1236 NativeRegExpMacroAssembler::Result result = |
| 1228 ExecuteIA32(*code, | 1237 Execute(*code, |
| 1229 *input, | 1238 *input, |
| 1230 0, | 1239 0, |
| 1231 start_adr, | 1240 start_adr, |
| 1232 start_adr + input->length(), | 1241 start_adr + input->length(), |
| 1233 NULL, | 1242 NULL, |
| 1234 true); | 1243 true); |
| 1235 | 1244 |
| 1236 CHECK_EQ(RegExpMacroAssemblerIA32::EXCEPTION, result); | 1245 CHECK_EQ(NativeRegExpMacroAssembler::EXCEPTION, result); |
| 1237 CHECK(Top::has_pending_exception()); | 1246 CHECK(Top::has_pending_exception()); |
| 1238 Top::clear_pending_exception(); | 1247 Top::clear_pending_exception(); |
| 1239 } | 1248 } |
| 1240 | 1249 |
| 1241 | 1250 |
| 1242 TEST(MacroAssemblerIA32LotsOfRegisters) { | 1251 TEST(MacroAssemblerNativeLotsOfRegisters) { |
| 1243 v8::V8::Initialize(); | 1252 v8::V8::Initialize(); |
| 1244 ContextInitializer initializer; | 1253 ContextInitializer initializer; |
| 1245 | 1254 |
| 1246 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 2); | 1255 ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2); |
| 1247 | 1256 |
| 1248 // At least 2048, to ensure the allocated space for registers | 1257 // At least 2048, to ensure the allocated space for registers |
| 1249 // span one full page. | 1258 // span one full page. |
| 1250 const int large_number = 8000; | 1259 const int large_number = 8000; |
| 1251 m.WriteCurrentPositionToRegister(large_number, 42); | 1260 m.WriteCurrentPositionToRegister(large_number, 42); |
| 1252 m.WriteCurrentPositionToRegister(0, 0); | 1261 m.WriteCurrentPositionToRegister(0, 0); |
| 1253 m.WriteCurrentPositionToRegister(1, 1); | 1262 m.WriteCurrentPositionToRegister(1, 1); |
| 1254 Label done; | 1263 Label done; |
| 1255 m.CheckNotBackReference(0, &done); // Performs a system-stack push. | 1264 m.CheckNotBackReference(0, &done); // Performs a system-stack push. |
| 1256 m.Bind(&done); | 1265 m.Bind(&done); |
| 1257 m.PushRegister(large_number, RegExpMacroAssembler::kNoStackLimitCheck); | 1266 m.PushRegister(large_number, RegExpMacroAssembler::kNoStackLimitCheck); |
| 1258 m.PopRegister(1); | 1267 m.PopRegister(1); |
| 1259 m.Succeed(); | 1268 m.Succeed(); |
| 1260 | 1269 |
| 1261 Handle<String> source = | 1270 Handle<String> source = |
| 1262 Factory::NewStringFromAscii(CStrVector("<huge register space test>")); | 1271 Factory::NewStringFromAscii(CStrVector("<huge register space test>")); |
| 1263 Handle<Object> code_object = m.GetCode(source); | 1272 Handle<Object> code_object = m.GetCode(source); |
| 1264 Handle<Code> code = Handle<Code>::cast(code_object); | 1273 Handle<Code> code = Handle<Code>::cast(code_object); |
| 1265 | 1274 |
| 1266 // String long enough for test (content doesn't matter). | 1275 // String long enough for test (content doesn't matter). |
| 1267 Handle<String> input = | 1276 Handle<String> input = |
| 1268 Factory::NewStringFromAscii(CStrVector("sample text")); | 1277 Factory::NewStringFromAscii(CStrVector("sample text")); |
| 1269 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); | 1278 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); |
| 1270 Address start_adr = seq_input->GetCharsAddress(); | 1279 Address start_adr = seq_input->GetCharsAddress(); |
| 1271 | 1280 |
| 1272 int captures[2]; | 1281 int captures[2]; |
| 1273 RegExpMacroAssemblerIA32::Result result = | 1282 NativeRegExpMacroAssembler::Result result = |
| 1274 ExecuteIA32(*code, | 1283 Execute(*code, |
| 1275 *input, | 1284 *input, |
| 1276 0, | 1285 0, |
| 1277 start_adr, | 1286 start_adr, |
| 1278 start_adr + input->length(), | 1287 start_adr + input->length(), |
| 1279 captures, | 1288 captures, |
| 1280 true); | 1289 true); |
| 1281 | 1290 |
| 1282 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 1291 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
| 1283 CHECK_EQ(0, captures[0]); | 1292 CHECK_EQ(0, captures[0]); |
| 1284 CHECK_EQ(42, captures[1]); | 1293 CHECK_EQ(42, captures[1]); |
| 1285 | 1294 |
| 1286 Top::clear_pending_exception(); | 1295 Top::clear_pending_exception(); |
| 1287 } | 1296 } |
| 1288 | 1297 |
| 1289 #endif // V8_REGEXP_NATIVE | 1298 #endif // V8_REGEXP_NATIVE |
| 1290 #endif // V8_TARGET_ARCH_IA32 | |
| 1291 | 1299 |
| 1292 | 1300 |
| 1293 TEST(AddInverseToTable) { | 1301 TEST(AddInverseToTable) { |
| 1294 static const int kLimit = 1000; | 1302 static const int kLimit = 1000; |
| 1295 static const int kRangeCount = 16; | 1303 static const int kRangeCount = 16; |
| 1296 for (int t = 0; t < 10; t++) { | 1304 for (int t = 0; t < 10; t++) { |
| 1297 ZoneScope zone_scope(DELETE_ON_EXIT); | 1305 ZoneScope zone_scope(DELETE_ON_EXIT); |
| 1298 ZoneList<CharacterRange>* ranges = | 1306 ZoneList<CharacterRange>* ranges = |
| 1299 new ZoneList<CharacterRange>(kRangeCount); | 1307 new ZoneList<CharacterRange>(kRangeCount); |
| 1300 for (int i = 0; i < kRangeCount; i++) { | 1308 for (int i = 0; i < kRangeCount; i++) { |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1529 CHECK(!InClass(i, excluded)); | 1537 CHECK(!InClass(i, excluded)); |
| 1530 } | 1538 } |
| 1531 } | 1539 } |
| 1532 } | 1540 } |
| 1533 | 1541 |
| 1534 | 1542 |
| 1535 TEST(Graph) { | 1543 TEST(Graph) { |
| 1536 V8::Initialize(NULL); | 1544 V8::Initialize(NULL); |
| 1537 Execute("(?:(?:x(.))?\1)+$", false, true, true); | 1545 Execute("(?:(?:x(.))?\1)+$", false, true, true); |
| 1538 } | 1546 } |
| OLD | NEW |