Bug 910771 (part 5) - Move tons of stuff out of inlines.h/-inl.h files into .h files. r=terrence.

This commit is contained in:
Nicholas Nethercote 2013-09-08 13:31:19 -07:00
Родитель 9339a831e1
Коммит ad78aeb254
20 изменённых файлов: 402 добавлений и 578 удалений

Просмотреть файл

@ -204,10 +204,16 @@ class JSFunction : public JSObject
JSAtom *atom() const { return hasGuessedAtom() ? NULL : atom_.get(); }
js::PropertyName *name() const { return hasGuessedAtom() || !atom_ ? NULL : atom_->asPropertyName(); }
inline void initAtom(JSAtom *atom);
void initAtom(JSAtom *atom) { atom_.init(atom); }
JSAtom *displayAtom() const { return atom_; }
inline void setGuessedAtom(JSAtom *atom);
void setGuessedAtom(JSAtom *atom) {
JS_ASSERT(atom_ == NULL);
JS_ASSERT(atom != NULL);
JS_ASSERT(!hasGuessedAtom());
atom_ = atom;
flags |= HAS_GUESSED_ATOM;
}
/* uint16_t representation bounds number of call object dynamic slots. */
enum { MAX_ARGS_AND_VARS = 2 * ((1U << 16) - 1) };
@ -220,8 +226,16 @@ class JSFunction : public JSObject
JS_ASSERT(isInterpreted());
return u.i.env_;
}
inline void setEnvironment(JSObject *obj);
inline void initEnvironment(JSObject *obj);
void setEnvironment(JSObject *obj) {
JS_ASSERT(isInterpreted());
*(js::HeapPtrObject *)&u.i.env_ = obj;
}
void initEnvironment(JSObject *obj) {
JS_ASSERT(isInterpreted());
((js::HeapPtrObject *)&u.i.env_)->init(obj);
}
static inline size_t offsetOfEnvironment() { return offsetof(JSFunction, u.i.env_); }
static inline size_t offsetOfAtom() { return offsetof(JSFunction, atom_); }
@ -304,6 +318,7 @@ class JSFunction : public JSObject
inline void setScript(JSScript *script_);
inline void initScript(JSScript *script_);
void initLazyScript(js::LazyScript *lazy) {
JS_ASSERT(isInterpreted());
flags &= ~INTERPRETED;
@ -366,7 +381,13 @@ class JSFunction : public JSObject
inline bool initBoundFunction(JSContext *cx, js::HandleValue thisArg,
const js::Value *args, unsigned argslen);
inline JSObject *getBoundFunctionTarget() const;
JSObject *getBoundFunctionTarget() const {
JS_ASSERT(isBoundFunction());
/* Bound functions abuse |parent| to store their target function. */
return getParent();
}
inline const js::Value &getBoundFunctionThis() const;
inline const js::Value &getBoundFunctionArgument(unsigned which) const;
inline size_t getBoundFunctionArgumentCount() const;
@ -489,6 +510,30 @@ JSFunction::toExtended() const
return static_cast<const js::FunctionExtended *>(this);
}
inline void
JSFunction::initializeExtended()
{
JS_ASSERT(isExtended());
JS_ASSERT(mozilla::ArrayLength(toExtended()->extendedSlots) == 2);
toExtended()->extendedSlots[0].init(js::UndefinedValue());
toExtended()->extendedSlots[1].init(js::UndefinedValue());
}
inline void
JSFunction::initExtendedSlot(size_t which, const js::Value &val)
{
JS_ASSERT(which < mozilla::ArrayLength(toExtended()->extendedSlots));
toExtended()->extendedSlots[which].init(val);
}
inline void
JSFunction::setExtendedSlot(size_t which, const js::Value &val)
{
JS_ASSERT(which < mozilla::ArrayLength(toExtended()->extendedSlots));
toExtended()->extendedSlots[which] = val;
}
inline const js::Value &
JSFunction::getExtendedSlot(size_t which) const
{

Просмотреть файл

@ -11,60 +11,6 @@
#include "vm/ScopeObject.h"
inline void
JSFunction::initAtom(JSAtom *atom)
{
atom_.init(atom);
}
inline void
JSFunction::setGuessedAtom(JSAtom *atom)
{
JS_ASSERT(atom_ == NULL);
JS_ASSERT(atom != NULL);
JS_ASSERT(!hasGuessedAtom());
atom_ = atom;
flags |= HAS_GUESSED_ATOM;
}
inline void
JSFunction::setEnvironment(JSObject *obj)
{
JS_ASSERT(isInterpreted());
*(js::HeapPtrObject *)&u.i.env_ = obj;
}
inline void
JSFunction::initEnvironment(JSObject *obj)
{
JS_ASSERT(isInterpreted());
((js::HeapPtrObject *)&u.i.env_)->init(obj);
}
inline void
JSFunction::initializeExtended()
{
JS_ASSERT(isExtended());
JS_ASSERT(mozilla::ArrayLength(toExtended()->extendedSlots) == 2);
toExtended()->extendedSlots[0].init(js::UndefinedValue());
toExtended()->extendedSlots[1].init(js::UndefinedValue());
}
inline void
JSFunction::initExtendedSlot(size_t which, const js::Value &val)
{
JS_ASSERT(which < mozilla::ArrayLength(toExtended()->extendedSlots));
toExtended()->extendedSlots[which].init(val);
}
inline void
JSFunction::setExtendedSlot(size_t which, const js::Value &val)
{
JS_ASSERT(which < mozilla::ArrayLength(toExtended()->extendedSlots));
toExtended()->extendedSlots[which] = val;
}
namespace js {
inline const char *
@ -175,13 +121,4 @@ JSFunction::initScript(JSScript *script_)
mutableScript().init(script_);
}
inline JSObject *
JSFunction::getBoundFunctionTarget() const
{
JS_ASSERT(isBoundFunction());
/* Bound functions abuse |parent| to store their target function. */
return getParent();
}
#endif /* jsfuninlines_h */

Просмотреть файл

@ -351,12 +351,25 @@ class JSObject : public js::ObjectImpl
* Trigger the write barrier on a range of slots that will no longer be
* reachable.
*/
inline void prepareSlotRangeForOverwrite(size_t start, size_t end);
inline void prepareElementRangeForOverwrite(size_t start, size_t end);
void prepareSlotRangeForOverwrite(size_t start, size_t end) {
for (size_t i = start; i < end; i++)
getSlotAddressUnchecked(i)->js::HeapSlot::~HeapSlot();
}
void prepareElementRangeForOverwrite(size_t start, size_t end) {
JS_ASSERT(end <= getDenseInitializedLength());
for (size_t i = start; i < end; i++)
elements[i].js::HeapSlot::~HeapSlot();
}
void rollbackProperties(js::ExclusiveContext *cx, uint32_t slotSpan);
inline void nativeSetSlot(uint32_t slot, const js::Value &value);
void nativeSetSlot(uint32_t slot, const js::Value &value) {
JS_ASSERT(uninlinedIsNative());
JS_ASSERT(slot < uninlinedSlotSpan());
return setSlot(slot, value);
}
static inline void nativeSetSlotWithType(js::ExclusiveContext *cx,
js::HandleObject, js::Shape *shape,
const js::Value &value);
@ -371,8 +384,15 @@ class JSObject : public js::ObjectImpl
return getSlotRef(index);
}
inline void initReservedSlot(uint32_t index, const js::Value &v);
inline void setReservedSlot(uint32_t index, const js::Value &v);
void initReservedSlot(uint32_t index, const js::Value &v) {
JS_ASSERT(index < JSSLOT_FREE(getClass()));
initSlot(index, v);
}
void setReservedSlot(uint32_t index, const js::Value &v) {
JS_ASSERT(index < JSSLOT_FREE(getClass()));
setSlot(index, v);
}
/*
* Marks this object as having a singleton type, and leave the type lazy.
@ -528,7 +548,12 @@ class JSObject : public js::ObjectImpl
static const char *className(JSContext *cx, js::HandleObject obj);
/* Accessors for elements. */
inline bool ensureElements(js::ThreadSafeContext *cx, uint32_t capacity);
bool ensureElements(js::ThreadSafeContext *cx, uint32_t capacity) {
if (capacity > getDenseCapacity())
return growElements(cx, capacity);
return true;
}
bool growElements(js::ThreadSafeContext *cx, uint32_t newcap);
void shrinkElements(js::ThreadSafeContext *cx, uint32_t cap);
void setDynamicElements(js::ObjectElements *header) {
@ -543,12 +568,32 @@ class JSObject : public js::ObjectImpl
return getElementsHeader()->capacity;
}
inline void setDenseInitializedLength(uint32_t length);
void setDenseInitializedLength(uint32_t length) {
JS_ASSERT(uninlinedIsNative());
JS_ASSERT(length <= getDenseCapacity());
prepareElementRangeForOverwrite(length, getElementsHeader()->initializedLength);
getElementsHeader()->initializedLength = length;
}
inline void ensureDenseInitializedLength(js::ExclusiveContext *cx,
uint32_t index, uint32_t extra);
inline void setDenseElement(uint32_t index, const js::Value &val);
inline void initDenseElement(uint32_t index, const js::Value &val);
inline void setDenseElementMaybeConvertDouble(uint32_t index, const js::Value &val);
void setDenseElement(uint32_t index, const js::Value &val) {
JS_ASSERT(uninlinedIsNative() && 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());
elements[index].init(this, js::HeapSlot::Element, index, val);
}
void setDenseElementMaybeConvertDouble(uint32_t index, const js::Value &val) {
if (val.isInt32() && shouldConvertDoubleElements())
setDenseElement(index, js::DoubleValue(val.toInt32()));
else
setDenseElement(index, val);
}
static inline void setDenseElementWithType(js::ExclusiveContext *cx, js::HandleObject obj,
uint32_t index, const js::Value &val);
static inline void initDenseElementWithType(js::ExclusiveContext *cx, js::HandleObject obj,
@ -558,7 +603,14 @@ class JSObject : public js::ObjectImpl
static inline void removeDenseElementForSparseIndex(js::ExclusiveContext *cx,
js::HandleObject obj, uint32_t index);
inline void copyDenseElements(uint32_t dstStart, const js::Value *src, uint32_t count);
inline void initDenseElements(uint32_t dstStart, const js::Value *src, uint32_t count);
void initDenseElements(uint32_t dstStart, const js::Value *src, uint32_t count) {
JS_ASSERT(dstStart + count <= getDenseCapacity());
JSRuntime *rt = runtimeFromMainThread();
for (uint32_t i = 0; i < count; ++i)
elements[dstStart + i].init(rt, this, js::HeapSlot::Element, dstStart + i, src[i]);
}
inline void moveDenseElements(uint32_t dstStart, uint32_t srcStart, uint32_t count);
inline void moveDenseElementsUnbarriered(uint32_t dstStart, uint32_t srcStart, uint32_t count);

Просмотреть файл

@ -129,44 +129,6 @@ JSObject::canRemoveLastProperty()
&& previous->getObjectFlags() == lastProperty()->getObjectFlags();
}
inline void
JSObject::setReservedSlot(uint32_t index, const js::Value &v)
{
JS_ASSERT(index < JSSLOT_FREE(getClass()));
setSlot(index, v);
}
inline void
JSObject::initReservedSlot(uint32_t index, const js::Value &v)
{
JS_ASSERT(index < JSSLOT_FREE(getClass()));
initSlot(index, v);
}
inline void
JSObject::prepareSlotRangeForOverwrite(size_t start, size_t end)
{
for (size_t i = start; i < end; i++)
getSlotAddressUnchecked(i)->js::HeapSlot::~HeapSlot();
}
inline void
JSObject::prepareElementRangeForOverwrite(size_t start, size_t end)
{
JS_ASSERT(end <= getDenseInitializedLength());
for (size_t i = start; i < end; i++)
elements[i].js::HeapSlot::~HeapSlot();
}
inline void
JSObject::setDenseInitializedLength(uint32_t length)
{
JS_ASSERT(isNative());
JS_ASSERT(length <= getDenseCapacity());
prepareElementRangeForOverwrite(length, getElementsHeader()->initializedLength);
getElementsHeader()->initializedLength = length;
}
inline void
JSObject::setShouldConvertDoubleElements()
{
@ -174,37 +136,6 @@ JSObject::setShouldConvertDoubleElements()
getElementsHeader()->setShouldConvertDoubleElements();
}
inline bool
JSObject::ensureElements(js::ThreadSafeContext *cx, uint32_t capacity)
{
if (capacity > getDenseCapacity())
return growElements(cx, capacity);
return true;
}
inline void
JSObject::setDenseElement(uint32_t index, const js::Value &val)
{
JS_ASSERT(isNative() && index < getDenseInitializedLength());
elements[index].set(this, js::HeapSlot::Element, index, val);
}
inline void
JSObject::setDenseElementMaybeConvertDouble(uint32_t index, const js::Value &val)
{
if (val.isInt32() && shouldConvertDoubleElements())
setDenseElement(index, js::DoubleValue(val.toInt32()));
else
setDenseElement(index, val);
}
inline void
JSObject::initDenseElement(uint32_t index, const js::Value &val)
{
JS_ASSERT(isNative() && index < getDenseInitializedLength());
elements[index].init(this, js::HeapSlot::Element, index, val);
}
/* static */ inline void
JSObject::setDenseElementWithType(js::ExclusiveContext *cx, js::HandleObject obj, uint32_t index,
const js::Value &val)
@ -249,15 +180,6 @@ JSObject::copyDenseElements(uint32_t dstStart, const js::Value *src, uint32_t co
elements[dstStart + i].set(zone, this, js::HeapSlot::Element, dstStart + i, src[i]);
}
inline void
JSObject::initDenseElements(uint32_t dstStart, const js::Value *src, uint32_t count)
{
JS_ASSERT(dstStart + count <= getDenseCapacity());
JSRuntime *rt = runtimeFromMainThread();
for (uint32_t i = 0; i < count; ++i)
elements[dstStart + i].init(rt, this, js::HeapSlot::Element, dstStart + i, src[i]);
}
inline void
JSObject::moveDenseElements(uint32_t dstStart, uint32_t srcStart, uint32_t count)
{
@ -647,14 +569,6 @@ JSObject::hasProperty(JSContext *cx, js::HandleObject obj,
return true;
}
inline void
JSObject::nativeSetSlot(uint32_t slot, const js::Value &value)
{
JS_ASSERT(isNative());
JS_ASSERT(slot < slotSpan());
return setSlot(slot, value);
}
/* static */ inline void
JSObject::nativeSetSlotWithType(js::ExclusiveContext *cx, js::HandleObject obj, js::Shape *shape,
const js::Value &value)

Просмотреть файл

@ -39,6 +39,7 @@
#include "jsfuninlines.h"
#include "jsinferinlines.h"
#include "jsobjinlines.h"
#include "vm/Runtime-inl.h"
#include "vm/ScopeObject-inl.h"

Просмотреть файл

@ -1,158 +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_GlobalObject_inl_h
#define vm_GlobalObject_inl_h
#include "vm/GlobalObject.h"
#include "vm/ObjectImpl-inl.h"
namespace js {
inline void
GlobalObject::setDetailsForKey(JSProtoKey key, JSObject *ctor, JSObject *proto)
{
JS_ASSERT(getSlotRef(key).isUndefined());
JS_ASSERT(getSlotRef(JSProto_LIMIT + key).isUndefined());
JS_ASSERT(getSlotRef(2 * JSProto_LIMIT + key).isUndefined());
setSlot(key, ObjectValue(*ctor));
setSlot(JSProto_LIMIT + key, ObjectValue(*proto));
setSlot(2 * JSProto_LIMIT + key, ObjectValue(*ctor));
}
inline void
GlobalObject::setObjectClassDetails(JSFunction *ctor, JSObject *proto)
{
setDetailsForKey(JSProto_Object, ctor, proto);
}
inline void
GlobalObject::setFunctionClassDetails(JSFunction *ctor, JSObject *proto)
{
setDetailsForKey(JSProto_Function, ctor, proto);
}
void
GlobalObject::setThrowTypeError(JSFunction *fun)
{
JS_ASSERT(getSlotRef(THROWTYPEERROR).isUndefined());
setSlot(THROWTYPEERROR, ObjectValue(*fun));
}
void
GlobalObject::setOriginalEval(JSObject *evalobj)
{
JS_ASSERT(getSlotRef(EVAL).isUndefined());
setSlot(EVAL, ObjectValue(*evalobj));
}
void
GlobalObject::setCreateArrayFromBufferHelper(uint32_t slot, Handle<JSFunction*> fun)
{
JS_ASSERT(getSlotRef(slot).isUndefined());
setSlot(slot, ObjectValue(*fun));
}
void
GlobalObject::setCreateDataViewForThis(Handle<JSFunction*> fun)
{
JS_ASSERT(getSlotRef(CREATE_DATAVIEW_FOR_THIS).isUndefined());
setSlot(CREATE_DATAVIEW_FOR_THIS, ObjectValue(*fun));
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<uint8_t>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_UINT8, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<int8_t>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_INT8, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<uint16_t>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_UINT16, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<int16_t>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_INT16, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<uint32_t>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_UINT32, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<int32_t>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_INT32, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<float>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_FLOAT32, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<double>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_FLOAT64, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<uint8_clamped>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_UINT8CLAMPED, fun);
}
void
GlobalObject::setProtoGetter(JSFunction *protoGetter)
{
JS_ASSERT(getSlotRef(PROTO_GETTER).isUndefined());
setSlot(PROTO_GETTER, ObjectValue(*protoGetter));
}
bool
GlobalObject::setIntrinsicValue(JSContext *cx, PropertyName *name, HandleValue value)
{
#ifdef DEBUG
RootedObject self(cx, this);
JS_ASSERT(cx->runtime()->isSelfHostingGlobal(self));
#endif
RootedObject holder(cx, intrinsicsHolder());
RootedValue valCopy(cx, value);
return JSObject::setProperty(cx, holder, holder, name, &valCopy, false);
}
void
GlobalObject::setIntrinsicsHolder(JSObject *obj)
{
JS_ASSERT(getSlotRef(INTRINSICS).isUndefined());
setSlot(INTRINSICS, ObjectValue(*obj));
}
} // namespace js
#endif /* vm_GlobalObject_inl_h */

