mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 07:48:38 +09:00
1320408 - Part 23: Change RegExpObject::{getShared,createShared,dumpBytecode} to static method.
This commit is contained in:
parent
317605333c
commit
8a42a64748
6 changed files with 28 additions and 26 deletions
|
|
@ -140,12 +140,12 @@ ExecuteRegExpImpl(JSContext* cx, RegExpStatics* res, RegExpShared& re, HandleLin
|
|||
|
||||
/* Legacy ExecuteRegExp behavior is baked into the JSAPI. */
|
||||
bool
|
||||
js::ExecuteRegExpLegacy(JSContext* cx, RegExpStatics* res, RegExpObject& reobj,
|
||||
js::ExecuteRegExpLegacy(JSContext* cx, RegExpStatics* res, Handle<RegExpObject*> reobj,
|
||||
HandleLinearString input, size_t* lastIndex, bool test,
|
||||
MutableHandleValue rval)
|
||||
{
|
||||
RegExpGuard shared(cx);
|
||||
if (!reobj.getShared(cx, &shared))
|
||||
if (!RegExpObject::getShared(cx, reobj, &shared))
|
||||
return false;
|
||||
|
||||
ScopedMatchPairs matches(&cx->tempLifoAlloc());
|
||||
|
|
@ -918,7 +918,7 @@ ExecuteRegExp(JSContext* cx, HandleObject regexp, HandleString string,
|
|||
Rooted<RegExpObject*> reobj(cx, ®exp->as<RegExpObject>());
|
||||
|
||||
RegExpGuard re(cx);
|
||||
if (!reobj->getShared(cx, &re))
|
||||
if (!RegExpObject::getShared(cx, reobj, &re))
|
||||
return RegExpRunStatus_Error;
|
||||
|
||||
RegExpStatics* res;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ enum RegExpStaticsUpdate { UpdateRegExpStatics, DontUpdateRegExpStatics };
|
|||
* |chars| and |length|.
|
||||
*/
|
||||
MOZ_MUST_USE bool
|
||||
ExecuteRegExpLegacy(JSContext* cx, RegExpStatics* res, RegExpObject& reobj,
|
||||
ExecuteRegExpLegacy(JSContext* cx, RegExpStatics* res, Handle<RegExpObject*> reobj,
|
||||
HandleLinearString input, size_t* lastIndex, bool test,
|
||||
MutableHandleValue rval);
|
||||
|
||||
|
|
|
|||
|
|
@ -4024,7 +4024,7 @@ DisRegExp(JSContext* cx, unsigned argc, Value* vp)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!reobj->dumpBytecode(cx, match_only, input))
|
||||
if (!RegExpObject::dumpBytecode(cx, reobj, match_only, input))
|
||||
return false;
|
||||
|
||||
args.rval().setUndefined();
|
||||
|
|
|
|||
|
|
@ -6054,7 +6054,7 @@ JS_ExecuteRegExp(JSContext* cx, HandleObject obj, HandleObject reobj, char16_t*
|
|||
if (!input)
|
||||
return false;
|
||||
|
||||
return ExecuteRegExpLegacy(cx, res, reobj->as<RegExpObject>(), input, indexp, test, rval);
|
||||
return ExecuteRegExpLegacy(cx, res, reobj.as<RegExpObject>(), input, indexp, test, rval);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
|
|
@ -6068,7 +6068,7 @@ JS_ExecuteRegExpNoStatics(JSContext* cx, HandleObject obj, char16_t* chars, size
|
|||
if (!input)
|
||||
return false;
|
||||
|
||||
return ExecuteRegExpLegacy(cx, nullptr, obj->as<RegExpObject>(), input, indexp, test,
|
||||
return ExecuteRegExpLegacy(cx, nullptr, obj.as<RegExpObject>(), input, indexp, test,
|
||||
rval);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -129,10 +129,10 @@ RegExpSharedReadBarrier(JSContext* cx, RegExpShared* shared)
|
|||
shared->unmarkGray();
|
||||
}
|
||||
|
||||
bool
|
||||
RegExpObject::getShared(JSContext* cx, RegExpGuard* g)
|
||||
/* static */ bool
|
||||
RegExpObject::getShared(JSContext* cx, Handle<RegExpObject*> regexp, RegExpGuard* g)
|
||||
{
|
||||
if (RegExpShared* shared = maybeShared()) {
|
||||
if (RegExpShared* shared = regexp->maybeShared()) {
|
||||
// Fetching a RegExpShared from an object requires a read
|
||||
// barrier, as the shared pointer might be weak.
|
||||
RegExpSharedReadBarrier(cx, shared);
|
||||
|
|
@ -141,7 +141,7 @@ RegExpObject::getShared(JSContext* cx, RegExpGuard* g)
|
|||
return true;
|
||||
}
|
||||
|
||||
return createShared(cx, g);
|
||||
return createShared(cx, regexp, g);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
|
|
@ -279,16 +279,14 @@ RegExpObject::create(ExclusiveContext* cx, HandleAtom source, RegExpFlag flags,
|
|||
return regexp;
|
||||
}
|
||||
|
||||
bool
|
||||
RegExpObject::createShared(JSContext* cx, RegExpGuard* g)
|
||||
/* static */ bool
|
||||
RegExpObject::createShared(JSContext* cx, Handle<RegExpObject*> regexp, RegExpGuard* g)
|
||||
{
|
||||
Rooted<RegExpObject*> self(cx, this);
|
||||
|
||||
MOZ_ASSERT(!maybeShared());
|
||||
if (!cx->compartment()->regExps.get(cx, getSource(), getFlags(), g))
|
||||
MOZ_ASSERT(!regexp->maybeShared());
|
||||
if (!cx->compartment()->regExps.get(cx, regexp->getSource(), regexp->getFlags(), g))
|
||||
return false;
|
||||
|
||||
self->setShared(**g);
|
||||
regexp->setShared(**g);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -892,11 +890,12 @@ RegExpShared::dumpBytecode(JSContext* cx, bool match_only, HandleLinearString in
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
RegExpObject::dumpBytecode(JSContext* cx, bool match_only, HandleLinearString input)
|
||||
/* static */ bool
|
||||
RegExpObject::dumpBytecode(JSContext* cx, Handle<RegExpObject*> regexp,
|
||||
bool match_only, HandleLinearString input)
|
||||
{
|
||||
RegExpGuard g(cx);
|
||||
if (!getShared(cx, &g))
|
||||
if (!getShared(cx, regexp, &g))
|
||||
return false;
|
||||
|
||||
return g.re()->dumpBytecode(cx, match_only, input);
|
||||
|
|
@ -1431,7 +1430,7 @@ js::CloneRegExpObject(JSContext* cx, JSObject* obj_)
|
|||
Rooted<JSAtom*> source(cx, regex->getSource());
|
||||
|
||||
RegExpGuard g(cx);
|
||||
if (!regex->getShared(cx, &g))
|
||||
if (!RegExpObject::getShared(cx, regex, &g))
|
||||
return nullptr;
|
||||
|
||||
clone->initAndZeroLastIndex(source, g->getFlags(), cx);
|
||||
|
|
|
|||
|
|
@ -483,7 +483,8 @@ class RegExpObject : public NativeObject
|
|||
|
||||
static bool isOriginalFlagGetter(JSNative native, RegExpFlag* mask);
|
||||
|
||||
bool getShared(JSContext* cx, RegExpGuard* g);
|
||||
static MOZ_MUST_USE bool getShared(JSContext* cx, Handle<RegExpObject*> regexp,
|
||||
RegExpGuard* g);
|
||||
|
||||
void setShared(RegExpShared& shared) {
|
||||
MOZ_ASSERT(!maybeShared());
|
||||
|
|
@ -500,7 +501,8 @@ class RegExpObject : public NativeObject
|
|||
void initAndZeroLastIndex(HandleAtom source, RegExpFlag flags, ExclusiveContext* cx);
|
||||
|
||||
#ifdef DEBUG
|
||||
bool dumpBytecode(JSContext* cx, bool match_only, HandleLinearString input);
|
||||
static MOZ_MUST_USE bool dumpBytecode(JSContext* cx, Handle<RegExpObject*> regexp,
|
||||
bool match_only, HandleLinearString input);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
|
@ -508,7 +510,8 @@ class RegExpObject : public NativeObject
|
|||
* Precondition: the syntax for |source| has already been validated.
|
||||
* Side effect: sets the private field.
|
||||
*/
|
||||
bool createShared(JSContext* cx, RegExpGuard* g);
|
||||
static MOZ_MUST_USE bool createShared(JSContext* cx, Handle<RegExpObject*> regexp,
|
||||
RegExpGuard* g);
|
||||
RegExpShared* maybeShared() const {
|
||||
return static_cast<RegExpShared*>(NativeObject::getPrivate(PRIVATE_SLOT));
|
||||
}
|
||||
|
|
@ -531,7 +534,7 @@ inline bool
|
|||
RegExpToShared(JSContext* cx, HandleObject obj, RegExpGuard* g)
|
||||
{
|
||||
if (obj->is<RegExpObject>())
|
||||
return obj->as<RegExpObject>().getShared(cx, g);
|
||||
return RegExpObject::getShared(cx, obj.as<RegExpObject>(), g);
|
||||
|
||||
return Proxy::regexp_toShared(cx, obj, g);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue