From 042449f24adbf1b36036fbe6bf1c8a869021010e Mon Sep 17 00:00:00 2001 From: Marc Horowitz Date: Wed, 9 May 2018 22:01:50 -0700 Subject: [PATCH] simplify handleMemoryPressure conditionalization, delete some dead code Reviewed By: javache Differential Revision: D7803912 fbshipit-source-id: 0bab4be07fc006a208caa75f94b5716c99b5d265 --- ReactAndroid/src/main/jni/react/jni/BUCK | 1 - ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp | 2 -- ReactCommon/cxxreact/Instance.cpp | 2 -- ReactCommon/cxxreact/Instance.h | 3 --- ReactCommon/cxxreact/JSCExecutor.cpp | 4 ++-- ReactCommon/cxxreact/JSCExecutor.h | 2 -- ReactCommon/cxxreact/NativeToJsBridge.cpp | 3 +-- ReactCommon/cxxreact/NativeToJsBridge.h | 3 --- 8 files changed, 3 insertions(+), 17 deletions(-) diff --git a/ReactAndroid/src/main/jni/react/jni/BUCK b/ReactAndroid/src/main/jni/react/jni/BUCK index dc0f2a76d5..e79a63dbde 100644 --- a/ReactAndroid/src/main/jni/react/jni/BUCK +++ b/ReactAndroid/src/main/jni/react/jni/BUCK @@ -47,7 +47,6 @@ rn_xplat_cxx_library( "-DLOG_TAG=\"ReactNativeJNI\"", "-DWITH_FBSYSTRACE=1", "-DWITH_INSPECTOR=1", - "-DWITH_JSC_MEMORY_PRESSURE=1", ], soname = "libreactnativejni.$(ext)", visibility = [ diff --git a/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp b/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp index aeb4cc55e1..0c5cf5c8f6 100644 --- a/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp +++ b/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp @@ -259,9 +259,7 @@ jlong CatalystInstanceImpl::getJavaScriptContext() { } void CatalystInstanceImpl::handleMemoryPressure(int pressureLevel) { - #ifdef WITH_JSC_MEMORY_PRESSURE instance_->handleMemoryPressure(pressureLevel); - #endif } }} diff --git a/ReactCommon/cxxreact/Instance.cpp b/ReactCommon/cxxreact/Instance.cpp index c3fd8cf607..534f4b981c 100644 --- a/ReactCommon/cxxreact/Instance.cpp +++ b/ReactCommon/cxxreact/Instance.cpp @@ -170,11 +170,9 @@ const ModuleRegistry &Instance::getModuleRegistry() const { ModuleRegistry &Instance::getModuleRegistry() { return *moduleRegistry_; } -#ifdef WITH_JSC_MEMORY_PRESSURE void Instance::handleMemoryPressure(int pressureLevel) { nativeToJsBridge_->handleMemoryPressure(pressureLevel); } -#endif } // namespace react } // namespace facebook diff --git a/ReactCommon/cxxreact/Instance.h b/ReactCommon/cxxreact/Instance.h index e35ce4bbe2..dffbe72465 100644 --- a/ReactCommon/cxxreact/Instance.h +++ b/ReactCommon/cxxreact/Instance.h @@ -6,7 +6,6 @@ #include #include -#include #ifndef RN_EXPORT #define RN_EXPORT __attribute__((visibility("default"))) @@ -66,9 +65,7 @@ public: const ModuleRegistry &getModuleRegistry() const; ModuleRegistry &getModuleRegistry(); -#ifdef WITH_JSC_MEMORY_PRESSURE void handleMemoryPressure(int pressureLevel); -#endif private: void callNativeModules(folly::dynamic &&calls, bool isEndOfBatch); diff --git a/ReactCommon/cxxreact/JSCExecutor.cpp b/ReactCommon/cxxreact/JSCExecutor.cpp index c88da5f5b7..d20c97a154 100644 --- a/ReactCommon/cxxreact/JSCExecutor.cpp +++ b/ReactCommon/cxxreact/JSCExecutor.cpp @@ -696,12 +696,12 @@ bool JSCExecutor::isInspectable() { return canUseInspector(m_context); } -#ifdef WITH_JSC_MEMORY_PRESSURE void JSCExecutor::handleMemoryPressure(int pressureLevel) { +#ifdef WITH_JSC_MEMORY_PRESSURE JSHandleMemoryPressure( this, m_context, static_cast(pressureLevel)); -} #endif +} void JSCExecutor::flushQueueImmediate(Value&& queue) { auto queueStr = queue.toJSONString(); diff --git a/ReactCommon/cxxreact/JSCExecutor.h b/ReactCommon/cxxreact/JSCExecutor.h index 44b13aa94b..b85e590d71 100644 --- a/ReactCommon/cxxreact/JSCExecutor.h +++ b/ReactCommon/cxxreact/JSCExecutor.h @@ -89,9 +89,7 @@ public: virtual bool isInspectable() override; -#ifdef WITH_JSC_MEMORY_PRESSURE virtual void handleMemoryPressure(int pressureLevel) override; -#endif virtual void destroy() override; diff --git a/ReactCommon/cxxreact/NativeToJsBridge.cpp b/ReactCommon/cxxreact/NativeToJsBridge.cpp index f8ae2856e6..3cf374f068 100644 --- a/ReactCommon/cxxreact/NativeToJsBridge.cpp +++ b/ReactCommon/cxxreact/NativeToJsBridge.cpp @@ -11,6 +11,7 @@ #include "SystraceSection.h" #include "MethodCall.h" #include "MessageQueueThread.h" +#include "ModuleRegistry.h" #include "RAMBundleRegistry.h" #ifdef WITH_FBSYSTRACE @@ -194,13 +195,11 @@ bool NativeToJsBridge::isInspectable() { return m_executor->isInspectable(); } -#ifdef WITH_JSC_MEMORY_PRESSURE void NativeToJsBridge::handleMemoryPressure(int pressureLevel) { runOnExecutorQueue([=] (JSExecutor* executor) { executor->handleMemoryPressure(pressureLevel); }); } -#endif void NativeToJsBridge::destroy() { // All calls made through runOnExecutorQueue have an early exit if diff --git a/ReactCommon/cxxreact/NativeToJsBridge.h b/ReactCommon/cxxreact/NativeToJsBridge.h index 78d960a08a..7e7aaf77ee 100644 --- a/ReactCommon/cxxreact/NativeToJsBridge.h +++ b/ReactCommon/cxxreact/NativeToJsBridge.h @@ -7,7 +7,6 @@ #include #include -#include #include namespace folly { @@ -74,9 +73,7 @@ public: void* getJavaScriptContext(); bool isInspectable(); - #ifdef WITH_JSC_MEMORY_PRESSURE void handleMemoryPressure(int pressureLevel); - #endif /** * Synchronously tears down the bridge and the main executor.