Commit 515994b8 authored by jgruber's avatar jgruber Committed by Commit bot

[regexp] Don't cache exec method in Regexp.proto[@@split]

The call to RegExpSubclassExec may refer to a different exec method
since splitter is newly constructed previously to the call.

BUG=v8:5351

Review-Url: https://codereview.chromium.org/2370733003
Cr-Commit-Position: refs/heads/master@{#39774}
parent 66e73b3a
......@@ -344,9 +344,8 @@ function RegExpSubclassSplit(string, limit) {
// TODO(adamk): this fast path is wrong as we doesn't ensure that 'exec'
// is actually a data property on RegExp.prototype.
var exec;
if (IS_REGEXP(this) && constructor === GlobalRegExp) {
exec = this.exec;
var exec = this.exec;
if (exec === RegExpExecJS) {
return %_Call(RegExpSplit, this, string, limit);
}
......@@ -371,9 +370,7 @@ function RegExpSubclassSplit(string, limit) {
var stringIndex = prevStringIndex;
while (stringIndex < size) {
splitter.lastIndex = stringIndex;
result = RegExpSubclassExec(splitter, string, exec);
// Ensure exec will be read again on the next loop through.
exec = UNDEFINED;
result = RegExpSubclassExec(splitter, string);
if (IS_NULL(result)) {
stringIndex += AdvanceStringIndex(string, stringIndex, unicode);
} else {
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var re = /[bc]/;
var str = "baba";
assertEquals(["", "a", "a"], str.split(re));
// Force slow path.
re.exec = (string) => RegExp.prototype.exec.call(re, string);
assertEquals(["", "a", "a"], str.split(re));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment