Bug 1287525 - Part 2: Do not use RegExp.prototype[@@split] optimized path if limit is not number. r=h4writer
authorTooru Fujisawa <arai_a@mac.com>
Fri, 29 Jul 2016 13:55:26 +0900
changeset 307213 75976803569d9626c1ac5f495a69b0936321ed9e
parent 307212 1b77ef6ac23ea2fc57246036dc7ae4dca98dbb19
child 307214 b40a60e2a4e138d4b99805b5471bcff268817f9a
push id30912
push usercbook@mozilla.com
push dateFri, 29 Jul 2016 10:38:29 +0000
treeherderautoland@4907812dbb41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs1287525
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1287525 - Part 2: Do not use RegExp.prototype[@@split] optimized path if limit is not number. r=h4writer
js/src/builtin/RegExp.js
js/src/tests/ecma_6/RegExp/split-limit.js
--- a/js/src/builtin/RegExp.js
+++ b/js/src/builtin/RegExp.js
@@ -599,17 +599,18 @@ function RegExpSplit(string, limit) {
     var C = SpeciesConstructor(rx, GetBuiltinConstructor("RegExp"));
 
     // Step 5.
     var flags = ToString(rx.flags);
 
     // Steps 6-7.
     var unicodeMatching = callFunction(std_String_includes, flags, "u");
 
-    var optimizable = IsRegExpSplitOptimizable(rx, C);
+    var optimizable = IsRegExpSplitOptimizable(rx, C) &&
+                      (limit === undefined || typeof limit == "number");
     var splitter;
     if (optimizable) {
         // Steps 8-9 (skipped).
 
         // Step 10.
         // If split operation is optimizable, perform non-sticky match.
         splitter = regexp_construct_no_sticky(rx, flags);
     } else {
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_6/RegExp/split-limit.js
@@ -0,0 +1,14 @@
+var BUGNUMBER = 1287525;
+var summary = "RegExp.prototype[@@split] shouldn't use optimized path if limit is not number.";
+
+print(BUGNUMBER + ": " + summary);
+
+var rx = /a/;
+var r = rx[Symbol.split]("abba", {valueOf() {
+  RegExp.prototype.exec = () => null;
+  return 100;
+}});
+assertEq(r.length, 1);
+
+if (typeof reportCompare === "function")
+    reportCompare(true, true);