зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1379461 - Refactor code to return RegExpShared* directly instead of using bool + outparam. r=evilpie
This commit is contained in:
Родитель
aac46d1b3e
Коммит
669d53bfea
|
@ -129,8 +129,7 @@ class CPOWProxyHandler : public BaseProxyHandler
|
|||
virtual bool isArray(JSContext* cx, HandleObject obj,
|
||||
IsArrayAnswer* answer) const override;
|
||||
virtual const char* className(JSContext* cx, HandleObject proxy) const override;
|
||||
virtual bool regexp_toShared(JSContext* cx, HandleObject proxy,
|
||||
MutableHandle<RegExpShared*> shared) const override;
|
||||
virtual RegExpShared* regexp_toShared(JSContext* cx, HandleObject proxy) const override;
|
||||
virtual void finalize(JSFreeOp* fop, JSObject* proxy) const override;
|
||||
virtual void objectMoved(JSObject* proxy, const JSObject* old) const override;
|
||||
virtual bool isCallable(JSObject* obj) const override;
|
||||
|
@ -146,15 +145,15 @@ class CPOWProxyHandler : public BaseProxyHandler
|
|||
const char CPOWProxyHandler::family = 0;
|
||||
const CPOWProxyHandler CPOWProxyHandler::singleton;
|
||||
|
||||
#define FORWARD(call, args) \
|
||||
#define FORWARD(call, args, failRetVal) \
|
||||
AUTO_PROFILER_LABEL(__func__, JS); \
|
||||
WrapperOwner* owner = OwnerOf(proxy); \
|
||||
if (!owner->active()) { \
|
||||
JS_ReportErrorASCII(cx, "cannot use a CPOW whose process is gone"); \
|
||||
return false; \
|
||||
return failRetVal; \
|
||||
} \
|
||||
if (!owner->allowMessage(cx)) { \
|
||||
return false; \
|
||||
return failRetVal; \
|
||||
} \
|
||||
{ \
|
||||
CPOWTimer timer(cx); \
|
||||
|
@ -165,7 +164,7 @@ bool
|
|||
CPOWProxyHandler::getPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id,
|
||||
MutableHandle<PropertyDescriptor> desc) const
|
||||
{
|
||||
FORWARD(getPropertyDescriptor, (cx, proxy, id, desc));
|
||||
FORWARD(getPropertyDescriptor, (cx, proxy, id, desc), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -195,7 +194,7 @@ bool
|
|||
CPOWProxyHandler::getOwnPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id,
|
||||
MutableHandle<PropertyDescriptor> desc) const
|
||||
{
|
||||
FORWARD(getOwnPropertyDescriptor, (cx, proxy, id, desc));
|
||||
FORWARD(getOwnPropertyDescriptor, (cx, proxy, id, desc), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -226,7 +225,7 @@ CPOWProxyHandler::defineProperty(JSContext* cx, HandleObject proxy, HandleId id,
|
|||
Handle<PropertyDescriptor> desc,
|
||||
ObjectOpResult& result) const
|
||||
{
|
||||
FORWARD(defineProperty, (cx, proxy, id, desc, result));
|
||||
FORWARD(defineProperty, (cx, proxy, id, desc, result), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -257,7 +256,7 @@ bool
|
|||
CPOWProxyHandler::ownPropertyKeys(JSContext* cx, HandleObject proxy,
|
||||
AutoIdVector& props) const
|
||||
{
|
||||
FORWARD(ownPropertyKeys, (cx, proxy, props));
|
||||
FORWARD(ownPropertyKeys, (cx, proxy, props), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -270,7 +269,7 @@ bool
|
|||
CPOWProxyHandler::delete_(JSContext* cx, HandleObject proxy, HandleId id,
|
||||
ObjectOpResult& result) const
|
||||
{
|
||||
FORWARD(delete_, (cx, proxy, id, result));
|
||||
FORWARD(delete_, (cx, proxy, id, result), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -303,7 +302,7 @@ CPOWProxyHandler::enumerate(JSContext* cx, HandleObject proxy) const
|
|||
bool
|
||||
CPOWProxyHandler::has(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const
|
||||
{
|
||||
FORWARD(has, (cx, proxy, id, bp));
|
||||
FORWARD(has, (cx, proxy, id, bp), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -327,7 +326,7 @@ WrapperOwner::has(JSContext* cx, HandleObject proxy, HandleId id, bool* bp)
|
|||
bool
|
||||
CPOWProxyHandler::hasOwn(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const
|
||||
{
|
||||
FORWARD(hasOwn, (cx, proxy, id, bp));
|
||||
FORWARD(hasOwn, (cx, proxy, id, bp), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -352,7 +351,7 @@ bool
|
|||
CPOWProxyHandler::get(JSContext* cx, HandleObject proxy, HandleValue receiver,
|
||||
HandleId id, MutableHandleValue vp) const
|
||||
{
|
||||
FORWARD(get, (cx, proxy, receiver, id, vp));
|
||||
FORWARD(get, (cx, proxy, receiver, id, vp), false);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -365,7 +364,7 @@ CPOWDOMQI(JSContext* cx, unsigned argc, Value* vp)
|
|||
}
|
||||
|
||||
RootedObject proxy(cx, &args.thisv().toObject());
|
||||
FORWARD(DOMQI, (cx, proxy, args));
|
||||
FORWARD(DOMQI, (cx, proxy, args), false);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -383,7 +382,7 @@ CPOWToString(JSContext* cx, unsigned argc, Value* vp)
|
|||
}
|
||||
|
||||
RootedObject proxy(cx, &cpowValue.toObject());
|
||||
FORWARD(toString, (cx, proxy, args));
|
||||
FORWARD(toString, (cx, proxy, args), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -530,7 +529,7 @@ bool
|
|||
CPOWProxyHandler::set(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::HandleValue v,
|
||||
JS::HandleValue receiver, JS::ObjectOpResult& result) const
|
||||
{
|
||||
FORWARD(set, (cx, proxy, id, v, receiver, result));
|
||||
FORWARD(set, (cx, proxy, id, v, receiver, result), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -564,7 +563,7 @@ bool
|
|||
CPOWProxyHandler::getOwnEnumerablePropertyKeys(JSContext* cx, HandleObject proxy,
|
||||
AutoIdVector& props) const
|
||||
{
|
||||
FORWARD(getOwnEnumerablePropertyKeys, (cx, proxy, props));
|
||||
FORWARD(getOwnEnumerablePropertyKeys, (cx, proxy, props), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -576,7 +575,7 @@ WrapperOwner::getOwnEnumerablePropertyKeys(JSContext* cx, HandleObject proxy, Au
|
|||
bool
|
||||
CPOWProxyHandler::preventExtensions(JSContext* cx, HandleObject proxy, ObjectOpResult& result) const
|
||||
{
|
||||
FORWARD(preventExtensions, (cx, proxy, result));
|
||||
FORWARD(preventExtensions, (cx, proxy, result), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -596,7 +595,7 @@ WrapperOwner::preventExtensions(JSContext* cx, HandleObject proxy, ObjectOpResul
|
|||
bool
|
||||
CPOWProxyHandler::isExtensible(JSContext* cx, HandleObject proxy, bool* extensible) const
|
||||
{
|
||||
FORWARD(isExtensible, (cx, proxy, extensible));
|
||||
FORWARD(isExtensible, (cx, proxy, extensible), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -616,13 +615,13 @@ WrapperOwner::isExtensible(JSContext* cx, HandleObject proxy, bool* extensible)
|
|||
bool
|
||||
CPOWProxyHandler::call(JSContext* cx, HandleObject proxy, const CallArgs& args) const
|
||||
{
|
||||
FORWARD(callOrConstruct, (cx, proxy, args, false));
|
||||
FORWARD(callOrConstruct, (cx, proxy, args, false), false);
|
||||
}
|
||||
|
||||
bool
|
||||
CPOWProxyHandler::construct(JSContext* cx, HandleObject proxy, const CallArgs& args) const
|
||||
{
|
||||
FORWARD(callOrConstruct, (cx, proxy, args, true));
|
||||
FORWARD(callOrConstruct, (cx, proxy, args, true), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -705,7 +704,7 @@ WrapperOwner::callOrConstruct(JSContext* cx, HandleObject proxy, const CallArgs&
|
|||
bool
|
||||
CPOWProxyHandler::hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v, bool* bp) const
|
||||
{
|
||||
FORWARD(hasInstance, (cx, proxy, v, bp));
|
||||
FORWARD(hasInstance, (cx, proxy, v, bp), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -729,7 +728,7 @@ WrapperOwner::hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue
|
|||
bool
|
||||
CPOWProxyHandler::getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls) const
|
||||
{
|
||||
FORWARD(getBuiltinClass, (cx, proxy, cls));
|
||||
FORWARD(getBuiltinClass, (cx, proxy, cls), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -752,7 +751,7 @@ bool
|
|||
CPOWProxyHandler::isArray(JSContext* cx, HandleObject proxy,
|
||||
IsArrayAnswer* answer) const
|
||||
{
|
||||
FORWARD(isArray, (cx, proxy, answer));
|
||||
FORWARD(isArray, (cx, proxy, answer), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -803,7 +802,7 @@ WrapperOwner::className(JSContext* cx, HandleObject proxy)
|
|||
bool
|
||||
CPOWProxyHandler::getPrototype(JSContext* cx, HandleObject proxy, MutableHandleObject objp) const
|
||||
{
|
||||
FORWARD(getPrototype, (cx, proxy, objp));
|
||||
FORWARD(getPrototype, (cx, proxy, objp), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -830,7 +829,7 @@ bool
|
|||
CPOWProxyHandler::getPrototypeIfOrdinary(JSContext* cx, HandleObject proxy, bool* isOrdinary,
|
||||
MutableHandleObject objp) const
|
||||
{
|
||||
FORWARD(getPrototypeIfOrdinary, (cx, proxy, isOrdinary, objp));
|
||||
FORWARD(getPrototypeIfOrdinary, (cx, proxy, isOrdinary, objp), false);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -854,35 +853,35 @@ WrapperOwner::getPrototypeIfOrdinary(JSContext* cx, HandleObject proxy, bool* is
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CPOWProxyHandler::regexp_toShared(JSContext* cx, HandleObject proxy,
|
||||
MutableHandle<RegExpShared*> shared) const
|
||||
RegExpShared*
|
||||
CPOWProxyHandler::regexp_toShared(JSContext* cx, HandleObject proxy) const
|
||||
{
|
||||
FORWARD(regexp_toShared, (cx, proxy, shared));
|
||||
FORWARD(regexp_toShared, (cx, proxy), nullptr);
|
||||
}
|
||||
|
||||
bool
|
||||
WrapperOwner::regexp_toShared(JSContext* cx, HandleObject proxy, MutableHandle<RegExpShared*> shared)
|
||||
RegExpShared*
|
||||
WrapperOwner::regexp_toShared(JSContext* cx, HandleObject proxy)
|
||||
{
|
||||
ObjectId objId = idOf(proxy);
|
||||
|
||||
ReturnStatus status;
|
||||
nsString source;
|
||||
unsigned flags = 0;
|
||||
if (!SendRegExpToShared(objId, &status, &source, &flags))
|
||||
return ipcfail(cx);
|
||||
|
||||
if (!SendRegExpToShared(objId, &status, &source, &flags)) {
|
||||
MOZ_ALWAYS_FALSE(ipcfail(cx));
|
||||
return nullptr;
|
||||
}
|
||||
LOG_STACK();
|
||||
|
||||
if (!ok(cx, status))
|
||||
return false;
|
||||
return nullptr;
|
||||
|
||||
RootedObject regexp(cx);
|
||||
regexp = JS_NewUCRegExpObject(cx, source.get(), source.Length(), flags);
|
||||
if (!regexp)
|
||||
return false;
|
||||
return nullptr;
|
||||
|
||||
return js::RegExpToSharedNonInline(cx, regexp, shared);
|
||||
return js::RegExpToSharedNonInline(cx, regexp);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1015,7 +1014,7 @@ bool
|
|||
DOMInstanceOf(JSContext* cx, JSObject* proxyArg, int prototypeID, int depth, bool* bp)
|
||||
{
|
||||
RootedObject proxy(cx, proxyArg);
|
||||
FORWARD(domInstanceOf, (cx, proxy, prototypeID, depth, bp));
|
||||
FORWARD(domInstanceOf, (cx, proxy, prototypeID, depth, bp), false);
|
||||
}
|
||||
|
||||
} /* namespace jsipc */
|
||||
|
|
|
@ -60,8 +60,7 @@ class WrapperOwner : public virtual JavaScriptShared
|
|||
bool getPrototypeIfOrdinary(JSContext* cx, JS::HandleObject proxy, bool* isOrdinary,
|
||||
JS::MutableHandleObject protop);
|
||||
|
||||
bool regexp_toShared(JSContext* cx, JS::HandleObject proxy,
|
||||
js::MutableHandle<js::RegExpShared*> shared);
|
||||
js::RegExpShared* regexp_toShared(JSContext* cx, JS::HandleObject proxy);
|
||||
|
||||
nsresult instanceOf(JSObject* obj, const nsID* id, bool* bp);
|
||||
|
||||
|
|
|
@ -331,8 +331,7 @@ class JS_FRIEND_API(BaseProxyHandler)
|
|||
virtual bool isArray(JSContext* cx, HandleObject proxy, JS::IsArrayAnswer* answer) const;
|
||||
virtual const char* className(JSContext* cx, HandleObject proxy) const;
|
||||
virtual JSString* fun_toString(JSContext* cx, HandleObject proxy, unsigned indent) const;
|
||||
virtual bool regexp_toShared(JSContext* cx, HandleObject proxy,
|
||||
MutableHandle<js::RegExpShared*> shared) const;
|
||||
virtual RegExpShared* regexp_toShared(JSContext* cx, HandleObject proxy) const;
|
||||
virtual bool boxedValue_unbox(JSContext* cx, HandleObject proxy, MutableHandleValue vp) const;
|
||||
virtual void trace(JSTracer* trc, JSObject* proxy) const;
|
||||
virtual void finalize(JSFreeOp* fop, JSObject* proxy) const;
|
||||
|
|
|
@ -146,8 +146,8 @@ js::ExecuteRegExpLegacy(JSContext* cx, RegExpStatics* res, Handle<RegExpObject*>
|
|||
HandleLinearString input, size_t* lastIndex, bool test,
|
||||
MutableHandleValue rval)
|
||||
{
|
||||
RootedRegExpShared shared(cx);
|
||||
if (!RegExpObject::getShared(cx, reobj, &shared))
|
||||
RootedRegExpShared shared(cx, RegExpObject::getShared(cx, reobj));
|
||||
if (!shared)
|
||||
return false;
|
||||
|
||||
ScopedMatchPairs matches(&cx->tempLifoAlloc());
|
||||
|
@ -234,8 +234,8 @@ RegExpInitializeIgnoringLastIndex(JSContext* cx, Handle<RegExpObject*> obj,
|
|||
|
||||
if (sharedUse == UseRegExpShared) {
|
||||
/* Steps 7-8. */
|
||||
RootedRegExpShared re(cx);
|
||||
if (!cx->zone()->regExps.get(cx, pattern, flags, &re))
|
||||
RegExpShared* re = cx->zone()->regExps.get(cx, pattern, flags);
|
||||
if (!re)
|
||||
return false;
|
||||
|
||||
/* Steps 9-12. */
|
||||
|
@ -340,12 +340,12 @@ regexp_compile_impl(JSContext* cx, const CallArgs& args)
|
|||
RegExpFlag flags;
|
||||
{
|
||||
// Step 3b.
|
||||
RootedRegExpShared g(cx);
|
||||
if (!RegExpToShared(cx, patternObj, &g))
|
||||
RegExpShared* shared = RegExpToShared(cx, patternObj);
|
||||
if (!shared)
|
||||
return false;
|
||||
|
||||
sourceAtom = g->getSource();
|
||||
flags = g->getFlags();
|
||||
sourceAtom = shared->getSource();
|
||||
flags = shared->getFlags();
|
||||
}
|
||||
|
||||
// Step 5, minus lastIndex zeroing.
|
||||
|
@ -435,14 +435,14 @@ js::regexp_construct(JSContext* cx, unsigned argc, Value* vp)
|
|||
RegExpFlag flags;
|
||||
{
|
||||
// Step 4.a.
|
||||
RootedRegExpShared g(cx);
|
||||
if (!RegExpToShared(cx, patternObj, &g))
|
||||
RegExpShared* shared = RegExpToShared(cx, patternObj);
|
||||
if (!shared)
|
||||
return false;
|
||||
sourceAtom = g->getSource();
|
||||
sourceAtom = shared->getSource();
|
||||
|
||||
// Step 4.b.
|
||||
// Get original flags in all cases, to compare with passed flags.
|
||||
flags = g->getFlags();
|
||||
flags = shared->getFlags();
|
||||
}
|
||||
|
||||
// Step 7.
|
||||
|
@ -899,8 +899,8 @@ ExecuteRegExp(JSContext* cx, HandleObject regexp, HandleString string,
|
|||
/* Steps 1-2 performed by the caller. */
|
||||
Rooted<RegExpObject*> reobj(cx, ®exp->as<RegExpObject>());
|
||||
|
||||
RootedRegExpShared re(cx);
|
||||
if (!RegExpObject::getShared(cx, reobj, &re))
|
||||
RootedRegExpShared re(cx, RegExpObject::getShared(cx, reobj));
|
||||
if (!re)
|
||||
return RegExpRunStatus_Error;
|
||||
|
||||
RegExpStatics* res;
|
||||
|
|
|
@ -6272,8 +6272,8 @@ JS_GetRegExpFlags(JSContext* cx, HandleObject obj)
|
|||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
RootedRegExpShared shared(cx);
|
||||
if (!RegExpToShared(cx, obj, &shared))
|
||||
RegExpShared* shared = RegExpToShared(cx, obj);
|
||||
if (!shared)
|
||||
return false;
|
||||
return shared->getFlags();
|
||||
}
|
||||
|
@ -6284,8 +6284,8 @@ JS_GetRegExpSource(JSContext* cx, HandleObject obj)
|
|||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
RootedRegExpShared shared(cx);
|
||||
if (!RegExpToShared(cx, obj, &shared))
|
||||
RegExpShared* shared = RegExpToShared(cx, obj);
|
||||
if (!shared)
|
||||
return nullptr;
|
||||
return shared->getSource();
|
||||
}
|
||||
|
|
|
@ -1181,9 +1181,8 @@ extern JS_FRIEND_API(unsigned)
|
|||
GetEnterCompartmentDepth(JSContext* cx);
|
||||
#endif
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
RegExpToSharedNonInline(JSContext* cx, JS::HandleObject regexp,
|
||||
JS::MutableHandle<RegExpShared*> shared);
|
||||
extern JS_FRIEND_API(RegExpShared*)
|
||||
RegExpToSharedNonInline(JSContext* cx, JS::HandleObject regexp);
|
||||
|
||||
/* Implemented in CrossCompartmentWrapper.cpp. */
|
||||
typedef enum NukeReferencesToWindow {
|
||||
|
|
|
@ -116,8 +116,7 @@ class JS_FRIEND_API(Wrapper) : public BaseProxyHandler
|
|||
virtual const char* className(JSContext* cx, HandleObject proxy) const override;
|
||||
virtual JSString* fun_toString(JSContext* cx, HandleObject proxy,
|
||||
unsigned indent) const override;
|
||||
virtual bool regexp_toShared(JSContext* cx, HandleObject proxy,
|
||||
MutableHandle<RegExpShared*> shared) const override;
|
||||
virtual RegExpShared* regexp_toShared(JSContext* cx, HandleObject proxy) const override;
|
||||
virtual bool boxedValue_unbox(JSContext* cx, HandleObject proxy,
|
||||
MutableHandleValue vp) const override;
|
||||
virtual bool isCallable(JSObject* obj) const override;
|
||||
|
@ -211,8 +210,7 @@ class JS_FRIEND_API(CrossCompartmentWrapper) : public Wrapper
|
|||
virtual const char* className(JSContext* cx, HandleObject proxy) const override;
|
||||
virtual JSString* fun_toString(JSContext* cx, HandleObject wrapper,
|
||||
unsigned indent) const override;
|
||||
virtual bool regexp_toShared(JSContext* cx, HandleObject proxy,
|
||||
MutableHandle<RegExpShared*> shared) const override;
|
||||
virtual RegExpShared* regexp_toShared(JSContext* cx, HandleObject proxy) const override;
|
||||
virtual bool boxedValue_unbox(JSContext* cx, HandleObject proxy, MutableHandleValue vp) const override;
|
||||
|
||||
// Allocate CrossCompartmentWrappers in the nursery.
|
||||
|
@ -309,8 +307,7 @@ class JS_FRIEND_API(SecurityWrapper) : public Base
|
|||
const CallArgs& args) const override;
|
||||
virtual bool getBuiltinClass(JSContext* cx, HandleObject wrapper, ESClass* cls) const override;
|
||||
virtual bool isArray(JSContext* cx, HandleObject wrapper, JS::IsArrayAnswer* answer) const override;
|
||||
virtual bool regexp_toShared(JSContext* cx, HandleObject proxy,
|
||||
MutableHandle<RegExpShared*> shared) const override;
|
||||
virtual RegExpShared* regexp_toShared(JSContext* cx, HandleObject proxy) const override;
|
||||
virtual bool boxedValue_unbox(JSContext* cx, HandleObject proxy, MutableHandleValue vp) const override;
|
||||
|
||||
// Allow isCallable and isConstructor. They used to be class-level, and so could not be guarded
|
||||
|
|
|
@ -325,9 +325,8 @@ BaseProxyHandler::fun_toString(JSContext* cx, HandleObject proxy, unsigned inden
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
BaseProxyHandler::regexp_toShared(JSContext* cx, HandleObject proxy,
|
||||
MutableHandleRegExpShared shared) const
|
||||
RegExpShared*
|
||||
BaseProxyHandler::regexp_toShared(JSContext* cx, HandleObject proxy) const
|
||||
{
|
||||
MOZ_CRASH("This should have been a wrapped regexp");
|
||||
}
|
||||
|
|
|
@ -463,21 +463,21 @@ CrossCompartmentWrapper::fun_toString(JSContext* cx, HandleObject wrapper, unsig
|
|||
return str;
|
||||
}
|
||||
|
||||
bool
|
||||
CrossCompartmentWrapper::regexp_toShared(JSContext* cx, HandleObject wrapper,
|
||||
MutableHandleRegExpShared shared) const
|
||||
RegExpShared*
|
||||
CrossCompartmentWrapper::regexp_toShared(JSContext* cx, HandleObject wrapper) const
|
||||
{
|
||||
RootedRegExpShared re(cx);
|
||||
{
|
||||
AutoCompartment call(cx, wrappedObject(wrapper));
|
||||
if (!Wrapper::regexp_toShared(cx, wrapper, &re))
|
||||
return false;
|
||||
re = Wrapper::regexp_toShared(cx, wrapper);
|
||||
if (!re)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Get an equivalent RegExpShared associated with the current compartment.
|
||||
RootedAtom source(cx, re->getSource());
|
||||
cx->markAtom(source);
|
||||
return cx->zone()->regExps.get(cx, source, re->getFlags(), shared);
|
||||
return cx->zone()->regExps.get(cx, source, re->getFlags());
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -160,12 +160,11 @@ DeadObjectProxy<CC>::fun_toString(JSContext* cx, HandleObject proxy, unsigned in
|
|||
}
|
||||
|
||||
template <DeadProxyIsCallableIsConstructorOption CC>
|
||||
bool
|
||||
DeadObjectProxy<CC>::regexp_toShared(JSContext* cx, HandleObject proxy,
|
||||
MutableHandle<RegExpShared*> shared) const
|
||||
RegExpShared*
|
||||
DeadObjectProxy<CC>::regexp_toShared(JSContext* cx, HandleObject proxy) const
|
||||
{
|
||||
ReportDead(cx);
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
|
|
|
@ -60,8 +60,7 @@ class DeadObjectProxy : public BaseProxyHandler
|
|||
virtual bool isArray(JSContext* cx, HandleObject proxy, JS::IsArrayAnswer* answer) const override;
|
||||
virtual const char* className(JSContext* cx, HandleObject proxy) const override;
|
||||
virtual JSString* fun_toString(JSContext* cx, HandleObject proxy, unsigned indent) const override;
|
||||
virtual bool regexp_toShared(JSContext* cx, HandleObject proxy,
|
||||
MutableHandle<RegExpShared*> shared) const override;
|
||||
virtual RegExpShared* regexp_toShared(JSContext* cx, HandleObject proxy) const override;
|
||||
|
||||
virtual bool isCallable(JSObject* obj) const override {
|
||||
return CC == DeadProxyIsCallableIsConstructor || CC == DeadProxyIsCallableNotConstructor;
|
||||
|
|
|
@ -575,12 +575,12 @@ Proxy::fun_toString(JSContext* cx, HandleObject proxy, unsigned indent)
|
|||
return handler->fun_toString(cx, proxy, indent);
|
||||
}
|
||||
|
||||
bool
|
||||
Proxy::regexp_toShared(JSContext* cx, HandleObject proxy, MutableHandleRegExpShared shared)
|
||||
RegExpShared*
|
||||
Proxy::regexp_toShared(JSContext* cx, HandleObject proxy)
|
||||
{
|
||||
if (!CheckRecursionLimit(cx))
|
||||
return false;
|
||||
return proxy->as<ProxyObject>().handler()->regexp_toShared(cx, proxy, shared);
|
||||
return nullptr;
|
||||
return proxy->as<ProxyObject>().handler()->regexp_toShared(cx, proxy);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -60,8 +60,7 @@ class Proxy
|
|||
static bool isArray(JSContext* cx, HandleObject proxy, JS::IsArrayAnswer* answer);
|
||||
static const char* className(JSContext* cx, HandleObject proxy);
|
||||
static JSString* fun_toString(JSContext* cx, HandleObject proxy, unsigned indent);
|
||||
static bool regexp_toShared(JSContext* cx, HandleObject proxy,
|
||||
MutableHandle<RegExpShared*> shared);
|
||||
static RegExpShared* regexp_toShared(JSContext* cx, HandleObject proxy);
|
||||
static bool boxedValue_unbox(JSContext* cx, HandleObject proxy, MutableHandleValue vp);
|
||||
|
||||
static bool watch(JSContext* cx, HandleObject proxy, HandleId id, HandleObject callable);
|
||||
|
|
|
@ -1267,12 +1267,10 @@ ScriptedProxyHandler::fun_toString(JSContext* cx, HandleObject proxy, unsigned i
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptedProxyHandler::regexp_toShared(JSContext* cx, HandleObject proxy,
|
||||
MutableHandleRegExpShared shared) const
|
||||
RegExpShared*
|
||||
ScriptedProxyHandler::regexp_toShared(JSContext* cx, HandleObject proxy) const
|
||||
{
|
||||
MOZ_CRASH("Should not end up in ScriptedProxyHandler::regexp_toShared");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -69,8 +69,7 @@ class ScriptedProxyHandler : public BaseProxyHandler
|
|||
virtual const char* className(JSContext* cx, HandleObject proxy) const override;
|
||||
virtual JSString* fun_toString(JSContext* cx, HandleObject proxy,
|
||||
unsigned indent) const override;
|
||||
virtual bool regexp_toShared(JSContext* cx, HandleObject proxy,
|
||||
MutableHandle<RegExpShared*> shared) const override;
|
||||
virtual RegExpShared* regexp_toShared(JSContext* cx, HandleObject proxy) const override;
|
||||
virtual bool boxedValue_unbox(JSContext* cx, HandleObject proxy,
|
||||
MutableHandleValue vp) const override;
|
||||
|
||||
|
|
|
@ -87,11 +87,10 @@ SecurityWrapper<Base>::isArray(JSContext* cx, HandleObject obj, JS::IsArrayAnswe
|
|||
}
|
||||
|
||||
template <class Base>
|
||||
bool
|
||||
SecurityWrapper<Base>::regexp_toShared(JSContext* cx, HandleObject obj,
|
||||
MutableHandle<RegExpShared*> shared) const
|
||||
RegExpShared*
|
||||
SecurityWrapper<Base>::regexp_toShared(JSContext* cx, HandleObject obj) const
|
||||
{
|
||||
return Base::regexp_toShared(cx, obj, shared);
|
||||
return Base::regexp_toShared(cx, obj);
|
||||
}
|
||||
|
||||
template <class Base>
|
||||
|
|
|
@ -271,11 +271,11 @@ Wrapper::fun_toString(JSContext* cx, HandleObject proxy, unsigned indent) const
|
|||
return fun_toStringHelper(cx, target, indent);
|
||||
}
|
||||
|
||||
bool
|
||||
Wrapper::regexp_toShared(JSContext* cx, HandleObject proxy, MutableHandleRegExpShared shared) const
|
||||
RegExpShared*
|
||||
Wrapper::regexp_toShared(JSContext* cx, HandleObject proxy) const
|
||||
{
|
||||
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
||||
return RegExpToShared(cx, target, shared);
|
||||
return RegExpToShared(cx, target);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -116,16 +116,13 @@ VectorMatchPairs::allocOrExpandArray(size_t pairCount)
|
|||
|
||||
/* RegExpObject */
|
||||
|
||||
/* static */ bool
|
||||
RegExpObject::getShared(JSContext* cx, Handle<RegExpObject*> regexp,
|
||||
MutableHandleRegExpShared shared)
|
||||
/* static */ RegExpShared*
|
||||
RegExpObject::getShared(JSContext* cx, Handle<RegExpObject*> regexp)
|
||||
{
|
||||
if (regexp->hasShared()) {
|
||||
shared.set(regexp->sharedRef());
|
||||
return true;
|
||||
}
|
||||
if (regexp->hasShared())
|
||||
return regexp->sharedRef();
|
||||
|
||||
return createShared(cx, regexp, shared);
|
||||
return createShared(cx, regexp);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
|
@ -270,17 +267,17 @@ RegExpObject::create(JSContext* cx, HandleAtom source, RegExpFlag flags,
|
|||
return regexp;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
RegExpObject::createShared(JSContext* cx, Handle<RegExpObject*> regexp,
|
||||
MutableHandleRegExpShared shared)
|
||||
/* static */ RegExpShared*
|
||||
RegExpObject::createShared(JSContext* cx, Handle<RegExpObject*> regexp)
|
||||
{
|
||||
MOZ_ASSERT(!regexp->hasShared());
|
||||
RootedAtom source(cx, regexp->getSource());
|
||||
if (!cx->zone()->regExps.get(cx, source, regexp->getFlags(), shared))
|
||||
return false;
|
||||
RegExpShared* shared = cx->zone()->regExps.get(cx, source, regexp->getFlags());
|
||||
if (!shared)
|
||||
return nullptr;
|
||||
|
||||
regexp->setShared(*shared);
|
||||
return true;
|
||||
return shared;
|
||||
}
|
||||
|
||||
Shape*
|
||||
|
@ -888,8 +885,8 @@ RegExpShared::dumpBytecode(JSContext* cx, MutableHandleRegExpShared re, bool mat
|
|||
RegExpObject::dumpBytecode(JSContext* cx, Handle<RegExpObject*> regexp,
|
||||
bool match_only, HandleLinearString input)
|
||||
{
|
||||
RootedRegExpShared shared(cx);
|
||||
if (!getShared(cx, regexp, &shared))
|
||||
RootedRegExpShared shared(cx, getShared(cx, regexp));
|
||||
if (!shared)
|
||||
return false;
|
||||
|
||||
return RegExpShared::dumpBytecode(cx, &shared, match_only, input);
|
||||
|
@ -1289,39 +1286,35 @@ RegExpCompartment::sweep(JSRuntime* rt)
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
RegExpZone::get(JSContext* cx, HandleAtom source, RegExpFlag flags,
|
||||
MutableHandleRegExpShared result)
|
||||
RegExpShared*
|
||||
RegExpZone::get(JSContext* cx, HandleAtom source, RegExpFlag flags)
|
||||
{
|
||||
DependentAddPtr<Set> p(cx, set_, Key(source, flags));
|
||||
if (p) {
|
||||
result.set(*p);
|
||||
return true;
|
||||
}
|
||||
if (p)
|
||||
return *p;
|
||||
|
||||
auto shared = Allocate<RegExpShared>(cx);
|
||||
if (!shared)
|
||||
return false;
|
||||
return nullptr;
|
||||
|
||||
new (shared) RegExpShared(source, flags);
|
||||
|
||||
if (!p.add(cx, set_, Key(source, flags), shared)) {
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
result.set(shared);
|
||||
return true;
|
||||
return shared;
|
||||
}
|
||||
|
||||
bool
|
||||
RegExpZone::get(JSContext* cx, HandleAtom atom, JSString* opt, MutableHandleRegExpShared shared)
|
||||
RegExpShared*
|
||||
RegExpZone::get(JSContext* cx, HandleAtom atom, JSString* opt)
|
||||
{
|
||||
RegExpFlag flags = RegExpFlag(0);
|
||||
if (opt && !ParseRegExpFlags(cx, opt, &flags))
|
||||
return false;
|
||||
return nullptr;
|
||||
|
||||
return get(cx, atom, flags, shared);
|
||||
return get(cx, atom, flags);
|
||||
}
|
||||
|
||||
size_t
|
||||
|
@ -1353,8 +1346,8 @@ js::CloneRegExpObject(JSContext* cx, JSObject* obj_)
|
|||
|
||||
Rooted<JSAtom*> source(cx, regex->getSource());
|
||||
|
||||
RootedRegExpShared shared(cx);
|
||||
if (!RegExpObject::getShared(cx, regex, &shared))
|
||||
RegExpShared* shared = RegExpObject::getShared(cx, regex);
|
||||
if (!shared)
|
||||
return nullptr;
|
||||
|
||||
clone->initAndZeroLastIndex(source, shared->getFlags(), cx);
|
||||
|
@ -1493,10 +1486,10 @@ js::CloneScriptRegExpObject(JSContext* cx, RegExpObject& reobj)
|
|||
TenuredObject);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
js::RegExpToSharedNonInline(JSContext* cx, HandleObject obj, MutableHandleRegExpShared shared)
|
||||
JS_FRIEND_API(RegExpShared*)
|
||||
js::RegExpToSharedNonInline(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
return RegExpToShared(cx, obj, shared);
|
||||
return RegExpToShared(cx, obj);
|
||||
}
|
||||
|
||||
JS::ubi::Node::Size
|
||||
|
|
|
@ -143,8 +143,7 @@ class RegExpObject : public NativeObject
|
|||
|
||||
static bool isOriginalFlagGetter(JSNative native, RegExpFlag* mask);
|
||||
|
||||
static MOZ_MUST_USE bool getShared(JSContext* cx, Handle<RegExpObject*> regexp,
|
||||
MutableHandleRegExpShared shared);
|
||||
static RegExpShared* getShared(JSContext* cx, Handle<RegExpObject*> regexp);
|
||||
|
||||
bool hasShared() {
|
||||
return !!sharedRef();
|
||||
|
@ -180,8 +179,7 @@ class RegExpObject : public NativeObject
|
|||
* Precondition: the syntax for |source| has already been validated.
|
||||
* Side effect: sets the private field.
|
||||
*/
|
||||
static MOZ_MUST_USE bool createShared(JSContext* cx, Handle<RegExpObject*> regexp,
|
||||
MutableHandleRegExpShared shared);
|
||||
static RegExpShared* createShared(JSContext* cx, Handle<RegExpObject*> regexp);
|
||||
|
||||
/* Call setShared in preference to setPrivate. */
|
||||
void setPrivate(void* priv) = delete;
|
||||
|
@ -197,13 +195,13 @@ bool
|
|||
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, MutableHandleRegExpShared shared)
|
||||
inline RegExpShared*
|
||||
RegExpToShared(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
if (obj->is<RegExpObject>())
|
||||
return RegExpObject::getShared(cx, obj.as<RegExpObject>(), shared);
|
||||
return RegExpObject::getShared(cx, obj.as<RegExpObject>());
|
||||
|
||||
return Proxy::regexp_toShared(cx, obj, shared);
|
||||
return Proxy::regexp_toShared(cx, obj);
|
||||
}
|
||||
|
||||
template<XDRMode mode>
|
||||
|
|
|
@ -273,11 +273,10 @@ class RegExpZone
|
|||
|
||||
bool empty() const { return set_.empty(); }
|
||||
|
||||
bool get(JSContext* cx, HandleAtom source, RegExpFlag flags, MutableHandleRegExpShared shared);
|
||||
RegExpShared* get(JSContext* cx, HandleAtom source, RegExpFlag flags);
|
||||
|
||||
/* Like 'get', but compile 'maybeOpt' (if non-null). */
|
||||
bool get(JSContext* cx, HandleAtom source, JSString* maybeOpt,
|
||||
MutableHandleRegExpShared shared);
|
||||
RegExpShared* get(JSContext* cx, HandleAtom source, JSString* maybeOpt);
|
||||
|
||||
size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf);
|
||||
};
|
||||
|
|
|
@ -82,9 +82,9 @@ RegExpStatics::executeLazy(JSContext* cx)
|
|||
MOZ_ASSERT(lazyIndex != size_t(-1));
|
||||
|
||||
/* Retrieve or create the RegExpShared in this zone. */
|
||||
RootedRegExpShared shared(cx);
|
||||
RootedAtom source(cx, lazySource);
|
||||
if (!cx->zone()->regExps.get(cx, source, lazyFlags, &shared))
|
||||
RootedRegExpShared shared(cx, cx->zone()->regExps.get(cx, source, lazyFlags));
|
||||
if (!shared)
|
||||
return false;
|
||||
|
||||
/*
|
||||
|
|
|
@ -1489,8 +1489,8 @@ JSStructuredCloneWriter::startWrite(HandleValue v)
|
|||
return false;
|
||||
|
||||
if (cls == ESClass::RegExp) {
|
||||
RootedRegExpShared re(context());
|
||||
if (!RegExpToShared(context(), obj, &re))
|
||||
RegExpShared* re = RegExpToShared(context(), obj);
|
||||
if (!re)
|
||||
return false;
|
||||
return out.writePair(SCTAG_REGEXP_OBJECT, re->getFlags()) &&
|
||||
writeString(SCTAG_STRING, re->getSource());
|
||||
|
|
Загрузка…
Ссылка в новой задаче