Up to higher level directory | |||
Name | Date | Size | |
---|---|---|---|
Android.bp | 22-Oct-2020 | 1.4K | |
check-null-fields.py | 22-Oct-2020 | 5.2K | |
fieldnull.cc | 22-Oct-2020 | 8.1K | |
README.md | 22-Oct-2020 | 2K |
1 # fieldnull 2 3 fieldnull is a JVMTI agent designed for testing for a given field the number of 4 instances with that field set to null. This can be useful for determining what 5 fields should be moved into side structures in cases where memory use is 6 important. 7 8 # Usage 9 ### Build 10 > `make libfieldnull` 11 12 The libraries will be built for 32-bit, 64-bit, host and target. Below examples 13 assume you want to use the 64-bit version. 14 15 ### Command Line 16 17 The agent is loaded using -agentpath like normal. It takes arguments in the 18 following format: 19 > `Lname/of/class;.nameOfField:Ltype/of/field;[,...]` 20 21 #### ART 22 > `art -Xplugin:$ANDROID_HOST_OUT/lib64/libopenjdkjvmti.so '-agentpath:libfieldnull.so=Lname/of/class;.nameOfField:Ltype/of/field;' -cp tmp/java/helloworld.dex -Xint helloworld` 23 24 * `-Xplugin` and `-agentpath` need to be used, otherwise the agent will fail during init. 25 * If using `libartd.so`, make sure to use the debug version of jvmti. 26 27 > `adb shell setenforce 0` 28 > 29 > `adb push $ANDROID_PRODUCT_OUT/system/lib64/libfieldnull.so /data/local/tmp/` 30 > 31 > `adb shell am start-activity --attach-agent '/data/local/tmp/libfieldnull.so=Ljava/lang/Class;.name:Ljava/lang/String;' some.debuggable.apps/.the.app.MainActivity` 32 33 #### RI 34 > `java '-agentpath:libfieldnull.so=Lname/of/class;.nameOfField:Ltype/of/field;' -cp tmp/helloworld/classes helloworld` 35 36 ### Printing the Results 37 All statistics gathered during the trace are printed automatically when the 38 program normally exits. In the case of Android applications, they are always 39 killed, so we need to manually print the results. 40 41 > `kill -SIGQUIT $(pid com.littleinc.orm_benchmark)` 42 43 Will initiate a dump of the counts (to logcat). 44 45 The dump will look something like this. 46 47 > `dalvikvm32 I 08-30 14:51:20 84818 84818 fieldnull.cc:96] Dumping counts of null fields.` 48 > 49 > `dalvikvm32 I 08-30 14:51:20 84818 84818 fieldnull.cc:97] Field name null count total count` 50 > 51 > `dalvikvm32 I 08-30 14:51:20 84818 84818 fieldnull.cc:135] Ljava/lang/Class;.name:Ljava/lang/String; 5 2936` 52