• R8 Optimization: Method Outlining

    Note: This post is part of a series on D8 and R8, Android’s new dexer and optimizer, respectively. For an intro to D8 read “Android’s Java 8 support”. For an intro to R8 read “R8 Optimization: Staticization”. I recently wrote about the economics of generated code which talked about performing optimizations to generated code that…

    Read More

  • Exceptions and proxies and coroutines, oh my!

    Checked exceptions are a concept that exist only in the Java compiler and are enforced only in source code. In Java bytecode and at runtime in the virtual machine you’re free to throw checked exceptions from anywhere regardless of whether they’re declared. At least, anywhere except from a instance created by a Java Proxy. A…

    Read More

  • Calculating the true impact of zip file entries

    How can we determine the impact of each entry on a zip file’s size? It seems like a trivial problem, but things quickly don’t add up. There’s three built-in ways to read information about the contents of zip file in Java: Mount the zip as a FileSystem using FileSystems.newFileSystem and then access its contents using…

    Read More

  • R8 Optimization: Class Reflection and Forced Inlining

    Note: This post is part of a series on D8 and R8, Android’s new dexer and optimizer, respectively. For an intro to D8 read “Android’s Java 8 support”. For an intro to R8 read “R8 Optimization: Staticization”. The previous post on R8 covered method outlining which automatically de-duplicated code. This was actually a detour from…

    Read More

  • R8 Optimization: Enum Ordinals and Names

    Note: This post is part of a series on D8 and R8, Android’s new dexer and optimizer, respectively. For an intro to D8 read “Android’s Java 8 support”. For an intro to R8 read “R8 Optimization: Staticization”. Enums are (and have always been!) a recommended way to model a fixed set of constants. Most commonly…

    Read More

  • R8 Optimization: Value Assumption

    Note: This post is part of a series on D8 and R8, Android’s new dexer and optimizer, respectively. For an intro to D8 read “Android’s Java 8 support”. For an intro to R8 read “R8 Optimization: Staticization”. The previous post (part 1, part 2) featured R8 performing data-flow analysis of variables in order to determine…

    Read More

  • R8 Optimization: String Constant Operations

    Note: This post is part of a series on D8 and R8, Android’s new dexer and optimizer, respectively. For an intro to D8 read “Android’s Java 8 support”. For an intro to R8 read “R8 Optimization: Staticization”. The previous post in the series covered an R8 flag which allows you to specify the return value…

    Read More

  • R8 Optimization: Class Constant Operations

    Note: This post is part of a series on D8 and R8, Android’s new dexer and optimizer, respectively. For an intro to D8 read “Android’s Java 8 support”. For an intro to R8 read “R8 Optimization: Staticization”. The previous post in the series showed R8 (and D8) invoking string methods at compile-time when the inputs…

    Read More

  • The Economics of Generated Code

    Among the many things that I’ve stolen learned from Jesse Wilson is the phrase “the economics of generated code”. This captures the idea that the things we value when generating code are different than those we value for code that’s manually written. A code generator is only written once but the code it generates occurs…

    Read More

  • Optimizing Bytecode by Manipulating Source Code

    This post is a follow-up to “The Economics of Generated Code” which argued that spending time optimizing generated code is more worthwhile than the same optimizations done in manually-written code. The second example from that post dealt with looking up views, checking for null, and potentially throwing an exception. In an effort to reduce the…

    Read More