午夜视频在线网站,日韩视频精品在线,中文字幕精品一区二区三区在线,在线播放精品,1024你懂我懂的旧版人,欧美日韩一级黄色片,一区二区三区在线观看视频

分享

JVM學習筆記

 臭小子的共享 2015-04-09

 

In addition to the local variables and operand stack, the Java stack frame includes data to support constant pool resolution, normal method return, and exception dispatch. This data is stored in the frame data portion of the Java stack frame.

除了局部變量區(qū)和操作數(shù)棧外,Java棧幀還需要一些數(shù)據(jù)來支持常量池解析、正常方法返回以及異常派發(fā)機制。這些信息都保存在Java棧幀的幀數(shù)據(jù)區(qū)中。

 

Many instructions in the Java Virtual Machine’s instruction set refer to entries in the constant pool. Some instructions merely push constant values of type int, long, float, double, or String from the constant pool onto the operand stack. Some instructions use constant pool entries to refer to classes or arrays to instantiate, fields to access, or methods to invoke. Other instructions determine whether a particular object is a descendant of a particular class or interface specified by a constant pool entry.

 

Java虛擬機中的大多數(shù)指令都涉及到常量池入口。有些指令僅僅是從常量池中取出數(shù)據(jù)然后壓入Java棧(這些數(shù)據(jù)的類型包括int,long、float、double和String);還有些指令使用常量池的數(shù)據(jù)來指示要實例化的類或數(shù)組,要訪問的字段,或要調(diào)用的方法;還有些指令需要常量池中的數(shù)據(jù)才能確定某個對象是否屬于某個類或?qū)崿F(xiàn)了某個接口。

 

 

Whenever the Java Virtual Machine encounters any of the instructions that refer to an entry in the constant pool, it uses the frame dataís pointer to the constant pool to access that information. As mentioned earlier, references to types, fields, and methods in the constant pool are initially symbolic. When the virtual machine looks up a constant pool entry that refers to a class, interface, field, or method, that reference may still be symbolic. If so, the virtual machine must resolve the reference at that time.

 

每當虛擬機要執(zhí)行某個需要用到常量池數(shù)據(jù)的指令時,它都會通過幀數(shù)據(jù)區(qū)中指向常量池的指針來訪問它。以前講過,常量池中對類型、字段和方法的引用在開始時都是符號。當虛擬機在常量池中搜索的時候,如果遇到指向類、接口、字段或者方法的入口,假若它們?nèi)匀皇欠?,虛擬機那時才會(也必須)進行解析。


 

 

Aside from constant pool resolution, the frame data must assist the virtual machine in processing a normal or abrupt method completion. If a method completes normally (by returning), the virtual machine must restore the stack frame of the invoking method. It must set the pc register to point to the instruction in the invoking method that follows the instruction that invoked the completing method. If the completing method returns a value, the virtual machine must push that value onto the operand stack of the invoking method.

 

 

除了用于常量池的解析外,幀數(shù)據(jù)區(qū)還要幫助虛擬機處理Java方法的正常結(jié)束或異常中止。如果是通過return正常結(jié)束,虛擬機必須恢復發(fā)起調(diào)用的方法的棧幀,包括設置PC寄存器指向發(fā)起調(diào)用的方法中的指令——即緊跟著調(diào)用了完成方法的指令的下一個指令。假如方法有返回值,虛擬機必須將它壓入到發(fā)起調(diào)用的方法的操作數(shù)棧。

 

The frame data must also contain some kind of reference to the method’s exception table, which the virtual machine uses to process any exceptions thrown during the course of execution of the method. An exception table, which is described in detail in Chapter 17, "Exceptions," defines ranges within the bytecodes of a method that are protected by catch clauses. Each entry in an exception table gives a starting and ending position of the range protected by a catch clause, an index into the constant pool that gives the exception class being caught, and a starting position of the catch clauseís code.

為了處理Java方法執(zhí)行期間的異常退出情況,幀數(shù)據(jù)區(qū)還必須保存一個對此方法異常表的引用。異常表定義了在這個方法的字節(jié)碼中受catch子句保護的范圍,異常表中的每一項都有一個被catch子句保護的代碼的起始和結(jié)束位置(譯者注:即try子句內(nèi)部的代碼),可能被catch的異常類在常量池中的索引值,以及catch子句內(nèi)的代碼開始的位置。

 

When a method throws an exception, the Java Virtual Machine uses the exception table referred to by the frame data to determine how to handle the exception. If the virtual machine finds a matching catch clause in the method’s exception table, it transfers control to the beginning of that catch clause. If the virtual machine doesnít find a matching catch clause, the method completes abnormally. The virtual machine uses the information in the frame data to restore the invoking methodís frame. It then rethrows the same exception in the context of the invoking method.

當某個方法拋出異常時,虛擬機根據(jù)幀數(shù)據(jù)區(qū)對應的異常表來決定如何處理。如果在異常表中找到了匹配的catch子句,就會把控制權轉(zhuǎn)交給catch子句內(nèi)的代碼。如果沒有發(fā)現(xiàn),方法會立即異常中止。然后虛擬機使用幀數(shù)據(jù)區(qū)的信息回復發(fā)起調(diào)用的方法的幀,然后在發(fā)起調(diào)用的方法的上下文中重新拋出同樣的異常。

 

In addition to data to support constant pool resolution, normal method return, and exception dispatch, the stack frame may also include other information that is implementation dependent, such as data to support debugging.

除了上述信息(支持常量池解析、正常方法返回和異常派發(fā)的數(shù)據(jù))外,虛擬機的實現(xiàn)者也可以將其他信息放入幀數(shù)據(jù)區(qū),如用于調(diào)試的數(shù)據(jù)等。

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多