JEE Study|JAVA EE|企业级开发学习网

标题: JVM:JAVA虚拟机中对pc的理解 [打印本页]

作者: JeeStudy    时间: 2016-8-21 18:15
标题: JVM:JAVA虚拟机中对pc的理解
在上一节中我们了解了从官方查看以及下载JAVA规范:JVM:java规范及虚拟机规范 官方查看及下载
这节我们看下关于JAVA规范中2.5.1节对pc的理解。

JAVA虚拟机(JVM)规范中的描述

2.5.1
The pc Register The Java Virtual Machine can support many threads of execution at once (JLS §17). Each Java Virtual Machine thread has its own pc (program counter) register. At any point, each Java Virtual Machine thread is executing the code of a single method, namely the current method (§2.6) for that thread. If that method is not native, the pc register contains the address of the Java Virtual Machine instruction currently being executed. If the method currently being executed by the thread is native, the value of the Java Virtual Machine's pc register is undefined. The Java Virtual Machine's pc register is wide enough to hold a returnAddress or a native pointer on the specific platform.


维基百科对PC的解释

The program counter (PC), commonly called the instruction pointer (IP) in Intel x86 and Itanium microprocessors, and sometimes called the instruction address register (IAR), the instruction counter, or just part of the instruction sequencer,is a processor register that indicates where a computer is in its program sequence.


In most processors, the PC is incremented after fetching an instruction, and holds the memory address of ("points to") the next instruction that would be executed. (In a processor where the incrementation precedes the fetch, the PC points to the current instruction being executed.)


Instructions are usually fetched sequentially from memory, but control transfer instructions change the sequence by placing a new value in the PC. These include branches (sometimes called jumps), subroutine calls, and returns. A transfer that is conditional on the truth of some assertion lets the computer follow a different sequence under different conditions.


A branch provides that the next instruction is fetched from somewhere else in memory. A subroutine call not only branches but saves the preceding contents of the PC somewhere. A return retrieves the saved contents of the PC and places it back in the PC, resuming sequential execution with the instruction following the subroutine call.




简单理解PC就是指令指针或指令地址寄存器,每一个指令取出后寄存器就自动增加一步(指针指向下一步)。





欢迎光临 JEE Study|JAVA EE|企业级开发学习网 (http://jeestudy.com/) Powered by Discuz! X3.2