Skip to content

Commit d22dbb5

Browse files
TheRogue76facebook-github-bot
authored andcommitted
chore(Android): Migrate Hermes Instruments to Kotlin (facebook#48378)
Summary: Time to migrate some of Hermes's instruments. I see that HermesMemoryDumper(`react/hermes/instrumentation/HermesMemoryDumper.h`) implements the interface on C++, ~but not sure if i need to update the `getId` call to just `id` (same with `getInternalStorage`) or if the interop between Kotlin and Java applies to these things as well. cortinico Any thoughts on your side would be appreciated. HermesSamplingProfiler just became an object, since it was a singleton and a static anyway. Here is what HermesMemoryDumper.h looks like: <img width="1840" alt="Screenshot 2024-12-24 at 10 03 00" src="https://github.com/user-attachments/assets/d18e378a-9b23-47a9-83c9-402d29aeaa5f" />~ *Updated*: I ended up making them match the function signature on Cxx, because even if it does have that implicit behavior, doesn't feel right to tap into it like this. ## Changelog: [INTERNAL] [FIXED] - Migrate HermesMemoryDumper and HermesSamplingProfiler to Kotlin Pull Request resolved: facebook#48378 Test Plan: `/gradlew test`: <img width="1840" alt="Screenshot 2024-12-24 at 09 54 29" src="https://github.com/user-attachments/assets/1b23fb6f-9da8-42e4-a348-7da868df77c1" /> Reviewed By: cortinico Differential Revision: D67657481 Pulled By: philIip fbshipit-source-id: 4fb5e003789d51d464d0cca5800704ea51324b69
1 parent cd40e4e commit d22dbb5

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
package com.facebook.hermes.instrumentation;
8+
package com.facebook.hermes.instrumentation
99

1010
public interface HermesMemoryDumper {
11-
boolean shouldSaveSnapshot();
11+
public fun shouldSaveSnapshot(): Boolean
1212

13-
String getInternalStorage();
13+
public fun getInternalStorage(): String
1414

15-
String getId();
15+
public fun getId(): String
1616

17-
void setMetaData(String crashId);
17+
public fun setMetaData(crashId: String)
1818
}
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,26 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
package com.facebook.hermes.instrumentation;
8+
package com.facebook.hermes.instrumentation
99

10-
import com.facebook.soloader.SoLoader;
10+
import com.facebook.soloader.SoLoader
1111

1212
/** Hermes sampling profiler static JSI API. */
13-
public class HermesSamplingProfiler {
14-
static {
15-
SoLoader.loadLibrary("jsijniprofiler");
13+
public object HermesSamplingProfiler {
14+
init {
15+
SoLoader.loadLibrary("jsijniprofiler")
1616
}
1717

1818
/** Start sample profiling. */
19-
public static native void enable();
19+
@JvmStatic public external fun enable()
2020

2121
/** Stop sample profiling. */
22-
public static native void disable();
22+
@JvmStatic public external fun disable()
2323

2424
/**
2525
* Dump sampled stack traces to file.
2626
*
2727
* @param filename the file to dump sampling trace to.
2828
*/
29-
public static native void dumpSampledTraceToFile(String filename);
30-
31-
private HermesSamplingProfiler() {}
29+
@JvmStatic public external fun dumpSampledTraceToFile(filename: String)
3230
}

0 commit comments

Comments
 (0)