Bug 1263340 - Part 2: Use internal slot for sticky flag in @@replace and @@search optimized path. r=h4writer
authorTooru Fujisawa <arai_a@mac.com>
Fri, 22 Apr 2016 10:35:41 +0900
changeset 318202 53b4512a42b434524730ddf84b6f448e0a0d3c80
parent 318201 3d31abc6b37d5c69fca3631377c36c09a3fa4d5b
child 318203 d9c905c8e1d102de622cbcf17f1e8797f7f5fa7b
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs1263340
milestone48.0a1
Bug 1263340 - Part 2: Use internal slot for sticky flag in @@replace and @@search optimized path. r=h4writer
js/src/builtin/RegExp.js
--- a/js/src/builtin/RegExp.js
+++ b/js/src/builtin/RegExp.js
@@ -373,17 +373,18 @@ function RegExpGlobalReplaceShortOpt(rx,
     rx.lastIndex = 0;
 
     // Step 12 (reordered).
     var accumulatedResult = "";
 
     // Step 13 (reordered).
     var nextSourcePosition = 0;
 
-    var sticky = !!rx.sticky;
+    var flags = UnsafeGetInt32FromReservedSlot(rx, REGEXP_FLAGS_SLOT);
+    var sticky = !!(flags & REGEXP_STICKY_FLAG);
 
     // Step 11.
     while (true) {
         // Step 11.a.
         var result = RegExpSearcher(rx, S, lastIndex, sticky);
 
         // Step 11.b.
         if (result === -1)
@@ -427,17 +428,18 @@ function RegExpGlobalReplaceOpt(rx, S, l
     rx.lastIndex = 0;
 
     // Step 12 (reordered).
     var accumulatedResult = "";
 
     // Step 13 (reordered).
     var nextSourcePosition = 0;
 
-    var sticky = !!rx.sticky;
+    var flags = UnsafeGetInt32FromReservedSlot(rx, REGEXP_FLAGS_SLOT);
+    var sticky = !!(flags & REGEXP_STICKY_FLAG);
 
     // Step 11.
     while (true) {
         // Step 11.a.
         var result = RegExpMatcher(rx, S, lastIndex, sticky);
 
         // Step 11.b.
         if (result === null)
@@ -478,17 +480,18 @@ function RegExpGlobalReplaceOpt(rx, S, l
     // Step 16.
     return accumulatedResult + Substring(S, nextSourcePosition, lengthS - nextSourcePosition);
 }
 
 // ES 2016 draft Mar 25, 2016 21.2.5.8 steps 11.a-16.
 // Optimized path for @@replace without global flag.
 function RegExpLocalReplaceOpt(rx, S, lengthS, replaceValue)
 {
-    var sticky = !!rx.sticky;
+    var flags = UnsafeGetInt32FromReservedSlot(rx, REGEXP_FLAGS_SLOT);
+    var sticky = !!(flags & REGEXP_STICKY_FLAG);
 
     var lastIndex;
     if (sticky) {
         lastIndex = ToLength(rx.lastIndex);
         if (lastIndex > lengthS) {
             rx.lastIndex = 0;
             return S;
         }
@@ -542,17 +545,18 @@ function RegExpSearch(string) {
     if (!IsObject(rx))
         ThrowTypeError(JSMSG_NOT_NONNULL_OBJECT, rx === null ? "null" : typeof rx);
 
     // Step 3.
     var S = ToString(string);
 
     var result;
     if (IsRegExpMethodOptimizable(rx) && S.length < 0x7fff) {
-        var sticky = !!rx.sticky;
+        var flags = UnsafeGetInt32FromReservedSlot(rx, REGEXP_FLAGS_SLOT);
+        var sticky = !!(flags & REGEXP_STICKY_FLAG);
 
         // Step 6.
         result = RegExpSearcher(rx, S, 0, sticky);
 
         // Step 8.
         if (result === -1)
             return -1;