Reviewers: ulan,
Description:
Fix wrong indexing in global regexp.
[email protected]
BUG=142087
Please review this at https://chromiumcodereview.appspot.com/10824278/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/jsregexp.cc
A + test/mjsunit/regress/regress-crbug-142087.js
Index: src/jsregexp.cc
diff --git a/src/jsregexp.cc b/src/jsregexp.cc
index
74ec739d9c136d47420827bd7859a3c69521bb5b..0bca6a997d4ce7e9f55a3787c0dd4e262f1a29af
100644
--- a/src/jsregexp.cc
+++ b/src/jsregexp.cc
@@ -753,7 +753,7 @@ RegExpImpl::GlobalCache::GlobalCache(Handle<JSRegExp>
regexp,
ASSERT(registers_per_match_ >= 2); // Each match has at least one
capture.
ASSERT_GE(register_array_size_, registers_per_match_);
int32_t* last_match =
- ®ister_array_[register_array_size_ - registers_per_match_];
+ ®ister_array_[(current_match_index_ - 1) * registers_per_match_];
last_match[0] = -1;
last_match[1] = 0;
}
@@ -779,7 +779,7 @@ int32_t* RegExpImpl::GlobalCache::FetchNext() {
}
int32_t* last_match =
- ®ister_array_[register_array_size_ - registers_per_match_];
+ ®ister_array_[(current_match_index_ - 1) *
registers_per_match_];
int last_end_index = last_match[1];
if (regexp_->TypeTag() == JSRegExp::ATOM) {
Index: test/mjsunit/regress/regress-crbug-142087.js
diff --git a/test/mjsunit/regress/regress-2119.js
b/test/mjsunit/regress/regress-crbug-142087.js
similarity index 87%
copy from test/mjsunit/regress/regress-2119.js
copy to test/mjsunit/regress/regress-crbug-142087.js
index
54840c238b977590ba3c850c6fa9d5f1a3c5fe34..f408a5605f18988ca6daa20e201bc87d0e4f7337
100644
--- a/test/mjsunit/regress/regress-2119.js
+++ b/test/mjsunit/regress/regress-crbug-142087.js
@@ -25,12 +25,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --nouse-ic
+var string = "What are you looking for?";
-function strict_function() {
- "use strict"
- undeclared = 1;
+var expected_match = [];
+for (var i = 0; i < string.length; i++) {
+ expected_match.push("");
}
-assertThrows(strict_function);
-
+string.replace(/(_)|(_|)/g, "");
+assertArrayEquals(expected_match, string.match(/(_)|(_|)/g, ""));
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev