Bug 1199887 - Rename StringRegExpGuard::init(JSContext*, JSObject*) to initRegExp for clarity. r=evilpie
authorJeff Walden <jwalden@mit.edu>
Wed, 26 Aug 2015 11:43:49 -0700
changeset 293673 dde65be15e240024e41a25c4a7ac009dbb82675c
parent 293672 b0f76dc4f5b0d6584a26366440661b0733db1c00
child 293674 9de14ef7802e2bb614ac09a3a0e1c81ea7c0e307
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersevilpie
bugs1199887
milestone43.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 1199887 - Rename StringRegExpGuard::init(JSContext*, JSObject*) to initRegExp for clarity. r=evilpie
js/src/jit/Recover.cpp
js/src/jit/VMFunctions.cpp
js/src/jsstr.cpp
js/src/jsstr.h
js/src/vm/RegExpObject.h
--- a/js/src/jit/Recover.cpp
+++ b/js/src/jit/Recover.cpp
@@ -1047,17 +1047,17 @@ MRegExpReplace::writeRecoverData(Compact
 
 RRegExpReplace::RRegExpReplace(CompactBufferReader& reader)
 { }
 
 bool
 RRegExpReplace::recover(JSContext* cx, SnapshotIterator& iter) const
 {
     RootedString string(cx, iter.read().toString());
-    RootedObject regexp(cx, &iter.read().toObject());
+    Rooted<RegExpObject*> regexp(cx, &iter.read().toObject().as<RegExpObject>());
     RootedString repl(cx, iter.read().toString());
     RootedValue result(cx);
 
     if (!js::str_replace_regexp_raw(cx, string, regexp, repl, &result))
         return false;
 
     iter.storeInstructionResult(result);
     return true;
--- a/js/src/jit/VMFunctions.cpp
+++ b/js/src/jit/VMFunctions.cpp
@@ -1037,17 +1037,17 @@ CreateDerivedTypedObj(JSContext* cx, Han
 
 JSString*
 RegExpReplace(JSContext* cx, HandleString string, HandleObject regexp, HandleString repl)
 {
     MOZ_ASSERT(string);
     MOZ_ASSERT(repl);
 
     RootedValue rval(cx);
-    if (!str_replace_regexp_raw(cx, string, regexp, repl, &rval))
+    if (!str_replace_regexp_raw(cx, string, regexp.as<RegExpObject>(), repl, &rval))
         return nullptr;
 
     return rval.toString();
 }
 
 JSString*
 StringReplace(JSContext* cx, HandleString string, HandleString pattern, HandleString repl)
 {
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -2096,17 +2096,17 @@ class MOZ_STACK_CLASS StringRegExpGuard
     explicit StringRegExpGuard(JSContext* cx)
       : re_(cx), fm(cx), obj_(cx)
     { }
 
     /* init must succeed in order to call tryFlatMatch or normalizeRegExp. */
     bool init(JSContext* cx, const CallArgs& args, bool convertVoid = false)
     {
         if (args.length() != 0 && IsObjectWithClass(args[0], ESClass_RegExp, cx))
-            return init(cx, &args[0].toObject());
+            return initRegExp(cx, &args[0].toObject());
 
         if (convertVoid && !args.hasDefined(0)) {
             fm.pat_ = cx->runtime()->emptyString;
             return true;
         }
 
         JSString* arg = ArgToRootedString(cx, args, 0);
         if (!arg)
@@ -2114,24 +2114,22 @@ class MOZ_STACK_CLASS StringRegExpGuard
 
         fm.pat_ = AtomizeString(cx, arg);
         if (!fm.pat_)
             return false;
 
         return true;
     }
 
-    bool init(JSContext* cx, JSObject* regexp) {
+    bool initRegExp(JSContext* cx, JSObject* regexp) {
         obj_ = regexp;
 
         MOZ_ASSERT(ObjectClassIs(obj_, ESClass_RegExp, cx));
 
-        if (!RegExpToShared(cx, obj_, &re_))
-            return false;
-        return true;
+        return RegExpToShared(cx, obj_, &re_);
     }
 
     bool init(JSContext* cx, HandleString pattern) {
         fm.pat_ = AtomizeString(cx, pattern);
         if (!fm.pat_)
             return false;
         return true;
     }
@@ -3341,39 +3339,39 @@ str_replace_regexp(JSContext* cx, const 
 {
     if (!rdata.g.normalizeRegExp(cx, true, 2, args))
         return false;
 
     return StrReplaceRegExp(cx, rdata, args.rval());
 }
 
 bool
-js::str_replace_regexp_raw(JSContext* cx, HandleString string, HandleObject regexp,
-                       HandleString replacement, MutableHandleValue rval)
+js::str_replace_regexp_raw(JSContext* cx, HandleString string, Handle<RegExpObject*> regexp,
+                           HandleString replacement, MutableHandleValue rval)
 {
     /* Optimize removal, so we don't have to create ReplaceData */
     if (replacement->length() == 0) {
         StringRegExpGuard guard(cx);
-        if (!guard.init(cx, regexp))
+        if (!guard.initRegExp(cx, regexp))
             return false;
 
         RegExpShared& re = guard.regExp();
         return StrReplaceRegexpRemove(cx, string, re, rval);
     }
 
     ReplaceData rdata(cx);
     rdata.str = string;
 
     JSLinearString* repl = replacement->ensureLinear(cx);
     if (!repl)
         return false;
 
     rdata.setReplacementString(repl);
 
-    if (!rdata.g.init(cx, regexp))
+    if (!rdata.g.initRegExp(cx, regexp))
         return false;
 
     return StrReplaceRegExp(cx, rdata, rval);
 }
 
 static inline bool
 StrReplaceString(JSContext* cx, ReplaceData& rdata, const FlatMatch& fm, MutableHandleValue rval)
 {
--- a/js/src/jsstr.h
+++ b/js/src/jsstr.h
@@ -424,20 +424,16 @@ str_search(JSContext* cx, unsigned argc,
 
 bool
 str_split(JSContext* cx, unsigned argc, Value* vp);
 
 JSObject*
 str_split_string(JSContext* cx, HandleObjectGroup group, HandleString str, HandleString sep);
 
 bool
-str_replace_regexp_raw(JSContext* cx, HandleString string, HandleObject regexp,
-                       HandleString replacement, MutableHandleValue rval);
-
-bool
 str_replace_string_raw(JSContext* cx, HandleString string, HandleString pattern,
                        HandleString replacement, MutableHandleValue rval);
 
 extern bool
 StringConstructor(JSContext* cx, unsigned argc, Value* vp);
 
 } /* namespace js */
 
--- a/js/src/vm/RegExpObject.h
+++ b/js/src/vm/RegExpObject.h
@@ -469,16 +469,20 @@ class RegExpObject : public NativeObject
     RegExpShared* maybeShared() const {
         return static_cast<RegExpShared*>(NativeObject::getPrivate(PRIVATE_SLOT));
     }
 
     /* Call setShared in preference to setPrivate. */
     void setPrivate(void* priv) = delete;
 };
 
+bool
+str_replace_regexp_raw(JSContext* cx, HandleString string, Handle<RegExpObject*> regexp,
+                       HandleString replacement, MutableHandleValue rval);
+
 /*
  * Parse regexp flags. Report an error and return false if an invalid
  * sequence of flags is encountered (repeat/invalid flag).
  *
  * N.B. flagStr must be rooted.
  */
 bool
 ParseRegExpFlags(JSContext* cx, JSString* flagStr, RegExpFlag* flagsOut);