Bug 1045181 - Miscellaneous small cleanups in js::gc; r=jonco

This commit is contained in:
Terrence Cole 2014-07-29 10:47:43 -07:00
parent 4f3fc78ee7
commit 3cc44bc3b7
10 changed files with 37 additions and 34 deletions

View File

@ -111,7 +111,7 @@ static MOZ_ALWAYS_INLINE js::gc::Cell *
AsCell(JSObject *obj)
{
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(obj);
AssertGCThingHasType(cell, JSTRACE_OBJECT);
js::gc::AssertGCThingHasType(cell, JSTRACE_OBJECT);
return cell;
}
@ -119,7 +119,7 @@ static MOZ_ALWAYS_INLINE js::gc::Cell *
AsCell(JSFunction *fun)
{
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(fun);
AssertGCThingHasType(cell, JSTRACE_OBJECT);
js::gc::AssertGCThingHasType(cell, JSTRACE_OBJECT);
return cell;
}
@ -127,7 +127,7 @@ static MOZ_ALWAYS_INLINE js::gc::Cell *
AsCell(JSString *str)
{
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(str);
AssertGCThingHasType(cell, JSTRACE_STRING);
js::gc::AssertGCThingHasType(cell, JSTRACE_STRING);
return cell;
}
@ -135,7 +135,7 @@ static MOZ_ALWAYS_INLINE js::gc::Cell *
AsCell(JSFlatString *flat)
{
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(flat);
AssertGCThingHasType(cell, JSTRACE_STRING);
js::gc::AssertGCThingHasType(cell, JSTRACE_STRING);
return cell;
}
@ -143,7 +143,7 @@ static MOZ_ALWAYS_INLINE js::gc::Cell *
AsCell(JS::Symbol *sym)
{
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(sym);
AssertGCThingHasType(cell, JSTRACE_SYMBOL);
js::gc::AssertGCThingHasType(cell, JSTRACE_SYMBOL);
return cell;
}
@ -151,7 +151,7 @@ static MOZ_ALWAYS_INLINE js::gc::Cell *
AsCell(JSScript *script)
{
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(script);
AssertGCThingHasType(cell, JSTRACE_SCRIPT);
js::gc::AssertGCThingHasType(cell, JSTRACE_SCRIPT);
return cell;
}
@ -289,6 +289,7 @@ GetObjectZone(JSObject *obj);
static MOZ_ALWAYS_INLINE bool
GCThingIsMarkedGray(void *thing)
{
MOZ_ASSERT(thing);
#ifdef JSGC_GENERATIONAL
/*
* GC things residing in the nursery cannot be gray: they have no mark bits.
@ -306,6 +307,10 @@ GCThingIsMarkedGray(void *thing)
static MOZ_ALWAYS_INLINE bool
IsIncrementalBarrierNeededOnTenuredGCThing(shadow::Runtime *rt, void *thing, JSGCTraceKind kind)
{
MOZ_ASSERT(thing);
#ifdef JSGC_GENERATIONAL
MOZ_ASSERT(!js::gc::IsInsideNursery((js::gc::Cell *)thing));
#endif
if (!rt->needsBarrier_)
return false;
JS::Zone *zone = GetTenuredGCThingZone(thing);

View File

@ -103,8 +103,6 @@
namespace js {
class ScriptSourceObject;
template <typename T>
struct GCMethods {};

View File

@ -1339,18 +1339,6 @@ class Value
friend Value JS_VALUE_CONSTEXPR (JS::UndefinedValue)();
};
inline bool
IsPoisonedValue(const Value &v)
{
if (v.isString())
return IsPoisonedPtr(v.toString());
if (v.isSymbol())
return IsPoisonedPtr(v.toSymbol());
if (v.isObject())
return IsPoisonedPtr(&v.toObject());
return false;
}
inline bool
IsOptimizedPlaceholderMagicValue(const Value &v)
{
@ -1638,13 +1626,17 @@ namespace js {
template <> struct GCMethods<const JS::Value>
{
static JS::Value initial() { return JS::UndefinedValue(); }
static bool poisoned(const JS::Value &v) { return JS::IsPoisonedValue(v); }
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 JS::IsPoisonedValue(v); }
static bool poisoned(const JS::Value &v) {
return v.isMarkable() && JS::IsPoisonedPtr(v.toGCThing());
}
static bool needsPostBarrier(const JS::Value &v) {
return v.isObject() && gc::IsInsideNursery(reinterpret_cast<gc::Cell*>(&v.toObject()));
}
@ -1864,6 +1856,12 @@ IMPL_TO_JSVAL(jsval_layout l)
namespace JS {
inline bool
IsPoisonedValue(const Value &v)
{
return js::GCMethods<Value>::poisoned(v);
}
#ifndef __GNUC__
/*
* The default assignment operator for |struct C| has the signature:

View File

@ -16,6 +16,7 @@ namespace js {
class AutoNameVector;
class LazyScript;
class LifoAlloc;
class ScriptSourceObject;
struct SourceCompressionTask;
namespace frontend {

View File

@ -786,6 +786,7 @@ class ArrayBufferObject;
class NestedScopeObject;
class DebugScopeObject;
class GlobalObject;
class ScriptSourceObject;
class Shape;
class BaseShape;
class UnownedBaseShape;

View File

@ -15,6 +15,7 @@ class JSLinearString;
namespace js {
class PropertyName;
class ScriptSourceObject;
class Shape;
namespace types { struct TypeObject; }
@ -26,7 +27,7 @@ typedef JS::Handle<types::TypeObject*> HandleTypeObject;
typedef JS::Handle<JSAtom*> HandleAtom;
typedef JS::Handle<JSLinearString*> HandleLinearString;
typedef JS::Handle<PropertyName*> HandlePropertyName;
typedef JS::Handle<js::ScriptSourceObject*> HandleScriptSource;
typedef JS::Handle<ScriptSourceObject*> HandleScriptSource;
typedef JS::MutableHandle<Shape*> MutableHandleShape;
typedef JS::MutableHandle<JSAtom*> MutableHandleAtom;
@ -36,7 +37,7 @@ typedef JS::Rooted<types::TypeObject*> RootedTypeObject;
typedef JS::Rooted<JSAtom*> RootedAtom;
typedef JS::Rooted<JSLinearString*> RootedLinearString;
typedef JS::Rooted<PropertyName*> RootedPropertyName;
typedef JS::Rooted<js::ScriptSourceObject*> RootedScriptSource;
typedef JS::Rooted<ScriptSourceObject*> RootedScriptSource;
} /* namespace js */

View File

@ -1036,7 +1036,7 @@ JS_WrapObject(JSContext *cx, MutableHandleObject objp)
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
if (objp)
JS::ExposeGCThingToActiveJS(objp, JSTRACE_OBJECT);
JS::ExposeObjectToActiveJS(objp);
return cx->compartment()->wrap(cx, objp);
}

