Bug 1540105 - Remove some unnecessary uses of PreBarriered<> and tidy Barrier.h r=sfink

This removes a couple of unnecessary uses of Prebarriered<> and improves comments in places where it is required. I removed a bunch of unused typesdefs from Barrier.h and tidied up.
This commit is contained in:
Jon Coppeard 2019-03-29 16:22:37 +00:00
Родитель e336b78caf
Коммит 82ed2af516
9 изменённых файлов: 63 добавлений и 86 удалений

Просмотреть файл

@ -25,6 +25,8 @@ namespace js {
* All values except ropes are hashable as-is.
*/
class HashableValue {
// This is used for map and set keys. We use OrderedHashTableRef to update all
// nursery keys on minor GC, so a post barrier is not required here.
PreBarrieredValue value;
public:

Просмотреть файл

@ -195,37 +195,10 @@
*/
class JSFlatString;
class JSLinearString;
namespace js {
class AccessorShape;
class ArrayObject;
class ArgumentsObject;
class ArrayBufferObjectMaybeShared;
class ArrayBufferObject;
class ArrayBufferViewObject;
class SharedArrayBufferObject;
class BaseShape;
class DebugEnvironmentProxy;
class GlobalObject;
class LazyScript;
class ModuleObject;
class ModuleEnvironmentObject;
class ModuleNamespaceObject;
class NativeObject;
class PlainObject;
class PropertyName;
class SavedFrame;
class EnvironmentObject;
class ScriptSourceObject;
class Shape;
class UnownedBaseShape;
class ObjectGroup;
namespace jit {
class JitCode;
} // namespace jit
#ifdef DEBUG
@ -399,7 +372,10 @@ class WriteBarrieredBase
* PreBarriered only automatically handles pre-barriers. Post-barriers must be
* manually implemented when using this class. GCPtr and HeapPtr should be used
* in all cases that do not require explicit low-level control of moving
* behavior, e.g. for HashMap keys.
* behavior.
*
* This class is useful for example for HashMap keys where automatically
* updating a moved nursery pointer would break the hash table.
*/
template <class T>
class PreBarriered : public WriteBarrieredBase<T> {
@ -911,9 +887,12 @@ struct DefaultHasher<js::ReadBarriered<T>> : js::ReadBarrieredHasher<T> {};
namespace js {
class ArrayObject;
class ArrayBufferObject;
class DebugEnvironmentProxy;
class GlobalObject;
class ObjectGroup;
class PropertyName;
class Scope;
class ScriptSourceObject;
class Shape;
@ -921,63 +900,49 @@ class BaseShape;
class UnownedBaseShape;
class WasmInstanceObject;
class WasmTableObject;
namespace jit {
class JitCode;
} // namespace jit
typedef PreBarriered<JSObject*> PreBarrieredObject;
typedef PreBarriered<JSScript*> PreBarrieredScript;
typedef PreBarriered<jit::JitCode*> PreBarrieredJitCode;
typedef PreBarriered<JSString*> PreBarrieredString;
typedef PreBarriered<JSAtom*> PreBarrieredAtom;
using PreBarrieredObject = PreBarriered<JSObject*>;
using PreBarrieredValue = PreBarriered<Value>;
typedef GCPtr<NativeObject*> GCPtrNativeObject;
typedef GCPtr<ArrayObject*> GCPtrArrayObject;
typedef GCPtr<ArrayBufferObjectMaybeShared*> GCPtrArrayBufferObjectMaybeShared;
typedef GCPtr<ArrayBufferObject*> GCPtrArrayBufferObject;
typedef GCPtr<BaseShape*> GCPtrBaseShape;
typedef GCPtr<JSAtom*> GCPtrAtom;
typedef GCPtr<JSFlatString*> GCPtrFlatString;
typedef GCPtr<JSFunction*> GCPtrFunction;
typedef GCPtr<JSLinearString*> GCPtrLinearString;
typedef GCPtr<JSObject*> GCPtrObject;
typedef GCPtr<JSScript*> GCPtrScript;
typedef GCPtr<JSString*> GCPtrString;
typedef GCPtr<ModuleObject*> GCPtrModuleObject;
typedef GCPtr<ModuleEnvironmentObject*> GCPtrModuleEnvironmentObject;
typedef GCPtr<ModuleNamespaceObject*> GCPtrModuleNamespaceObject;
typedef GCPtr<PlainObject*> GCPtrPlainObject;
typedef GCPtr<PropertyName*> GCPtrPropertyName;
typedef GCPtr<Shape*> GCPtrShape;
typedef GCPtr<UnownedBaseShape*> GCPtrUnownedBaseShape;
typedef GCPtr<jit::JitCode*> GCPtrJitCode;
typedef GCPtr<ObjectGroup*> GCPtrObjectGroup;
typedef GCPtr<Scope*> GCPtrScope;
using GCPtrNativeObject = GCPtr<NativeObject*>;
using GCPtrArrayObject = GCPtr<ArrayObject*>;
using GCPtrBaseShape = GCPtr<BaseShape*>;
using GCPtrAtom = GCPtr<JSAtom*>;
using GCPtrFlatString = GCPtr<JSFlatString*>;
using GCPtrFunction = GCPtr<JSFunction*>;
using GCPtrObject = GCPtr<JSObject*>;
using GCPtrScript = GCPtr<JSScript*>;
using GCPtrString = GCPtr<JSString*>;
using GCPtrShape = GCPtr<Shape*>;
using GCPtrUnownedBaseShape = GCPtr<UnownedBaseShape*>;
using GCPtrObjectGroup = GCPtr<ObjectGroup*>;
using GCPtrScope = GCPtr<Scope*>;
using GCPtrValue = GCPtr<Value>;
using GCPtrId = GCPtr<jsid>;
typedef PreBarriered<Value> PreBarrieredValue;
typedef GCPtr<Value> GCPtrValue;
using ImmutablePropertyNamePtr = ImmutableTenuredPtr<PropertyName*>;
using ImmutableSymbolPtr = ImmutableTenuredPtr<JS::Symbol*>;
typedef PreBarriered<jsid> PreBarrieredId;
typedef GCPtr<jsid> GCPtrId;
using ReadBarrieredDebugEnvironmentProxy =
ReadBarriered<DebugEnvironmentProxy*>;
using ReadBarrieredGlobalObject = ReadBarriered<GlobalObject*>;
using ReadBarrieredObject = ReadBarriered<JSObject*>;
using ReadBarrieredScript = ReadBarriered<JSScript*>;
using ReadBarrieredScriptSourceObject = ReadBarriered<ScriptSourceObject*>;
using ReadBarrieredShape = ReadBarriered<Shape*>;
using ReadBarrieredJitCode = ReadBarriered<jit::JitCode*>;
using ReadBarrieredObjectGroup = ReadBarriered<ObjectGroup*>;
using ReadBarrieredSymbol = ReadBarriered<JS::Symbol*>;
using ReadBarrieredWasmInstanceObject = ReadBarriered<WasmInstanceObject*>;
using ReadBarrieredWasmTableObject = ReadBarriered<WasmTableObject*>;
typedef ImmutableTenuredPtr<PropertyName*> ImmutablePropertyNamePtr;
typedef ImmutableTenuredPtr<JS::Symbol*> ImmutableSymbolPtr;
typedef ReadBarriered<DebugEnvironmentProxy*>
ReadBarrieredDebugEnvironmentProxy;
typedef ReadBarriered<GlobalObject*> ReadBarrieredGlobalObject;
typedef ReadBarriered<JSObject*> ReadBarrieredObject;
typedef ReadBarriered<JSFunction*> ReadBarrieredFunction;
typedef ReadBarriered<JSScript*> ReadBarrieredScript;
typedef ReadBarriered<ScriptSourceObject*> ReadBarrieredScriptSourceObject;
typedef ReadBarriered<Shape*> ReadBarrieredShape;
typedef ReadBarriered<jit::JitCode*> ReadBarrieredJitCode;
typedef ReadBarriered<ObjectGroup*> ReadBarrieredObjectGroup;
typedef ReadBarriered<JS::Symbol*> ReadBarrieredSymbol;
typedef ReadBarriered<WasmInstanceObject*> ReadBarrieredWasmInstanceObject;
typedef ReadBarriered<WasmTableObject*> ReadBarrieredWasmTableObject;
typedef ReadBarriered<Value> ReadBarrieredValue;
using HeapPtrJitCode = HeapPtr<jit::JitCode*>;
using HeapPtrRegExpShared = HeapPtr<RegExpShared*>;
using HeapPtrValue = HeapPtr<Value>;
namespace detail {

Просмотреть файл

@ -150,7 +150,7 @@ class IonIC;
struct IonScript {
private:
// Code pointer containing the actual method.
PreBarrieredJitCode method_;
HeapPtrJitCode method_;
// Entrypoint for OSR, or nullptr.
jsbytecode* osrPc_;
@ -257,6 +257,8 @@ struct IonScript {
return (SnapshotOffset*)&bottomBuffer()[bailoutTable_];
}
PreBarrieredValue* constants() {
// Nursery constants are manually barriered in CodeGenerator::link() so a
// post barrier is not required..
return (PreBarrieredValue*)&bottomBuffer()[constantTable_];
}
const SafepointIndex* safepointIndices() const {

Просмотреть файл

@ -16,6 +16,9 @@
#include "vm/JSScript.h"
namespace js {
class ArgumentsObject;
namespace jit {
typedef void* CalleeToken;

Просмотреть файл

@ -15,6 +15,7 @@
namespace js {
class AbstractFramePtr;
class ArgumentsObject;
class ScriptFrameIter;
namespace jit {

Просмотреть файл

@ -1951,7 +1951,10 @@ class Breakpoint {
BreakpointSite* const site;
private:
/* |handler| is marked unconditionally during minor GC. */
/*
* |handler| is marked unconditionally during minor GC so a post barrier is
* not required.
*/
js::PreBarrieredObject handler;
/**
@ -1969,7 +1972,7 @@ class Breakpoint {
Breakpoint* nextInDebugger();
Breakpoint* nextInSite();
const PreBarrieredObject& getHandler() const { return handler; }
JSObject* getHandler() const { return handler; }
PreBarrieredObject& getHandlerRef() { return handler; }
inline WasmBreakpoint* asWasm();

Просмотреть файл

@ -153,9 +153,9 @@ class RegExpObject : public NativeObject {
sharedRef().init(&shared);
}
PreBarriered<RegExpShared*>& sharedRef() {
HeapPtrRegExpShared& sharedRef() {
auto& ref = NativeObject::privateRef(PRIVATE_SLOT);
return reinterpret_cast<PreBarriered<RegExpShared*>&>(ref);
return reinterpret_cast<HeapPtrRegExpShared&>(ref);
}
static void trace(JSTracer* trc, JSObject* obj);

Просмотреть файл

@ -912,7 +912,7 @@ class Shape : public gc::TenuredCell {
protected:
GCPtrBaseShape base_;
PreBarrieredId propid_;
GCPtrId propid_;
// Flags that are not modified after the Shape is created. Off-thread Ion
// compilation can access the immutableFlags word, so we don't want any
@ -1287,12 +1287,12 @@ class Shape : public gc::TenuredCell {
mutableFlags = (mutableFlags & ~LINEAR_SEARCHES_MASK) | (count + 1);
}
const PreBarrieredId& propid() const {
const GCPtrId& propid() const {
MOZ_ASSERT(!isEmptyShape());
MOZ_ASSERT(!JSID_IS_VOID(propid_));
return propid_;
}
PreBarrieredId& propidRef() {
GCPtrId& propidRef() {
MOZ_ASSERT(!JSID_IS_VOID(propid_));
return propid_;
}

Просмотреть файл

@ -25,6 +25,7 @@
namespace js {
class ArrayBufferObjectMaybeShared;
class GlobalObject;
class StructTypeDescr;
class TypedArrayObject;