1

The Dalvik Virtual Machine (DVM) has a register-based architecture, as opposed to the Java Virtual Machine (JVM) which is stack-based. So I assume that the local variables of an Android app are stored in the registers. Am I correct? If not, please correct me. If yes, what kind of memory is used for the registers? Are the registers part of a CPU (Central Processing Unit) on the smart phone? Where are these registers located in the phone's hardware?

Monica Marcus
  • 187
  • 2
  • 10

1 Answers1

0

From https://source.android.com/devices/tech/dalvik/dalvik-bytecode.html:

Because, in practice, it is uncommon for a method to need more than 16 registers, and because needing more than eight registers is reasonably common, many instructions are limited to only addressing the first 16 registers. When reasonably possible, instructions allow references to up to the first 256 registers. In addition, some instructions have variants that allow for much larger register counts, including a pair of catch-all move instructions that can address registers in the range v0 – v65535. In cases where an instruction variant isn't available to address a desired register, it is expected that the register contents get moved from the original register to a low register (before the operation) and/or moved from a low result register to a high register (after the operation).

The registers are in the Dalvik VM--non-native Android code doesn't run directly on the CPU but in the VM. Native code, obviously, is very different.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • thank you very much for the link and for the explanation. I guess I have to ask my question differently, because I didn't find all I wanted to know. – Monica Marcus Jun 22 '15 at 17:43