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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 } | 741 } |
742 | 742 |
743 if (register_array_size_ > Isolate::kJSRegexpStaticOffsetsVectorSize) { | 743 if (register_array_size_ > Isolate::kJSRegexpStaticOffsetsVectorSize) { |
744 register_array_ = NewArray<int32_t>(register_array_size_); | 744 register_array_ = NewArray<int32_t>(register_array_size_); |
745 } else { | 745 } else { |
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_ - 1; |
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_[(current_match_index_ - 1) * registers_per_match_]; | 756 ®ister_array_[current_match_index_ * 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_); |
(...skipping 5391 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 |