Reviewed By: dcaspi

Differential Revision: D5185504

fbshipit-source-id: 4f7e9f9068598418b346a7370f6be241a0784b60
This commit is contained in:
Pieter De Baets 2017-06-07 10:17:58 -07:00 коммит произвёл Facebook Github Bot
Родитель f7c89b4187
Коммит 81c2f3b189
5 изменённых файлов: 49 добавлений и 46 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -1,30 +1,31 @@
// 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 {
@ -32,6 +33,7 @@ namespace react {
namespace {
// TODO: can we avoid these wrapper classes, and instead specialize the logic in CatalystInstanceImpl
class JSCJavaScriptExecutorHolder : public HybridClass<JSCJavaScriptExecutorHolder,
JavaScriptExecutorHolder> {
public:
@ -151,19 +153,15 @@ 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();
@ -171,7 +169,11 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
ReadableNativeMap::registerNatives();
WritableNativeMap::registerNatives();
ReadableNativeMapKeySetIterator::registerNatives();
#ifdef WITH_INSPECTOR
JInspector::registerNatives();
#endif
});
}
}}
} }

Просмотреть файл

@ -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);
@ -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)) {

Просмотреть файл

@ -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__

Просмотреть файл

@ -14,6 +14,7 @@ namespace facebook {
namespace react {
namespace ReactMarker {
enum ReactMarkerId {
NATIVE_REQUIRE_START,
NATIVE_REQUIRE_STOP,
@ -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;
}
} }