summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authortrav90 <travawine@palemoon.org>2018-08-12 07:57:10 -0500
committertrav90 <travawine@palemoon.org>2018-08-12 07:57:10 -0500
commit9ac48ef8319087fcb68d9021db0af9d5cb1080af (patch)
tree425d7acdb472e54cb530684654d6786a50876fdf /js
parent9d1bfd4dc7338a39642f07eeea316f76bec43b8c (diff)
downloadUXP-9ac48ef8319087fcb68d9021db0af9d5cb1080af.tar
UXP-9ac48ef8319087fcb68d9021db0af9d5cb1080af.tar.gz
UXP-9ac48ef8319087fcb68d9021db0af9d5cb1080af.tar.lz
UXP-9ac48ef8319087fcb68d9021db0af9d5cb1080af.tar.xz
UXP-9ac48ef8319087fcb68d9021db0af9d5cb1080af.zip
Simplify HeapSlot to make it trivially copyable
This removes the constructors, which were never called since we allocate arrays of HeapSlot with pod_malloc. The destructor is only ever called explicitly since we free this memory with js_free so it has been renamed to destroy(). Also removed is an unused manual barrier.
Diffstat (limited to 'js')
-rw-r--r--js/src/gc/Barrier.h27
-rw-r--r--js/src/vm/NativeObject.h10
2 files changed, 8 insertions, 29 deletions
diff --git a/js/src/gc/Barrier.h b/js/src/gc/Barrier.h
index effc9233e..dce3b2a20 100644
--- a/js/src/gc/Barrier.h
+++ b/js/src/gc/Barrier.h
@@ -667,29 +667,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;
bool preconditionForWriteBarrierPost(NativeObject* obj, Kind kind, uint32_t slot,
@@ -703,11 +689,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) {
MOZ_ASSERT(preconditionForWriteBarrierPost(owner, kind, slot, target));
diff --git a/js/src/vm/NativeObject.h b/js/src/vm/NativeObject.h
index f4199b4cf..4dbc167ab 100644
--- a/js/src/vm/NativeObject.h
+++ b/js/src/vm/NativeObject.h
@@ -876,7 +876,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();
}
/*
@@ -885,7 +885,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();
}
public:
@@ -1130,8 +1130,7 @@ class NativeObject : public ShapedObject
dst->set(this, HeapSlot::Element, dst - elements_, *src);
}
} else {
- memmove(reinterpret_cast<Value*>(elements_ + dstStart), elements_ + srcStart,
- count * sizeof(Value));
+ memmove(elements_ + dstStart, elements_ + srcStart, count * sizeof(HeapSlot));
elementsRangeWriteBarrierPost(dstStart, count);
}
}
@@ -1144,8 +1143,7 @@ class NativeObject : public ShapedObject
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);
}