Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(Android): Migrate Hermes Instruments to Kotlin #48378

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
* 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.hermes.instrumentation;
package com.facebook.hermes.instrumentation

public interface HermesMemoryDumper {
boolean shouldSaveSnapshot();
public fun shouldSaveSnapshot(): Boolean

String getInternalStorage();
public fun getInternalStorage(): String

String getId();
public fun getId(): String
Comment on lines -13 to +14
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I marked these as String and not String? since in Cxx the return type is std::string and not a pointer, but i do see some pointer shenanigans going on over there. Will leave it up to the person who reviews to give their thoughts as well. I can not find any use of this class anywhere, in Cxx or in the JVM land so i can't tell by usage


void setMetaData(String crashId);
public fun setMetaData(crashId: String)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* 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.hermes.instrumentation

import com.facebook.soloader.SoLoader

/** Hermes sampling profiler static JSI API. */
public object HermesSamplingProfiler {
init {
SoLoader.loadLibrary("jsijniprofiler")
}

/** Start sample profiling. */
@JvmStatic
public external fun enable()

/** Stop sample profiling. */
@JvmStatic
public external fun disable()

/**
* Dump sampled stack traces to file.
*
* @param filename the file to dump sampling trace to.
*/
@JvmStatic
public external fun dumpSampledTraceToFile(filename: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package com.facebook.hermes.reactexecutor;

import androidx.annotation.NonNull;
import com.facebook.hermes.instrumentation.HermesSamplingProfiler;
import com.facebook.react.bridge.JavaScriptExecutor;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
Expand Down Expand Up @@ -34,6 +35,7 @@ public void setDebuggerName(String debuggerName) {
mDebuggerName = debuggerName;
}

@NonNull
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaScriptExecutorFactory explicitly marks these values as non nullable, so it is ok to mark them here as well.
Screenshot 2024-12-24 at 23 27 06

@Override
public JavaScriptExecutor create() {
return new HermesExecutor(mConfig, mEnableDebugger, mDebuggerName);
Expand All @@ -45,11 +47,12 @@ public void startSamplingProfiler() {
}

@Override
public void stopSamplingProfiler(String filename) {
public void stopSamplingProfiler(@NonNull String filename) {
HermesSamplingProfiler.dumpSampledTraceToFile(filename);
HermesSamplingProfiler.disable();
}

@NonNull
@Override
public String toString() {
return "JSIExecutor+HermesRuntime";
Expand Down
Loading