Bug 1143521 - Remove IsPoisonedPtr stuff, r=sfink.

This commit is contained in:
Brian Hackett 2015-03-18 18:01:35 -07:00
parent 7afd45ea42
commit a054a9a07e
22 changed files with 3 additions and 138 deletions

View File

@ -91,11 +91,6 @@ struct GCMethods<nsXBLMaybeCompiled<UncompiledT> >
static nsXBLMaybeCompiled<UncompiledT> initial() { return nsXBLMaybeCompiled<UncompiledT>(); }
static bool poisoned(nsXBLMaybeCompiled<UncompiledT> function)
{
return function.IsCompiled() && Base::poisoned(function.GetJSFunction());
}
static bool needsPostBarrier(nsXBLMaybeCompiled<UncompiledT> function)
{
return function.IsCompiled() && Base::needsPostBarrier(function.GetJSFunction());

View File

@ -539,7 +539,6 @@ struct PointerHasher
{
typedef Key Lookup;
static HashNumber hash(const Lookup &l) {
MOZ_ASSERT(!JS::IsPoisonedPtr(l));
size_t word = reinterpret_cast<size_t>(l) >> zeroBits;
static_assert(sizeof(HashNumber) == 4,
"subsequent code assumes a four-byte hash");
@ -553,8 +552,6 @@ struct PointerHasher
#endif
}
static bool match(const Key &k, const Lookup &l) {
MOZ_ASSERT(!JS::IsPoisonedPtr(k));
MOZ_ASSERT(!JS::IsPoisonedPtr(l));
return k == l;
}
static void rekey(Key &k, const Key& newKey) {

View File

@ -126,7 +126,6 @@ SYMBOL_TO_JSID(JS::Symbol *sym)
MOZ_ASSERT(sym != nullptr);
MOZ_ASSERT((size_t(sym) & JSID_TYPE_MASK) == 0);
MOZ_ASSERT(!js::gc::IsInsideNursery(reinterpret_cast<js::gc::Cell *>(sym)));
MOZ_ASSERT(!JS::IsPoisonedPtr(sym));
JSID_BITS(id) = (size_t(sym) | JSID_TYPE_SYMBOL);
return id;
}
@ -169,20 +168,9 @@ extern JS_PUBLIC_DATA(const JS::HandleId) JSID_EMPTYHANDLE;
namespace js {
inline bool
IsPoisonedId(jsid id)
{
if (JSID_IS_STRING(id))
return JS::IsPoisonedPtr(JSID_TO_STRING(id));
if (JSID_IS_SYMBOL(id))
return JS::IsPoisonedPtr(JSID_TO_SYMBOL(id));
return false;
}
template <> struct GCMethods<jsid>
{
static jsid initial() { return JSID_VOID; }
static bool poisoned(jsid id) { return IsPoisonedId(id); }
static bool needsPostBarrier(jsid id) { return false; }
static void postBarrier(jsid *idp) {}
static void relocate(jsid *idp) {}

View File

@ -282,14 +282,12 @@ class Heap : public js::HeapBase<T>
private:
void init(T newPtr) {
MOZ_ASSERT(!js::GCMethods<T>::poisoned(newPtr));
ptr = newPtr;
if (js::GCMethods<T>::needsPostBarrier(ptr))
post();
}
void set(T newPtr) {
MOZ_ASSERT(!js::GCMethods<T>::poisoned(newPtr));
if (js::GCMethods<T>::needsPostBarrier(newPtr)) {
ptr = newPtr;
post();
@ -362,7 +360,6 @@ class TenuredHeap : public js::HeapBase<T>
void setPtr(T newPtr) {
MOZ_ASSERT((reinterpret_cast<uintptr_t>(newPtr) & flagsMask) == 0);
MOZ_ASSERT(!js::GCMethods<T>::poisoned(newPtr));
if (newPtr)
AssertGCThingMustBeTenured(newPtr);
bits = (bits & flagsMask) | reinterpret_cast<uintptr_t>(newPtr);
@ -526,7 +523,6 @@ class MOZ_STACK_CLASS MutableHandle : public js::MutableHandleBase<T>
public:
void set(T v) {
MOZ_ASSERT(!js::GCMethods<T>::poisoned(v));
*ptr = v;
}
@ -642,7 +638,6 @@ template <typename T>
struct GCMethods<T *>
{
static T *initial() { return nullptr; }
static bool poisoned(T *v) { return JS::IsPoisonedPtr(v); }
static bool needsPostBarrier(T *v) { return false; }
static void postBarrier(T **vp) {}
static void relocate(T **vp) {}
@ -652,7 +647,6 @@ template <>
struct GCMethods<JSObject *>
{
static JSObject *initial() { return nullptr; }
static bool poisoned(JSObject *v) { return JS::IsPoisonedPtr(v); }
static gc::Cell *asGCThingOrNull(JSObject *v) {
if (!v)
return nullptr;
@ -674,7 +668,6 @@ template <>
struct GCMethods<JSFunction *>
{
static JSFunction *initial() { return nullptr; }
static bool poisoned(JSFunction *v) { return JS::IsPoisonedPtr(v); }
static bool needsPostBarrier(JSFunction *v) {
return v != nullptr && gc::IsInsideNursery(reinterpret_cast<gc::Cell *>(v));
}
@ -708,8 +701,6 @@ class MOZ_STACK_CLASS Rooted : public js::RootedBase<T>
this->stack = &cx->thingGCRooters[kind];
this->prev = *stack;
*stack = reinterpret_cast<Rooted<void*>*>(this);
MOZ_ASSERT(!js::GCMethods<T>::poisoned(ptr));
}
public:
@ -789,7 +780,6 @@ class MOZ_STACK_CLASS Rooted : public js::RootedBase<T>
* interchangeably with a MutableHandleValue.
*/
void set(T value) {
MOZ_ASSERT(!js::GCMethods<T>::poisoned(value));
ptr = value;
}
@ -889,7 +879,6 @@ class FakeRooted : public RootedBase<T>
T ptr;
void set(const T &value) {
MOZ_ASSERT(!GCMethods<T>::poisoned(value));
ptr = value;
}
@ -912,7 +901,6 @@ class FakeMutableHandle : public js::MutableHandleBase<T>
}
void set(T v) {
MOZ_ASSERT(!js::GCMethods<T>::poisoned(v));
*ptr = v;
}
@ -1158,7 +1146,6 @@ class PersistentRooted : public js::PersistentRootedBase<T>,
private:
void set(T value) {
MOZ_ASSERT(initialized());
MOZ_ASSERT(!js::GCMethods<T>::poisoned(value));
ptr = value;
}

View File

@ -395,40 +395,6 @@ ScrambleHashCode(HashNumber h)
} /* namespace js */
namespace JS {
/*
* Methods for poisoning GC heap pointer words and checking for poisoned words.
* These are in this file for use in Value methods and so forth.
*
* If the moving GC hazard analysis is in use and detects a non-rooted stack
* pointer to a GC thing, one byte of that pointer is poisoned to refer to an
* invalid location. For both 32 bit and 64 bit systems, the fourth byte of the
* pointer is overwritten, to reduce the likelihood of accidentally changing
* a live integer value.
*/
inline void PoisonPtr(void *v)
{
#if defined(JSGC_ROOT_ANALYSIS) && defined(JS_DEBUG)
uint8_t *ptr = (uint8_t *) v + 3;
*ptr = JS_FREE_PATTERN;
#endif
}
template <typename T>
inline bool IsPoisonedPtr(T *v)
{
#if defined(JSGC_ROOT_ANALYSIS) && defined(JS_DEBUG)
uint32_t mask = uintptr_t(v) & 0xff000000;
return mask == uint32_t(JS_FREE_PATTERN << 24);
#else
return false;
#endif
}
}
/* sixgill annotation defines */
#ifndef HAVE_STATIC_ANNOTATIONS
# define HAVE_STATIC_ANNOTATIONS

View File

@ -1043,17 +1043,14 @@ class Value
}
void setString(JSString *str) {
MOZ_ASSERT(!IsPoisonedPtr(str));
data = STRING_TO_JSVAL_IMPL(str);
}
void setSymbol(JS::Symbol *sym) {
MOZ_ASSERT(!IsPoisonedPtr(sym));
data = SYMBOL_TO_JSVAL_IMPL(sym);
}
void setObject(JSObject &obj) {
MOZ_ASSERT(!IsPoisonedPtr(&obj));
data = OBJECT_TO_JSVAL_IMPL(&obj);
}
@ -1641,17 +1638,11 @@ namespace js {
template <> struct GCMethods<const JS::Value>
{
static JS::Value initial() { return JS::UndefinedValue(); }
static bool poisoned(const JS::Value &v) {
return v.isMarkable() && JS::IsPoisonedPtr(v.toGCThing());
}
};
template <> struct GCMethods<JS::Value>
{
static JS::Value initial() { return JS::UndefinedValue(); }
static bool poisoned(const JS::Value &v) {
return v.isMarkable() && JS::IsPoisonedPtr(v.toGCThing());
}
static gc::Cell *asGCThingOrNull(const JS::Value &v) {
return v.isMarkable() ? v.toGCThing() : nullptr;
}
@ -1890,12 +1881,6 @@ IMPL_TO_JSVAL(jsval_layout l)
namespace JS {
inline bool
IsPoisonedValue(const Value &v)
{
return js::GCMethods<Value>::poisoned(v);
}
#ifdef JS_DEBUG
namespace detail {

View File

@ -56,7 +56,6 @@ using JS::BooleanValue;
using JS::DoubleValue;
using JS::Float32Value;
using JS::Int32Value;
using JS::IsPoisonedValue;
using JS::MagicValue;
using JS::NullValue;
using JS::NumberValue;
@ -67,8 +66,6 @@ using JS::PrivateValue;
using JS::StringValue;
using JS::UndefinedValue;
using JS::IsPoisonedPtr;
using JS::Latin1Char;
using JS::Latin1Chars;
using JS::Latin1CharsZ;

View File

@ -565,7 +565,7 @@ template <typename ParseHandler>
ObjectBox *
Parser<ParseHandler>::newObjectBox(JSObject *obj)
{
MOZ_ASSERT(obj && !IsPoisonedPtr(obj));
MOZ_ASSERT(obj);
/*
* We use JSContext.tempLifoAlloc to allocate parsed objects and place them
@ -660,7 +660,7 @@ FunctionBox *
Parser<ParseHandler>::newFunctionBox(Node fn, JSFunction *fun, ParseContext<ParseHandler> *outerpc,
Directives inheritedDirectives, GeneratorKind generatorKind)
{
MOZ_ASSERT(fun && !IsPoisonedPtr(fun));
MOZ_ASSERT(fun);
/*
* We use JSContext.tempLifoAlloc to allocate parsed objects and place them

View File

@ -115,7 +115,6 @@ struct Token
void setName(PropertyName *name) {
MOZ_ASSERT(type == TOK_NAME);
MOZ_ASSERT(!IsPoisonedPtr(name));
u.name = name;
}
@ -123,7 +122,6 @@ struct Token
MOZ_ASSERT(type == TOK_STRING ||
type == TOK_TEMPLATE_HEAD ||
type == TOK_NO_SUBS_TEMPLATE);
MOZ_ASSERT(!IsPoisonedPtr(atom));
u.atom = atom;
}

View File

@ -427,7 +427,6 @@ class BarrieredBase : public BarrieredBaseMixins<T>
public:
void init(T v) {
MOZ_ASSERT(!GCMethods<T>::poisoned(v));
this->value = v;
}
@ -492,7 +491,6 @@ class PreBarriered : public BarrieredBase<T>
private:
void set(const T &v) {
this->pre();
MOZ_ASSERT(!GCMethods<T>::poisoned(v));
this->value = v;
}
};
@ -518,7 +516,6 @@ class HeapPtr : public BarrieredBase<T>
explicit HeapPtr(const HeapPtr<T> &v) : BarrieredBase<T>(v) { post(); }
void init(T v) {
MOZ_ASSERT(!GCMethods<T>::poisoned(v));
this->value = v;
post();
}
@ -538,7 +535,6 @@ class HeapPtr : public BarrieredBase<T>
private:
void set(const T &v) {
this->pre();
MOZ_ASSERT(!GCMethods<T>::poisoned(v));
this->value = v;
post();
}
@ -625,7 +621,6 @@ class RelocatablePtr : public BarrieredBase<T>
protected:
void set(const T &v) {
this->pre();
MOZ_ASSERT(!GCMethods<T>::poisoned(v));
if (GCMethods<T>::needsPostBarrier(v)) {
this->value = v;
post();
@ -840,14 +835,12 @@ class HeapSlot : public BarrieredBase<Value>
explicit HeapSlot(NativeObject *obj, Kind kind, uint32_t slot, const Value &v)
: BarrieredBase<Value>(v)
{
MOZ_ASSERT(!IsPoisonedValue(v));
post(obj, kind, slot, v);
}
explicit HeapSlot(NativeObject *obj, Kind kind, uint32_t slot, const HeapSlot &s)
: BarrieredBase<Value>(s.value)
{
MOZ_ASSERT(!IsPoisonedValue(s.value));
post(obj, kind, slot, s);
}
@ -868,7 +861,6 @@ class HeapSlot : public BarrieredBase<Value>
void set(NativeObject *owner, Kind kind, uint32_t slot, const Value &v) {
MOZ_ASSERT(preconditionForSet(owner, kind, slot));
MOZ_ASSERT(!IsPoisonedValue(v));
pre();
value = v;
post(owner, kind, slot, v);
@ -876,7 +868,6 @@ class HeapSlot : public BarrieredBase<Value>
void set(Zone *zone, NativeObject *owner, Kind kind, uint32_t slot, const Value &v) {
MOZ_ASSERT(preconditionForSet(zone, owner, kind, slot));
MOZ_ASSERT(!IsPoisonedValue(v));
pre(zone);
value = v;
post(owner, kind, slot, v);

View File

@ -226,8 +226,6 @@ class ImmMaybeNurseryPtr
public:
explicit ImmMaybeNurseryPtr(const gc::Cell *ptr) : value(ptr)
{
MOZ_ASSERT(!IsPoisonedPtr(ptr));
// asm.js shouldn't be creating GC things
MOZ_ASSERT(!IsCompilingAsmJS());
}
@ -257,7 +255,6 @@ class ImmGCPtr
explicit ImmGCPtr(const gc::Cell *ptr) : value(ptr)
{
MOZ_ASSERT(!IsPoisonedPtr(ptr));
MOZ_ASSERT_IF(ptr, ptr->isTenured());
// asm.js shouldn't be creating GC things
@ -266,7 +263,6 @@ class ImmGCPtr
explicit ImmGCPtr(IonNurseryPtr ptr) : value(ptr.ptr)
{
MOZ_ASSERT(!IsPoisonedPtr(value));
MOZ_ASSERT(value);
// asm.js shouldn't be creating GC things
@ -279,8 +275,6 @@ class ImmGCPtr
friend class AssemblerShared;
explicit ImmGCPtr(ImmMaybeNurseryPtr ptr) : value(ptr.value)
{
MOZ_ASSERT(!IsPoisonedPtr(ptr.value));
// asm.js shouldn't be creating GC things
MOZ_ASSERT(!IsCompilingAsmJS());
}

View File

@ -2671,12 +2671,6 @@ namespace js {
template <>
struct GCMethods<JSPropertyDescriptor> {
static JSPropertyDescriptor initial() { return JSPropertyDescriptor(); }
static bool poisoned(const JSPropertyDescriptor &desc) {
return (desc.obj && JS::IsPoisonedPtr(desc.obj)) ||
(desc.attrs & JSPROP_GETTER && desc.getter && JS::IsPoisonedPtr(desc.getter)) ||
(desc.attrs & JSPROP_SETTER && desc.setter && JS::IsPoisonedPtr(desc.setter)) ||
(desc.value.isGCThing() && JS::IsPoisonedPtr(desc.value.toGCThing()));
}
};
template <>

View File

@ -378,7 +378,6 @@ ExclusiveContext::typeLifoAlloc()
inline void
JSContext::setPendingException(js::Value v)
{
MOZ_ASSERT(!IsPoisonedValue(v));
// overRecursed_ is set after the fact by ReportOverRecursed.
this->overRecursed_ = false;
this->throwing = true;

View File

@ -252,9 +252,6 @@ bool
JSCompartment::putWrapper(JSContext *cx, const CrossCompartmentKey &wrapped, const js::Value &wrapper)
{
MOZ_ASSERT(wrapped.wrapped);
MOZ_ASSERT(!IsPoisonedPtr(wrapped.wrapped));
MOZ_ASSERT(!IsPoisonedPtr(wrapped.debugger));
MOZ_ASSERT(!IsPoisonedPtr(wrapper.toGCThing()));
MOZ_ASSERT_IF(wrapped.kind == CrossCompartmentKey::StringWrapper, wrapper.isString());
MOZ_ASSERT_IF(wrapped.kind != CrossCompartmentKey::StringWrapper, wrapper.isObject());
bool success = crossCompartmentWrappers.put(wrapped, ReadBarriered<Value>(wrapper));

View File

@ -110,7 +110,6 @@ struct CrossCompartmentKey
struct WrapperHasher : public DefaultHasher<CrossCompartmentKey>
{
static HashNumber hash(const CrossCompartmentKey &key) {
MOZ_ASSERT(!IsPoisonedPtr(key.wrapped));
static_assert(sizeof(HashNumber) == sizeof(uint32_t),
"subsequent code assumes a four-byte hash");
return uint32_t(uintptr_t(key.wrapped)) | uint32_t(key.kind);

View File

@ -320,9 +320,6 @@ class Bindings
template <>
struct GCMethods<Bindings> {
static Bindings initial();
static bool poisoned(const Bindings &bindings) {
return IsPoisonedPtr(bindings.callObjShape());
}
};
class ScriptCounts

View File

@ -6127,8 +6127,6 @@ EvaluateInEnv(JSContext *cx, Handle<Env*> env, HandleValue thisv, AbstractFrameP
MOZ_ASSERT_IF(frame, thisv.get() == frame.thisValue());
MOZ_ASSERT_IF(frame, pc);
MOZ_ASSERT(!IsPoisonedPtr(chars.start().get()));
/*
* NB: This function breaks the assumption that the compiler can see all
* calls and properly compute a static level. In practice, any non-zero

View File

@ -71,13 +71,11 @@ struct RootKind<TaggedProto>
template <> struct GCMethods<const TaggedProto>
{
static TaggedProto initial() { return TaggedProto(); }
static bool poisoned(const TaggedProto &v) { return IsPoisonedPtr(v.raw()); }
};
template <> struct GCMethods<TaggedProto>
{
static TaggedProto initial() { return TaggedProto(); }
static bool poisoned(const TaggedProto &v) { return IsPoisonedPtr(v.raw()); }
};
template<class Outer>

View File

@ -162,10 +162,7 @@ AutoRooterGetterSetter::Inner::Inner(ExclusiveContext *cx, uint8_t attrs,
GetterOp *pgetter_, SetterOp *psetter_)
: CustomAutoRooter(cx), attrs(attrs),
pgetter(pgetter_), psetter(psetter_)
{
MOZ_ASSERT_IF(attrs & JSPROP_GETTER, !IsPoisonedPtr(*pgetter));
MOZ_ASSERT_IF(attrs & JSPROP_SETTER, !IsPoisonedPtr(*psetter));
}
{}
inline
AutoRooterGetterSetter::AutoRooterGetterSetter(ExclusiveContext *cx, uint8_t attrs,

View File

@ -1289,9 +1289,6 @@ struct StackShape
{}
void updateGetterSetter(GetterOp rawGetter, SetterOp rawSetter) {
MOZ_ASSERT_IF((attrs & JSPROP_GETTER) && rawGetter, !IsPoisonedPtr(rawGetter));
MOZ_ASSERT_IF((attrs & JSPROP_SETTER) && rawSetter, !IsPoisonedPtr(rawSetter));
if (rawGetter || rawSetter || (attrs & (JSPROP_GETTER|JSPROP_SETTER)))
flags |= Shape::ACCESSOR_SHAPE;
else

View File

@ -136,7 +136,6 @@ MOZ_ALWAYS_INLINE void
JSDependentString::init(js::ExclusiveContext *cx, JSLinearString *base, size_t start,
size_t length)
{
MOZ_ASSERT(!js::IsPoisonedPtr(base));
MOZ_ASSERT(start + length <= base->length());
d.u1.length = length;
JS::AutoCheckCannotGC nogc;

View File

@ -1098,20 +1098,12 @@ template <>
struct GCMethods<const TypeSet::Type>
{
static TypeSet::Type initial() { return TypeSet::UnknownType(); }
static bool poisoned(TypeSet::Type v) {
return (v.isGroup() && IsPoisonedPtr(v.group()))
|| (v.isSingleton() && IsPoisonedPtr(v.singleton()));
}
};
template <>
struct GCMethods<TypeSet::Type>
{
static TypeSet::Type initial() { return TypeSet::UnknownType(); }
static bool poisoned(TypeSet::Type v) {
return (v.isGroup() && IsPoisonedPtr(v.group()))
|| (v.isSingleton() && IsPoisonedPtr(v.singleton()));
}
};
} // namespace js