Bug 1105069 - Part 21: Remove AsCell in preference of GCCellPtr; r=jonco, r=mccr8

--HG--
extra : rebase_source : 5c4470f3efbd9dbe3caee08ed88b07da549912e0
This commit is contained in:
Terrence Cole 2014-12-14 08:27:52 -08:00
parent 9ce9f9b75c
commit 455fff82ba
5 changed files with 12 additions and 58 deletions

View File

@ -105,58 +105,6 @@ const uint32_t DefaultNurseryBytes = 16 * js::gc::ChunkSize;
/* Default maximum heap size in bytes to pass to JS_NewRuntime(). */
const uint32_t DefaultHeapMaxBytes = 32 * 1024 * 1024;
/*
* We cannot expose the class hierarchy: the implementation is hidden. Instead
* we provide cast functions with strong debug-mode assertions.
*/
static MOZ_ALWAYS_INLINE js::gc::Cell *
AsCell(JSObject *obj)
{
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(obj);
js::gc::AssertGCThingHasType(cell, JSTRACE_OBJECT);
return cell;
}
static MOZ_ALWAYS_INLINE js::gc::Cell *
AsCell(JSFunction *fun)
{
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(fun);
js::gc::AssertGCThingHasType(cell, JSTRACE_OBJECT);
return cell;
}
static MOZ_ALWAYS_INLINE js::gc::Cell *
AsCell(JSString *str)
{
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(str);
js::gc::AssertGCThingHasType(cell, JSTRACE_STRING);
return cell;
}
static MOZ_ALWAYS_INLINE js::gc::Cell *
AsCell(JSFlatString *flat)
{
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(flat);
js::gc::AssertGCThingHasType(cell, JSTRACE_STRING);
return cell;
}
static MOZ_ALWAYS_INLINE js::gc::Cell *
AsCell(JS::Symbol *sym)
{
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(sym);
js::gc::AssertGCThingHasType(cell, JSTRACE_SYMBOL);
return cell;
}
static MOZ_ALWAYS_INLINE js::gc::Cell *
AsCell(JSScript *script)
{
js::gc::Cell *cell = reinterpret_cast<js::gc::Cell *>(script);
js::gc::AssertGCThingHasType(cell, JSTRACE_SCRIPT);
return cell;
}
namespace shadow {
struct Zone
@ -384,6 +332,12 @@ GetTenuredGCThingZone(void *thing)
extern JS_PUBLIC_API(Zone *)
GetObjectZone(JSObject *obj);
static MOZ_ALWAYS_INLINE bool
ObjectIsTenured(JSObject *obj)
{
return !js::gc::IsInsideNursery(reinterpret_cast<js::gc::Cell *>(obj));
}
static MOZ_ALWAYS_INLINE bool
ObjectIsMarkedGray(JSObject *obj)
{

View File

@ -127,7 +127,7 @@ SYMBOL_TO_JSID(JS::Symbol *sym)
jsid id;
MOZ_ASSERT(sym != nullptr);
MOZ_ASSERT((size_t(sym) & JSID_TYPE_MASK) == 0);
MOZ_ASSERT(!js::gc::IsInsideNursery(JS::AsCell(sym)));
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;

View File

@ -307,8 +307,8 @@ class StoreBuffer
return !(*this == other);
}
bool maybeInRememberedSet(const Nursery &) const {
return !IsInsideNursery(JS::AsCell(reinterpret_cast<JSObject *>(object())));
bool maybeInRememberedSet(const Nursery &n) const {
return !IsInsideNursery(reinterpret_cast<Cell *>(object()));
}
void mark(JSTracer *trc) const;

View File

@ -2664,7 +2664,7 @@ public:
void AppendJSObjectToPurpleBuffer(JSObject* obj) const
{
if (obj && JS::ObjectIsMarkedGray(obj)) {
MOZ_ASSERT(!js::gc::IsInsideNursery(JS::AsCell(obj)));
MOZ_ASSERT(JS::ObjectIsTenured(obj));
mCollector->GetJSPurpleBuffer()->mObjects.InfallibleAppend(obj);
}
}

View File

@ -55,7 +55,7 @@ RunTest(JSRuntime* rt, JSContext* cx, ArrayT* array)
const char* property = "foo";
for (size_t i = 0; i < ElementCount; ++i) {
RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
ASSERT_TRUE(js::gc::IsInsideNursery(AsCell(obj)));
ASSERT_FALSE(JS::ObjectIsTenured(obj));
value = Int32Value(i);
ASSERT_TRUE(JS_SetProperty(cx, obj, property, value));
array->AppendElement(obj);
@ -72,7 +72,7 @@ RunTest(JSRuntime* rt, JSContext* cx, ArrayT* array)
*/
for (size_t i = 0; i < ElementCount; ++i) {
RootedObject obj(cx, array->ElementAt(i));
ASSERT_FALSE(js::gc::IsInsideNursery(AsCell(obj)));
ASSERT_TRUE(JS::ObjectIsTenured(obj));
ASSERT_TRUE(JS_GetProperty(cx, obj, property, &value));
ASSERT_TRUE(value.isInt32());
ASSERT_EQ(static_cast<int32_t>(i), value.toInt32());