Bug 1219757 - Part 8: Remove RegExpStatics::getFlags and RegExpStatics::flags. r=till
authorTooru Fujisawa <arai_a@mac.com>
Wed, 25 Nov 2015 22:38:05 +0900
changeset 289955 485ed8b35eac2d1d15064163e07600ccafc8d239
parent 289954 ca7fffec2dddbc955428a27379cfc344520bb4fd
child 289956 8ed1480aac04f99f41988a1ee16615328cc6d350
push id74045
push userarai_a@mac.com
push dateWed, 23 Mar 2016 04:58:59 +0000
treeherdermozilla-inbound@604a180b6cc0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs1219757
milestone48.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 1219757 - Part 8: Remove RegExpStatics::getFlags and RegExpStatics::flags. r=till
js/src/vm/RegExpObject.cpp
js/src/vm/RegExpStatics.h
--- a/js/src/vm/RegExpObject.cpp
+++ b/js/src/vm/RegExpObject.cpp
@@ -915,37 +915,22 @@ js::CloneRegExpObject(JSContext* cx, JSO
         return nullptr;
     clone->initPrivate(nullptr);
 
     if (!EmptyShape::ensureInitialCustomShape<RegExpObject>(cx, clone))
         return nullptr;
 
     Rooted<JSAtom*> source(cx, regex->getSource());
 
-    // Check that the RegExpShared for |regex| is okay to reuse in the clone.
-    RegExpStatics* currentStatics = regex->getProto()->global().getRegExpStatics(cx);
-    if (!currentStatics)
+    RegExpGuard g(cx);
+    if (!regex->getShared(cx, &g))
         return nullptr;
 
-    RegExpFlag origFlags = regex->getFlags();
-    RegExpFlag staticsFlags = currentStatics->getFlags();
-    if ((origFlags & staticsFlags) != staticsFlags) {
-        // If |currentStatics| provides additional flags, we'll have to use a
-        // new |RegExpShared|.
-        clone->initAndZeroLastIndex(source, RegExpFlag(origFlags | staticsFlags), cx);
-    } else {
-        // Otherwise we can use |regexp|'s RegExpShared.  Initialize using its
-        // flags and associate it with the clone.
-        RegExpGuard g(cx);
-        if (!regex->getShared(cx, &g))
-            return nullptr;
-
-        clone->initAndZeroLastIndex(source, g->getFlags(), cx);
-        clone->setShared(*g.re());
-    }
+    clone->initAndZeroLastIndex(source, g->getFlags(), cx);
+    clone->setShared(*g.re());
 
     return clone;
 }
 
 static bool
 HandleRegExpFlag(RegExpFlag flag, RegExpFlag* flags)
 {
     if (*flags & flag)
--- a/js/src/vm/RegExpStatics.h
+++ b/js/src/vm/RegExpStatics.h
@@ -30,17 +30,16 @@ class RegExpStatics
      */
     RelocatablePtrAtom      lazySource;
     RegExpFlag              lazyFlags;
     size_t                  lazyIndex;
     bool                    lazySticky;
 
     /* The latest RegExp input, set before execution. */
     RelocatablePtrString    pendingInput;
-    RegExpFlag              flags;
 
     /*
      * If non-zero, |matchesInput| and the |lazy*| fields may be used
      * to replay the last executed RegExp, and |matches| is invalid.
      */
     int32_t                 pendingLazyEvaluation;
 
   public:
@@ -86,18 +85,16 @@ class RegExpStatics
     const MatchPairs& getMatches() const {
         /* Safe: only used by String methods, which do not set lazy mode. */
         MOZ_ASSERT(!pendingLazyEvaluation);
         return matches;
     }
 
     JSString* getPendingInput() const { return pendingInput; }
 
-    RegExpFlag getFlags() const { return flags; }
-
     void mark(JSTracer* trc) {
         /*
          * Changes to this function must also be reflected in
          * RegExpStatics::AutoRooter::trace().
          */
         if (matchesInput)
             TraceEdge(trc, &matchesInput, "res->matchesInput");
         if (lazySource)
@@ -377,17 +374,16 @@ RegExpStatics::clear()
 {
     matches.forgetArray();
     matchesInput = nullptr;
     lazySource = nullptr;
     lazyFlags = RegExpFlag(0);
     lazyIndex = size_t(-1);
     lazySticky = false;
     pendingInput = nullptr;
-    flags = RegExpFlag(0);
     pendingLazyEvaluation = false;
 }
 
 inline void
 RegExpStatics::setPendingInput(JSString* newInput)
 {
     pendingInput = newInput;
 }