Merge remote-tracking branch 'origin/master' into media-works

This commit is contained in:
2021-07-27 16:05:29 +08:00
8 changed files with 25 additions and 45 deletions
+1 -1
View File
@@ -132,7 +132,7 @@ class MutableTraceableVectorOperations
vec().infallibleAppend(aBegin, aLength);
}
void popBack() { vec().popBack(); }
T popCopy() { return vec().podCopy(); }
T popCopy() { return vec().popCopy(); }
template<typename U> T* insert(T* aP, U&& aVal) {
return vec().insert(aP, mozilla::Forward<U>(aVal));
}
+11 -15
View File
@@ -10,39 +10,35 @@
#include "jsapi.h"
#include "NamespaceImports.h"
#include "gc/Tracer.h"
#include "js/Id.h"
#include "js/TraceableVector.h"
namespace js {
struct IdValuePair
{
jsid id;
Value value;
jsid id;
IdValuePair()
: id(JSID_EMPTY), value(UndefinedValue())
: value(UndefinedValue()), id(JSID_EMPTY)
{}
explicit IdValuePair(jsid idArg)
: id(idArg), value(UndefinedValue())
: value(UndefinedValue()), id(idArg)
{}
IdValuePair(jsid idArg, Value valueArg)
: id(idArg), value(valueArg)
: value(valueArg), id(idArg)
{}
};
class MOZ_STACK_CLASS AutoIdValueVector : public JS::AutoVectorRooterBase<IdValuePair>
{
public:
explicit AutoIdValueVector(ContextFriendFields* cx
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: AutoVectorRooterBase<IdValuePair>(cx, IDVALVECTOR)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
void trace(JSTracer* trc) {
TraceRoot(trc, &value, "IdValuePair::value");
TraceRoot(trc, &id, "IdValuePair::id");
}
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
using IdValueVector = TraceableVector<IdValuePair>;
} /* namespace js */
#endif /* ds_IdValuePair_h */
+1 -1
View File
@@ -4832,7 +4832,7 @@ ParseNode::getConstantValue(ExclusiveContext* cx, AllowConstantObjects allowObje
}
MOZ_ASSERT(allowObjects == AllowObjects);
AutoIdValueVector properties(cx);
Rooted<IdValueVector> properties(cx, IdValueVector(cx));
RootedValue value(cx), idvalue(cx);
for (ParseNode* pn = pn_head; pn; pn = pn->pn_next) {
-15
View File
@@ -152,27 +152,12 @@ AutoGCRooter::trace(JSTracer* trc)
return;
}
case IDVALVECTOR: {
AutoIdValueVector::VectorImpl& vector = static_cast<AutoIdValueVector*>(this)->vector;
for (size_t i = 0; i < vector.length(); i++) {
TraceRoot(trc, &vector[i].id, "js::AutoIdValueVector id");
TraceRoot(trc, &vector[i].value, "js::AutoIdValueVector value");
}
return;
}
case OBJVECTOR: {
AutoObjectVector::VectorImpl& vector = static_cast<AutoObjectVector*>(this)->vector;
TraceRootRange(trc, vector.length(), vector.begin(), "JS::AutoObjectVector.vector");
return;
}
case STRINGVECTOR: {
AutoStringVector::VectorImpl& vector = static_cast<AutoStringVector*>(this)->vector;
TraceRootRange(trc, vector.length(), vector.begin(), "js::AutoStringVector.vector");
return;
}
case NAMEVECTOR: {
AutoNameVector::VectorImpl& vector = static_cast<AutoNameVector*>(this)->vector;
TraceRootRange(trc, vector.length(), vector.begin(), "js::AutoNameVector.vector");
+4 -3
View File
@@ -505,10 +505,11 @@ struct AutoResolving {
/*
* Enumerate all contexts in a runtime.
*/
class ContextIter {
class ContextIter
{
JSContext* iter;
public:
public:
explicit ContextIter(JSRuntime* rt) {
iter = rt->contextList.getFirst();
}
@@ -663,10 +664,10 @@ CheckForInterrupt(JSContext* cx)
/************************************************************************/
typedef JS::AutoVectorRooter<JSString*> AutoStringVector;
typedef JS::AutoVectorRooter<PropertyName*> AutoPropertyNameVector;
using ShapeVector = js::TraceableVector<Shape*>;
using StringVector = js::TraceableVector<JSString*>;
/* AutoArrayRooter roots an external array of Values. */
class AutoArrayRooter : private JS::AutoGCRooter
+6 -5
View File
@@ -1227,7 +1227,8 @@ GetScriptArrayObjectElements(JSContext* cx, HandleObject obj, AutoValueVector& v
}
static bool
GetScriptPlainObjectProperties(JSContext* cx, HandleObject obj, AutoIdValueVector& properties)
GetScriptPlainObjectProperties(JSContext* cx, HandleObject obj,
MutableHandle<IdValueVector> properties)
{
if (obj->is<PlainObject>()) {
PlainObject* nobj = &obj->as<PlainObject>();
@@ -1313,8 +1314,8 @@ js::DeepCloneObjectLiteral(JSContext* cx, HandleObject obj, NewObjectKind newKin
arrayKind);
}
AutoIdValueVector properties(cx);
if (!GetScriptPlainObjectProperties(cx, obj, properties))
Rooted<IdValueVector> properties(cx, IdValueVector(cx));
if (!GetScriptPlainObjectProperties(cx, obj, &properties))
return nullptr;
for (size_t i = 0; i < properties.length(); i++) {
@@ -1464,8 +1465,8 @@ js::XDRObjectLiteral(XDRState<mode>* xdr, MutableHandleObject obj)
}
// Code the properties in the object.
AutoIdValueVector properties(cx);
if (mode == XDR_ENCODE && !GetScriptPlainObjectProperties(cx, obj, properties))
Rooted<IdValueVector> properties(cx, IdValueVector(cx));
if (mode == XDR_ENCODE && !GetScriptPlainObjectProperties(cx, obj, &properties))
return false;
uint32_t nproperties = properties.length();
-3
View File
@@ -222,9 +222,7 @@ class JS_PUBLIC_API(AutoGCRooter)
IDARRAY = -6, /* js::AutoIdArray */
VALVECTOR = -10, /* js::AutoValueVector */
IDVECTOR = -11, /* js::AutoIdVector */
IDVALVECTOR = -12, /* js::AutoIdValueVector */
OBJVECTOR = -14, /* js::AutoObjectVector */
STRINGVECTOR =-15, /* js::AutoStringVector */
SCRIPTVECTOR =-16, /* js::AutoScriptVector */
NAMEVECTOR = -17, /* js::AutoNameVector */
HASHABLEVALUE=-18, /* js::HashableValue */
@@ -239,7 +237,6 @@ class JS_PUBLIC_API(AutoGCRooter)
static ptrdiff_t GetTag(const jsid& id) { return IDVECTOR; }
static ptrdiff_t GetTag(JSObject* obj) { return OBJVECTOR; }
static ptrdiff_t GetTag(JSScript* script) { return SCRIPTVECTOR; }
static ptrdiff_t GetTag(JSString* string) { return STRINGVECTOR; }
private:
AutoGCRooter ** const stackTop;
+2 -2
View File
@@ -1348,7 +1348,7 @@ class StringSegmentRange
{
// If malloc() shows up in any profiles from this vector, we can add a new
// StackAllocPolicy which stashes a reusable freed-at-gc buffer in the cx.
AutoStringVector stack;
Rooted<StringVector> stack;
RootedLinearString cur;
bool settle(JSString* str) {
@@ -1364,7 +1364,7 @@ class StringSegmentRange
public:
explicit StringSegmentRange(JSContext* cx)
: stack(cx), cur(cx)
: stack(cx, StringVector(cx)), cur(cx)
{}
MOZ_WARN_UNUSED_RESULT bool init(JSString* str) {