Remove unused JS Sampling Profiler code

Reviewed By: cwdick

Differential Revision: D7803915

fbshipit-source-id: 3edb42d449ff7b272f7d25ac8f16a646839f8c20
This commit is contained in:
Marc Horowitz 2018-05-09 22:01:36 -07:00 committed by Facebook Github Bot
parent ef258b0106
commit d1d09c208a
11 changed files with 1 additions and 306 deletions

View File

@ -81,7 +81,6 @@ public class DevServerHelper {
void onPackagerReloadCommand();
void onPackagerDevMenuCommand();
void onCaptureHeapCommand(final Responder responder);
void onPokeSamplingProfilerCommand(final Responder responder);
}
public interface SymbolicationListener {
@ -163,12 +162,6 @@ public class DevServerHelper {
commandListener.onCaptureHeapCommand(responder);
}
});
handlers.put("pokeSamplingProfiler", new RequestOnlyHandler() {
@Override
public void onRequest(@Nullable Object params, Responder responder) {
commandListener.onPokeSamplingProfilerCommand(responder);
}
});
handlers.putAll(new FileIoHandler().handlers());
ConnectionCallback onPackagerConnectedCallback =

View File

@ -841,29 +841,6 @@ public class DevSupportManagerImpl implements
});
}
@Override
public void onPokeSamplingProfilerCommand(final Responder responder) {
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run() {
if (mCurrentContext == null) {
responder.error("JSCContext is missing, unable to profile");
return;
}
try {
JavaScriptContextHolder jsContext = mCurrentContext.getJavaScriptContextHolder();
synchronized (jsContext) {
Class clazz = Class.forName("com.facebook.react.packagerconnection.SamplingProfilerPackagerMethod");
RequestHandler handler = (RequestHandler)clazz.getConstructor(long.class).newInstance(jsContext.get());
handler.onRequest(null, responder);
}
} catch (Exception e) {
// Module not present
}
}
});
}
private void handleCaptureHeap(final Responder responder) {
if (mCurrentContext == null) {
return;

View File

@ -4,7 +4,6 @@ rn_android_library(
name = "packagerconnection",
srcs = glob(
["**/*.java"],
excludes = ["SamplingProfilerPackagerMethod.java"] if IS_OSS_BUILD else [],
),
visibility = [
"PUBLIC",
@ -19,5 +18,5 @@ rn_android_library(
react_native_dep("third-party/java/okhttp:okhttp3"),
react_native_dep("third-party/java/okio:okio"),
react_native_target("java/com/facebook/react/modules/systeminfo:systeminfo-moduleless"),
] + ([react_native_target("jni/packagerconnection:jni")] if not IS_OSS_BUILD else []),
],
)

View File

@ -1,53 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.packagerconnection;
import javax.annotation.Nullable;
import android.os.Looper;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.soloader.SoLoader;
public class SamplingProfilerPackagerMethod extends RequestOnlyHandler {
static {
SoLoader.loadLibrary("packagerconnectionjnifb");
}
final private static class SamplingProfilerJniMethod {
@DoNotStrip
private final HybridData mHybridData;
public SamplingProfilerJniMethod(long javaScriptContext) {
if (Looper.myLooper() == null) {
Looper.prepare();
}
mHybridData = initHybrid(javaScriptContext);
}
@DoNotStrip
private native void poke(Responder responder);
@DoNotStrip
private static native HybridData initHybrid(long javaScriptContext);
}
private SamplingProfilerJniMethod mJniMethod;
public SamplingProfilerPackagerMethod(long javaScriptContext) {
mJniMethod = new SamplingProfilerJniMethod(javaScriptContext);
}
@Override
public void onRequest(@Nullable Object params, Responder responder) {
mJniMethod.poke(responder);
}
}

View File

@ -1,29 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := packagerconnectionjnifb
LOCAL_SRC_FILES := \
JSPackagerClientResponder.h \
SamplingProfilerPackagerMethod.cpp \
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../
LOCAL_CFLAGS += -Wall -Werror -fvisibility=hidden -fexceptions -frtti
CXX11_FLAGS := -std=c++11
LOCAL_CFLAGS += $(CXX11_FLAGS)
LOCAL_EXPORT_CPPFLAGS := $(CXX11_FLAGS)
LOCAL_LDLIBS += -landroid
LOCAL_SHARED_LIBRARIES := libfolly_json libfbjni libjsc libglog_init
include $(BUILD_SHARED_LIBRARY)
$(call import-module,fb)
$(call import-module,jsc)
$(call import-module,folly)
$(call import-module,fbgloginit)
$(call import-module,jni)
$(call import-module,jscwrapper)

View File

@ -1,35 +0,0 @@
load("//ReactNative:DEFS.bzl", "rn_xplat_cxx_library", "FBJNI_TARGET", "ANDROID_JSC_DEPS", "APPLE_JSC_DEPS", "ANDROID", "IS_OSS_BUILD", "react_native_xplat_target")
rn_xplat_cxx_library(
name = "jni",
srcs = glob(["*.cpp"]),
headers = glob(
["*.h"],
),
header_namespace = "",
compiler_flags = [
"-Wall",
"-Werror",
"-fexceptions",
"-std=c++1y",
"-frtti",
],
fbandroid_deps = ANDROID_JSC_DEPS,
fbobjc_deps = APPLE_JSC_DEPS,
platforms = ANDROID,
preprocessor_flags = [
"-DLOG_TAG=\"PackagerConnectionJNI\"",
"-DWITH_FBSYSTRACE=1",
"-DWITH_INSPECTOR=1",
],
soname = "libpackagerconnectionjnifb.$(ext)",
visibility = [
"PUBLIC",
],
deps = ([
FBJNI_TARGET,
"xplat//folly:molly",
react_native_xplat_target("jschelpers:jschelpers"),
react_native_xplat_target("jsinspector:jsinspector"),
]) if not IS_OSS_BUILD else [],
)

View File

@ -1,32 +0,0 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#include "JSPackagerClientResponder.h"
#include <jni/LocalString.h>
using namespace facebook::jni;
namespace facebook {
namespace react {
void JSPackagerClientResponder::respond(alias_ref<jobject> result) {
static auto method =
javaClassStatic()->getMethod<void(alias_ref<jobject>)>("respond");
method(self(), result);
}
void JSPackagerClientResponder::respond(const std::string &result) {
respond(LocalString(result).string());
}
void JSPackagerClientResponder::error(alias_ref<jobject> result) {
static auto method =
javaClassStatic()->getMethod<void(alias_ref<jobject>)>("error");
method(self(), result);
}
void JSPackagerClientResponder::error(const std::string &result) {
error(LocalString(result).string());
}
}
}

View File

@ -1,22 +0,0 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#include <fb/fbjni.h>
namespace facebook {
namespace react {
class JSPackagerClientResponder
: public jni::JavaClass<JSPackagerClientResponder> {
public:
static constexpr auto kJavaDescriptor =
"Lcom/facebook/react/packagerconnection/Responder;";
void respond(jni::alias_ref<jobject> result);
void respond(const std::string& result);
void error(jni::alias_ref<jobject> result);
void error(const std::string& result);
};
}
}

View File

@ -1,17 +0,0 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#include <fb/fbjni.h>
#include <jni.h>
#include "SamplingProfilerJniMethod.h"
using namespace facebook::jni;
namespace facebook {
namespace react {
extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
return initialize(vm, [] { SamplingProfilerJniMethod::registerNatives(); });
}
}
}

View File

@ -1,53 +0,0 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#include "SamplingProfilerJniMethod.h"
#include <JavaScriptCore/JSProfilerPrivate.h>
#include <jschelpers/JSCHelpers.h>
#include <jni.h>
#include <string>
using namespace facebook::jni;
namespace facebook {
namespace react {
/* static */ jni::local_ref<SamplingProfilerJniMethod::jhybriddata>
SamplingProfilerJniMethod::initHybrid(jni::alias_ref<jclass>,
jlong javaScriptContext) {
return makeCxxInstance(javaScriptContext);
}
/* static */ void SamplingProfilerJniMethod::registerNatives() {
registerHybrid(
{makeNativeMethod("initHybrid", SamplingProfilerJniMethod::initHybrid),
makeNativeMethod("poke", SamplingProfilerJniMethod::poke)});
}
SamplingProfilerJniMethod::SamplingProfilerJniMethod(jlong javaScriptContext) {
context_ = reinterpret_cast<JSGlobalContextRef>(javaScriptContext);
}
void SamplingProfilerJniMethod::poke(
jni::alias_ref<JSPackagerClientResponder::javaobject> responder) {
if (!JSC_JSSamplingProfilerEnabled(context_)) {
responder->error("The JSSamplingProfiler is disabled. See this "
"https://fburl.com/u4lw7xeq for some help");
return;
}
JSValueRef jsResult = JSC_JSPokeSamplingProfiler(context_);
if (JSC_JSValueGetType(context_, jsResult) == kJSTypeNull) {
responder->respond("started");
} else {
JSStringRef resultStrRef = JSValueToStringCopy(context_, jsResult, nullptr);
size_t length = JSStringGetLength(resultStrRef);
char buffer[length + 1];
JSStringGetUTF8CString(resultStrRef, buffer, length + 1);
JSStringRelease(resultStrRef);
responder->respond(buffer);
}
}
}
}

View File

@ -1,33 +0,0 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#include <fb/fbjni.h>
#include <JavaScriptCore/JSValueRef.h>
#include "JSPackagerClientResponder.h"
namespace facebook {
namespace react {
class SamplingProfilerJniMethod
: public jni::HybridClass<SamplingProfilerJniMethod> {
public:
static constexpr auto kJavaDescriptor =
"Lcom/facebook/react/packagerconnection/"
"SamplingProfilerPackagerMethod$SamplingProfilerJniMethod;";
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jclass> jthis,
jlong javaScriptContext);
static void registerNatives();
private:
friend HybridBase;
explicit SamplingProfilerJniMethod(jlong javaScriptContext);
void poke(jni::alias_ref<JSPackagerClientResponder::javaobject> responder);
JSGlobalContextRef context_;
};
}
}