File tree Expand file tree Collapse file tree
packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88#pragma once
99
10+ #include < cstdint>
1011#include < memory>
1112#include < string>
1213#include < unordered_map>
@@ -58,7 +59,7 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
5859 // If we have a JS wrapper, cache the result of this lookup
5960 // We don't cache misses, to allow for methodMap_ to dynamically be
6061 // extended
61- if (jsRepresentation_ && !prop.isUndefined ()) {
62+ if (jsRepresentation_ && reinterpret_cast <std:: uintptr_t >(&runtime) == representationRuntimeAddress_ && !prop.isUndefined ()) {
6263 jsRepresentation_->lock (runtime).asObject (runtime).setProperty (runtime, propName, prop);
6364 }
6465 return prop;
@@ -138,6 +139,9 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
138139 private:
139140 friend class TurboModuleBinding ;
140141 std::unique_ptr<jsi::WeakObject> jsRepresentation_;
142+ /* * This address is used only for identifying the runtime associated with the
143+ * JS representation. Do not dereference or use for any other purpose. */
144+ std::uintptr_t representationRuntimeAddress_;
141145};
142146
143147/* *
Original file line number Diff line number Diff line change 1010#include < ReactCommon/TurboModuleWithJSIBindings.h>
1111#include < cxxreact/TraceSection.h>
1212#include < react/utils/jsi-utils.h>
13+ #include < cstdint>
1314#include < stdexcept>
1415#include < string>
1516
@@ -177,6 +178,8 @@ jsi::Value TurboModuleBinding::getModule(
177178 jsi::Object jsRepresentation (runtime);
178179 weakJsRepresentation =
179180 std::make_unique<jsi::WeakObject>(runtime, jsRepresentation);
181+ module ->representationRuntimeAddress_ =
182+ reinterpret_cast <std::uintptr_t >(&runtime);
180183
181184 // Lazily populate the jsRepresentation, on property access.
182185 //
You can’t perform that action at this time.
0 commit comments