Create tracing name in C++ instead of Java

Reviewed By: mhorowitz

Differential Revision: D3469140

fbshipit-source-id: 77a00a7150573e44f219972556cbb936a57d7054
This commit is contained in:
Alexander Blom
2016-07-07 08:43:56 -07:00
committed by Facebook Github Bot 1
parent af24e8001a
commit 95401aba72
15 changed files with 35 additions and 54 deletions

View File

@@ -32,8 +32,7 @@ public interface CatalystInstance extends MemoryPressureListener {
ExecutorToken executorToken,
String module,
String method,
NativeArray arguments,
String tracingName);
NativeArray arguments);
/**
* Destroys this catalyst instance, waiting for any other threads in ReactQueueConfiguration
* (besides the UI thread) to finish running. Must be called from the UI thread so that we can

View File

@@ -164,8 +164,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
ExecutorToken executorToken,
String module,
String method,
NativeArray arguments,
String tracingName) {
NativeArray arguments) {
if (mIsBeingDestroyed) {
FLog.w(ReactConstants.TAG, "Calling JS function after bridge has been destroyed.");
return;
@@ -178,10 +177,11 @@ public class CatalystInstanceImpl implements CatalystInstance {
incrementPendingJSCalls();
Assertions.assertNotNull(mBridge).callFunction(executorToken,
module,
method, arguments, tracingName);
}
Assertions.assertNotNull(mBridge).callFunction(
executorToken,
module,
method, arguments);
}
}
// This is called from java code, so it won't be stripped anyway, but proguard will rename it,

View File

@@ -13,10 +13,8 @@ import javax.annotation.concurrent.Immutable;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.facebook.react.common.build.ReactBuildConfig;
@@ -28,11 +26,9 @@ import com.facebook.react.common.build.ReactBuildConfig;
public class JavaScriptModuleRegistration {
private final Class<? extends JavaScriptModule> mModuleInterface;
private final Map<Method, String> mMethodsToTracingNames;
public JavaScriptModuleRegistration(Class<? extends JavaScriptModule> moduleInterface) {
mModuleInterface = moduleInterface;
mMethodsToTracingNames = new HashMap<>();
if (ReactBuildConfig.DEBUG) {
Set<String> methodNames = new LinkedHashSet<>();
@@ -46,15 +42,6 @@ public class JavaScriptModuleRegistration {
}
}
public String getTracingName(Method method) {
String name = mMethodsToTracingNames.get(method);
if (name == null) {
name = "JSCall__" + getName() + "_" + method.getName();
mMethodsToTracingNames.put(method, name);
}
return name;
}
public Class<? extends JavaScriptModule> getModuleInterface() {
return mModuleInterface;
}

View File

@@ -106,14 +106,13 @@ public class JavaScriptModuleRegistry {
FLog.w(ReactConstants.TAG, "Dropping JS call, ExecutorToken went away...");
return null;
}
String tracingName = mModuleRegistration.getTracingName(method);
NativeArray jsArgs = args != null ? Arguments.fromJavaArgs(args) : new WritableNativeArray();
mCatalystInstance.callFunction(
executorToken,
mModuleRegistration.getName(),
method.getName(),
jsArgs,
tracingName);
jsArgs
);
return null;
}
}

View File

@@ -88,7 +88,7 @@ public class ReactBridge extends Countable {
*/
public native void loadScriptFromAssets(AssetManager assetManager, String assetName);
public native void loadScriptFromFile(@Nullable String fileName, @Nullable String sourceURL);
public native void callFunction(ExecutorToken executorToken, String module, String method, NativeArray arguments, String tracingName);
public native void callFunction(ExecutorToken executorToken, String module, String method, NativeArray arguments);
public native void invokeCallback(ExecutorToken executorToken, int callbackID, NativeArray arguments);
public native void setGlobalVariable(String propertyName, String jsonEncodedArgument);
public native boolean supportsProfiling();