Skip to content

Commit

Permalink
Cleanup Platform
Browse files Browse the repository at this point in the history
Reviewed By: dcaspi

Differential Revision: D5185504

fbshipit-source-id: 4f7e9f9068598418b346a7370f6be241a0784b60
  • Loading branch information
javache authored and facebook-github-bot committed Jun 7, 2017
1 parent f7c89b4 commit 81c2f3b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 46 deletions.
6 changes: 3 additions & 3 deletions React/CxxBridge/RCTJSCHelpers.mm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ JSValueRef nativePerformanceNow(

void RCTPrepareJSCExecutor() {
ReactMarker::logTaggedMarker = [](const ReactMarker::ReactMarkerId, const char *tag) {};
PerfLogging::installNativeHooks = RCTFBQuickPerformanceLoggerConfigureHooks;
JSNativeHooks::loggingHook = nativeLoggingHook;
JSNativeHooks::nowHook = nativePerformanceNow;
JSCNativeHooks::loggingHook = nativeLoggingHook;
JSCNativeHooks::nowHook = nativePerformanceNow;
JSCNativeHooks::installPerfHooks = RCTFBQuickPerformanceLoggerConfigureHooks;
}
40 changes: 21 additions & 19 deletions ReactAndroid/src/main/jni/react/jni/OnLoad.cpp
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
// Copyright 2004-present Facebook. All Rights Reserved.

#include <folly/dynamic.h>
#include <fb/fbjni.h>
#include <fb/glog_init.h>
#include <fb/log.h>
#include <string>

#include <cxxreact/Executor.h>
#include <cxxreact/JSCExecutor.h>
#include <cxxreact/Platform.h>
#include <jschelpers/JSCHelpers.h>
#include <fb/fbjni.h>
#include <fb/glog_init.h>
#include <fb/log.h>
#include <folly/dynamic.h>
#include <jschelpers/Value.h>

#include "CatalystInstanceImpl.h"
#include "CxxModuleWrapper.h"
#include "JavaScriptExecutorHolder.h"
#include "JSCPerfLogging.h"
#include "ProxyExecutor.h"
#include "JCallback.h"
#include "JSCPerfLogging.h"
#include "JSLogging.h"
#include "ProxyExecutor.h"
#include "WritableNativeArray.h"
#include "WritableNativeMap.h"

#ifdef WITH_INSPECTOR
#include "JInspector.h"
#endif

#include "WritableNativeMap.h"
#include "WritableNativeArray.h"

#include <string>

using namespace facebook::jni;

namespace facebook {
namespace react {

namespace {

// TODO: can we avoid these wrapper classes, and instead specialize the logic in CatalystInstanceImpl
class JSCJavaScriptExecutorHolder : public HybridClass<JSCJavaScriptExecutorHolder,
JavaScriptExecutorHolder> {
public:
Expand Down Expand Up @@ -151,27 +153,27 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
gloginit::initialize();
// Inject some behavior into react/
ReactMarker::logTaggedMarker = logPerfMarker;
PerfLogging::installNativeHooks = addNativePerfLoggingHooks;
JSNativeHooks::loggingHook = nativeLoggingHook;
JSNativeHooks::nowHook = nativePerformanceNow;
JSCNativeHooks::loggingHook = nativeLoggingHook;
JSCNativeHooks::nowHook = nativePerformanceNow;
JSCNativeHooks::installPerfHooks = addNativePerfLoggingHooks;
JSCJavaScriptExecutorHolder::registerNatives();
ProxyJavaScriptExecutorHolder::registerNatives();
CatalystInstanceImpl::registerNatives();
CxxModuleWrapperBase::registerNatives();
CxxModuleWrapper::registerNatives();
JCxxCallbackImpl::registerNatives();
#ifdef WITH_INSPECTOR
JInspector::registerNatives();
#endif

NativeArray::registerNatives();
ReadableNativeArray::registerNatives();
WritableNativeArray::registerNatives();
NativeMap::registerNatives();
ReadableNativeMap::registerNatives();
WritableNativeMap::registerNatives();
ReadableNativeMapKeySetIterator::registerNatives();

#ifdef WITH_INSPECTOR
JInspector::registerNatives();
#endif
});
}

}}
} }
6 changes: 3 additions & 3 deletions ReactCommon/cxxreact/JSCExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ void JSCExecutor::initOnJSVMThread() throw(JSException) {
installNativeHook<&JSCExecutor::nativeFlushQueueImmediate>("nativeFlushQueueImmediate");
installNativeHook<&JSCExecutor::nativeCallSyncHook>("nativeCallSyncHook");

installGlobalFunction(m_context, "nativeLoggingHook", JSNativeHooks::loggingHook);
installGlobalFunction(m_context, "nativePerformanceNow", JSNativeHooks::nowHook);
installGlobalFunction(m_context, "nativeLoggingHook", JSCNativeHooks::loggingHook);
installGlobalFunction(m_context, "nativePerformanceNow", JSCNativeHooks::nowHook);

#if DEBUG
installGlobalFunction(m_context, "nativeInjectHMRUpdate", nativeInjectHMRUpdate);
Expand All @@ -242,7 +242,7 @@ void JSCExecutor::initOnJSVMThread() throw(JSException) {
addNativeTracingLegacyHooks(m_context);
#endif

PerfLogging::installNativeHooks(m_context);
JSCNativeHooks::installPerfHooks(m_context);

#if defined(__APPLE__) || defined(WITH_JSC_EXTRA_TRACING)
if (JSC_JSSamplingProfilerEnabled(m_context)) {
Expand Down
12 changes: 6 additions & 6 deletions ReactCommon/cxxreact/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ namespace react {
#endif

namespace ReactMarker {
LogTaggedMarker logTaggedMarker = nullptr;

LogTaggedMarker logTaggedMarker = nullptr;
void logMarker(const ReactMarkerId markerId) {
logTaggedMarker(markerId, nullptr);
}
};

namespace PerfLogging {
InstallNativeHooks installNativeHooks = nullptr;
};
}

namespace JSCNativeHooks {

namespace JSNativeHooks {
Hook loggingHook = nullptr;
Hook nowHook = nullptr;
ConfigurationHook installPerfHooks = nullptr;

}

#if __clang__
Expand Down
31 changes: 16 additions & 15 deletions ReactCommon/cxxreact/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace facebook {
namespace react {

namespace ReactMarker {

enum ReactMarkerId {
NATIVE_REQUIRE_START,
NATIVE_REQUIRE_STOP,
Expand All @@ -29,23 +30,23 @@ extern LogTaggedMarker logTaggedMarker;

extern void logMarker(const ReactMarkerId markerId);

};
}

namespace PerfLogging {
using InstallNativeHooks = std::function<void(JSGlobalContextRef)>;
extern InstallNativeHooks installNativeHooks;
};
namespace JSCNativeHooks {

using Hook = JSValueRef(*)(
JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef *exception);
extern Hook loggingHook;
extern Hook nowHook;

using ConfigurationHook = std::function<void(JSGlobalContextRef)>;
extern ConfigurationHook installPerfHooks;

namespace JSNativeHooks {
using Hook = JSValueRef (*) (
JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef *exception);
extern Hook loggingHook;
extern Hook nowHook;
}

} }

0 comments on commit 81c2f3b

Please sign in to comment.