View File

@ -983,14 +983,16 @@ JS::IncrementalReferenceBarrier(void *ptr, JSGCTraceKind kind)
JSScript::writeBarrierPre(static_cast<JSScript*>(cell));
else if (kind == JSTRACE_LAZY_SCRIPT)
LazyScript::writeBarrierPre(static_cast<LazyScript*>(cell));
else if (kind == JSTRACE_JITCODE)
jit::JitCode::writeBarrierPre(static_cast<jit::JitCode*>(cell));
else if (kind == JSTRACE_SHAPE)
Shape::writeBarrierPre(static_cast<Shape*>(cell));
else if (kind == JSTRACE_BASE_SHAPE)
BaseShape::writeBarrierPre(static_cast<BaseShape*>(cell));
else if (kind == JSTRACE_TYPE_OBJECT)
types::TypeObject::writeBarrierPre((types::TypeObject *) ptr);
types::TypeObject::writeBarrierPre(static_cast<types::TypeObject *>(cell));
else
MOZ_ASSUME_UNREACHABLE("invalid trace kind");
MOZ_CRASH("invalid trace kind");
}
JS_FRIEND_API(void)

View File

@ -273,7 +273,7 @@ template <>
struct GCMethods<Bindings> {
static Bindings initial();
static bool poisoned(const Bindings &bindings) {
return IsPoisonedPtr(static_cast<Shape *>(bindings.callObjShape()));
return IsPoisonedPtr(bindings.callObjShape());
}
};

View File

@ -317,12 +317,9 @@ template <>
struct GCMethods<PropDesc> {
static PropDesc initial() { return PropDesc(); }
static bool poisoned(const PropDesc &desc) {
return (desc.value_.isGCThing() &&
JS::IsPoisonedPtr(desc.value_.toGCThing())) ||
(desc.get_.isGCThing() &&
JS::IsPoisonedPtr(desc.get_.toGCThing())) ||
(desc.set_.isGCThing() &&
JS::IsPoisonedPtr(desc.set_.toGCThing()));
return JS::IsPoisonedValue(desc.value_) ||
JS::IsPoisonedValue(desc.get_) ||
JS::IsPoisonedValue(desc.set_);
}
};