Просмотреть файл

@ -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/GlobalObject-inl.h"
#include "vm/GlobalObject.h"
#include "jscntxt.h"
#include "jsdate.h"

Просмотреть файл

@ -124,15 +124,42 @@ class GlobalObject : public JSObject
JSObject *
initFunctionAndObjectClasses(JSContext *cx);
inline void setDetailsForKey(JSProtoKey key, JSObject *ctor, JSObject *proto);
inline void setObjectClassDetails(JSFunction *ctor, JSObject *proto);
inline void setFunctionClassDetails(JSFunction *ctor, JSObject *proto);
void setDetailsForKey(JSProtoKey key, JSObject *ctor, JSObject *proto) {
JS_ASSERT(getSlotRef(key).isUndefined());
JS_ASSERT(getSlotRef(JSProto_LIMIT + key).isUndefined());
JS_ASSERT(getSlotRef(2 * JSProto_LIMIT + key).isUndefined());
setSlot(key, ObjectValue(*ctor));
setSlot(JSProto_LIMIT + key, ObjectValue(*proto));
setSlot(2 * JSProto_LIMIT + key, ObjectValue(*ctor));
}
inline void setThrowTypeError(JSFunction *fun);
inline void setOriginalEval(JSObject *evalobj);
inline void setProtoGetter(JSFunction *protoGetter);
void setObjectClassDetails(JSFunction *ctor, JSObject *proto) {
setDetailsForKey(JSProto_Object, ctor, proto);
}
inline void setIntrinsicsHolder(JSObject *obj);
void setFunctionClassDetails(JSFunction *ctor, JSObject *proto) {
setDetailsForKey(JSProto_Function, ctor, proto);
}
void setThrowTypeError(JSFunction *fun) {
JS_ASSERT(getSlotRef(THROWTYPEERROR).isUndefined());
setSlot(THROWTYPEERROR, ObjectValue(*fun));
}
void setOriginalEval(JSObject *evalobj) {
JS_ASSERT(getSlotRef(EVAL).isUndefined());
setSlot(EVAL, ObjectValue(*evalobj));
}
void setProtoGetter(JSFunction *protoGetter) {
JS_ASSERT(getSlotRef(PROTO_GETTER).isUndefined());
setSlot(PROTO_GETTER, ObjectValue(*protoGetter));
}
void setIntrinsicsHolder(JSObject *obj) {
JS_ASSERT(getSlotRef(INTRINSICS).isUndefined());
setSlot(INTRINSICS, ObjectValue(*obj));
}
Value getConstructor(JSProtoKey key) const {
JS_ASSERT(key <= JSProto_LIMIT);
@ -193,11 +220,17 @@ class GlobalObject : public JSObject
return getSlot(slot);
}
inline void setCreateArrayFromBufferHelper(uint32_t slot, Handle<JSFunction*> fun);
void setCreateArrayFromBufferHelper(uint32_t slot, Handle<JSFunction*> fun) {
JS_ASSERT(getSlotRef(slot).isUndefined());
setSlot(slot, ObjectValue(*fun));
}
public:
/* XXX Privatize me! */
inline void setCreateDataViewForThis(Handle<JSFunction*> fun);
void setCreateDataViewForThis(Handle<JSFunction*> fun) {
JS_ASSERT(getSlotRef(CREATE_DATAVIEW_FOR_THIS).isUndefined());
setSlot(CREATE_DATAVIEW_FOR_THIS, ObjectValue(*fun));
}
template<typename T>
inline void setCreateArrayFromBuffer(Handle<JSFunction*> fun);
@ -416,9 +449,20 @@ class GlobalObject : public JSObject
return true;
}
inline bool setIntrinsicValue(JSContext *cx, PropertyName *name, HandleValue value);
bool setIntrinsicValue(JSContext *cx, PropertyName *name, HandleValue value) {
#ifdef DEBUG
RootedObject self(cx, this);
JS_ASSERT(cx->runtime()->isSelfHostingGlobal(self));
#endif
RootedObject holder(cx, intrinsicsHolder());
RootedValue valCopy(cx, value);
return JSObject::setProperty(cx, holder, holder, name, &valCopy, false);
}
inline RegExpStatics *getRegExpStatics() const;
RegExpStatics *getRegExpStatics() const {
JSObject &resObj = getSlot(REGEXP_STATICS).toObject();
return static_cast<RegExpStatics *>(resObj.getPrivate());
}
JSObject *getThrowTypeError() const {
JS_ASSERT(functionObjectClassesInitialized());
@ -482,6 +526,69 @@ class GlobalObject : public JSObject
static bool addDebugger(JSContext *cx, Handle<GlobalObject*> global, Debugger *dbg);
};
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<uint8_t>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_UINT8, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<int8_t>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_INT8, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<uint16_t>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_UINT16, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<int16_t>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_INT16, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<uint32_t>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_UINT32, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<int32_t>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_INT32, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<float>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_FLOAT32, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<double>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_FLOAT64, fun);
}
template<>
inline void
GlobalObject::setCreateArrayFromBuffer<uint8_clamped>(Handle<JSFunction*> fun)
{
setCreateArrayFromBufferHelper(FROM_BUFFER_UINT8CLAMPED, fun);
}
template<>
inline Value
GlobalObject::createArrayFromBuffer<uint8_t>() const

