Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Side by Side Diff: src/jsregexp.cc

Issue 19749: Fix http://code.google.com/p/chromium/issues/detail?id=7258 crash in IsFlat.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 if (!entry->IsNull()) { 665 if (!entry->IsNull()) {
666 return Handle<FixedArray>(FixedArray::cast(entry)); 666 return Handle<FixedArray>(FixedArray::cast(entry));
667 } 667 }
668 668
669 // Compile the RegExp. 669 // Compile the RegExp.
670 ZoneScope zone_scope(DELETE_ON_EXIT); 670 ZoneScope zone_scope(DELETE_ON_EXIT);
671 671
672 JSRegExp::Flags flags = re->GetFlags(); 672 JSRegExp::Flags flags = re->GetFlags();
673 673
674 Handle<String> pattern(re->Pattern()); 674 Handle<String> pattern(re->Pattern());
675 StringShape shape(*pattern); 675 if (!pattern->IsFlat(StringShape(*pattern))) {
676 if (!pattern->IsFlat(shape)) {
677 FlattenString(pattern); 676 FlattenString(pattern);
678 } 677 }
679 678
680 RegExpCompileData compile_data; 679 RegExpCompileData compile_data;
681 FlatStringReader reader(pattern); 680 FlatStringReader reader(pattern);
682 if (!ParseRegExp(&reader, flags.is_multiline(), &compile_data)) { 681 if (!ParseRegExp(&reader, flags.is_multiline(), &compile_data)) {
683 // Throw an exception if we fail to parse the pattern. 682 // Throw an exception if we fail to parse the pattern.
684 // THIS SHOULD NOT HAPPEN. We already parsed it successfully once. 683 // THIS SHOULD NOT HAPPEN. We already parsed it successfully once.
685 ThrowRegExpException(re, 684 ThrowRegExpException(re,
686 pattern, 685 pattern,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 previous_index, 775 previous_index,
777 offsets.vector(), 776 offsets.vector(),
778 offsets.length()); 777 offsets.length());
779 } 778 }
780 779
781 780
782 Handle<Object> RegExpImpl::IrregexpExecGlobal(Handle<JSRegExp> regexp, 781 Handle<Object> RegExpImpl::IrregexpExecGlobal(Handle<JSRegExp> regexp,
783 Handle<String> subject) { 782 Handle<String> subject) {
784 ASSERT_EQ(regexp->TypeTag(), JSRegExp::IRREGEXP); 783 ASSERT_EQ(regexp->TypeTag(), JSRegExp::IRREGEXP);
785 784
786 StringShape shape(*subject); 785 bool is_ascii = StringShape(*subject).IsAsciiRepresentation();
787 bool is_ascii = shape.IsAsciiRepresentation();
788 Handle<FixedArray> irregexp = GetCompiledIrregexp(regexp, is_ascii); 786 Handle<FixedArray> irregexp = GetCompiledIrregexp(regexp, is_ascii);
789 if (irregexp.is_null()) { 787 if (irregexp.is_null()) {
790 return Handle<Object>::null(); 788 return Handle<Object>::null();
791 } 789 }
792 790
793 // Prepare space for the return values. 791 // Prepare space for the return values.
794 int number_of_registers = IrregexpNumberOfRegisters(irregexp); 792 int number_of_registers = IrregexpNumberOfRegisters(irregexp);
795 OffsetsVector offsets(number_of_registers); 793 OffsetsVector offsets(number_of_registers);
796 794
797 int previous_index = 0; 795 int previous_index = 0;
798 796
799 Handle<JSArray> result = Factory::NewJSArray(0); 797 Handle<JSArray> result = Factory::NewJSArray(0);
800 int i = 0; 798 int i = 0;
801 Handle<Object> matches; 799 Handle<Object> matches;
802 800
803 if (!subject->IsFlat(shape)) { 801 if (!subject->IsFlat(StringShape(*subject))) {
804 FlattenString(subject); 802 FlattenString(subject);
805 } 803 }
806 804
807 while (true) { 805 while (true) {
808 if (previous_index > subject->length() || previous_index < 0) { 806 if (previous_index > subject->length() || previous_index < 0) {
809 // Per ECMA-262 15.10.6.2, if the previous index is greater than the 807 // Per ECMA-262 15.10.6.2, if the previous index is greater than the
810 // string length, there is no match. 808 // string length, there is no match.
811 matches = Factory::null_value(); 809 matches = Factory::null_value();
812 return result; 810 return result;
813 } else { 811 } else {
(...skipping 3984 matching lines...) Expand 10 before | Expand all | Expand 10 after
4798 EmbeddedVector<byte, 1024> codes; 4796 EmbeddedVector<byte, 1024> codes;
4799 RegExpMacroAssemblerIrregexp macro_assembler(codes); 4797 RegExpMacroAssemblerIrregexp macro_assembler(codes);
4800 return compiler.Assemble(&macro_assembler, 4798 return compiler.Assemble(&macro_assembler,
4801 node, 4799 node,
4802 data->capture_count, 4800 data->capture_count,
4803 pattern); 4801 pattern);
4804 } 4802 }
4805 4803
4806 4804
4807 }} // namespace v8::internal 4805 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698