| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 } | 690 } |
| 691 | 691 |
| 692 // Compile the RegExp. | 692 // Compile the RegExp. |
| 693 ZoneScope zone_scope(DELETE_ON_EXIT); | 693 ZoneScope zone_scope(DELETE_ON_EXIT); |
| 694 | 694 |
| 695 JSRegExp::Flags flags = re->GetFlags(); | 695 JSRegExp::Flags flags = re->GetFlags(); |
| 696 | 696 |
| 697 Handle<String> pattern(re->Pattern()); | 697 Handle<String> pattern(re->Pattern()); |
| 698 StringShape shape(*pattern); | 698 StringShape shape(*pattern); |
| 699 if (!pattern->IsFlat(shape)) { | 699 if (!pattern->IsFlat(shape)) { |
| 700 pattern->Flatten(shape); | 700 FlattenString(pattern); |
| 701 } | 701 } |
| 702 | 702 |
| 703 RegExpCompileData compile_data; | 703 RegExpCompileData compile_data; |
| 704 FlatStringReader reader(pattern); | 704 FlatStringReader reader(pattern); |
| 705 if (!ParseRegExp(&reader, flags.is_multiline(), &compile_data)) { | 705 if (!ParseRegExp(&reader, flags.is_multiline(), &compile_data)) { |
| 706 // Throw an exception if we fail to parse the pattern. | 706 // Throw an exception if we fail to parse the pattern. |
| 707 // THIS SHOULD NOT HAPPEN. We already parsed it successfully once. | 707 // THIS SHOULD NOT HAPPEN. We already parsed it successfully once. |
| 708 ThrowRegExpException(re, | 708 ThrowRegExpException(re, |
| 709 pattern, | 709 pattern, |
| 710 compile_data.error, | 710 compile_data.error, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 int number_of_registers = IrregexpNumberOfRegisters(irregexp); | 817 int number_of_registers = IrregexpNumberOfRegisters(irregexp); |
| 818 OffsetsVector offsets(number_of_registers); | 818 OffsetsVector offsets(number_of_registers); |
| 819 | 819 |
| 820 int previous_index = 0; | 820 int previous_index = 0; |
| 821 | 821 |
| 822 Handle<JSArray> result = Factory::NewJSArray(0); | 822 Handle<JSArray> result = Factory::NewJSArray(0); |
| 823 int i = 0; | 823 int i = 0; |
| 824 Handle<Object> matches; | 824 Handle<Object> matches; |
| 825 | 825 |
| 826 if (!subject->IsFlat(shape)) { | 826 if (!subject->IsFlat(shape)) { |
| 827 subject->Flatten(shape); | 827 FlattenString(subject); |
| 828 } | 828 } |
| 829 | 829 |
| 830 while (true) { | 830 while (true) { |
| 831 if (previous_index > subject->length() || previous_index < 0) { | 831 if (previous_index > subject->length() || previous_index < 0) { |
| 832 // Per ECMA-262 15.10.6.2, if the previous index is greater than the | 832 // Per ECMA-262 15.10.6.2, if the previous index is greater than the |
| 833 // string length, there is no match. | 833 // string length, there is no match. |
| 834 matches = Factory::null_value(); | 834 matches = Factory::null_value(); |
| 835 return result; | 835 return result; |
| 836 } else { | 836 } else { |
| 837 #ifdef DEBUG | 837 #ifdef DEBUG |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 address = reinterpret_cast<const byte*>(ext->resource()->data()); | 913 address = reinterpret_cast<const byte*>(ext->resource()->data()); |
| 914 } | 914 } |
| 915 res = RegExpMacroAssemblerIA32::Execute( | 915 res = RegExpMacroAssemblerIA32::Execute( |
| 916 *code, | 916 *code, |
| 917 const_cast<Address*>(&address), | 917 const_cast<Address*>(&address), |
| 918 start_offset << char_size_shift, | 918 start_offset << char_size_shift, |
| 919 end_offset << char_size_shift, | 919 end_offset << char_size_shift, |
| 920 offsets_vector, | 920 offsets_vector, |
| 921 previous_index == 0); | 921 previous_index == 0); |
| 922 } else { // Sequential string | 922 } else { // Sequential string |
| 923 ASSERT(StringShape(*subject).IsSequential()); |
| 923 Address char_address = | 924 Address char_address = |
| 924 is_ascii ? SeqAsciiString::cast(*subject)->GetCharsAddress() | 925 is_ascii ? SeqAsciiString::cast(*subject)->GetCharsAddress() |
| 925 : SeqTwoByteString::cast(*subject)->GetCharsAddress(); | 926 : SeqTwoByteString::cast(*subject)->GetCharsAddress(); |
| 926 int byte_offset = char_address - reinterpret_cast<Address>(*subject); | 927 int byte_offset = char_address - reinterpret_cast<Address>(*subject); |
| 927 res = RegExpMacroAssemblerIA32::Execute( | 928 res = RegExpMacroAssemblerIA32::Execute( |
| 928 *code, | 929 *code, |
| 929 reinterpret_cast<Address*>(subject.location()), | 930 reinterpret_cast<Address*>(subject.location()), |
| 930 byte_offset + (start_offset << char_size_shift), | 931 byte_offset + (start_offset << char_size_shift), |
| 931 byte_offset + (end_offset << char_size_shift), | 932 byte_offset + (end_offset << char_size_shift), |
| 932 offsets_vector, | 933 offsets_vector, |
| (...skipping 3748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4681 EmbeddedVector<byte, 1024> codes; | 4682 EmbeddedVector<byte, 1024> codes; |
| 4682 RegExpMacroAssemblerIrregexp macro_assembler(codes); | 4683 RegExpMacroAssemblerIrregexp macro_assembler(codes); |
| 4683 return compiler.Assemble(¯o_assembler, | 4684 return compiler.Assemble(¯o_assembler, |
| 4684 node, | 4685 node, |
| 4685 data->capture_count, | 4686 data->capture_count, |
| 4686 pattern); | 4687 pattern); |
| 4687 } | 4688 } |
| 4688 | 4689 |
| 4689 | 4690 |
| 4690 }} // namespace v8::internal | 4691 }} // namespace v8::internal |
| OLD | NEW |