Просмотреть файл

@ -23,7 +23,6 @@
#include "jsinferinlines.h"
#include "jsobjinlines.h"
#include "vm/GlobalObject-inl.h"
#include "vm/Stack-inl.h"
namespace js {

Просмотреть файл

@ -67,68 +67,6 @@ js::ObjectImpl::isNative() const
return lastProperty()->isNative();
}
#ifdef DEBUG
inline bool
IsObjectValueInCompartment(js::Value v, JSCompartment *comp)
{
if (!v.isObject())
return true;
return v.toObject().compartment() == comp;
}
#endif
inline void
js::ObjectImpl::setSlot(uint32_t slot, const js::Value &value)
{
MOZ_ASSERT(slotInRange(slot));
MOZ_ASSERT(IsObjectValueInCompartment(value, asObjectPtr()->compartment()));
getSlotRef(slot).set(this->asObjectPtr(), HeapSlot::Slot, slot, value);
}
inline void
js::ObjectImpl::setCrossCompartmentSlot(uint32_t slot, const js::Value &value)
{
MOZ_ASSERT(slotInRange(slot));
getSlotRef(slot).set(this->asObjectPtr(), HeapSlot::Slot, slot, value);
}
inline void
js::ObjectImpl::initSlot(uint32_t slot, const js::Value &value)
{
MOZ_ASSERT(getSlot(slot).isUndefined());
MOZ_ASSERT(slotInRange(slot));
MOZ_ASSERT(IsObjectValueInCompartment(value, asObjectPtr()->compartment()));
initSlotUnchecked(slot, value);
}
inline void
js::ObjectImpl::initCrossCompartmentSlot(uint32_t slot, const js::Value &value)
{
MOZ_ASSERT(getSlot(slot).isUndefined());
MOZ_ASSERT(slotInRange(slot));
initSlotUnchecked(slot, value);
}
inline void
js::ObjectImpl::initSlotUnchecked(uint32_t slot, const js::Value &value)
{
getSlotAddressUnchecked(slot)->init(this->asObjectPtr(), HeapSlot::Slot, slot, value);
}
inline void
js::ObjectImpl::setFixedSlot(uint32_t slot, const js::Value &value)
{
MOZ_ASSERT(slot < numFixedSlots());
fixedSlots()[slot].set(this->asObjectPtr(), HeapSlot::Slot, slot, value);
}
inline void
js::ObjectImpl::initFixedSlot(uint32_t slot, const js::Value &value)
{
MOZ_ASSERT(slot < numFixedSlots());
fixedSlots()[slot].init(this->asObjectPtr(), HeapSlot::Slot, slot, value);
}
inline uint32_t
js::ObjectImpl::slotSpan() const
{
@ -188,14 +126,6 @@ js::ObjectImpl::privateWriteBarrierPre(void **old)
#endif
}
inline void
js::ObjectImpl::privateWriteBarrierPost(void **pprivate)
{
#ifdef JSGC_GENERATIONAL
runtimeFromAnyThread()->gcStoreBuffer.putCell(reinterpret_cast<js::gc::Cell **>(pprivate));
#endif
}
/* static */ inline void
js::ObjectImpl::writeBarrierPre(ObjectImpl *obj)
{
@ -217,32 +147,6 @@ js::ObjectImpl::writeBarrierPre(ObjectImpl *obj)
#endif
}
/* static */ inline void
js::ObjectImpl::writeBarrierPost(ObjectImpl *obj, void *addr)
{
#ifdef JSGC_GENERATIONAL
if (IsNullTaggedPointer(obj))
return;
obj->runtimeFromAnyThread()->gcStoreBuffer.putCell((Cell **)addr);
#endif
}
/* static */ inline void
js::ObjectImpl::writeBarrierPostRelocate(ObjectImpl *obj, void *addr)
{
#ifdef JSGC_GENERATIONAL
obj->runtimeFromAnyThread()->gcStoreBuffer.putRelocatableCell((Cell **)addr);
#endif
}
/* static */ inline void
js::ObjectImpl::writeBarrierPostRemove(ObjectImpl *obj, void *addr)
{
#ifdef JSGC_GENERATIONAL
obj->runtimeFromAnyThread()->gcStoreBuffer.removeRelocatableCell((Cell **)addr);
#endif
}
inline void
js::ObjectImpl::setPrivate(void *data)
{

Просмотреть файл

@ -16,6 +16,12 @@
using namespace js;
JSCompartment *
js::ObjectImpl::uninlinedCompartment() const
{
return compartment();
}
bool
js::ObjectImpl::uninlinedIsNative() const
{

Просмотреть файл

@ -18,6 +18,7 @@
#include "gc/Barrier.h"
#include "gc/Heap.h"
#include "gc/Marking.h"
#include "js/Value.h"
#include "vm/NumericConversions.h"
#include "vm/String.h"
@ -1145,6 +1146,11 @@ class TaggedProto;
inline Value
ObjectValue(ObjectImpl &obj);
#ifdef DEBUG
static inline bool
IsObjectValueInCompartment(js::Value v, JSCompartment *comp);
#endif
/*
* ObjectImpl specifies the internal implementation of an object. (In contrast
* JSObject specifies an "external" interface, at the conceptual level of that
@ -1197,7 +1203,7 @@ class ObjectImpl : public gc::Cell
protected:
/*
* Shape of the object, encodes the layout of the object's properties and
* all other information about its structure. See jsscope.h.
* all other information about its structure. See vm/Shape.h.
*/
HeapPtrShape shape_;
@ -1436,7 +1442,9 @@ 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;
// uninlinedIsNative() is equivalent to isNative(), but isn't inlined.
inline bool isNative() const;
@ -1573,11 +1581,33 @@ class ObjectImpl : public gc::Cell
return getSlot(slot);
}
inline void setSlot(uint32_t slot, const Value &value);
inline void setCrossCompartmentSlot(uint32_t slot, const Value &value);
inline void initSlot(uint32_t slot, const Value &value);
inline void initCrossCompartmentSlot(uint32_t slot, const Value &value);
inline void initSlotUnchecked(uint32_t slot, const Value &value);
void setSlot(uint32_t slot, const Value &value) {
MOZ_ASSERT(slotInRange(slot));
MOZ_ASSERT(IsObjectValueInCompartment(value, uninlinedCompartment()));
getSlotRef(slot).set(this->asObjectPtr(), HeapSlot::Slot, slot, value);
}
inline void setCrossCompartmentSlot(uint32_t slot, const Value &value) {
MOZ_ASSERT(slotInRange(slot));
getSlotRef(slot).set(this->asObjectPtr(), HeapSlot::Slot, slot, value);
}
void initSlot(uint32_t slot, const Value &value) {
MOZ_ASSERT(getSlot(slot).isUndefined());
MOZ_ASSERT(slotInRange(slot));
MOZ_ASSERT(IsObjectValueInCompartment(value, uninlinedCompartment()));
initSlotUnchecked(slot, value);
}
void initCrossCompartmentSlot(uint32_t slot, const Value &value) {
MOZ_ASSERT(getSlot(slot).isUndefined());
MOZ_ASSERT(slotInRange(slot));
initSlotUnchecked(slot, value);
}
void initSlotUnchecked(uint32_t slot, const Value &value) {
getSlotAddressUnchecked(slot)->init(this->asObjectPtr(), HeapSlot::Slot, slot, value);
}
/* For slots which are known to always be fixed, due to the way they are allocated. */
@ -1591,8 +1621,15 @@ class ObjectImpl : public gc::Cell
return fixedSlots()[slot];
}
inline void setFixedSlot(uint32_t slot, const Value &value);
inline void initFixedSlot(uint32_t slot, const Value &value);
void setFixedSlot(uint32_t slot, const Value &value) {
MOZ_ASSERT(slot < numFixedSlots());
fixedSlots()[slot].set(this->asObjectPtr(), HeapSlot::Slot, slot, value);
}
void initFixedSlot(uint32_t slot, const Value &value) {
MOZ_ASSERT(slot < numFixedSlots());
fixedSlots()[slot].init(this->asObjectPtr(), HeapSlot::Slot, slot, value);
}
/*
* Get the number of dynamic slots to allocate to cover the properties in
@ -1658,14 +1695,39 @@ class ObjectImpl : public gc::Cell
/* GC support. */
JS_ALWAYS_INLINE Zone *zone() const;
static inline ThingRootKind rootKind() { return THING_ROOT_OBJECT; }
static ThingRootKind rootKind() { return THING_ROOT_OBJECT; }
static inline void readBarrier(ObjectImpl *obj);
static inline void writeBarrierPre(ObjectImpl *obj);
static inline void writeBarrierPost(ObjectImpl *obj, void *addr);
static inline void writeBarrierPostRelocate(ObjectImpl *obj, void *addr);
static inline void writeBarrierPostRemove(ObjectImpl *obj, void *addr);
static void writeBarrierPost(ObjectImpl *obj, void *addr) {
#ifdef JSGC_GENERATIONAL
if (IsNullTaggedPointer(obj))
return;
obj->shadowRuntimeFromAnyThread()->gcStoreBufferPtr()->putCell((Cell **)addr);
#endif
}
static void writeBarrierPostRelocate(ObjectImpl *obj, void *addr) {
#ifdef JSGC_GENERATIONAL
obj->shadowRuntimeFromAnyThread()->gcStoreBufferPtr()->putRelocatableCell((Cell **)addr);
#endif
}
static void writeBarrierPostRemove(ObjectImpl *obj, void *addr) {
#ifdef JSGC_GENERATIONAL
obj->shadowRuntimeFromAnyThread()->gcStoreBufferPtr()->removeRelocatableCell((Cell **)addr);
#endif
}
inline void privateWriteBarrierPre(void **oldval);
inline void privateWriteBarrierPost(void **pprivate);
void privateWriteBarrierPost(void **pprivate) {
#ifdef JSGC_GENERATIONAL
shadowRuntimeFromAnyThread()->gcStoreBufferPtr()->putCell(reinterpret_cast<js::gc::Cell **>(pprivate));
#endif
}
void markChildren(JSTracer *trc);
/* Private data accessors. */
@ -1736,6 +1798,16 @@ Downcast(Handle<ObjectImpl*> obj)
return Handle<JSObject*>::fromMarkedLocation(reinterpret_cast<JSObject* const*>(obj.address()));
}
#ifdef DEBUG
static inline bool
IsObjectValueInCompartment(js::Value v, JSCompartment *comp)
{
if (!v.isObject())
return true;
return reinterpret_cast<ObjectImpl*>(&v.toObject())->uninlinedCompartment() == comp;
}
#endif
extern JSObject *
ArrayBufferDelegate(JSContext *cx, Handle<ObjectImpl*> obj);

