| 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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 env_.Dispose(); | 585 env_.Dispose(); |
| 586 } | 586 } |
| 587 private: | 587 private: |
| 588 v8::Persistent<v8::Context> env_; | 588 v8::Persistent<v8::Context> env_; |
| 589 v8::HandleScope scope_; | 589 v8::HandleScope scope_; |
| 590 v8::internal::StackGuard stack_guard_; | 590 v8::internal::StackGuard stack_guard_; |
| 591 }; | 591 }; |
| 592 | 592 |
| 593 | 593 |
| 594 TEST(MacroAssemblerIA32Success) { | 594 TEST(MacroAssemblerIA32Success) { |
| 595 V8::Initialize(NULL); | 595 v8::V8::Initialize(); |
| 596 ContextInitializer initializer; | 596 ContextInitializer initializer; |
| 597 | 597 |
| 598 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 4); | 598 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 4); |
| 599 | 599 |
| 600 m.Succeed(); | 600 m.Succeed(); |
| 601 | 601 |
| 602 Handle<String> source = Factory::NewStringFromAscii(CStrVector("")); | 602 Handle<String> source = Factory::NewStringFromAscii(CStrVector("")); |
| 603 Handle<Object> code_object = m.GetCode(source); | 603 Handle<Object> code_object = m.GetCode(source); |
| 604 Handle<Code> code = Handle<Code>::cast(code_object); | 604 Handle<Code> code = Handle<Code>::cast(code_object); |
| 605 | 605 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 620 | 620 |
| 621 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 621 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); |
| 622 CHECK_EQ(-1, captures[0]); | 622 CHECK_EQ(-1, captures[0]); |
| 623 CHECK_EQ(-1, captures[1]); | 623 CHECK_EQ(-1, captures[1]); |
| 624 CHECK_EQ(-1, captures[2]); | 624 CHECK_EQ(-1, captures[2]); |
| 625 CHECK_EQ(-1, captures[3]); | 625 CHECK_EQ(-1, captures[3]); |
| 626 } | 626 } |
| 627 | 627 |
| 628 | 628 |
| 629 TEST(MacroAssemblerIA32Simple) { | 629 TEST(MacroAssemblerIA32Simple) { |
| 630 V8::Initialize(NULL); | 630 v8::V8::Initialize(); |
| 631 ContextInitializer initializer; | 631 ContextInitializer initializer; |
| 632 | 632 |
| 633 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 4); | 633 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 4); |
| 634 | 634 |
| 635 uc16 foo_chars[3] = {'f', 'o', 'o'}; | 635 uc16 foo_chars[3] = {'f', 'o', 'o'}; |
| 636 Vector<const uc16> foo(foo_chars, 3); | 636 Vector<const uc16> foo(foo_chars, 3); |
| 637 | 637 |
| 638 Label fail; | 638 Label fail; |
| 639 m.CheckCharacters(foo, 0, &fail, true); | 639 m.CheckCharacters(foo, 0, &fail, true); |
| 640 m.WriteCurrentPositionToRegister(0, 0); | 640 m.WriteCurrentPositionToRegister(0, 0); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 start_offset, | 680 start_offset, |
| 681 end_offset, | 681 end_offset, |
| 682 captures, | 682 captures, |
| 683 true); | 683 true); |
| 684 | 684 |
| 685 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result); | 685 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result); |
| 686 } | 686 } |
| 687 | 687 |
| 688 | 688 |
| 689 TEST(MacroAssemblerIA32SimpleUC16) { | 689 TEST(MacroAssemblerIA32SimpleUC16) { |
| 690 V8::Initialize(NULL); | 690 v8::V8::Initialize(); |
| 691 ContextInitializer initializer; | 691 ContextInitializer initializer; |
| 692 | 692 |
| 693 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::UC16, 4); | 693 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::UC16, 4); |
| 694 | 694 |
| 695 uc16 foo_chars[3] = {'f', 'o', 'o'}; | 695 uc16 foo_chars[3] = {'f', 'o', 'o'}; |
| 696 Vector<const uc16> foo(foo_chars, 3); | 696 Vector<const uc16> foo(foo_chars, 3); |
| 697 | 697 |
| 698 Label fail; | 698 Label fail; |
| 699 m.CheckCharacters(foo, 0, &fail, true); | 699 m.CheckCharacters(foo, 0, &fail, true); |
| 700 m.WriteCurrentPositionToRegister(0, 0); | 700 m.WriteCurrentPositionToRegister(0, 0); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 start_offset, | 743 start_offset, |
| 744 end_offset, | 744 end_offset, |
| 745 captures, | 745 captures, |
| 746 true); | 746 true); |
| 747 | 747 |
| 748 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result); | 748 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result); |
| 749 } | 749 } |
| 750 | 750 |
| 751 | 751 |
| 752 TEST(MacroAssemblerIA32Backtrack) { | 752 TEST(MacroAssemblerIA32Backtrack) { |
| 753 V8::Initialize(NULL); | 753 v8::V8::Initialize(); |
| 754 ContextInitializer initializer; | 754 ContextInitializer initializer; |
| 755 | 755 |
| 756 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0); | 756 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0); |
| 757 | 757 |
| 758 Label fail; | 758 Label fail; |
| 759 Label backtrack; | 759 Label backtrack; |
| 760 m.LoadCurrentCharacter(10, &fail); | 760 m.LoadCurrentCharacter(10, &fail); |
| 761 m.Succeed(); | 761 m.Succeed(); |
| 762 m.Bind(&fail); | 762 m.Bind(&fail); |
| 763 m.PushBacktrack(&backtrack); | 763 m.PushBacktrack(&backtrack); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 782 start_offset, | 782 start_offset, |
| 783 end_offset, | 783 end_offset, |
| 784 NULL, | 784 NULL, |
| 785 true); | 785 true); |
| 786 | 786 |
| 787 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result); | 787 CHECK_EQ(RegExpMacroAssemblerIA32::FAILURE, result); |
| 788 } | 788 } |
| 789 | 789 |
| 790 | 790 |
| 791 TEST(MacroAssemblerIA32BackReference) { | 791 TEST(MacroAssemblerIA32BackReference) { |
| 792 V8::Initialize(NULL); | 792 v8::V8::Initialize(); |
| 793 ContextInitializer initializer; | 793 ContextInitializer initializer; |
| 794 | 794 |
| 795 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 3); | 795 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 3); |
| 796 | 796 |
| 797 m.WriteCurrentPositionToRegister(0, 0); | 797 m.WriteCurrentPositionToRegister(0, 0); |
| 798 m.AdvanceCurrentPosition(2); | 798 m.AdvanceCurrentPosition(2); |
| 799 m.WriteCurrentPositionToRegister(1, 0); | 799 m.WriteCurrentPositionToRegister(1, 0); |
| 800 Label nomatch; | 800 Label nomatch; |
| 801 m.CheckNotBackReference(0, &nomatch); | 801 m.CheckNotBackReference(0, &nomatch); |
| 802 m.Fail(); | 802 m.Fail(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 829 true); | 829 true); |
| 830 | 830 |
| 831 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 831 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); |
| 832 CHECK_EQ(0, output[0]); | 832 CHECK_EQ(0, output[0]); |
| 833 CHECK_EQ(2, output[1]); | 833 CHECK_EQ(2, output[1]); |
| 834 CHECK_EQ(6, output[2]); | 834 CHECK_EQ(6, output[2]); |
| 835 } | 835 } |
| 836 | 836 |
| 837 | 837 |
| 838 TEST(MacroAssemblerIA32AtStart) { | 838 TEST(MacroAssemblerIA32AtStart) { |
| 839 V8::Initialize(NULL); | 839 v8::V8::Initialize(); |
| 840 ContextInitializer initializer; | 840 ContextInitializer initializer; |
| 841 | 841 |
| 842 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0); | 842 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0); |
| 843 | 843 |
| 844 Label not_at_start, newline, fail; | 844 Label not_at_start, newline, fail; |
| 845 m.CheckNotAtStart(¬_at_start); | 845 m.CheckNotAtStart(¬_at_start); |
| 846 // Check that prevchar = '\n' and current = 'f'. | 846 // Check that prevchar = '\n' and current = 'f'. |
| 847 m.CheckCharacter('\n', &newline); | 847 m.CheckCharacter('\n', &newline); |
| 848 m.Bind(&fail); | 848 m.Bind(&fail); |
| 849 m.Fail(); | 849 m.Fail(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 NULL, | 890 NULL, |
| 891 false); | 891 false); |
| 892 | 892 |
| 893 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 893 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); |
| 894 } | 894 } |
| 895 | 895 |
| 896 | 896 |
| 897 | 897 |
| 898 | 898 |
| 899 TEST(MacroAssemblerIA32BackRefNoCase) { | 899 TEST(MacroAssemblerIA32BackRefNoCase) { |
| 900 V8::Initialize(NULL); | 900 v8::V8::Initialize(); |
| 901 ContextInitializer initializer; | 901 ContextInitializer initializer; |
| 902 | 902 |
| 903 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 4); | 903 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 4); |
| 904 | 904 |
| 905 Label fail, succ; | 905 Label fail, succ; |
| 906 | 906 |
| 907 m.WriteCurrentPositionToRegister(0, 0); | 907 m.WriteCurrentPositionToRegister(0, 0); |
| 908 m.WriteCurrentPositionToRegister(2, 0); | 908 m.WriteCurrentPositionToRegister(2, 0); |
| 909 m.AdvanceCurrentPosition(3); | 909 m.AdvanceCurrentPosition(3); |
| 910 m.WriteCurrentPositionToRegister(3, 0); | 910 m.WriteCurrentPositionToRegister(3, 0); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 948 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); |
| 949 CHECK_EQ(0, output[0]); | 949 CHECK_EQ(0, output[0]); |
| 950 CHECK_EQ(12, output[1]); | 950 CHECK_EQ(12, output[1]); |
| 951 CHECK_EQ(0, output[2]); | 951 CHECK_EQ(0, output[2]); |
| 952 CHECK_EQ(3, output[3]); | 952 CHECK_EQ(3, output[3]); |
| 953 } | 953 } |
| 954 | 954 |
| 955 | 955 |
| 956 | 956 |
| 957 TEST(MacroAssemblerIA32Registers) { | 957 TEST(MacroAssemblerIA32Registers) { |
| 958 V8::Initialize(NULL); | 958 v8::V8::Initialize(); |
| 959 ContextInitializer initializer; | 959 ContextInitializer initializer; |
| 960 | 960 |
| 961 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 5); | 961 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 5); |
| 962 | 962 |
| 963 uc16 foo_chars[3] = {'f', 'o', 'o'}; | 963 uc16 foo_chars[3] = {'f', 'o', 'o'}; |
| 964 Vector<const uc16> foo(foo_chars, 3); | 964 Vector<const uc16> foo(foo_chars, 3); |
| 965 | 965 |
| 966 enum registers { out1, out2, out3, out4, out5, sp, loop_cnt }; | 966 enum registers { out1, out2, out3, out4, out5, sp, loop_cnt }; |
| 967 Label fail; | 967 Label fail; |
| 968 Label backtrack; | 968 Label backtrack; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); | 1049 CHECK_EQ(RegExpMacroAssemblerIA32::SUCCESS, result); |
| 1050 CHECK_EQ(0, output[0]); | 1050 CHECK_EQ(0, output[0]); |
| 1051 CHECK_EQ(3, output[1]); | 1051 CHECK_EQ(3, output[1]); |
| 1052 CHECK_EQ(6, output[2]); | 1052 CHECK_EQ(6, output[2]); |
| 1053 CHECK_EQ(9, output[3]); | 1053 CHECK_EQ(9, output[3]); |
| 1054 CHECK_EQ(9, output[4]); | 1054 CHECK_EQ(9, output[4]); |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 | 1057 |
| 1058 TEST(MacroAssemblerIA32StackOverflow) { | 1058 TEST(MacroAssemblerIA32StackOverflow) { |
| 1059 V8::Initialize(NULL); | 1059 v8::V8::Initialize(); |
| 1060 ContextInitializer initializer; | 1060 ContextInitializer initializer; |
| 1061 | 1061 |
| 1062 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0); | 1062 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0); |
| 1063 | 1063 |
| 1064 Label loop; | 1064 Label loop; |
| 1065 m.Bind(&loop); | 1065 m.Bind(&loop); |
| 1066 m.PushBacktrack(&loop); | 1066 m.PushBacktrack(&loop); |
| 1067 m.GoTo(&loop); | 1067 m.GoTo(&loop); |
| 1068 | 1068 |
| 1069 Handle<String> source = | 1069 Handle<String> source = |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 CHECK(!InClass(i, excluded)); | 1334 CHECK(!InClass(i, excluded)); |
| 1335 } | 1335 } |
| 1336 } | 1336 } |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 | 1339 |
| 1340 TEST(Graph) { | 1340 TEST(Graph) { |
| 1341 V8::Initialize(NULL); | 1341 V8::Initialize(NULL); |
| 1342 Execute("\\bboy\\b", false, true, true); | 1342 Execute("\\bboy\\b", false, true, true); |
| 1343 } | 1343 } |
| OLD | NEW |