Skip to content

Commit cd176f9

Browse files
authored
Lukas's feedback
1 parent 79caf49 commit cd176f9

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎_overviews/compiler-options/optimizer.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ By **[Lukas Rytz](https://github.com/lrytz) (2018)**, **[Andrew Marki](https://g
1515
as it breaks binary compatibility, prevents the use of newer dependencies, and breaks incremental compilation.
1616
- The typical way to enable the optimizer is with the compiler arguments `-opt -opt-inline:**,!java.**`,
1717
which enables local optimizations and allows inlining of anything not in the JDK itself.
18+
- When compiling an application with such global inlining, ensure that the run-time classpath is **exactly the same** as the compile-time classpath.
19+
- Alternatively, use `-opt:inline:my.package.**` to only inline from packages within your library, or within libraries you control.
1820
- The optimizer's main focus is to _inline_ functions and methods that are considered worth inlining, in particular higher-order functions.
1921
You can tell the inliner to always inline a specific method with the `@inline` annotation and to never do so with the `@noinline` annotation,
2022
but you should normally not need these annotations.
@@ -105,7 +107,7 @@ The reason for this restriction is that dependency management tools like sbt wil
105107
## Using and interacting with the optimizer
106108

107109
There are two compiler flags you should know about:
108-
- `-opt` enables local optimizations. While these do not break binary compatibility and can always be used, they typically do not improve performance on their own, such as:
110+
- `-opt` enables local optimizations. While these do not break binary compatibility and can always be used, they typically do not improve performance on their own.
109111
- Elimination of code that loads unused values
110112
- Rewriting of null and `isInstanceOf` checks whose result is known at compile-time
111113
- Elimination of value boxes like `java.lang.Integer` or `scala.runtime.DoubleRef` that are created within a method and don't escape it

0 commit comments

Comments
 (0)