Reviewed By: tadeuzagallo

Differential Revision: D2748749

fb-gh-sync-id: 4d1dbae61f69a07b7106cb57caff03cadfb85776
This commit is contained in:
Mike Armstrong 2015-12-11 07:28:50 -08:00 коммит произвёл facebook-github-bot-7
Родитель a86171a482
Коммит 1a94698658
1 изменённых файлов: 25 добавлений и 0 удалений

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

@ -9,6 +9,7 @@
#include <folly/json.h>
#include <folly/String.h>
#include <jni/fbjni/Exceptions.h>
#include <sys/time.h>
#include "Value.h"
#include "jni/OnLoad.h"
@ -34,6 +35,9 @@ using fbsystrace::FbSystraceSection;
#include <jsc_config_android.h>
#endif
static const int64_t NANOSECONDS_IN_SECOND = 1000000000LL;
static const int64_t NANOSECONDS_IN_MILLISECOND = 1000000LL;
using namespace facebook::jni;
namespace facebook {
@ -54,6 +58,13 @@ static JSValueRef nativeLoggingHook(
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef *exception);
static JSValueRef nativePerformanceNow(
JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef *exception);
static JSValueRef evaluateScriptWithJSC(
JSGlobalContextRef ctx,
@ -110,6 +121,7 @@ JSCExecutor::JSCExecutor(FlushImmediateCallback cb) :
s_globalContextRefToJSCExecutor[m_context] = this;
installGlobalFunction(m_context, "nativeFlushQueueImmediate", nativeFlushQueueImmediate);
installGlobalFunction(m_context, "nativeLoggingHook", nativeLoggingHook);
installGlobalFunction(m_context, "nativePerformanceNow", nativePerformanceNow);
#ifdef WITH_FB_JSC_TUNING
configureJSCForAndroid();
@ -283,4 +295,17 @@ static JSValueRef nativeLoggingHook(
return JSValueMakeUndefined(ctx);
}
static JSValueRef nativePerformanceNow(
JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[], JSValueRef *exception) {
// This is equivalent to android.os.SystemClock.elapsedRealtime() in native
struct timespec now;
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
int64_t nano = now.tv_sec * NANOSECONDS_IN_SECOND + now.tv_nsec;
return JSValueMakeNumber(ctx, (nano / (double)NANOSECONDS_IN_MILLISECOND));
}
} }