mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 891215 (part 13) - Slim down ArgumentsObject-inl.h. r=terrence.
--HG-- extra : rebase_source : 79499e11b72b79a1b6436c08c94a09228c6b8fa3
This commit is contained in:
parent
ac57e7a3fe
commit
dd3d1773ed
@ -16,58 +16,6 @@
|
||||
|
||||
namespace js {
|
||||
|
||||
inline uint32_t
|
||||
ArgumentsObject::initialLength() const
|
||||
{
|
||||
uint32_t argc = uint32_t(getFixedSlot(INITIAL_LENGTH_SLOT).toInt32()) >> PACKED_BITS_COUNT;
|
||||
JS_ASSERT(argc <= ARGS_LENGTH_MAX);
|
||||
return argc;
|
||||
}
|
||||
|
||||
inline void
|
||||
ArgumentsObject::markLengthOverridden()
|
||||
{
|
||||
uint32_t v = getFixedSlot(INITIAL_LENGTH_SLOT).toInt32() | LENGTH_OVERRIDDEN_BIT;
|
||||
setFixedSlot(INITIAL_LENGTH_SLOT, Int32Value(v));
|
||||
}
|
||||
|
||||
inline bool
|
||||
ArgumentsObject::hasOverriddenLength() const
|
||||
{
|
||||
const Value &v = getFixedSlot(INITIAL_LENGTH_SLOT);
|
||||
return v.toInt32() & LENGTH_OVERRIDDEN_BIT;
|
||||
}
|
||||
|
||||
inline ArgumentsData *
|
||||
ArgumentsObject::data() const
|
||||
{
|
||||
return reinterpret_cast<ArgumentsData *>(getFixedSlot(DATA_SLOT).toPrivate());
|
||||
}
|
||||
|
||||
inline JSScript *
|
||||
ArgumentsObject::containingScript() const
|
||||
{
|
||||
return data()->script;
|
||||
}
|
||||
|
||||
inline const Value &
|
||||
ArgumentsObject::arg(unsigned i) const
|
||||
{
|
||||
JS_ASSERT(i < data()->numArgs);
|
||||
const Value &v = data()->args[i];
|
||||
JS_ASSERT(!v.isMagic(JS_FORWARD_TO_CALL_OBJECT));
|
||||
return v;
|
||||
}
|
||||
|
||||
inline void
|
||||
ArgumentsObject::setArg(unsigned i, const Value &v)
|
||||
{
|
||||
JS_ASSERT(i < data()->numArgs);
|
||||
HeapValue &lhs = data()->args[i];
|
||||
JS_ASSERT(!lhs.isMagic(JS_FORWARD_TO_CALL_OBJECT));
|
||||
lhs = v;
|
||||
}
|
||||
|
||||
inline const Value &
|
||||
ArgumentsObject::element(uint32_t i) const
|
||||
{
|
||||
@ -100,36 +48,6 @@ ArgumentsObject::setElement(JSContext *cx, uint32_t i, const Value &v)
|
||||
lhs = v;
|
||||
}
|
||||
|
||||
inline bool
|
||||
ArgumentsObject::isElementDeleted(uint32_t i) const
|
||||
{
|
||||
JS_ASSERT(i < data()->numArgs);
|
||||
if (i >= initialLength())
|
||||
return false;
|
||||
return IsBitArrayElementSet(data()->deletedBits, initialLength(), i);
|
||||
}
|
||||
|
||||
inline bool
|
||||
ArgumentsObject::isAnyElementDeleted() const
|
||||
{
|
||||
return IsAnyBitArrayElementSet(data()->deletedBits, initialLength());
|
||||
}
|
||||
|
||||
inline void
|
||||
ArgumentsObject::markElementDeleted(uint32_t i)
|
||||
{
|
||||
SetBitArrayElement(data()->deletedBits, initialLength(), i);
|
||||
}
|
||||
|
||||
inline bool
|
||||
ArgumentsObject::maybeGetElement(uint32_t i, MutableHandleValue vp)
|
||||
{
|
||||
if (i >= initialLength() || isElementDeleted(i))
|
||||
return false;
|
||||
vp.set(element(i));
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool
|
||||
ArgumentsObject::maybeGetElements(uint32_t start, uint32_t count, Value *vp)
|
||||
{
|
||||
@ -144,24 +62,6 @@ ArgumentsObject::maybeGetElements(uint32_t start, uint32_t count, Value *vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
inline size_t
|
||||
ArgumentsObject::sizeOfMisc(mozilla::MallocSizeOf mallocSizeOf) const
|
||||
{
|
||||
return mallocSizeOf(data());
|
||||
}
|
||||
|
||||
inline const Value &
|
||||
NormalArgumentsObject::callee() const
|
||||
{
|
||||
return data()->callee;
|
||||
}
|
||||
|
||||
inline void
|
||||
NormalArgumentsObject::clearCallee()
|
||||
{
|
||||
data()->callee.set(zone(), MagicValue(JS_OVERWRITTEN_CALLEE));
|
||||
}
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
#endif /* vm_ArgumentsObject_inl_h */
|
||||
|
@ -63,6 +63,12 @@ struct ArgumentsData
|
||||
static ptrdiff_t offsetOfArgs() { return offsetof(ArgumentsData, args); }
|
||||
};
|
||||
|
||||
// Maximum supported value of arguments.length. This bounds the maximum
|
||||
// number of arguments that can be supplied to Function.prototype.apply.
|
||||
// This value also bounds the number of elements parsed in an array
|
||||
// initialiser.
|
||||
static const unsigned ARGS_LENGTH_MAX = 500 * 1000;
|
||||
|
||||
/*
|
||||
* ArgumentsObject instances represent |arguments| objects created to store
|
||||
* function arguments when a function is called. It's expensive to create such
|
||||
@ -116,7 +122,9 @@ class ArgumentsObject : public JSObject
|
||||
static ArgumentsObject *create(JSContext *cx, HandleScript script, HandleFunction callee,
|
||||
unsigned numActuals, CopyArgs ©);
|
||||
|
||||
inline ArgumentsData *data() const;
|
||||
ArgumentsData *data() const {
|
||||
return reinterpret_cast<ArgumentsData *>(getFixedSlot(DATA_SLOT).toPrivate());
|
||||
}
|
||||
|
||||
public:
|
||||
static const uint32_t RESERVED_SLOTS = 3;
|
||||
@ -142,14 +150,27 @@ class ArgumentsObject : public JSObject
|
||||
* Return the initial length of the arguments. This may differ from the
|
||||
* current value of arguments.length!
|
||||
*/
|
||||
inline uint32_t initialLength() const;
|
||||
uint32_t initialLength() const {
|
||||
uint32_t argc = uint32_t(getFixedSlot(INITIAL_LENGTH_SLOT).toInt32()) >> PACKED_BITS_COUNT;
|
||||
JS_ASSERT(argc <= ARGS_LENGTH_MAX);
|
||||
return argc;
|
||||
}
|
||||
|
||||
/* The script for the function containing this arguments object. */
|
||||
JSScript *containingScript() const;
|
||||
JSScript *containingScript() const {
|
||||
return data()->script;
|
||||
}
|
||||
|
||||
/* True iff arguments.length has been assigned or its attributes changed. */
|
||||
inline bool hasOverriddenLength() const;
|
||||
inline void markLengthOverridden();
|
||||
bool hasOverriddenLength() const {
|
||||
const Value &v = getFixedSlot(INITIAL_LENGTH_SLOT);
|
||||
return v.toInt32() & LENGTH_OVERRIDDEN_BIT;
|
||||
}
|
||||
|
||||
void markLengthOverridden() {
|
||||
uint32_t v = getFixedSlot(INITIAL_LENGTH_SLOT).toInt32() | LENGTH_OVERRIDDEN_BIT;
|
||||
setFixedSlot(INITIAL_LENGTH_SLOT, Int32Value(v));
|
||||
}
|
||||
|
||||
/*
|
||||
* Because the arguments object is a real object, its elements may be
|
||||
@ -165,9 +186,20 @@ class ArgumentsObject : public JSObject
|
||||
* it gets regular properties with regular getters/setters that don't alias
|
||||
* ArgumentsData::slots.
|
||||
*/
|
||||
inline bool isElementDeleted(uint32_t i) const;
|
||||
inline bool isAnyElementDeleted() const;
|
||||
inline void markElementDeleted(uint32_t i);
|
||||
bool isElementDeleted(uint32_t i) const {
|
||||
JS_ASSERT(i < data()->numArgs);
|
||||
if (i >= initialLength())
|
||||
return false;
|
||||
return IsBitArrayElementSet(data()->deletedBits, initialLength(), i);
|
||||
}
|
||||
|
||||
bool isAnyElementDeleted() const {
|
||||
return IsAnyBitArrayElementSet(data()->deletedBits, initialLength());
|
||||
}
|
||||
|
||||
void markElementDeleted(uint32_t i) {
|
||||
SetBitArrayElement(data()->deletedBits, initialLength(), i);
|
||||
}
|
||||
|
||||
/*
|
||||
* An ArgumentsObject serves two roles:
|
||||
@ -184,10 +216,23 @@ class ArgumentsObject : public JSObject
|
||||
* value is not JS_FORWARD_TO_CALL_OBJECT (since, if such forwarding was
|
||||
* needed, the frontend should have emitted JSOP_GETALIASEDVAR.
|
||||
*/
|
||||
inline const Value &element(uint32_t i) const;
|
||||
const Value &element(uint32_t i) const;
|
||||
|
||||
inline void setElement(JSContext *cx, uint32_t i, const Value &v);
|
||||
inline const Value &arg(unsigned i) const;
|
||||
inline void setArg(unsigned i, const Value &v);
|
||||
|
||||
const Value &arg(unsigned i) const {
|
||||
JS_ASSERT(i < data()->numArgs);
|
||||
const Value &v = data()->args[i];
|
||||
JS_ASSERT(!v.isMagic(JS_FORWARD_TO_CALL_OBJECT));
|
||||
return v;
|
||||
}
|
||||
|
||||
void setArg(unsigned i, const Value &v) {
|
||||
JS_ASSERT(i < data()->numArgs);
|
||||
HeapValue &lhs = data()->args[i];
|
||||
JS_ASSERT(!lhs.isMagic(JS_FORWARD_TO_CALL_OBJECT));
|
||||
lhs = v;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attempt to speedily and efficiently access the i-th element of this
|
||||
@ -198,14 +243,22 @@ class ArgumentsObject : public JSObject
|
||||
*
|
||||
* NB: Returning false does not indicate error!
|
||||
*/
|
||||
inline bool maybeGetElement(uint32_t i, MutableHandleValue vp);
|
||||
bool maybeGetElement(uint32_t i, MutableHandleValue vp) {
|
||||
if (i >= initialLength() || isElementDeleted(i))
|
||||
return false;
|
||||
vp.set(element(i));
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool maybeGetElements(uint32_t start, uint32_t count, js::Value *vp);
|
||||
|
||||
/*
|
||||
* Measures things hanging off this ArgumentsObject that are counted by the
|
||||
* |miscSize| argument in JSObject::sizeOfExcludingThis().
|
||||
*/
|
||||
inline size_t sizeOfMisc(mozilla::MallocSizeOf mallocSizeOf) const;
|
||||
size_t sizeOfMisc(mozilla::MallocSizeOf mallocSizeOf) const {
|
||||
return mallocSizeOf(data());
|
||||
}
|
||||
|
||||
static void finalize(FreeOp *fop, JSObject *obj);
|
||||
static void trace(JSTracer *trc, JSObject *obj);
|
||||
@ -234,10 +287,14 @@ class NormalArgumentsObject : public ArgumentsObject
|
||||
* Stores arguments.callee, or MagicValue(JS_ARGS_HOLE) if the callee has
|
||||
* been cleared.
|
||||
*/
|
||||
inline const js::Value &callee() const;
|
||||
const js::Value &callee() const {
|
||||
return data()->callee;
|
||||
}
|
||||
|
||||
/* Clear the location storing arguments.callee's initial value. */
|
||||
inline void clearCallee();
|
||||
void clearCallee() {
|
||||
data()->callee.set(zone(), MagicValue(JS_OVERWRITTEN_CALLEE));
|
||||
}
|
||||
};
|
||||
|
||||
class StrictArgumentsObject : public ArgumentsObject
|
||||
|
@ -1615,12 +1615,6 @@ class MOZ_STACK_CLASS AutoKeepAtoms
|
||||
~AutoKeepAtoms() { JS_UNKEEP_ATOMS(rt); }
|
||||
};
|
||||
|
||||
// Maximum supported value of arguments.length. This bounds the maximum
|
||||
// number of arguments that can be supplied to Function.prototype.apply.
|
||||
// This value also bounds the number of elements parsed in an array
|
||||
// initialiser.
|
||||
static const unsigned ARGS_LENGTH_MAX = 500 * 1000;
|
||||
|
||||
inline void
|
||||
PerThreadData::setIonStackLimit(uintptr_t limit)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user