You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/HermesMemoryDumper.kt
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,14 @@
5
5
* LICENSE file in the root directory of this source tree.
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/HermesSamplingProfiler.kt
+8-10Lines changed: 8 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -5,28 +5,26 @@
5
5
* LICENSE file in the root directory of this source tree.
6
6
*/
7
7
8
-
packagecom.facebook.hermes.instrumentation;
8
+
packagecom.facebook.hermes.instrumentation
9
9
10
-
importcom.facebook.soloader.SoLoader;
10
+
importcom.facebook.soloader.SoLoader
11
11
12
12
/** Hermes sampling profiler static JSI API. */
13
-
publicclassHermesSamplingProfiler {
14
-
static {
15
-
SoLoader.loadLibrary("jsijniprofiler");
13
+
publicobject HermesSamplingProfiler {
14
+
init {
15
+
SoLoader.loadLibrary("jsijniprofiler")
16
16
}
17
17
18
18
/** Start sample profiling. */
19
-
publicstaticnativevoidenable();
19
+
@JvmStatic publicexternalfunenable()
20
20
21
21
/** Stop sample profiling. */
22
-
publicstaticnativevoiddisable();
22
+
@JvmStatic publicexternalfundisable()
23
23
24
24
/**
25
25
* Dump sampled stack traces to file.
26
26
*
27
27
* @param filename the file to dump sampling trace to.
0 commit comments