What optimizations can I expect from Dalvik and the Android toolchain?

前端 未结 3 995
盖世英雄少女心
盖世英雄少女心 2020-11-28 03:09

I\'m working on a high-performance Android application (a game), and though I try to code for readability first, I like to keep in the back of my mind a picture of what is h

3条回答
  •  独厮守ぢ
    2020-11-28 03:47

    First, let me preface this by saying that I'm not an expert on dalvik, and some of my responses may be wrong. But I have dug into the JIT code in dalvik, and I'm quite familiar with the bytecode that dalvik runs.

    1. Method inlining - as far as I know, this never happens. I'm almost positive it never happens at the bytecode level, and I don't think it happens at the JIT level currently - although it might in the future.

    2. Common subexpression elimination - I believe this would only be done for subexpressions that don't use any non-final variables/fields. I'm not entirely positive if it would happen even then. If it is done, I would expect it to be done at the bytecode level, probably not the JIT level.

    3. Bounds checking on array lookups - no clue

    4. Value inlining - As far as I know, yes - they will be inlined in all of those scenarios.

    5. Branch prediction - not sure

    6. Simple arithmetic - not as far as I know

    Also, I'd like to mention another avenue of approach to you - dx and dalvik are both open source, so you can dig into them all you like. Although, they're obviously not small codebases, so would take a fair bit of effort to dig into them at that level

提交回复
热议问题