summaryrefslogtreecommitdiff
path: root/js/src/vm/RegExpObject.h
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/vm/RegExpObject.h')
-rw-r--r--js/src/vm/RegExpObject.h25
1 files changed, 14 insertions, 11 deletions
diff --git a/js/src/vm/RegExpObject.h b/js/src/vm/RegExpObject.h
index 16ba7f41fd..41f5e623ae 100644
--- a/js/src/vm/RegExpObject.h
+++ b/js/src/vm/RegExpObject.h
@@ -32,10 +32,8 @@
*
* To save memory, a RegExpShared is not created for a RegExpObject until it is
* needed for execution. When a RegExpShared needs to be created, it is looked
- * up in a per-compartment table to allow reuse between objects. Lastly, on
- * GC, every RegExpShared (that is not active on the callstack) is discarded.
- * Because of the last point, any code using a RegExpShared (viz., by executing
- * a regexp) must indicate the RegExpShared is active via RegExpGuard.
+ * up in a per-compartment table to allow reuse between objects. Lastly, on GC,
+ * every RegExpShared that is not in active use is discarded.
*/
namespace js {
@@ -251,6 +249,10 @@ class RegExpShared : public gc::TenuredCell
#endif
};
+using RootedRegExpShared = JS::Rooted<RegExpShared*>;
+using HandleRegExpShared = JS::Handle<RegExpShared*>;
+using MutableHandleRegExpShared = JS::MutableHandle<RegExpShared*>;
+
class RegExpCompartment
{
struct Key {
@@ -321,10 +323,11 @@ class RegExpCompartment
bool empty() { return set_.empty(); }
- bool get(JSContext* cx, JSAtom* source, RegExpFlag flags, RegExpGuard* g);
+ bool get(JSContext* cx, JSAtom* source, RegExpFlag flags, MutableHandleRegExpShared shared);
/* Like 'get', but compile 'maybeOpt' (if non-null). */
- bool get(JSContext* cx, HandleAtom source, JSString* maybeOpt, RegExpGuard* g);
+ bool get(JSContext* cx, HandleAtom source, JSString* maybeOpt,
+ MutableHandleRegExpShared shared);
/* Get or create template object used to base the result of .exec() on. */
ArrayObject* getOrCreateMatchResultTemplateObject(JSContext* cx) {
@@ -447,7 +450,7 @@ class RegExpObject : public NativeObject
static bool isOriginalFlagGetter(JSNative native, RegExpFlag* mask);
static MOZ_MUST_USE bool getShared(JSContext* cx, Handle<RegExpObject*> regexp,
- RegExpGuard* g);
+ MutableHandleRegExpShared shared);
bool hasShared() {
return !!sharedRef();
@@ -479,7 +482,7 @@ class RegExpObject : public NativeObject
* Side effect: sets the private field.
*/
static MOZ_MUST_USE bool createShared(JSContext* cx, Handle<RegExpObject*> regexp,
- RegExpGuard* g);
+ MutableHandleRegExpShared shared);
ReadBarriered<RegExpShared*>& sharedRef() {
auto& ref = NativeObject::privateRef(PRIVATE_SLOT);
@@ -501,12 +504,12 @@ ParseRegExpFlags(JSContext* cx, JSString* flagStr, RegExpFlag* flagsOut);
/* Assuming GetBuiltinClass(obj) is ESClass::RegExp, return a RegExpShared for obj. */
inline bool
-RegExpToShared(JSContext* cx, HandleObject obj, RegExpGuard* g)
+RegExpToShared(JSContext* cx, HandleObject obj, MutableHandleRegExpShared shared)
{
if (obj->is<RegExpObject>())
- return RegExpObject::getShared(cx, obj.as<RegExpObject>(), g);
+ return RegExpObject::getShared(cx, obj.as<RegExpObject>(), shared);
- return Proxy::regexp_toShared(cx, obj, g);
+ return Proxy::regexp_toShared(cx, obj, shared);
}
template<XDRMode mode>