зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset b0cc716aa5c0 (bug 1645710) for causing leaks on Browser-chrome
This commit is contained in:
Родитель
c5c364d39b
Коммит
a31f276c5c
|
@ -296,8 +296,6 @@ static_assert(js::jit::CodeAlignment >= MinFirstWordAlignment,
|
|||
"CellFlagBitsReservedForGC should support JIT code");
|
||||
static_assert(js::gc::JSClassAlignBytes >= MinFirstWordAlignment,
|
||||
"CellFlagBitsReservedForGC should support JSClass pointers");
|
||||
static_assert(js::ScopeDataAlignBytes >= MinFirstWordAlignment,
|
||||
"CellFlagBitsReservedForGC should support scope data pointers");
|
||||
|
||||
static_assert(mozilla::ArrayLength(slotsToThingKind) ==
|
||||
SLOTS_TO_THING_KIND_LIMIT,
|
||||
|
|
|
@ -1377,8 +1377,8 @@ void WasmFunctionScope::AbstractData<JSAtom>::trace(JSTracer* trc) {
|
|||
TraceBindingNames(trc, trailingNames.start(), length);
|
||||
}
|
||||
void Scope::traceChildren(JSTracer* trc) {
|
||||
TraceNullableCellHeaderEdge(trc, this, "scope enclosing");
|
||||
TraceNullableEdge(trc, &environmentShape_, "scope env shape");
|
||||
TraceNullableEdge(trc, &enclosingScope_, "scope enclosing");
|
||||
applyScopeDataTyped([trc](auto data) { data->trace(trc); });
|
||||
}
|
||||
inline void js::GCMarker::eagerlyMarkChildren(Scope* scope) {
|
||||
|
|
|
@ -354,12 +354,12 @@ ConcreteScope* Scope::create(
|
|||
template <typename ConcreteScope>
|
||||
inline void Scope::initData(
|
||||
MutableHandle<UniquePtr<typename ConcreteScope::Data>> data) {
|
||||
MOZ_ASSERT(!rawData());
|
||||
MOZ_ASSERT(!data_);
|
||||
|
||||
AddCellMemory(this, SizeOfAllocatedData(data.get().get()),
|
||||
MemoryUse::ScopeData);
|
||||
|
||||
setHeaderPtr(data.get().release());
|
||||
data_ = data.get().release();
|
||||
}
|
||||
|
||||
uint32_t Scope::chainLength() const {
|
||||
|
@ -480,12 +480,12 @@ void Scope::finalize(JSFreeOp* fop) {
|
|||
applyScopeDataTyped([this, fop](auto data) {
|
||||
fop->delete_(this, data, SizeOfAllocatedData(data), MemoryUse::ScopeData);
|
||||
});
|
||||
setHeaderPtr(nullptr);
|
||||
data_ = nullptr;
|
||||
}
|
||||
|
||||
size_t Scope::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
|
||||
if (rawData()) {
|
||||
return mallocSizeOf(rawData());
|
||||
if (data_) {
|
||||
return mallocSizeOf(data_);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -124,16 +124,9 @@ class AbstractBindingName {
|
|||
|
||||
using BindingName = AbstractBindingName<JSAtom>;
|
||||
|
||||
const size_t ScopeDataAlignBytes = size_t(1) << gc::CellFlagBitsReservedForGC;
|
||||
|
||||
/**
|
||||
* Empty base class for scope Data classes to inherit from.
|
||||
*
|
||||
* Scope GC things store a pointer to these in their first word so they must be
|
||||
* suitably aligned to allow storing GC flags in the low bits.
|
||||
*/
|
||||
/** Empty base class for scope Data classes to inherit from. */
|
||||
template <typename NameT>
|
||||
class alignas(ScopeDataAlignBytes) AbstractBaseScopeData {};
|
||||
class AbstractBaseScopeData {};
|
||||
|
||||
using BaseScopeData = AbstractBaseScopeData<JSAtom>;
|
||||
|
||||
|
@ -272,15 +265,15 @@ class WrappedPtrOperations<Scope*, Wrapper> {
|
|||
//
|
||||
// The base class of all Scopes.
|
||||
//
|
||||
class Scope : public gc::TenuredCellWithNonGCPointer<BaseScopeData> {
|
||||
class Scope : public gc::CellWithTenuredGCPointer<gc::TenuredCell, Scope> {
|
||||
friend class GCMarker;
|
||||
friend class frontend::ScopeCreationData;
|
||||
|
||||
protected:
|
||||
// The raw data pointer, stored in the cell header.
|
||||
BaseScopeData* rawData() { return headerPtr(); }
|
||||
const BaseScopeData* rawData() const { return headerPtr(); }
|
||||
public:
|
||||
// The enclosing scope or nullptr, stored in the cell header.
|
||||
Scope* enclosing() const { return headerPtr(); }
|
||||
|
||||
protected:
|
||||
// The kind determines data_.
|
||||
const ScopeKind kind_;
|
||||
|
||||
|
@ -288,14 +281,13 @@ class Scope : public gc::TenuredCellWithNonGCPointer<BaseScopeData> {
|
|||
// EnvironmentObject. Otherwise nullptr.
|
||||
const GCPtrShape environmentShape_;
|
||||
|
||||
// The enclosing scope or nullptr.
|
||||
GCPtrScope enclosingScope_;
|
||||
BaseScopeData* data_;
|
||||
|
||||
Scope(ScopeKind kind, Scope* enclosing, Shape* environmentShape)
|
||||
: TenuredCellWithNonGCPointer(nullptr),
|
||||
: CellWithTenuredGCPointer(enclosing),
|
||||
kind_(kind),
|
||||
environmentShape_(environmentShape),
|
||||
enclosingScope_(enclosing) {}
|
||||
data_(nullptr) {}
|
||||
|
||||
static Scope* create(JSContext* cx, ScopeKind kind, HandleScope enclosing,
|
||||
HandleShape envShape);
|
||||
|
@ -343,8 +335,6 @@ class Scope : public gc::TenuredCellWithNonGCPointer<BaseScopeData> {
|
|||
|
||||
Shape* environmentShape() const { return environmentShape_; }
|
||||
|
||||
Scope* enclosing() const { return enclosingScope_; }
|
||||
|
||||
static bool hasEnvironment(ScopeKind kind, bool environmentShape) {
|
||||
switch (kind) {
|
||||
case ScopeKind::With:
|
||||
|
@ -477,8 +467,9 @@ class LexicalScope : public Scope {
|
|||
MutableHandle<UniquePtr<Data>> data,
|
||||
ShapeType envShape);
|
||||
|
||||
Data& data() { return *static_cast<Data*>(rawData()); }
|
||||
const Data& data() const { return *static_cast<const Data*>(rawData()); }
|
||||
Data& data() { return *static_cast<Data*>(data_); }
|
||||
|
||||
const Data& data() const { return *static_cast<Data*>(data_); }
|
||||
|
||||
static uint32_t nextFrameSlot(const AbstractScopePtr& scope);
|
||||
|
||||
|
@ -617,9 +608,9 @@ class FunctionScope : public Scope {
|
|||
HandleFunction fun,
|
||||
HandleScope enclosing);
|
||||
|
||||
Data& data() { return *static_cast<Data*>(rawData()); }
|
||||
Data& data() { return *static_cast<Data*>(data_); }
|
||||
|
||||
const Data& data() const { return *static_cast<const Data*>(rawData()); }
|
||||
const Data& data() const { return *static_cast<Data*>(data_); }
|
||||
|
||||
public:
|
||||
uint32_t nextFrameSlot() const { return data().nextFrameSlot; }
|
||||
|
@ -702,9 +693,9 @@ class VarScope : public Scope {
|
|||
JSContext* cx,
|
||||
MutableHandle<frontend::EnvironmentShapeCreationData> envShape,
|
||||
bool needsEnvironment);
|
||||
Data& data() { return *static_cast<Data*>(rawData()); }
|
||||
Data& data() { return *static_cast<Data*>(data_); }
|
||||
|
||||
const Data& data() const { return *static_cast<const Data*>(rawData()); }
|
||||
const Data& data() const { return *static_cast<Data*>(data_); }
|
||||
|
||||
public:
|
||||
uint32_t firstFrameSlot() const;
|
||||
|
@ -786,9 +777,9 @@ class GlobalScope : public Scope {
|
|||
static GlobalScope* createWithData(JSContext* cx, ScopeKind kind,
|
||||
MutableHandle<UniquePtr<Data>> data);
|
||||
|
||||
Data& data() { return *static_cast<Data*>(rawData()); }
|
||||
Data& data() { return *static_cast<Data*>(data_); }
|
||||
|
||||
const Data& data() const { return *static_cast<const Data*>(rawData()); }
|
||||
const Data& data() const { return *static_cast<Data*>(data_); }
|
||||
|
||||
public:
|
||||
bool isSyntactic() const { return kind() != ScopeKind::NonSyntactic; }
|
||||
|
@ -885,9 +876,9 @@ class EvalScope : public Scope {
|
|||
JSContext* cx,
|
||||
MutableHandle<frontend::EnvironmentShapeCreationData> envShape,
|
||||
ScopeKind scopeKind);
|
||||
Data& data() { return *static_cast<Data*>(rawData()); }
|
||||
Data& data() { return *static_cast<Data*>(data_); }
|
||||
|
||||
const Data& data() const { return *static_cast<const Data*>(rawData()); }
|
||||
const Data& data() const { return *static_cast<Data*>(data_); }
|
||||
|
||||
public:
|
||||
// Starting a scope, the nearest var scope that a direct eval can
|
||||
|
@ -986,9 +977,9 @@ class ModuleScope : public Scope {
|
|||
JSContext* cx,
|
||||
MutableHandle<frontend::EnvironmentShapeCreationData> envShape);
|
||||
|
||||
Data& data() { return *static_cast<Data*>(rawData()); }
|
||||
Data& data() { return *static_cast<Data*>(data_); }
|
||||
|
||||
const Data& data() const { return *static_cast<const Data*>(rawData()); }
|
||||
const Data& data() const { return *static_cast<Data*>(data_); }
|
||||
|
||||
public:
|
||||
uint32_t nextFrameSlot() const { return data().nextFrameSlot; }
|
||||
|
@ -1035,9 +1026,9 @@ class WasmInstanceScope : public Scope {
|
|||
static WasmInstanceScope* create(JSContext* cx, WasmInstanceObject* instance);
|
||||
|
||||
private:
|
||||
Data& data() { return *static_cast<Data*>(rawData()); }
|
||||
Data& data() { return *static_cast<Data*>(data_); }
|
||||
|
||||
const Data& data() const { return *static_cast<const Data*>(rawData()); }
|
||||
const Data& data() const { return *static_cast<Data*>(data_); }
|
||||
|
||||
public:
|
||||
WasmInstanceObject* instance() const { return data().instance; }
|
||||
|
@ -1087,9 +1078,9 @@ class WasmFunctionScope : public Scope {
|
|||
uint32_t funcIndex);
|
||||
|
||||
private:
|
||||
Data& data() { return *static_cast<Data*>(rawData()); }
|
||||
Data& data() { return *static_cast<Data*>(data_); }
|
||||
|
||||
const Data& data() const { return *static_cast<const Data*>(rawData()); }
|
||||
const Data& data() const { return *static_cast<Data*>(data_); }
|
||||
|
||||
public:
|
||||
static Shape* getEmptyEnvironmentShape(JSContext* cx);
|
||||
|
|
Загрузка…
Ссылка в новой задаче