Android 应用程序的局部变量存储在哪里?
Where are the local variables of an Android app stored?
Dalvik 虚拟机 (DVM) 具有基于寄存器的架构,与基于堆栈的 Java 虚拟机 (JVM) 不同。所以我假设 Android 应用程序的局部变量存储在寄存器中。我对么?如果不是,请纠正我。如果是,寄存器使用什么样的内存?寄存器是智能 phone 上 CPU(中央处理单元)的一部分吗?这些寄存器位于 phone 的硬件中的什么位置?
来自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).
寄存器在 Dalvik VM 中——非本机 Android 代码不直接在 CPU 上 运行,而是在 VM 中。显然,本机代码非常不同。
Dalvik 虚拟机 (DVM) 具有基于寄存器的架构,与基于堆栈的 Java 虚拟机 (JVM) 不同。所以我假设 Android 应用程序的局部变量存储在寄存器中。我对么?如果不是,请纠正我。如果是,寄存器使用什么样的内存?寄存器是智能 phone 上 CPU(中央处理单元)的一部分吗?这些寄存器位于 phone 的硬件中的什么位置?
来自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).
寄存器在 Dalvik VM 中——非本机 Android 代码不直接在 CPU 上 运行,而是在 VM 中。显然,本机代码非常不同。