Bug 914032 (part 2) - Move a bunch of stuff out of -inl.h files. r=terrence.

--HG--
extra : rebase_source : c0f771690e5ff4a076dc60701b3e9e9268d3538c
This commit is contained in:
Nicholas Nethercote 2013-09-09 15:50:06 -07:00
parent 60aaf7ae7f
commit 5eedb65ac6
14 changed files with 147 additions and 236 deletions

View File

@ -1,20 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef builtin_Iterator_inl_h
#define builtin_Iterator_inl_h
#include "jsiter.h"
#include "vm/ObjectImpl-inl.h"
inline void
js::PropertyIteratorObject::setNativeIterator(js::NativeIterator *ni)
{
setPrivate(ni);
}
#endif /* builtin_Iterator_inl_h */

View File

@ -13,7 +13,6 @@
#include "jsobjinlines.h"
#include "vm/RegExpObject-inl.h"
#include "vm/RegExpStatics-inl.h"
using namespace js;

View File

@ -49,6 +49,11 @@ HeapSlot::preconditionForWriteBarrierPost(JSObject *obj, Kind kind, uint32_t slo
static_cast<HeapSlot *>(obj->getDenseElements() + slot)->get() == target);
}
bool
RuntimeFromMainThreadIsHeapMajorCollecting(JS::shadow::Zone *shadowZone)
{
return shadowZone->runtimeFromMainThread()->isHeapMajorCollecting();
}
#endif // DEBUG
} // namespace js

View File

@ -922,6 +922,11 @@ class ReadBarrieredValue
inline JSObject &toObject() const;
};
#ifdef DEBUG
bool
RuntimeFromMainThreadIsHeapMajorCollecting(JS::shadow::Zone *shadowZone);
#endif
} /* namespace js */
#endif /* gc_Barrier_h */

View File

