mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1409380 - Simplify HeapSlot to make it trivially copyable r=sfink
This commit is contained in:
parent
e1ac6c9b10
commit
9c377844d3
@ -660,29 +660,15 @@ class HeapSlot : public WriteBarrieredBase<Value>
|
||||
Element = 1
|
||||
};
|
||||
|
||||
explicit HeapSlot() = delete;
|
||||
|
||||
explicit HeapSlot(NativeObject* obj, Kind kind, uint32_t slot, const Value& v)
|
||||
: WriteBarrieredBase<Value>(v)
|
||||
{
|
||||
post(obj, kind, slot, v);
|
||||
}
|
||||
|
||||
explicit HeapSlot(NativeObject* obj, Kind kind, uint32_t slot, const HeapSlot& s)
|
||||
: WriteBarrieredBase<Value>(s.value)
|
||||
{
|
||||
post(obj, kind, slot, s);
|
||||
}
|
||||
|
||||
~HeapSlot() {
|
||||
pre();
|
||||
}
|
||||
|
||||
void init(NativeObject* owner, Kind kind, uint32_t slot, const Value& v) {
|
||||
value = v;
|
||||
post(owner, kind, slot, v);
|
||||
}
|
||||
|
||||
void destroy() {
|
||||
pre();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
bool preconditionForSet(NativeObject* owner, Kind kind, uint32_t slot) const;
|
||||
void assertPreconditionForWriteBarrierPost(NativeObject* obj, Kind kind, uint32_t slot,
|
||||
@ -696,11 +682,6 @@ class HeapSlot : public WriteBarrieredBase<Value>
|
||||
post(owner, kind, slot, v);
|
||||
}
|
||||
|
||||
/* For users who need to manually barrier the raw types. */
|
||||
static void writeBarrierPost(NativeObject* owner, Kind kind, uint32_t slot, const Value& target) {
|
||||
reinterpret_cast<HeapSlot*>(const_cast<Value*>(&target))->post(owner, kind, slot, target);
|
||||
}
|
||||
|
||||
private:
|
||||
void post(NativeObject* owner, Kind kind, uint32_t slot, const Value& target) {
|
||||
#ifdef DEBUG
|
||||
|
@ -260,8 +260,7 @@ NativeObject::moveDenseElements(uint32_t dstStart, uint32_t srcStart, uint32_t c
|
||||
dst->set(this, HeapSlot::Element, dst - elements_ + numShifted, *src);
|
||||
}
|
||||
} else {
|
||||
memmove(reinterpret_cast<Value*>(elements_ + dstStart), elements_ + srcStart,
|
||||
count * sizeof(Value));
|
||||
memmove(elements_ + dstStart, elements_ + srcStart, count * sizeof(HeapSlot));
|
||||
elementsRangeWriteBarrierPost(dstStart, count);
|
||||
}
|
||||
}
|
||||
@ -276,8 +275,7 @@ NativeObject::moveDenseElementsNoPreBarrier(uint32_t dstStart, uint32_t srcStart
|
||||
MOZ_ASSERT(!denseElementsAreCopyOnWrite());
|
||||
MOZ_ASSERT(!denseElementsAreFrozen());
|
||||
|
||||
memmove(reinterpret_cast<Value*>(elements_ + dstStart), elements_ + srcStart,
|
||||
count * sizeof(Value));
|
||||
memmove(elements_ + dstStart, elements_ + srcStart, count * sizeof(HeapSlot));
|
||||
elementsRangeWriteBarrierPost(dstStart, count);
|
||||
}
|
||||
|
||||
|
@ -1013,7 +1013,7 @@ class NativeObject : public ShapedObject
|
||||
MOZ_ASSERT(end <= getDenseInitializedLength());
|
||||
MOZ_ASSERT(!denseElementsAreCopyOnWrite());
|
||||
for (size_t i = start; i < end; i++)
|
||||
elements_[i].HeapSlot::~HeapSlot();
|
||||
elements_[i].destroy();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1022,7 +1022,7 @@ class NativeObject : public ShapedObject
|
||||
*/
|
||||
void prepareSlotRangeForOverwrite(size_t start, size_t end) {
|
||||
for (size_t i = start; i < end; i++)
|
||||
getSlotAddressUnchecked(i)->HeapSlot::~HeapSlot();
|
||||
getSlotAddressUnchecked(i)->destroy();
|
||||
}
|
||||
|
||||
inline void shiftDenseElementsUnchecked(uint32_t count);
|
||||
|
Loading…
Reference in New Issue
Block a user