Bug 728411 - Move write barrier bits to ObjectImpl. r=bhackett

--HG--
extra : rebase_source : b1d72f92b2befd3a1277afe0cc5188fef2ebddf8
This commit is contained in:
Jeff Walden 2012-02-16 19:11:06 -08:00
parent f697b95866
commit 29b604027d
4 changed files with 64 additions and 59 deletions

View File

@ -1156,12 +1156,6 @@ struct JSObject : public js::ObjectImpl
inline void initArrayClass();
static inline void writeBarrierPre(JSObject *obj);
static inline void writeBarrierPost(JSObject *obj, void *addr);
static inline void readBarrier(JSObject *obj);
inline void privateWriteBarrierPre(void **oldval);
inline void privateWriteBarrierPost(void **oldval);
/*
* In addition to the generic object interface provided by JSObject,
* specific types of objects may provide additional operations. To access,

View File

@ -2000,57 +2000,4 @@ JSObject::initFixedSlot(uintN slot, const js::Value &value)
fixedSlots()[slot].init(value);
}
inline void
JSObject::privateWriteBarrierPre(void **old)
{
#ifdef JSGC_INCREMENTAL
JSCompartment *comp = compartment();
if (comp->needsBarrier()) {
if (*old && getClass()->trace)
getClass()->trace(comp->barrierTracer(), this);
}
#endif
}
inline void
JSObject::privateWriteBarrierPost(void **old)
{
}
inline void
JSObject::writeBarrierPre(JSObject *obj)
{
#ifdef JSGC_INCREMENTAL
/*
* This would normally be a null test, but TypeScript::global uses 0x1 as a
* special value.
*/
if (uintptr_t(obj) < 32)
return;
JSCompartment *comp = obj->compartment();
if (comp->needsBarrier()) {
JS_ASSERT(!comp->rt->gcRunning);
MarkObjectUnbarriered(comp->barrierTracer(), obj, "write barrier");
}
#endif
}
inline void
JSObject::readBarrier(JSObject *obj)
{
#ifdef JSGC_INCREMENTAL
JSCompartment *comp = obj->compartment();
if (comp->needsBarrier()) {
JS_ASSERT(!comp->rt->gcRunning);
MarkObjectUnbarriered(comp->barrierTracer(), obj, "read barrier");
}
#endif
}
inline void
JSObject::writeBarrierPost(JSObject *obj, void *addr)
{
}
#endif /* jsobjinlines_h___ */

View File

@ -11,7 +11,9 @@
#include "mozilla/Assertions.h"
#include "jscell.h"
#include "jscompartment.h"
#include "jsgc.h"
#include "jsgcmark.h"
#include "js/TemplateLib.h"
@ -79,6 +81,59 @@ js::ObjectImpl::sizeOfThis() const
return arenaHeader()->getThingSize();
}
/* static */ inline void
js::ObjectImpl::readBarrier(ObjectImpl *obj)
{
#ifdef JSGC_INCREMENTAL
JSCompartment *comp = obj->compartment();
if (comp->needsBarrier()) {
MOZ_ASSERT(!comp->rt->gcRunning);
MarkObjectUnbarriered(comp->barrierTracer(), obj->asObjectPtr(), "read barrier");
}
#endif
}
inline void
js::ObjectImpl::privateWriteBarrierPre(void **old)
{
#ifdef JSGC_INCREMENTAL
JSCompartment *comp = compartment();
if (comp->needsBarrier()) {
if (*old && getClass()->trace)
getClass()->trace(comp->barrierTracer(), this->asObjectPtr());
}
#endif
}
inline void
js::ObjectImpl::privateWriteBarrierPost(void **old)
{
}
/* static */ inline void
js::ObjectImpl::writeBarrierPre(ObjectImpl *obj)
{
#ifdef JSGC_INCREMENTAL
/*
* This would normally be a null test, but TypeScript::global uses 0x1 as a
* special value.
*/
if (uintptr_t(obj) < 32)
return;
JSCompartment *comp = obj->compartment();
if (comp->needsBarrier()) {
MOZ_ASSERT(!comp->rt->gcRunning);
MarkObjectUnbarriered(comp->barrierTracer(), obj->asObjectPtr(), "write barrier");
}
#endif
}
/* static */ inline void
js::ObjectImpl::writeBarrierPost(ObjectImpl *obj, void *addr)
{
}
inline bool
js::ObjectImpl::isExtensible() const
{

View File

@ -169,6 +169,8 @@ class ObjectImpl : public gc::Cell
"shadow placeholder must match actual elements");
}
JSObject * asObjectPtr() { return reinterpret_cast<JSObject *>(this); }
protected:
friend struct GCMarker;
friend struct Shape;
@ -257,6 +259,13 @@ class ObjectImpl : public gc::Cell
return ObjectElements::fromElements(elements);
}
/* Write barrier support. */
static inline void readBarrier(ObjectImpl *obj);
static inline void writeBarrierPre(ObjectImpl *obj);
static inline void writeBarrierPost(ObjectImpl *obj, void *addr);
inline void privateWriteBarrierPre(void **oldval);
inline void privateWriteBarrierPost(void **oldval);
/* JIT Accessors */
static size_t offsetOfShape() { return offsetof(ObjectImpl, shape_); }
HeapPtrShape *addressOfShape() { return &shape_; }