Bug 738072 - Slot numbers are uint32_t, so use uint32_t rather than unsigned for slot numbers, slot counts, and so on. r=dmandelin

--HG--
extra : rebase_source : f67146dbd510e1e94b1298344d8335c35350b7c8
This commit is contained in:
Jeff Walden 2012-03-22 11:50:49 -07:00
parent 6c0e0d27b1
commit 81709e7dd8
3 changed files with 54 additions and 54 deletions

View File

@ -23,7 +23,7 @@
namespace js {
static MOZ_ALWAYS_INLINE void
Debug_SetSlotRangeToCrashOnTouch(HeapSlot *vec, size_t len)
Debug_SetSlotRangeToCrashOnTouch(HeapSlot *vec, uint32_t len)
{
#ifdef DEBUG
Debug_SetValueRangeToCrashOnTouch((Value *) vec, len);
@ -83,28 +83,28 @@ js::ObjectImpl::getDenseArrayElements()
}
inline const js::Value &
js::ObjectImpl::getDenseArrayElement(unsigned idx)
js::ObjectImpl::getDenseArrayElement(uint32_t idx)
{
MOZ_ASSERT(isDenseArray() && idx < getDenseArrayInitializedLength());
return elements[idx];
}
inline void
js::ObjectImpl::getSlotRangeUnchecked(size_t start, size_t length,
js::ObjectImpl::getSlotRangeUnchecked(uint32_t start, uint32_t length,
HeapSlot **fixedStart, HeapSlot **fixedEnd,
HeapSlot **slotsStart, HeapSlot **slotsEnd)
{
MOZ_ASSERT(!isDenseArray());
MOZ_ASSERT(start + length >= start);
size_t fixed = numFixedSlots();
uint32_t fixed = numFixedSlots();
if (start < fixed) {
if (start + length < fixed) {
*fixedStart = &fixedSlots()[start];
*fixedEnd = &fixedSlots()[start + length];
*slotsStart = *slotsEnd = NULL;
} else {
size_t localCopy = fixed - start;
uint32_t localCopy = fixed - start;
*fixedStart = &fixedSlots()[start];
*fixedEnd = &fixedSlots()[start + localCopy];
*slotsStart = &slots[0];
@ -118,7 +118,7 @@ js::ObjectImpl::getSlotRangeUnchecked(size_t start, size_t length,
}
inline void
js::ObjectImpl::getSlotRange(size_t start, size_t length,
js::ObjectImpl::getSlotRange(uint32_t start, uint32_t length,
HeapSlot **fixedStart, HeapSlot **fixedEnd,
HeapSlot **slotsStart, HeapSlot **slotsEnd)
{
@ -127,7 +127,7 @@ js::ObjectImpl::getSlotRange(size_t start, size_t length,
}
inline bool
js::ObjectImpl::hasContiguousSlots(size_t start, size_t count) const
js::ObjectImpl::hasContiguousSlots(uint32_t start, uint32_t count) const
{
/*
* Check that the range [start, start+count) is either all inline or all
@ -138,7 +138,7 @@ js::ObjectImpl::hasContiguousSlots(size_t start, size_t count) const
}
inline void
js::ObjectImpl::invalidateSlotRange(size_t start, size_t length)
js::ObjectImpl::invalidateSlotRange(uint32_t start, uint32_t length)
{
#ifdef DEBUG
MOZ_ASSERT(!isDenseArray());
@ -151,7 +151,7 @@ js::ObjectImpl::invalidateSlotRange(size_t start, size_t length)
}
inline void
js::ObjectImpl::initializeSlotRange(size_t start, size_t length)
js::ObjectImpl::initializeSlotRange(uint32_t start, uint32_t length)
{
/*
* No bounds check, as this is used when the object's shape does not
@ -161,7 +161,7 @@ js::ObjectImpl::initializeSlotRange(size_t start, size_t length)
getSlotRangeUnchecked(start, length, &fixedStart, &fixedEnd, &slotsStart, &slotsEnd);
JSCompartment *comp = compartment();
size_t offset = start;
uint32_t offset = start;
for (HeapSlot *sp = fixedStart; sp < fixedEnd; sp++)
sp->init(comp, this->asObjectPtr(), offset++, UndefinedValue());
for (HeapSlot *sp = slotsStart; sp < slotsEnd; sp++)
@ -175,7 +175,7 @@ js::ObjectImpl::isNative() const
}
inline js::HeapSlot &
js::ObjectImpl::nativeGetSlotRef(unsigned slot)
js::ObjectImpl::nativeGetSlotRef(uint32_t slot)
{
MOZ_ASSERT(isNative());
MOZ_ASSERT(slot < slotSpan());
@ -183,7 +183,7 @@ js::ObjectImpl::nativeGetSlotRef(unsigned slot)
}
inline const js::Value &
js::ObjectImpl::nativeGetSlot(unsigned slot) const
js::ObjectImpl::nativeGetSlot(uint32_t slot) const
{
MOZ_ASSERT(isNative());
MOZ_ASSERT(slot < slotSpan());
@ -191,14 +191,14 @@ js::ObjectImpl::nativeGetSlot(unsigned slot) const
}
inline void
js::ObjectImpl::setSlot(unsigned slot, const js::Value &value)
js::ObjectImpl::setSlot(uint32_t slot, const js::Value &value)
{
MOZ_ASSERT(slotInRange(slot));
getSlotRef(slot).set(this->asObjectPtr(), slot, value);
}
inline void
js::ObjectImpl::initSlot(unsigned slot, const js::Value &value)
js::ObjectImpl::initSlot(uint32_t slot, const js::Value &value)
{
MOZ_ASSERT(getSlot(slot).isUndefined() || getSlot(slot).isMagic(JS_ARRAY_HOLE));
MOZ_ASSERT(slotInRange(slot));
@ -206,20 +206,20 @@ js::ObjectImpl::initSlot(unsigned slot, const js::Value &value)
}
inline void
js::ObjectImpl::initSlotUnchecked(unsigned slot, const js::Value &value)
js::ObjectImpl::initSlotUnchecked(uint32_t slot, const js::Value &value)
{
getSlotAddressUnchecked(slot)->init(this->asObjectPtr(), slot, value);
}
inline void
js::ObjectImpl::setFixedSlot(unsigned slot, const js::Value &value)
js::ObjectImpl::setFixedSlot(uint32_t slot, const js::Value &value)
{
MOZ_ASSERT(slot < numFixedSlots());
fixedSlots()[slot].set(this->asObjectPtr(), slot, value);
}
inline void
js::ObjectImpl::initFixedSlot(unsigned slot, const js::Value &value)
js::ObjectImpl::initFixedSlot(uint32_t slot, const js::Value &value)
{
MOZ_ASSERT(slot < numFixedSlots());
fixedSlots()[slot].init(this->asObjectPtr(), slot, value);
@ -233,7 +233,7 @@ js::ObjectImpl::slotSpan() const
return lastProperty()->slotSpan();
}
inline size_t
inline uint32_t
js::ObjectImpl::numDynamicSlots() const
{
return dynamicSlotsCount(numFixedSlots(), slotSpan());
@ -275,8 +275,8 @@ js::ObjectImpl::inDictionaryMode() const
return lastProperty()->inDictionary();
}
/* static */ inline size_t
js::ObjectImpl::dynamicSlotsCount(size_t nfixed, size_t span)
/* static */ inline uint32_t
js::ObjectImpl::dynamicSlotsCount(uint32_t nfixed, uint32_t span)
{
if (span <= nfixed)
return 0;
@ -284,7 +284,7 @@ js::ObjectImpl::dynamicSlotsCount(size_t nfixed, size_t span)
if (span <= SLOT_CAPACITY_MIN)
return SLOT_CAPACITY_MIN;
size_t slots = RoundUpPow2(span);
uint32_t slots = RoundUpPow2(span);
MOZ_ASSERT(slots >= span);
return slots;
}
@ -379,7 +379,7 @@ js::ObjectImpl::getPrivate() const
}
inline void *
js::ObjectImpl::getPrivate(size_t nfixed) const
js::ObjectImpl::getPrivate(uint32_t nfixed) const
{
return privateRef(nfixed);
}

View File

@ -92,7 +92,7 @@ js::ObjectImpl::checkShapeConsistency()
#endif
void
js::ObjectImpl::initSlotRange(size_t start, const Value *vector, size_t length)
js::ObjectImpl::initSlotRange(uint32_t start, const Value *vector, uint32_t length)
{
JSCompartment *comp = compartment();
HeapSlot *fixedStart, *fixedEnd, *slotsStart, *slotsEnd;
@ -104,7 +104,7 @@ js::ObjectImpl::initSlotRange(size_t start, const Value *vector, size_t length)
}
void
js::ObjectImpl::copySlotRange(size_t start, const Value *vector, size_t length)
js::ObjectImpl::copySlotRange(uint32_t start, const Value *vector, uint32_t length)
{
JSCompartment *comp = compartment();
HeapSlot *fixedStart, *fixedEnd, *slotsStart, *slotsEnd;
@ -117,9 +117,9 @@ js::ObjectImpl::copySlotRange(size_t start, const Value *vector, size_t length)
#ifdef DEBUG
bool
js::ObjectImpl::slotInRange(unsigned slot, SentinelAllowed sentinel) const
js::ObjectImpl::slotInRange(uint32_t slot, SentinelAllowed sentinel) const
{
size_t capacity = numFixedSlots() + numDynamicSlots();
uint32_t capacity = numFixedSlots() + numDynamicSlots();
if (sentinel == SENTINEL_ALLOWED)
return slot <= capacity;
return slot < capacity;

View File

@ -192,7 +192,7 @@ class ObjectImpl : public gc::Cell
inline bool isArray() const;
inline HeapSlotArray getDenseArrayElements();
inline const Value & getDenseArrayElement(unsigned idx);
inline const Value & getDenseArrayElement(uint32_t idx);
inline uint32_t getDenseArrayInitializedLength();
protected:
@ -207,10 +207,10 @@ class ObjectImpl : public gc::Cell
* Get internal pointers to the range of values starting at start and
* running for length.
*/
inline void getSlotRangeUnchecked(size_t start, size_t length,
inline void getSlotRangeUnchecked(uint32_t start, uint32_t length,
HeapSlot **fixedStart, HeapSlot **fixedEnd,
HeapSlot **slotsStart, HeapSlot **slotsEnd);
inline void getSlotRange(size_t start, size_t length,
inline void getSlotRange(uint32_t start, uint32_t length,
HeapSlot **fixedStart, HeapSlot **fixedEnd,
HeapSlot **slotsStart, HeapSlot **slotsEnd);
@ -219,22 +219,22 @@ class ObjectImpl : public gc::Cell
friend struct Shape;
friend class NewObjectCache;
inline bool hasContiguousSlots(size_t start, size_t count) const;
inline bool hasContiguousSlots(uint32_t start, uint32_t count) const;
inline void invalidateSlotRange(size_t start, size_t count);
inline void initializeSlotRange(size_t start, size_t count);
inline void invalidateSlotRange(uint32_t start, uint32_t count);
inline void initializeSlotRange(uint32_t start, uint32_t count);
/*
* Initialize a flat array of slots to this object at a start slot. The
* caller must ensure that are enough slots.
*/
void initSlotRange(size_t start, const Value *vector, size_t length);
void initSlotRange(uint32_t start, const Value *vector, uint32_t length);
/*
* Copy a flat array of slots to this object at a start slot. Caller must
* ensure there are enough slots in this object.
*/
void copySlotRange(size_t start, const Value *vector, size_t length);
void copySlotRange(uint32_t start, const Value *vector, uint32_t length);
#ifdef DEBUG
enum SentinelAllowed {
@ -246,7 +246,7 @@ class ObjectImpl : public gc::Cell
* Check that slot is in range for the object's allocated slots.
* If sentinelAllowed then slot may equal the slot capacity.
*/
bool slotInRange(unsigned slot, SentinelAllowed sentinel = SENTINEL_NOT_ALLOWED) const;
bool slotInRange(uint32_t slot, SentinelAllowed sentinel = SENTINEL_NOT_ALLOWED) const;
#endif
/* Minimum size for dynamically allocated slots. */
@ -274,7 +274,7 @@ class ObjectImpl : public gc::Cell
return type_;
}
size_t numFixedSlots() const {
uint32_t numFixedSlots() const {
return reinterpret_cast<const shadow::Object *>(this)->numFixedSlots();
}
@ -293,7 +293,7 @@ class ObjectImpl : public gc::Cell
inline uint32_t slotSpan() const;
/* Compute dynamicSlotsCount() for this object. */
inline size_t numDynamicSlots() const;
inline uint32_t numDynamicSlots() const;
const Shape * nativeLookup(JSContext *cx, jsid id);
@ -320,22 +320,22 @@ class ObjectImpl : public gc::Cell
*/
inline bool inDictionaryMode() const;
const Value &getSlot(unsigned slot) const {
const Value &getSlot(uint32_t slot) const {
MOZ_ASSERT(slotInRange(slot));
size_t fixed = numFixedSlots();
uint32_t fixed = numFixedSlots();
if (slot < fixed)
return fixedSlots()[slot];
return slots[slot - fixed];
}
HeapSlot *getSlotAddressUnchecked(unsigned slot) {
size_t fixed = numFixedSlots();
HeapSlot *getSlotAddressUnchecked(uint32_t slot) {
uint32_t fixed = numFixedSlots();
if (slot < fixed)
return fixedSlots() + slot;
return slots + (slot - fixed);
}
HeapSlot *getSlotAddress(unsigned slot) {
HeapSlot *getSlotAddress(uint32_t slot) {
/*
* This can be used to get the address of the end of the slots for the
* object, which may be necessary when fetching zero-length arrays of
@ -345,32 +345,32 @@ class ObjectImpl : public gc::Cell
return getSlotAddressUnchecked(slot);
}
HeapSlot &getSlotRef(unsigned slot) {
HeapSlot &getSlotRef(uint32_t slot) {
MOZ_ASSERT(slotInRange(slot));
return *getSlotAddress(slot);
}
inline HeapSlot &nativeGetSlotRef(unsigned slot);
inline const Value &nativeGetSlot(unsigned slot) const;
inline HeapSlot &nativeGetSlotRef(uint32_t slot);
inline const Value &nativeGetSlot(uint32_t slot) const;
inline void setSlot(unsigned slot, const Value &value);
inline void initSlot(unsigned slot, const Value &value);
inline void initSlotUnchecked(unsigned slot, const Value &value);
inline void setSlot(uint32_t slot, const Value &value);
inline void initSlot(uint32_t slot, const Value &value);
inline void initSlotUnchecked(uint32_t slot, const Value &value);
/* For slots which are known to always be fixed, due to the way they are allocated. */
HeapSlot &getFixedSlotRef(unsigned slot) {
HeapSlot &getFixedSlotRef(uint32_t slot) {
MOZ_ASSERT(slot < numFixedSlots());
return fixedSlots()[slot];
}
const Value &getFixedSlot(unsigned slot) const {
const Value &getFixedSlot(uint32_t slot) const {
MOZ_ASSERT(slot < numFixedSlots());
return fixedSlots()[slot];
}
inline void setFixedSlot(unsigned slot, const Value &value);
inline void initFixedSlot(unsigned slot, const Value &value);
inline void setFixedSlot(uint32_t slot, const Value &value);
inline void initFixedSlot(uint32_t slot, const Value &value);
/*
* Get the number of dynamic slots to allocate to cover the properties in
@ -378,7 +378,7 @@ class ObjectImpl : public gc::Cell
* capacity is not stored explicitly, and the allocated size of the slot
* array is kept in sync with this count.
*/
static inline size_t dynamicSlotsCount(size_t nfixed, size_t span);
static inline uint32_t dynamicSlotsCount(uint32_t nfixed, uint32_t span);
/* Memory usage functions. */
inline size_t sizeOfThis() const;
@ -428,7 +428,7 @@ class ObjectImpl : public gc::Cell
inline void initPrivate(void *data);
/* Access private data for an object with a known number of fixed slots. */
inline void *getPrivate(size_t nfixed) const;
inline void *getPrivate(uint32_t nfixed) const;
/* JIT Accessors */
static size_t offsetOfShape() { return offsetof(ObjectImpl, shape_); }