Просмотреть файл

@ -18,48 +18,6 @@ RegExpObject::setShared(ExclusiveContext *cx, RegExpShared &shared)
JSObject::setPrivate(&shared);
}
inline void
RegExpObject::setLastIndex(double d)
{
setSlot(LAST_INDEX_SLOT, NumberValue(d));
}
inline void
RegExpObject::zeroLastIndex()
{
setSlot(LAST_INDEX_SLOT, Int32Value(0));
}
inline void
RegExpObject::setSource(JSAtom *source)
{
setSlot(SOURCE_SLOT, StringValue(source));
}
inline void
RegExpObject::setIgnoreCase(bool enabled)
{
setSlot(IGNORE_CASE_FLAG_SLOT, BooleanValue(enabled));
}
inline void
RegExpObject::setGlobal(bool enabled)
{
setSlot(GLOBAL_FLAG_SLOT, BooleanValue(enabled));
}
inline void
RegExpObject::setMultiline(bool enabled)
{
setSlot(MULTILINE_FLAG_SLOT, BooleanValue(enabled));
}
inline void
RegExpObject::setSticky(bool enabled)
{
setSlot(STICKY_FLAG_SLOT, BooleanValue(enabled));
}
} /* namespace js */
#endif /* vm_RegExpObject_inl_h */