@ -99,6 +99,7 @@ struct Cell
MOZ_ALWAYS_INLINE void unmark(uint32_t color) const;
inline JSRuntime *runtimeFromMainThread() const;
inline JS::shadow::Runtime *shadowRuntimeFromMainThread() const;
inline JS::Zone *tenuredZone() const;
inline bool tenuredIsInsideZone(JS::Zone *zone) const;
@ -963,6 +964,12 @@ Cell::runtimeFromMainThread() const
return rt;
}
inline JS::shadow::Runtime *
Cell::shadowRuntimeFromMainThread() const
{
return reinterpret_cast<JS::shadow::Runtime*>(runtimeFromMainThread());
}
inline JSRuntime *
Cell::runtimeFromAnyThread() const
{

View File

@ -35,7 +35,6 @@
#include "jsinferinlines.h"
#include "jsobjinlines.h"
#include "builtin/Iterator-inl.h"
#include "vm/Stack-inl.h"
#include "vm/String-inl.h"

View File

@ -122,7 +122,9 @@ class PropertyIteratorObject : public JSObject
NativeIterator *getNativeIterator() const {
return static_cast<js::NativeIterator *>(getPrivate());
}
inline void setNativeIterator(js::NativeIterator *ni);
void setNativeIterator(js::NativeIterator *ni) {
setPrivate(ni);
}
size_t sizeOfMisc(mozilla::MallocSizeOf mallocSizeOf) const;

View File

@ -365,8 +365,8 @@ class JSObject : public js::ObjectImpl
void rollbackProperties(js::ExclusiveContext *cx, uint32_t slotSpan);
void nativeSetSlot(uint32_t slot, const js::Value &value) {
JS_ASSERT(uninlinedIsNative());
JS_ASSERT(slot < uninlinedSlotSpan());
JS_ASSERT(isNative());
JS_ASSERT(slot < slotSpan());
return setSlot(slot, value);
}
@ -563,13 +563,13 @@ class JSObject : public js::ObjectImpl
}
uint32_t getDenseCapacity() {
JS_ASSERT(uninlinedIsNative());
JS_ASSERT(isNative());
JS_ASSERT(getElementsHeader()->capacity >= getElementsHeader()->initializedLength);
return getElementsHeader()->capacity;
}
void setDenseInitializedLength(uint32_t length) {
JS_ASSERT(uninlinedIsNative());
JS_ASSERT(isNative());
JS_ASSERT(length <= getDenseCapacity());
prepareElementRangeForOverwrite(length, getElementsHeader()->initializedLength);
getElementsHeader()->initializedLength = length;
@ -578,12 +578,12 @@ class JSObject : public js::ObjectImpl
inline void ensureDenseInitializedLength(js::ExclusiveContext *cx,
uint32_t index, uint32_t extra);
void setDenseElement(uint32_t index, const js::Value &val) {
JS_ASSERT(uninlinedIsNative() && index < getDenseInitializedLength());
JS_ASSERT(isNative() && index < getDenseInitializedLength());
elements[index].set(this, js::HeapSlot::Element, index, val);
}
void initDenseElement(uint32_t index, const js::Value &val) {
JS_ASSERT(uninlinedIsNative() && index < getDenseInitializedLength());
JS_ASSERT(isNative() && index < getDenseInitializedLength());
elements[index].init(this, js::HeapSlot::Element, index, val);
}
@ -615,7 +615,7 @@ class JSObject : public js::ObjectImpl
inline void moveDenseElementsUnbarriered(uint32_t dstStart, uint32_t srcStart, uint32_t count);
bool shouldConvertDoubleElements() {
JS_ASSERT(uninlinedIsNative());
JS_ASSERT(isNative());
return getElementsHeader()->shouldConvertDoubleElements();
}

View File

@ -19,33 +19,6 @@
#include "gc/Barrier-inl.h"
inline JSCompartment *
js::ObjectImpl::compartment() const
{
return lastProperty()->base()->compartment();
}
inline bool
js::ObjectImpl::nativeContains(ExclusiveContext *cx, Shape *shape)
{
return nativeLookup(cx, shape->propid()) == shape;
}
inline bool
js::ObjectImpl::nativeContainsPure(Shape *shape)
{
return nativeLookupPure(shape->propid()) == shape;
}
inline bool
js::ObjectImpl::nonProxyIsExtensible() const
{
MOZ_ASSERT(!asObjectPtr()->is<ProxyObject>());
// [[Extensible]] for ordinary non-proxy objects is an object flag.
return !lastProperty()->hasObjectFlag(BaseShape::NOT_EXTENSIBLE);
}
/* static */ inline bool
js::ObjectImpl::isExtensible(ExclusiveContext *cx, js::Handle<ObjectImpl*> obj, bool *extensible)
{
@ -61,107 +34,4 @@ js::ObjectImpl::isExtensible(ExclusiveContext *cx, js::Handle<ObjectImpl*> obj,
return true;
}
inline bool
js::ObjectImpl::isNative() const
{
return lastProperty()->isNative();
}
inline uint32_t
js::ObjectImpl::slotSpan() const
{
if (inDictionaryMode())
return lastProperty()->base()->slotSpan();
return lastProperty()->slotSpan();
}
inline uint32_t
js::ObjectImpl::numDynamicSlots() const
{
return dynamicSlotsCount(numFixedSlots(), slotSpan());
}
inline bool
js::ObjectImpl::isDelegate() const
{
return lastProperty()->hasObjectFlag(BaseShape::DELEGATE);
}
inline bool
js::ObjectImpl::inDictionaryMode() const
{
return lastProperty()->inDictionary();
}
JS_ALWAYS_INLINE JS::Zone *
js::ObjectImpl::zone() const
{
JS_ASSERT(CurrentThreadCanAccessZone(shape_->zone()));
return shape_->zone();
}
/* static */ inline void
js::ObjectImpl::readBarrier(ObjectImpl *obj)
{
#ifdef JSGC_INCREMENTAL
Zone *zone = obj->zone();
if (zone->needsBarrier()) {
MOZ_ASSERT(!zone->runtimeFromMainThread()->isHeapMajorCollecting());
JSObject *tmp = obj->asObjectPtr();
MarkObjectUnbarriered(zone->barrierTracer(), &tmp, "read barrier");
MOZ_ASSERT(tmp == obj->asObjectPtr());
}
#endif
}
inline void
js::ObjectImpl::privateWriteBarrierPre(void **old)
{
#ifdef JSGC_INCREMENTAL
Zone *zone = this->zone();
if (zone->needsBarrier()) {
if (*old && getClass()->trace)
getClass()->trace(zone->barrierTracer(), this->asObjectPtr());
}
#endif
}
/* 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 (IsNullTaggedPointer(obj) || !obj->runtimeFromMainThread()->needsBarrier())
return;
Zone *zone = obj->zone();
if (zone->needsBarrier()) {
MOZ_ASSERT(!zone->runtimeFromMainThread()->isHeapMajorCollecting());
JSObject *tmp = obj->asObjectPtr();
MarkObjectUnbarriered(zone->barrierTracer(), &tmp, "write barrier");
MOZ_ASSERT(tmp == obj->asObjectPtr());
}
#endif
}
inline void
js::ObjectImpl::setPrivate(void *data)
{
void **pprivate = &privateRef(numFixedSlots());
privateWriteBarrierPre(pprivate);
*pprivate = data;
}
inline void
js::ObjectImpl::setPrivateGCThing(js::gc::Cell *cell)
{
void **pprivate = &privateRef(numFixedSlots());
privateWriteBarrierPre(pprivate);
*pprivate = reinterpret_cast<void *>(cell);
privateWriteBarrierPost(pprivate);
}
#endif /* vm_ObjectImpl_inl_h */

View File

@ -16,24 +16,6 @@
using namespace js;
JSCompartment *
js::ObjectImpl::uninlinedCompartment() const
{
return compartment();
}
bool
js::ObjectImpl::uninlinedIsNative() const
{
return isNative();
}
uint32_t
js::ObjectImpl::uninlinedSlotSpan() const
{
return slotSpan();
}
PropDesc::PropDesc()
: pd_(UndefinedValue()),
value_(UndefinedValue()),
@ -303,6 +285,12 @@ js::ObjectImpl::copySlotRange(uint32_t start, const Value *vector, uint32_t leng
}
#ifdef DEBUG
bool
js::ObjectImpl::isProxy() const
{
return asObjectPtr()->is<ProxyObject>();
}
bool
js::ObjectImpl::slotInRange(uint32_t slot, SentinelAllowed sentinel) const
{

View File

@ -980,7 +980,16 @@ class ObjectImpl : public gc::Cell
// This method really shouldn't exist -- but there are a few internal
// places that want it (JITs and the like), and it'd be a pain to mark them
// all as friends.
inline bool nonProxyIsExtensible() const;
bool nonProxyIsExtensible() const {
MOZ_ASSERT(!isProxy());
// [[Extensible]] for ordinary non-proxy objects is an object flag.
return !lastProperty()->hasObjectFlag(BaseShape::NOT_EXTENSIBLE);
}
#ifdef DEBUG
bool isProxy() const;
#endif
// Attempt to change the [[Extensible]] bit on |obj| to false. Callers
// must ensure that |obj| is currently extensible before calling this!
@ -988,24 +997,24 @@ class ObjectImpl : public gc::Cell
preventExtensions(JSContext *cx, Handle<ObjectImpl*> obj);
HeapSlotArray getDenseElements() {
JS_ASSERT(uninlinedIsNative());
JS_ASSERT(isNative());
return HeapSlotArray(elements);
}
const Value &getDenseElement(uint32_t idx) {
JS_ASSERT(uninlinedIsNative());
JS_ASSERT(isNative());
MOZ_ASSERT(idx < getDenseInitializedLength());
return elements[idx];
}
bool containsDenseElement(uint32_t idx) {
JS_ASSERT(uninlinedIsNative());
JS_ASSERT(isNative());
return idx < getDenseInitializedLength() && !elements[idx].isMagic(JS_ELEMENTS_HOLE);
}
uint32_t getDenseInitializedLength() {
JS_ASSERT(uninlinedIsNative());
JS_ASSERT(isNative());
return getElementsHeader()->initializedLength;
}
uint32_t getDenseCapacity() {
JS_ASSERT(uninlinedIsNative());
JS_ASSERT(isNative());
return getElementsHeader()->capacity;
}
@ -1161,13 +1170,13 @@ class ObjectImpl : public gc::Cell
return replaceWithNewEquivalentShape(cx, lastProperty(), newShape);
}
// uninlinedCompartment() is equivalent to compartment(), but isn't inlined.
inline JSCompartment *compartment() const;
JSCompartment *uninlinedCompartment() const;
JSCompartment *compartment() const {
return lastProperty()->base()->compartment();
}
// uninlinedIsNative() is equivalent to isNative(), but isn't inlined.
inline bool isNative() const;
bool uninlinedIsNative() const;
bool isNative() const {
return lastProperty()->isNative();
}
types::TypeObject *type() const {
MOZ_ASSERT(!hasLazyType());
@ -1190,12 +1199,16 @@ class ObjectImpl : public gc::Cell
*/
bool hasLazyType() const { return type_->lazy(); }
// uninlinedSlotSpan() is the same as slotSpan(), but isn't inlined.
inline uint32_t slotSpan() const;
uint32_t uninlinedSlotSpan() const;
uint32_t slotSpan() const {
if (inDictionaryMode())
return lastProperty()->base()->slotSpan();
return lastProperty()->slotSpan();
}
/* Compute dynamicSlotsCount() for this object. */
inline uint32_t numDynamicSlots() const;
uint32_t numDynamicSlots() const {
return dynamicSlotsCount(numFixedSlots(), slotSpan());
}
Shape *nativeLookup(ExclusiveContext *cx, jsid id);
Shape *nativeLookup(ExclusiveContext *cx, PropertyId pid) {
@ -1211,7 +1224,9 @@ class ObjectImpl : public gc::Cell
bool nativeContains(ExclusiveContext *cx, PropertyName* name) {
return nativeLookup(cx, name) != NULL;
}
inline bool nativeContains(ExclusiveContext *cx, Shape* shape);
bool nativeContains(ExclusiveContext *cx, Shape* shape) {
return nativeLookup(cx, shape->propid()) == shape;
}
/*
* Contextless; can be called from parallel code. Returns false if the
@ -1231,7 +1246,9 @@ class ObjectImpl : public gc::Cell
bool nativeContainsPure(PropertyName* name) {
return nativeContainsPure(NameToId(name));
}
bool nativeContainsPure(Shape* shape);
bool nativeContainsPure(Shape* shape) {
return nativeLookupPure(shape->propid()) == shape;
}
JSClass *getJSClass() const {
return Jsvalify(getClass());
@ -1252,14 +1269,18 @@ class ObjectImpl : public gc::Cell
* definition helps to optimize shape-based property cache invalidation
* (see Purge{Scope,Proto}Chain in jsobj.cpp).
*/
inline bool isDelegate() const;
bool isDelegate() const {
return lastProperty()->hasObjectFlag(BaseShape::DELEGATE);
}
/*
* Return true if this object is a native one that has been converted from
* shared-immutable prototype-rooted shape storage to dictionary-shapes in
* a doubly-linked list.
*/
inline bool inDictionaryMode() const;
bool inDictionaryMode() const {
return lastProperty()->inDictionary();
}
const Value &getSlot(uint32_t slot) const {
MOZ_ASSERT(slotInRange(slot));
@ -1292,17 +1313,17 @@ class ObjectImpl : public gc::Cell
}
HeapSlot &nativeGetSlotRef(uint32_t slot) {
JS_ASSERT(uninlinedIsNative() && slot < uninlinedSlotSpan());
JS_ASSERT(isNative() && slot < slotSpan());
return getSlotRef(slot);
}
const Value &nativeGetSlot(uint32_t slot) const {
JS_ASSERT(uninlinedIsNative() && slot < uninlinedSlotSpan());
JS_ASSERT(isNative() && slot < slotSpan());
return getSlot(slot);
}
void setSlot(uint32_t slot, const Value &value) {
MOZ_ASSERT(slotInRange(slot));
MOZ_ASSERT(IsObjectValueInCompartment(value, uninlinedCompartment()));
MOZ_ASSERT(IsObjectValueInCompartment(value, compartment()));
getSlotRef(slot).set(this->asObjectPtr(), HeapSlot::Slot, slot, value);
}
@ -1314,7 +1335,7 @@ class ObjectImpl : public gc::Cell
void initSlot(uint32_t slot, const Value &value) {
MOZ_ASSERT(getSlot(slot).isUndefined());
MOZ_ASSERT(slotInRange(slot));
MOZ_ASSERT(IsObjectValueInCompartment(value, uninlinedCompartment()));
MOZ_ASSERT(IsObjectValueInCompartment(value, compartment()));
initSlotUnchecked(slot, value);
}
@ -1413,11 +1434,47 @@ class ObjectImpl : public gc::Cell
}
/* GC support. */
JS_ALWAYS_INLINE Zone *zone() const;
JS_ALWAYS_INLINE Zone *zone() const {
JS_ASSERT(CurrentThreadCanAccessZone(shape_->zone()));
return shape_->zone();
}
JS_ALWAYS_INLINE JS::shadow::Zone *shadowZone() const {
return JS::shadow::Zone::asShadowZone(zone());
}
static ThingRootKind rootKind() { return THING_ROOT_OBJECT; }
static inline void readBarrier(ObjectImpl *obj);
static inline void writeBarrierPre(ObjectImpl *obj);
static void readBarrier(ObjectImpl *obj) {
#ifdef JSGC_INCREMENTAL
JS::shadow::Zone *shadowZone = obj->shadowZone();
if (shadowZone->needsBarrier()) {
MOZ_ASSERT(!RuntimeFromMainThreadIsHeapMajorCollecting(shadowZone));
JSObject *tmp = obj->asObjectPtr();
js::gc::MarkObjectUnbarriered(shadowZone->barrierTracer(), &tmp, "read barrier");
MOZ_ASSERT(tmp == obj->asObjectPtr());
}
#endif
}
static void writeBarrierPre(ObjectImpl *obj) {
#ifdef JSGC_INCREMENTAL
/*
* This would normally be a null test, but TypeScript::global uses 0x1 as a
* special value.
*/
if (IsNullTaggedPointer(obj) || !obj->shadowRuntimeFromMainThread()->needsBarrier())
return;
JS::shadow::Zone *shadowZone = obj->shadowZone();
if (shadowZone->needsBarrier()) {
MOZ_ASSERT(!RuntimeFromMainThreadIsHeapMajorCollecting(shadowZone));
JSObject *tmp = obj->asObjectPtr();
js::gc::MarkObjectUnbarriered(shadowZone->barrierTracer(), &tmp, "write barrier");
MOZ_ASSERT(tmp == obj->asObjectPtr());
}
#endif
}
static void writeBarrierPost(ObjectImpl *obj, void *addr) {
#ifdef JSGC_GENERATIONAL
@ -1439,7 +1496,15 @@ class ObjectImpl : public gc::Cell
#endif
}
inline void privateWriteBarrierPre(void **oldval);
void privateWriteBarrierPre(void **oldval) {
#ifdef JSGC_INCREMENTAL
JS::shadow::Zone *shadowZone = this->shadowZone();
if (shadowZone->needsBarrier()) {
if (*oldval && getClass()->trace)
getClass()->trace(shadowZone->barrierTracer(), this->asObjectPtr());
}
#endif
}
void privateWriteBarrierPost(void **pprivate) {
#ifdef JSGC_GENERATIONAL
@ -1463,14 +1528,25 @@ class ObjectImpl : public gc::Cell
return *reinterpret_cast<void**>(end);
}
inline bool hasPrivate() const {
bool hasPrivate() const {
return getClass()->hasPrivate();
}
inline void *getPrivate() const {
void *getPrivate() const {
return privateRef(numFixedSlots());
}
inline void setPrivate(void *data);
inline void setPrivateGCThing(gc::Cell *cell);
void setPrivate(void *data) {
void **pprivate = &privateRef(numFixedSlots());
privateWriteBarrierPre(pprivate);
*pprivate = data;
}
void setPrivateGCThing(gc::Cell *cell) {
void **pprivate = &privateRef(numFixedSlots());
privateWriteBarrierPre(pprivate);
*pprivate = reinterpret_cast<void *>(cell);
privateWriteBarrierPost(pprivate);
}
void setPrivateUnbarriered(void *data) {
void **pprivate = &privateRef(numFixedSlots());
*pprivate = data;
@ -1523,7 +1599,7 @@ IsObjectValueInCompartment(js::Value v, JSCompartment *comp)
{
if (!v.isObject())
return true;
return reinterpret_cast<ObjectImpl*>(&v.toObject())->uninlinedCompartment() == comp;
return reinterpret_cast<ObjectImpl*>(&v.toObject())->compartment() == comp;
}
#endif

View File

@ -1,23 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef vm_RegExpObject_inl_h
#define vm_RegExpObject_inl_h
#include "vm/RegExpObject.h"
namespace js {
inline void
RegExpObject::setShared(ExclusiveContext *cx, RegExpShared &shared)
{
shared.prepareForUse(cx);
JSObject::setPrivate(&shared);
}
} /* namespace js */
#endif /* vm_RegExpObject_inl_h */

View File

@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "vm/RegExpObject-inl.h"
#include "vm/RegExpObject.h"
#include "mozilla/MemoryReporting.h"

View File

@ -428,7 +428,10 @@ class RegExpObject : public JSObject
return createShared(cx, g);
}
inline void setShared(ExclusiveContext *cx, RegExpShared &shared);
void setShared(ExclusiveContext *cx, RegExpShared &shared) {
shared.prepareForUse(cx);
JSObject::setPrivate(&shared);
}
private:
friend class RegExpObjectBuilder;