From b6b2b2842679dacd4874e7de14b98894490d59ef Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Tue, 5 Nov 2024 08:31:52 -0800 Subject: [PATCH 1/2] let Pointer be nothrow-move-constructible (#47331) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47331 Reviewed By: Gownta Differential Revision: D65271354 --- packages/react-native/ReactCommon/jsi/jsi/jsi.cpp | 2 +- packages/react-native/ReactCommon/jsi/jsi/jsi.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native/ReactCommon/jsi/jsi/jsi.cpp b/packages/react-native/ReactCommon/jsi/jsi/jsi.cpp index 8de94ebc2f27..13588e1d04bc 100644 --- a/packages/react-native/ReactCommon/jsi/jsi/jsi.cpp +++ b/packages/react-native/ReactCommon/jsi/jsi/jsi.cpp @@ -258,7 +258,7 @@ std::u16string Runtime::utf16(const String& str) { return convertUTF8ToUTF16(utf8Str); } -Pointer& Pointer::operator=(Pointer&& other) { +Pointer& Pointer::operator=(Pointer&& other) noexcept { if (ptr_) { ptr_->invalidate(); } diff --git a/packages/react-native/ReactCommon/jsi/jsi/jsi.h b/packages/react-native/ReactCommon/jsi/jsi/jsi.h index 8d75b06c96e0..07e3722cb0e3 100644 --- a/packages/react-native/ReactCommon/jsi/jsi/jsi.h +++ b/packages/react-native/ReactCommon/jsi/jsi/jsi.h @@ -418,7 +418,7 @@ class JSI_EXPORT Runtime { // Base class for pointer-storing types. class JSI_EXPORT Pointer { protected: - explicit Pointer(Pointer&& other) : ptr_(other.ptr_) { + explicit Pointer(Pointer&& other) noexcept : ptr_(other.ptr_) { other.ptr_ = nullptr; } @@ -428,7 +428,7 @@ class JSI_EXPORT Pointer { } } - Pointer& operator=(Pointer&& other); + Pointer& operator=(Pointer&& other) noexcept; friend class Runtime; friend class Value; From a8160ec7fdd3283df8b9a889a9dce3b4f0f5b827 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Tue, 5 Nov 2024 08:31:52 -0800 Subject: [PATCH 2/2] let PointerValue::invalidate() be noexcept (#47354) Summary: `PointerValue::invalidate()` is called from `Pointer` destructor, which is implicitly `noexcept`, and from `Pointer` move-assignment operator, which is now `noexcept`. Reviewed By: neildhar Differential Revision: D65271399 --- packages/react-native/ReactCommon/jsc/JSCRuntime.cpp | 12 ++++++------ packages/react-native/ReactCommon/jsi/jsi/jsi.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp b/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp index 2216126af410..6ea718b1e473 100644 --- a/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp +++ b/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp @@ -94,7 +94,7 @@ class JSCRuntime : public jsi::Runtime { const std::atomic& ctxInvalid, JSValueRef sym); #endif - void invalidate() override; + void invalidate() noexcept override; JSGlobalContextRef ctx_; const std::atomic& ctxInvalid_; @@ -114,7 +114,7 @@ class JSCRuntime : public jsi::Runtime { #else JSCStringValue(JSStringRef str); #endif - void invalidate() override; + void invalidate() noexcept override; JSStringRef str_; #ifndef NDEBUG @@ -135,7 +135,7 @@ class JSCRuntime : public jsi::Runtime { #endif ); - void invalidate() override; + void invalidate() noexcept override; JSGlobalContextRef ctx_; const std::atomic& ctxInvalid_; @@ -506,7 +506,7 @@ JSCRuntime::JSCSymbolValue::JSCSymbolValue( #endif } -void JSCRuntime::JSCSymbolValue::invalidate() { +void JSCRuntime::JSCSymbolValue::invalidate() noexcept { #ifndef NDEBUG counter_ -= 1; #endif @@ -531,7 +531,7 @@ JSCRuntime::JSCStringValue::JSCStringValue(JSStringRef str) : str_(JSStringRetain(str)) {} #endif -void JSCRuntime::JSCStringValue::invalidate() { +void JSCRuntime::JSCStringValue::invalidate() noexcept { // These JSC{String,Object}Value objects are implicitly owned by the // {String,Object} objects, thus when a String/Object is destructed // the JSC{String,Object}Value should be released. @@ -566,7 +566,7 @@ JSCRuntime::JSCObjectValue::JSCObjectValue( #endif } -void JSCRuntime::JSCObjectValue::invalidate() { +void JSCRuntime::JSCObjectValue::invalidate() noexcept { #ifndef NDEBUG counter_ -= 1; #endif diff --git a/packages/react-native/ReactCommon/jsi/jsi/jsi.h b/packages/react-native/ReactCommon/jsi/jsi/jsi.h index 07e3722cb0e3..a826923a6401 100644 --- a/packages/react-native/ReactCommon/jsi/jsi/jsi.h +++ b/packages/react-native/ReactCommon/jsi/jsi/jsi.h @@ -288,7 +288,7 @@ class JSI_EXPORT Runtime { // rvalue arguments/methods would also reduce the number of clones. struct PointerValue { - virtual void invalidate() = 0; + virtual void invalidate() noexcept = 0; protected: virtual ~PointerValue() = default;