Java Virtual Machine Specification(1)

Run-Time Data Areas


The Java Virtual Machine defines various run-time data areas that are used during execution of a program. Some of these data areas are created on Java Virtual machine start-up and are destroyed only when the Java Virtual Machine exits. Other data areas are per thread. Per-thread data areas are created when a thread is created and destroyed when the thread exits.

    JVM定义了各种运行时数据类型及区域。有些是与JVM生命周期相同,有些与线程生命周期相同。


 2.5.1 The pc Register

The Java Virtual Machine can support many threads of execution at once. Each Java Virtual Machine threads 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 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寄存器,由于指示当前运行地址。


2.5.2 Java Virtual Machine Stacks

Each Java Virtual Machine thread has a private Java Virtual Machine stack, created at the same time as the thread. A Java Virtual Machine stack stores frames. A Java Virtual Machine stack is analogous to the stack of a conventional language such as C: it holds local variable and partial result, and plays a part in method invocation and return. Because the Java Virtual Machine stack is never manipulated directly except to push and pop frames, frames may be heap allocated. The memory for a Java Virtual Machine stack not need to be contiguous.

JStack基本元素是frame,可以看出JStack维护着frame地址链表。那么什么是frame呢?后面会给出定义。

This specification permits Java Virtual Machine stacks either to be of a fixed size or to dynamically expand and contract as required by the computation. If the Java Virtual Machine stacks are of a fixed size, the size of each Java Virtual Machine stack may be chosen independently when that stack is created.

Jstack 大小可以fixed或者动态伸缩。如果fixed,每一个Jstack的size也可以不同。

The following exceptional conditions are associated with Java Virtual Machine stacks:

      • If the computation in a thread requires a larger Java Virtual Machine stack than is permitted, the Java Virtual Machine throws a stackOverflowError.
      • If Java Virtual Machine stacks can be dynamically expanded, and expansion is attempted but insufficient memory can be made available to effect the expansion, or if insufficient memory can be made available to create the initial Java Virtual Machine stack for a new thread, the Java Virtual Machine throws an outOfMemoryError.

2.5.3 Heap

The Java Virtual Machine has a heap that is shared among all Java Virtual Machine threads. The heap is the run-time data area from which memory for all class instances and array is allocated.

The heap is created on virtual machine start-up. Heap storage for objects is reclaimed by an automatic storage management system; objects are never wxplicitly deallocated. The java Virtual Machine assumes no particular type of automatic storage management system, and the storage management technique may be chosen according to the implementor's system requirements. The heap may be of a fixed size or may be expanded as rquired by the computation and may be contracted if a larger heap becomes unnecessary. The memory for the heap does not need to be contiguous.
比较常见的堆的定义。堆在物理内存上不必连续。
  The following exceptional condition is associated with the heap:
If a computation requires more heap than can be made available by the automatic storage management system, the Java Virtual Machine throws an OutOfMemoryError.

2.5.4 Method Area
The Java Virtual Machine has a method area that is shared among all Java Virtual Machine threads. The method area is analogous to the storage area for compiled code of a conventional language or analogous to the "text" segment in an operating system process. It stores per-class structures such as the run-time constant pool,field and method data, and the code for methods and constructors, including the special methods used in class and instance initialization and interface initialization.
JVM有一块区域是所有线程都可共享的,即method area。类似于传统语言存放编译代码的地方,也类似于操作系统中的“text”段。MA存放每个类的相关结构数据,例如常量池,字段,方法属性和code in methods(包含类的初始化方法和实例的初始化方法)
The Method area is created on virtual machine start-up. Although the method area is logically part of the heap, simple implementation may choose not to either garbage collect or compact it.  This version of the Java Virtual specification does not manadate the location of the method area or the policies used to manage compiled code. The method area may be of a fixed size or may be expanded as required by the computation and may be contracted if a larger method area becomes unnecesary. The memory for the method area does not need to be contiguous.
ME在JVM启动之初创立。尽管ME逻辑上是堆的一部分,一般的实现不会去压缩或回收它。

2.5.5 Run-Time Constant Pool
A run-time constant pool is per-class or per-interface run-time representation of the constant_pool table in a class file. It contains serveral kinds of constants, ranging from numeric literals known at compile-time to method and field references that must be resolved at run-time. The run-time constant pool serves a function similar to that of a symbol table for a conventional programming language, although it contains a wider range of data than a typical symbol table.
run-time常量池是类文件中的常量池定义的动态表现,包含从编译时的数字常量到runtime才能确定的字段引用等。
Each run-time constant pool is allocated from the Java Virtual Machine's method area. The run-time constant pool for a class or interface is constructed when the class or interface is created by the Java Virtual Machine.
运行时常量池坐落在ME中,在JVM在load类或接口时创建。

先写这些吧!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值