OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 register_array_ = isolate->jsregexp_static_offsets_vector(); | 746 register_array_ = isolate->jsregexp_static_offsets_vector(); |
747 } | 747 } |
748 | 748 |
749 // Set state so that fetching the results the first time triggers a call | 749 // Set state so that fetching the results the first time triggers a call |
750 // to the compiled regexp. | 750 // to the compiled regexp. |
751 current_match_index_ = max_matches_; | 751 current_match_index_ = max_matches_; |
752 num_matches_ = max_matches_; | 752 num_matches_ = max_matches_; |
753 ASSERT(registers_per_match_ >= 2); // Each match has at least one capture. | 753 ASSERT(registers_per_match_ >= 2); // Each match has at least one capture. |
754 ASSERT_GE(register_array_size_, registers_per_match_); | 754 ASSERT_GE(register_array_size_, registers_per_match_); |
755 int32_t* last_match = | 755 int32_t* last_match = |
756 ®ister_array_[register_array_size_ - registers_per_match_]; | 756 ®ister_array_[(current_match_index_ - 1) * registers_per_match_]; |
757 last_match[0] = -1; | 757 last_match[0] = -1; |
758 last_match[1] = 0; | 758 last_match[1] = 0; |
759 } | 759 } |
760 | 760 |
761 | 761 |
762 RegExpImpl::GlobalCache::~GlobalCache() { | 762 RegExpImpl::GlobalCache::~GlobalCache() { |
763 // Deallocate the register array if we allocated it in the constructor | 763 // Deallocate the register array if we allocated it in the constructor |
764 // (as opposed to using the existing jsregexp_static_offsets_vector). | 764 // (as opposed to using the existing jsregexp_static_offsets_vector). |
765 if (register_array_size_ > Isolate::kJSRegexpStaticOffsetsVectorSize) { | 765 if (register_array_size_ > Isolate::kJSRegexpStaticOffsetsVectorSize) { |
766 DeleteArray(register_array_); | 766 DeleteArray(register_array_); |
767 } | 767 } |
768 } | 768 } |
769 | 769 |
770 | 770 |
771 int32_t* RegExpImpl::GlobalCache::FetchNext() { | 771 int32_t* RegExpImpl::GlobalCache::FetchNext() { |
772 current_match_index_++; | 772 current_match_index_++; |
773 if (current_match_index_ >= num_matches_) { | 773 if (current_match_index_ >= num_matches_) { |
774 // Current batch of results exhausted. | 774 // Current batch of results exhausted. |
775 // Fail if last batch was not even fully filled. | 775 // Fail if last batch was not even fully filled. |
776 if (num_matches_ < max_matches_) { | 776 if (num_matches_ < max_matches_) { |
777 num_matches_ = 0; // Signal failed match. | 777 num_matches_ = 0; // Signal failed match. |
778 return NULL; | 778 return NULL; |
779 } | 779 } |
780 | 780 |
781 int32_t* last_match = | 781 int32_t* last_match = |
782 ®ister_array_[register_array_size_ - registers_per_match_]; | 782 ®ister_array_[(current_match_index_ - 1) * registers_per_match_]; |
783 int last_end_index = last_match[1]; | 783 int last_end_index = last_match[1]; |
784 | 784 |
785 if (regexp_->TypeTag() == JSRegExp::ATOM) { | 785 if (regexp_->TypeTag() == JSRegExp::ATOM) { |
786 num_matches_ = RegExpImpl::AtomExecRaw(regexp_, | 786 num_matches_ = RegExpImpl::AtomExecRaw(regexp_, |
787 subject_, | 787 subject_, |
788 last_end_index, | 788 last_end_index, |
789 register_array_, | 789 register_array_, |
790 register_array_size_); | 790 register_array_size_); |
791 } else { | 791 } else { |
792 int last_start_index = last_match[0]; | 792 int last_start_index = last_match[0]; |
(...skipping 5365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6158 } | 6158 } |
6159 | 6159 |
6160 return compiler.Assemble(¯o_assembler, | 6160 return compiler.Assemble(¯o_assembler, |
6161 node, | 6161 node, |
6162 data->capture_count, | 6162 data->capture_count, |
6163 pattern); | 6163 pattern); |
6164 } | 6164 } |
6165 | 6165 |
6166 | 6166 |
6167 }} // namespace v8::internal | 6167 }} // namespace v8::internal |
OLD | NEW |