Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
romainguy committed Aug 22, 2024
1 parent 59b7dc0 commit 580d192
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ which panels are visible using the *View* menu.
- Shows the number of instructions and branches per method.
- Click a disassembled instruction or register to highlight all occurrences.

# Kotlin Explorer and R8

You can use *Build > Optimize with R8* to optimize the compiled code with the R8 tool.
By default, all public classes/members/etc. will be kept, allowing you to analyze them
in the disassembly panels.

However, keeping everything is not representative of what R8 will do on an actual
application so you can disable that feature, and instead use the `@Keep` annotation
to choose an entry point leading to the desired disassembly. You can also create a
`fun main()` entry point and call your code from there. Be careful to not use constants
when calling other methods as this may lead to aggressive optimization by R8.

# Running Kotlin Explorer

Run Kotlin Explorer with `./gradlew jvmRun`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ private fun FrameWindowScope.MainMenu(
)
Separator()
MenuCheckboxItem("Optimize with R8", CtrlShift(O), explorerState::optimize)
MenuCheckboxItem("Keep everything", CtrlShift(K), explorerState::keepEverything)
MenuCheckboxItem("Keep Everything", CtrlShift(K), explorerState::keepEverything)
MenuCheckboxItem("Build on Startup", shortcut = null, explorerState::autoBuildOnStartup)
MenuItem(
"Build & Disassemble",
Expand Down
2 changes: 1 addition & 1 deletion src/jvmMain/kotlin/dev/romainguy/kotlin/explorer/State.kt
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private fun readSourceCode(toolPaths: ToolPaths) = if (toolPaths.sourceFile.exis
Files.readString(toolPaths.sourceFile)
} else {
"""
// NOTE: If Build > Keep everything is *not* checked, used the @Keep
// NOTE: If Build > Keep Everything is *not* checked, used the @Keep
// annotation to keep the classes/methods/etc. you want to disassemble
fun square(a: Int): Int {
return a * a
Expand Down

0 comments on commit 580d192

Please sign in to comment.