Просмотреть файл

@ -366,13 +366,22 @@ class RegExpObject : public JSObject
static unsigned lastIndexSlot() { return LAST_INDEX_SLOT; }
const Value &getLastIndex() const { return getSlot(LAST_INDEX_SLOT); }
inline void setLastIndex(double d);
inline void zeroLastIndex();
void setLastIndex(double d) {
setSlot(LAST_INDEX_SLOT, NumberValue(d));
}
void zeroLastIndex() {
setSlot(LAST_INDEX_SLOT, Int32Value(0));
}
JSFlatString *toString(JSContext *cx) const;
JSAtom *getSource() const { return &getSlot(SOURCE_SLOT).toString()->asAtom(); }
inline void setSource(JSAtom *source);
void setSource(JSAtom *source) {
setSlot(SOURCE_SLOT, StringValue(source));
}
RegExpFlag getFlags() const {
unsigned flags = 0;
@ -385,10 +394,22 @@ class RegExpObject : public JSObject
/* Flags. */
inline void setIgnoreCase(bool enabled);
inline void setGlobal(bool enabled);
inline void setMultiline(bool enabled);
inline void setSticky(bool enabled);
void setIgnoreCase(bool enabled) {
setSlot(IGNORE_CASE_FLAG_SLOT, BooleanValue(enabled));
}
void setGlobal(bool enabled) {
setSlot(GLOBAL_FLAG_SLOT, BooleanValue(enabled));
}
void setMultiline(bool enabled) {
setSlot(MULTILINE_FLAG_SLOT, BooleanValue(enabled));
}
void setSticky(bool enabled) {
setSlot(STICKY_FLAG_SLOT, BooleanValue(enabled));
}
bool ignoreCase() const { return getSlot(IGNORE_CASE_FLAG_SLOT).toBoolean(); }
bool global() const { return getSlot(GLOBAL_FLAG_SLOT).toBoolean(); }
bool multiline() const { return getSlot(MULTILINE_FLAG_SLOT).toBoolean(); }
@ -406,6 +427,7 @@ class RegExpObject : public JSObject
}
return createShared(cx, g);
}
inline void setShared(ExclusiveContext *cx, RegExpShared &shared);
private:

Просмотреть файл

@ -200,13 +200,6 @@ class PreserveRegExpStatics
~PreserveRegExpStatics() { original->restore(); }
};
inline js::RegExpStatics *
js::GlobalObject::getRegExpStatics() const
{
JSObject &resObj = getSlot(REGEXP_STATICS).toObject();
return static_cast<RegExpStatics *>(resObj.getPrivate());
}
inline bool
RegExpStatics::createDependent(JSContext *cx, size_t start, size_t end, MutableHandleValue out)
{

Просмотреть файл

@ -10,18 +10,9 @@
#include "vm/ScopeObject.h"
#include "jsinferinlines.h"
#include "jsobjinlines.h"
namespace js {
inline void
ScopeObject::setEnclosingScope(HandleObject obj)
{
JS_ASSERT_IF(obj->is<CallObject>() || obj->is<DeclEnvObject>() || obj->is<BlockObject>(),
obj->isDelegate());
setFixedSlot(SCOPE_CHAIN_SLOT, ObjectValue(*obj));
}
inline void
ScopeObject::setAliasedVar(JSContext *cx, ScopeCoordinate sc, PropertyName *name, const Value &v)
{
@ -45,63 +36,6 @@ CallObject::setAliasedVar(JSContext *cx, AliasedFormalIter fi, PropertyName *nam
types::AddTypePropertyId(cx, this, NameToId(name), v);
}
inline void
BlockObject::setSlotValue(unsigned i, const Value &v)
{
setSlot(RESERVED_SLOTS + i, v);
}
inline void
StaticBlockObject::initPrevBlockChainFromParser(StaticBlockObject *prev)
{
setReservedSlot(SCOPE_CHAIN_SLOT, ObjectOrNullValue(prev));
}
inline void
StaticBlockObject::resetPrevBlockChainFromParser()
{
setReservedSlot(SCOPE_CHAIN_SLOT, UndefinedValue());
}
inline void
StaticBlockObject::initEnclosingStaticScope(JSObject *obj)
{
JS_ASSERT(getReservedSlot(SCOPE_CHAIN_SLOT).isUndefined());
setReservedSlot(SCOPE_CHAIN_SLOT, ObjectOrNullValue(obj));
}
inline void
StaticBlockObject::setStackDepth(uint32_t depth)
{
JS_ASSERT(getReservedSlot(DEPTH_SLOT).isUndefined());
initReservedSlot(DEPTH_SLOT, PrivateUint32Value(depth));
}
inline void
StaticBlockObject::setDefinitionParseNode(unsigned i, frontend::Definition *def)
{
JS_ASSERT(slotValue(i).isUndefined());
setSlotValue(i, PrivateValue(def));
}
inline void
StaticBlockObject::setAliased(unsigned i, bool aliased)
{
JS_ASSERT_IF(i > 0, slotValue(i-1).isBoolean());
setSlotValue(i, BooleanValue(aliased));
if (aliased && !needsClone()) {
setSlotValue(0, MagicValue(JS_BLOCK_NEEDS_CLONE));
JS_ASSERT(needsClone());
}
}
inline void
ClonedBlockObject::setVar(unsigned i, const Value &v, MaybeCheckAliasing checkAliasing)
{
JS_ASSERT_IF(checkAliasing, staticBlock().isAliased(i));
setSlotValue(i, v);
}
} /* namespace js */
#endif /* vm_ScopeObject_inl_h */

Просмотреть файл

@ -166,6 +166,14 @@ js::ScopeCoordinateFunctionScript(JSContext *cx, JSScript *script, jsbytecode *p
/*****************************************************************************/
inline void
ScopeObject::setEnclosingScope(HandleObject obj)
{
JS_ASSERT_IF(obj->is<CallObject>() || obj->is<DeclEnvObject>() || obj->is<BlockObject>(),
obj->isDelegate());
setFixedSlot(SCOPE_CHAIN_SLOT, ObjectValue(*obj));
}
/*
* Construct a bare-bones call object given a shape, type, and slots pointer.
* The call object must be further initialized to be usable.

Просмотреть файл

@ -170,7 +170,8 @@ class ScopeObject : public JSObject
inline JSObject &enclosingScope() const {
return getReservedSlot(SCOPE_CHAIN_SLOT).toObject();
}
void setEnclosingScope(HandleObject obj);
inline void setEnclosingScope(HandleObject obj);
/*
* Get or set an aliased variable contained in this scope. Unaliased
@ -342,7 +343,9 @@ class BlockObject : public NestedScopeObject
return getSlotRef(RESERVED_SLOTS + i);
}
inline void setSlotValue(unsigned i, const Value &v);
void setSlotValue(unsigned i, const Value &v) {
setSlot(RESERVED_SLOTS + i, v);
}
};
class StaticBlockObject : public BlockObject
@ -388,15 +391,34 @@ class StaticBlockObject : public BlockObject
/* Frontend-only functions ***********************************************/
/* Initialization functions for above fields. */
void setAliased(unsigned i, bool aliased);
void setStackDepth(uint32_t depth);
void initEnclosingStaticScope(JSObject *obj);
void setAliased(unsigned i, bool aliased) {
JS_ASSERT_IF(i > 0, slotValue(i-1).isBoolean());
setSlotValue(i, BooleanValue(aliased));
if (aliased && !needsClone()) {
setSlotValue(0, MagicValue(JS_BLOCK_NEEDS_CLONE));
JS_ASSERT(needsClone());
}
}
void setStackDepth(uint32_t depth) {
JS_ASSERT(getReservedSlot(DEPTH_SLOT).isUndefined());
initReservedSlot(DEPTH_SLOT, PrivateUint32Value(depth));
}
void initEnclosingStaticScope(JSObject *obj) {
JS_ASSERT(getReservedSlot(SCOPE_CHAIN_SLOT).isUndefined());
setReservedSlot(SCOPE_CHAIN_SLOT, ObjectOrNullValue(obj));
}
/*
* Frontend compilation temporarily uses the object's slots to link
* a let var to its associated Definition parse node.
*/
void setDefinitionParseNode(unsigned i, frontend::Definition *def);
void setDefinitionParseNode(unsigned i, frontend::Definition *def) {
JS_ASSERT(slotValue(i).isUndefined());
setSlotValue(i, PrivateValue(def));
}
frontend::Definition *maybeDefinitionParseNode(unsigned i) {
Value v = slotValue(i);
return v.isUndefined() ? NULL : reinterpret_cast<frontend::Definition *>(v.toPrivate());
@ -408,8 +430,13 @@ class StaticBlockObject : public BlockObject
* be the same as enclosingBlock, initEnclosingStaticScope must be called
* separately in the emitter. 'reset' is just for asserting stackiness.
*/
void initPrevBlockChainFromParser(StaticBlockObject *prev);
void resetPrevBlockChainFromParser();
void initPrevBlockChainFromParser(StaticBlockObject *prev) {
setReservedSlot(SCOPE_CHAIN_SLOT, ObjectOrNullValue(prev));
}
void resetPrevBlockChainFromParser() {
setReservedSlot(SCOPE_CHAIN_SLOT, UndefinedValue());
}
static Shape *addVar(ExclusiveContext *cx, Handle<StaticBlockObject*> block, HandleId id,
int index, bool *redeclared);
@ -432,7 +459,10 @@ class ClonedBlockObject : public BlockObject
return slotValue(i);
}
void setVar(unsigned i, const Value &v, MaybeCheckAliasing checkAliasing = CHECK_ALIASING);
void setVar(unsigned i, const Value &v, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) {
JS_ASSERT_IF(checkAliasing, staticBlock().isAliased(i));
setSlotValue(i, v);
}
/* Copy in all the unaliased formals and locals. */
void copyUnaliasedValues(AbstractFramePtr frame);

Просмотреть файл

@ -16,6 +16,8 @@
#include "jit/BaselineFrame.h"
#include "vm/ScopeObject.h"
#include "jsobjinlines.h"
#include "jit/BaselineFrame-inl.h"
#include "jit/IonFrameIterator-inl.h"

Просмотреть файл

@ -40,8 +40,6 @@
#include "jsinferinlines.h"
#include "jsobjinlines.h"
#include "vm/GlobalObject-inl.h"
#if JS_USE_NEW_OBJECT_REPRESENTATION
// See the comment above OldObjectRepresentationHack.
# error "TypedArray support for new object representation unimplemented."