Java中的存根类与StubQueue类的用法

  介绍

本篇内容介绍了“Java中的存根类与StubQueue类的用法”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

<编辑类="目录">目录 <李>

1, InterpreterCodelet与存根类

<李>

2, StubQueue类

在文章开始前先简单介绍TemplateInterpreter::初始化()函数,在这个函数中会调用TemplateTable::初始化()函数初始化模板表,随后会使用新关键字初始化定义在AbstractInterpreter类中的_code静态属性,如下:

static  StubQueue *, _code;

由于TemplateInterpreter继承自AbstractInterpreter,所以在TemplateInterpreter中初始化的_code属性其实就是AbstractInterpreter类中定义的_code属性。

在初始化()函数中初始化_code变量的<>强代码如下:

//, InterpreterCodeSize是在平台相关//,的templateInterpreter_x86.hpp中//,定义的64位下是256,*,1024   int  code_size =, InterpreterCodeSize;   时间=_code  new  StubQueue (   ,,,,,,,,,,,,,,,new  InterpreterCodeletInterface,,   ,,,,,,,,,,,,,,,code_size,,   ,,,,,,,,,,,,,,,空,   ,,,,,,,,,,,,,,,“Interpreter");

StubQueue是用来保存生成的本地代码的存根队列,队列每一个元素对应一个<代码> InterpreterCodelet> InterpreterCodelet> 存根代码,<代码> InterpreterCodelet> CodeletMark>

1, InterpreterCodelet与存根类

<强>存根类的定义如下:

class  Stub  VALUE_OBJ_CLASS_SPEC  {,,,},

<强> InterpreterCodelet类继承自存根类强,具体的<>强定义如下:

class  InterpreterCodelet:, public  Stub  {   ,私人:   int 才能,,,,,,,,,,,,,,,,_size;,,,,,,,,,//,, size 字节拷贝   const 才能;char *,,,,,,,, _description;,,//, a  description  of 从而codelet,, for  debugging 及印刷   字节码::Code 才能,,,_bytecode;,,,,,//, associated  bytecode  if 任何   ,   ,公众://才能,Code 信息   address 才能;code_begin (), const , {   ,,,,return (地址)却;能够+,round_to (sizeof (InterpreterCodelet), CodeEntryAlignment);   ,,}   address 才能;code_end (), const  {   ,,,,return (地址)却;能够+,大小();   ,,}   ,   int 才能;大小(),const  {   ,,,,return  _size;   ,,}//,才能……   int 才能;code_size (), const  {,   ,,,,return  code_end(),安康;code_begin ();,,   ,,}//,才能……   };

<代码> InterpreterCodelet 实例存储在<代码> StubQueue> InterpreterCodelet 实例都代表一段机器指令(包含了字节码对应的机器指令片段以及一些调试和输出信息),如每个字节码都有一个<代码> InterpreterCodelet 实例,所以在解释执行时,如果要执行某个字节码,则执行的就是由<代码> InterpreterCodelet 实例代表的机器指令片段。

类中定义了3个属性及一些函数,其内存布局如下图所示。

, Java中的存根类与StubQueue类的用法

在对齐至CodeEntryAlignment后,紧接着InterpreterCodelet的就是生成的目标代码。

2, StubQueue类

StubQueue是用来保存生成的本地机器指令片段的存根队列,队列每一个元素都是一个InterpreterCodelet实例。

<强> StubQueue类的定义如下:

class  StubQueue:, public  CHeapObj, {   ,私人:   StubInterface *,才能_stub_interface;,,,,,//,, interface 原型   address 才能,,,,,,,,_stub_buffer;,,,,,,,,//, where  all  stubs 断开连接,存储   ,   int 才能,,,,,,,,,,,,_buffer_size;,,,,,,,//,, buffer  size 字节拷贝   int 才能,,,,,,,,,,,,_buffer_limit;,,,,,,//,,(字节),index  of 从而actual  buffer  limit  (_buffer_limit  & lt;=, _buffer_size)   ,   int 才能,,,,,,,,,,,,_queue_begin;,,,,,,,//,,(字节),index  of 从而first  queue  entry (字之间对齐)   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

Java中的存根类与StubQueue类的用法