Fix warnings about implicitly defined copy and assignment
Summary: Various classes defined an `operator=` without a copy ctor, or vice versa. This causes a deprecation warning in new versions of the compiler, so add a corresponding definition for each. Delete the `GCPointer` copy ctor, which requires using `CompressedPointer` instead in a few places and forces an extra `vmcast` because `CompressedPointer` doesn't retain GCCell type info. There is also one patch to LLVM. Reviewed By: neildhar Differential Revision: D28551199 fbshipit-source-id: b306fb71ad6dbb7d8cd27ae0cc72f982f686a462
This commit is contained in:
Родитель
d60d2335cf
Коммит
85e8632d8b
|
@ -175,6 +175,7 @@ class TimerGroup {
|
|||
std::string Description;
|
||||
|
||||
PrintRecord(const PrintRecord &Other) = default;
|
||||
PrintRecord &operator=(const PrintRecord &Other) = default;
|
||||
PrintRecord(const TimeRecord &Time, const std::string &Name,
|
||||
const std::string &Description)
|
||||
: Time(Time), Name(Name), Description(Description) {}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
diff --git a/external/llvh/include/llvh/Support/Timer.h b/external/llvh/include/llvh/Support/Timer.h
|
||||
--- a/external/llvh/include/llvh/Support/Timer.h
|
||||
+++ b/external/llvh/include/llvh/Support/Timer.h
|
||||
@@ -175,6 +175,7 @@
|
||||
std::string Description;
|
||||
|
||||
PrintRecord(const PrintRecord &Other) = default;
|
||||
+ PrintRecord &operator=(const PrintRecord &Other) = default;
|
||||
PrintRecord(const TimeRecord &Time, const std::string &Name,
|
||||
const std::string &Description)
|
||||
: Time(Time), Name(Name), Description(Description) {}
|
|
@ -106,15 +106,17 @@ class CompressedPointer {
|
|||
}
|
||||
#endif
|
||||
|
||||
CompressedPointer(const CompressedPointer &) = default;
|
||||
|
||||
/// We delete the assignment operator, subclasses should determine how the
|
||||
/// value is assigned and then use setNoBarrier.
|
||||
/// (except in MSVC: this is to work around lack of CWG 1734.
|
||||
/// CompressedPointer will not be considered trivial otherwise.)
|
||||
/// TODO(T40821815) Consider removing this workaround when updating MSVC
|
||||
#ifndef _MSC_VER
|
||||
CompressedPointer &operator=(const CompressedPointer &hv) = delete;
|
||||
CompressedPointer &operator=(const CompressedPointer &) = delete;
|
||||
#else
|
||||
CompressedPointer &operator=(const CompressedPointer &hv) = default;
|
||||
CompressedPointer &operator=(const CompressedPointer &) = default;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
|
|
@ -73,6 +73,7 @@ class GCPointer : public GCPointerBase {
|
|||
/// We are not allowed to copy-construct or assign GCPointers.
|
||||
GCPointer(const GCPointerBase &) = delete;
|
||||
GCPointer &operator=(const GCPointerBase &) = delete;
|
||||
GCPointer(const GCPointer<T> &) = delete;
|
||||
GCPointer &operator=(const GCPointer<T> &) = delete;
|
||||
|
||||
/// Get the raw pointer value.
|
||||
|
|
|
@ -78,6 +78,7 @@ struct Metadata final {
|
|||
startOffset(startOffset),
|
||||
lengthOffset(lengthOffset),
|
||||
stride(stride) {}
|
||||
ArrayData(const ArrayData &data) = default;
|
||||
ArrayData &operator=(const ArrayData &data) = default;
|
||||
};
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ class StringView {
|
|||
|
||||
/// Allows for copying.
|
||||
const_iterator(const const_iterator &other) = default;
|
||||
const_iterator &operator=(const const_iterator &other) = default;
|
||||
|
||||
const_iterator &operator++() {
|
||||
if (charPtr_) {
|
||||
|
|
|
@ -116,6 +116,8 @@ class TwineChar16 {
|
|||
assert(isValid());
|
||||
}
|
||||
|
||||
TwineChar16(const TwineChar16 &other) = default;
|
||||
|
||||
TwineChar16(const char *str) : TwineChar16(llvh::StringRef(str)) {}
|
||||
|
||||
/// Make a twine out of the null-terminated \p str.
|
||||
|
|
|
@ -2282,9 +2282,9 @@ tailCall:
|
|||
}
|
||||
gcScope.flushToSmallCount(KEEP_HANDLES);
|
||||
#endif
|
||||
auto clazzGCPtr = obj->getClassGCPtr();
|
||||
CompressedPointer clazzPtr{obj->getClassGCPtr()};
|
||||
#ifndef NDEBUG
|
||||
if (clazzGCPtr.get(runtime)->isDictionary())
|
||||
if (vmcast<HiddenClass>(clazzPtr.get(runtime))->isDictionary())
|
||||
++NumGetByIdDict;
|
||||
#else
|
||||
(void)NumGetByIdDict;
|
||||
|
@ -2292,7 +2292,7 @@ tailCall:
|
|||
|
||||
// If we have a cache hit, reuse the cached offset and immediately
|
||||
// return the property.
|
||||
if (LLVM_LIKELY(cacheEntry->clazz == clazzGCPtr)) {
|
||||
if (LLVM_LIKELY(cacheEntry->clazz == clazzPtr)) {
|
||||
++NumGetByIdCacheHits;
|
||||
CAPTURE_IP(
|
||||
O1REG(GetById) =
|
||||
|
@ -2314,17 +2314,18 @@ tailCall:
|
|||
|
||||
// cacheIdx == 0 indicates no caching so don't update the cache in
|
||||
// those cases.
|
||||
auto *clazz = clazzGCPtr.getNonNull(runtime);
|
||||
HiddenClass *clazz =
|
||||
vmcast<HiddenClass>(clazzPtr.getNonNull(runtime));
|
||||
if (LLVM_LIKELY(!clazz->isDictionaryNoCache()) &&
|
||||
LLVM_LIKELY(cacheIdx != hbc::PROPERTY_CACHING_DISABLED)) {
|
||||
#ifdef HERMES_SLOW_DEBUG
|
||||
if (cacheEntry->clazz && cacheEntry->clazz != clazzGCPtr)
|
||||
if (cacheEntry->clazz && cacheEntry->clazz != clazzPtr)
|
||||
++NumGetByIdCacheEvicts;
|
||||
#else
|
||||
(void)NumGetByIdCacheEvicts;
|
||||
#endif
|
||||
// Cache the class, id and property slot.
|
||||
cacheEntry->clazz = clazzGCPtr;
|
||||
cacheEntry->clazz = clazzPtr;
|
||||
cacheEntry->slot = desc.slot;
|
||||
}
|
||||
|
||||
|
@ -2475,10 +2476,10 @@ tailCall:
|
|||
}
|
||||
gcScope.flushToSmallCount(KEEP_HANDLES);
|
||||
#endif
|
||||
auto clazzGCPtr = obj->getClassGCPtr();
|
||||
CompressedPointer clazzPtr{obj->getClassGCPtr()};
|
||||
// If we have a cache hit, reuse the cached offset and immediately
|
||||
// return the property.
|
||||
if (LLVM_LIKELY(cacheEntry->clazz == clazzGCPtr)) {
|
||||
if (LLVM_LIKELY(cacheEntry->clazz == clazzPtr)) {
|
||||
++NumPutByIdCacheHits;
|
||||
CAPTURE_IP(
|
||||
JSObject::setNamedSlotValueUnsafe<PropStorage::Inline::Yes>(
|
||||
|
@ -2498,17 +2499,18 @@ tailCall:
|
|||
|
||||
// cacheIdx == 0 indicates no caching so don't update the cache in
|
||||
// those cases.
|
||||
auto *clazz = clazzGCPtr.getNonNull(runtime);
|
||||
HiddenClass *clazz =
|
||||
vmcast<HiddenClass>(clazzPtr.getNonNull(runtime));
|
||||
if (LLVM_LIKELY(!clazz->isDictionary()) &&
|
||||
LLVM_LIKELY(cacheIdx != hbc::PROPERTY_CACHING_DISABLED)) {
|
||||
#ifdef HERMES_SLOW_DEBUG
|
||||
if (cacheEntry->clazz && cacheEntry->clazz != clazzGCPtr)
|
||||
if (cacheEntry->clazz && cacheEntry->clazz != clazzPtr)
|
||||
++NumPutByIdCacheEvicts;
|
||||
#else
|
||||
(void)NumPutByIdCacheEvicts;
|
||||
#endif
|
||||
// Cache the class and property slot.
|
||||
cacheEntry->clazz = clazzGCPtr;
|
||||
cacheEntry->clazz = clazzPtr;
|
||||
cacheEntry->slot = desc.slot;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,9 +85,9 @@ std::shared_ptr<Runtime> Runtime::create(const RuntimeConfig &runtimeConfig) {
|
|||
CallResult<PseudoHandle<>> Runtime::getNamed(
|
||||
Handle<JSObject> obj,
|
||||
PropCacheID id) {
|
||||
auto clazzGCPtr = obj->getClassGCPtr();
|
||||
CompressedPointer clazzPtr{obj->getClassGCPtr()};
|
||||
auto *cacheEntry = &fixedPropCache_[static_cast<int>(id)];
|
||||
if (LLVM_LIKELY(cacheEntry->clazz == clazzGCPtr)) {
|
||||
if (LLVM_LIKELY(cacheEntry->clazz == clazzPtr)) {
|
||||
// The slot is cached, so it is safe to use the Internal function.
|
||||
return createPseudoHandle(
|
||||
JSObject::getNamedSlotValueUnsafe<PropStorage::Inline::Yes>(
|
||||
|
@ -102,10 +102,10 @@ CallResult<PseudoHandle<>> Runtime::getNamed(
|
|||
JSObject::tryGetOwnNamedDescriptorFast(*obj, this, sym, desc)) &&
|
||||
!desc.flags.accessor && desc.flags.writable &&
|
||||
!desc.flags.internalSetter) {
|
||||
auto *clazz = clazzGCPtr.getNonNull(this);
|
||||
HiddenClass *clazz = vmcast<HiddenClass>(clazzPtr.getNonNull(this));
|
||||
if (LLVM_LIKELY(!clazz->isDictionary())) {
|
||||
// Cache the class, id and property slot.
|
||||
cacheEntry->clazz = clazzGCPtr;
|
||||
cacheEntry->clazz = clazzPtr;
|
||||
cacheEntry->slot = desc.slot;
|
||||
}
|
||||
return JSObject::getNamedSlotValue(createPseudoHandle(*obj), this, desc);
|
||||
|
@ -117,9 +117,9 @@ ExecutionStatus Runtime::putNamedThrowOnError(
|
|||
Handle<JSObject> obj,
|
||||
PropCacheID id,
|
||||
HermesValue hv) {
|
||||
auto clazzGCPtr = obj->getClassGCPtr();
|
||||
CompressedPointer clazzPtr{obj->getClassGCPtr()};
|
||||
auto *cacheEntry = &fixedPropCache_[static_cast<int>(id)];
|
||||
if (LLVM_LIKELY(cacheEntry->clazz == clazzGCPtr)) {
|
||||
if (LLVM_LIKELY(cacheEntry->clazz == clazzPtr)) {
|
||||
auto shv = SmallHermesValue::encodeHermesValue(hv, this);
|
||||
JSObject::setNamedSlotValueUnsafe<PropStorage::Inline::Yes>(
|
||||
*obj, this, cacheEntry->slot, shv);
|
||||
|
@ -131,10 +131,10 @@ ExecutionStatus Runtime::putNamedThrowOnError(
|
|||
JSObject::tryGetOwnNamedDescriptorFast(*obj, this, sym, desc)) &&
|
||||
!desc.flags.accessor && desc.flags.writable &&
|
||||
!desc.flags.internalSetter) {
|
||||
auto *clazz = clazzGCPtr.getNonNull(this);
|
||||
HiddenClass *clazz = vmcast<HiddenClass>(clazzPtr.getNonNull(this));
|
||||
if (LLVM_LIKELY(!clazz->isDictionary())) {
|
||||
// Cache the class and property slot.
|
||||
cacheEntry->clazz = clazzGCPtr;
|
||||
cacheEntry->clazz = clazzPtr;
|
||||
cacheEntry->slot = desc.slot;
|
||||
}
|
||||
auto shv = SmallHermesValue::encodeHermesValue(hv, this);
|
||||
|
|
Загрузка…
Ссылка в новой задаче