| 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 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 bool success = RegExpMacroAssemblerIA32::Execute(*code, | 761 bool success = RegExpMacroAssemblerIA32::Execute(*code, |
| 762 seq_input.location(), | 762 seq_input.location(), |
| 763 start_offset, | 763 start_offset, |
| 764 end_offset, | 764 end_offset, |
| 765 NULL, | 765 NULL, |
| 766 true); | 766 true); |
| 767 | 767 |
| 768 CHECK(!success); | 768 CHECK(!success); |
| 769 } | 769 } |
| 770 | 770 |
| 771 |
| 772 TEST(MacroAssemblerIA32BackReference) { |
| 773 V8::Initialize(NULL); |
| 774 |
| 775 // regexp-macro-assembler-ia32 needs a handle scope to allocate |
| 776 // byte-arrays for constants. |
| 777 v8::HandleScope scope; |
| 778 |
| 779 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 3); |
| 780 |
| 781 m.WriteCurrentPositionToRegister(0); |
| 782 m.AdvanceCurrentPosition(2); |
| 783 m.WriteCurrentPositionToRegister(1); |
| 784 Label nomatch; |
| 785 m.CheckNotBackReference(0, &nomatch); |
| 786 m.Fail(); |
| 787 m.Bind(&nomatch); |
| 788 m.AdvanceCurrentPosition(2); |
| 789 Label missing_match; |
| 790 m.CheckNotBackReference(0, &missing_match); |
| 791 m.WriteCurrentPositionToRegister(2); |
| 792 m.Succeed(); |
| 793 m.Bind(&missing_match); |
| 794 m.Fail(); |
| 795 |
| 796 Handle<Object> code_object = m.GetCode(); |
| 797 Handle<Code> code = Handle<Code>::cast(code_object); |
| 798 |
| 799 Handle<String> input = Factory::NewStringFromAscii(CStrVector("fooofo")); |
| 800 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); |
| 801 Address start_adr = seq_input->GetCharsAddress(); |
| 802 int start_offset = start_adr - reinterpret_cast<Address>(*seq_input); |
| 803 int end_offset = start_offset + seq_input->length(); |
| 804 |
| 805 int output[3]; |
| 806 bool success = RegExpMacroAssemblerIA32::Execute(*code, |
| 807 seq_input.location(), |
| 808 start_offset, |
| 809 end_offset, |
| 810 output, |
| 811 true); |
| 812 |
| 813 CHECK(success); |
| 814 CHECK_EQ(0, output[0]); |
| 815 CHECK_EQ(2, output[1]); |
| 816 CHECK_EQ(6, output[2]); |
| 817 } |
| 818 |
| 819 |
| 820 |
| 771 TEST(MacroAssemblerIA32AtStart) { | 821 TEST(MacroAssemblerIA32AtStart) { |
| 772 V8::Initialize(NULL); | 822 V8::Initialize(NULL); |
| 773 | 823 |
| 774 // regexp-macro-assembler-ia32 needs a handle scope to allocate | 824 // regexp-macro-assembler-ia32 needs a handle scope to allocate |
| 775 // byte-arrays for constants. | 825 // byte-arrays for constants. |
| 776 v8::HandleScope scope; | 826 v8::HandleScope scope; |
| 777 | 827 |
| 778 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0); | 828 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0); |
| 779 | 829 |
| 780 uc16 foo_chars[3] = {'f', 'o', 'o'}; | 830 uc16 foo_chars[3] = {'f', 'o', 'o'}; |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 CHECK(!InClass(i, excluded)); | 1228 CHECK(!InClass(i, excluded)); |
| 1179 } | 1229 } |
| 1180 } | 1230 } |
| 1181 } | 1231 } |
| 1182 | 1232 |
| 1183 | 1233 |
| 1184 TEST(Graph) { | 1234 TEST(Graph) { |
| 1185 V8::Initialize(NULL); | 1235 V8::Initialize(NULL); |
| 1186 Execute("\\b\\w", false, true); | 1236 Execute("\\b\\w", false, true); |
| 1187 } | 1237 } |
| OLD | NEW |