这个函数的入口是bytecodes_init()函数。
在讲解字节码指令定义前,先了解下def各参数的含义:
接下来我们讲一下format参数,有点汇编基础的都了解,一条指令是由操作码和操作数组成的,操作码可以想像成我们这里的bytecode这一列,操作数就是操作码要操作的数值,比如加1减1中的这个1就是操作数,format这个参数就表示字节码指令的格式,当这一列字符串中有一个字符时就表示该指令长度就是一个字节,当为2个字符时就表示指令长度为2个字节,依此类推。比如_iconst_0指令就占一个字节宽度,_store的format值是"bi",表示占2个字节。format也可能是空字符,为空时,表示当前的字节码指令不是Java虚拟机规范中定义的,_fast_agetfield、_fast_bgetfield这两个指令的format就是空字符,这一类字节码都是虚拟机内部定义的。另外,format还能表示字节码的格式,字符串中各个字符的含义如下:
以上这些描述,大家知道大概意思就行,无需深入研究。
// 字节码指令定义的函数
void Bytecodes::def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap, Code java_code) {
assert(wide_format == NULL || format != NULL, "short form must exist if there's a wide form");
// 得出format字符占的长度
int len = (format != NULL ? (int) strlen(format) : 0);
// 得出format字符占的长度
int wlen = (wide_format != NULL ? (int) strlen(wide_format) : 0);
// _name/_result_type/_depth/_lengths/_java_code 这些都是数组,这里的意思就是把字节码指令的相关属性都按字节数组存储起来,数组的index都是对应的字节码code
_name [code] = name;
_result_type [code] = result_type;
_depth [code] = depth;
// 这里用1个字节存放了format(低4位)和wide_format(高4位)
_lengths [code] = (wlen << 4) | (len & 0xF);
_java_code [code] = java_code;
int bc_flags = 0;
// bc_flags 用低2位分别表示can_trap和can_rewrite
if (can_trap) bc_flags |= _bc_can_trap;
if (java_code != code) bc_flags |= _bc_can_rewrite;
// 将bc_flags、format和wide_format通过位运算操作都整到一个整型值中,并存储到_flags数组中,用的时候再按位拆解出来
_flags[(u1)code+0*(1<<BitsPerByte)] = compute_flags(format, bc_flags);
_flags[(u1)code+1*(1<<BitsPerByte)] = compute_flags(wide_format, bc_flags);
assert(is_defined(code) == (format != NULL), "");
assert(wide_is_defined(code) == (wide_format != NULL), "");
assert(length_for(code) == len, "");
assert(wide_length_for(code) == wlen, "");
}
/*
* 总结一下字节码定义函数def做的事情:就是将所有字节码的信息按着字节码指令操作码(bytecode)
* 归整到对应的索引值的数组中,方便使用时,直接按bytecode索引值取出来就行
*/
void Bytecodes::initialize() {
if (_is_initialized) return; // 重复初始化判断
// 字节码指令个数不能大于256,Java字节码指令都是精简指令,用一个字节表示,所以最多256个
assert(number_of_codes <= 256, "too many bytecodes");
// Java bytecodes 下面都是Java规范中定义的字节码
// bytecode bytecode name format wide f. result tp stk traps
def(_nop , "nop" , "b" , NULL , T_VOID , 0, false);
def(_aconst_null , "aconst_null" , "b" , NULL , T_OBJECT , 1, false);
def(_iconst_m1 , "iconst_m1" , "b" , NULL , T_INT , 1, false);
def(_iconst_0 , "iconst_0" , "b" , NULL , T_INT , 1, false);
def(_iconst_1 , "iconst_1" , "b" , NULL , T_INT , 1, false);
def(_iconst_2 , "iconst_2" , "b" , NULL , T_INT , 1, false);
def(_iconst_3 , "iconst_3" , "b" , NULL , T_INT , 1, false);
def(_iconst_4 , "iconst_4" , "b" , NULL , T_INT , 1, false);
def(_iconst_5 , "iconst_5" , "b" , NULL , T_INT , 1, false);
def(_lconst_0 , "lconst_0" , "b" , NULL , T_LONG , 2, false);
def(_lconst_1 , "lconst_1" , "b" , NULL , T_LONG , 2, false);
def(_fconst_0 , "fconst_0" , "b" , NULL , T_FLOAT , 1, false);
def(_fconst_1 , "fconst_1" , "b" , NULL , T_FLOAT , 1, false);
def(_fconst_2 , "fconst_2" , "b" , NULL , T_FLOAT , 1, false);
def(_dconst_0 , "dconst_0" , "b" , NULL , T_DOUBLE , 2, false);
def(_dconst_1 , "dconst_1" , "b" , NULL , T_DOUBLE , 2, false);
def(_bipush , "bipush" , "bc" , NULL , T_INT , 1, false);
def(_sipush , "sipush" , "bcc" , NULL , T_INT , 1, false);
def(_ldc , "ldc" , "bk" , NULL , T_ILLEGAL, 1, true );
def(_ldc_w , "ldc_w" , "bkk" , NULL , T_ILLEGAL, 1, true );
def(_ldc2_w , "ldc2_w" , "bkk" , NULL , T_ILLEGAL, 2, true );
def(_iload , "iload" , "bi" , "wbii" , T_INT , 1, false);
def(_lload , "lload" , "bi" , "wbii" , T_LONG , 2, false);
def(_fload , "fload" , "bi" , "wbii" , T_FLOAT , 1, false);
def(_dload , "dload" , "bi" , "wbii" , T_DOUBLE , 2, false);
def(_aload , "aload" , "bi" , "wbii" , T_OBJECT , 1, false);
def(_iload_0 , "iload_0" , "b" , NULL , T_INT , 1, false);
def(_iload_1 , "iload_1" , "b" , NULL , T_INT , 1, false);
def(_iload_2 , "iload_2" , "b" , NULL , T_INT , 1, false);
def(_iload_3 , "iload_3" , "b" , NULL , T_INT , 1, false);
def(_lload_0 , "lload_0" , "b" , NULL , T_LONG , 2, false);
def(_lload_1 , "lload_1" , "b" , NULL , T_LONG , 2, false);
def(_lload_2 , "lload_2" , "b" , NULL , T_LONG , 2, false);
def(_lload_3 , "lload_3" , "b" , NULL , T_LONG , 2, false);
def(_fload_0 , "fload_0" , "b" , NULL , T_FLOAT , 1, false);
def(_fload_1 , "fload_1" , "b" , NULL , T_FLOAT , 1, false);
def(_fload_2 , "fload_2" , "b" , NULL , T_FLOAT , 1, false);
def(_fload_3 , "fload_3" , "b" , NULL , T_FLOAT , 1, false);
def(_dload_0 , "dload_0" , "b" , NULL , T_DOUBLE , 2, false);
def(_dload_1 , "dload_1" , "b" , NULL , T_DOUBLE , 2, false);
def(_dload_2 , "dload_2" , "b" , NULL , T_DOUBLE , 2, false);
def(_dload_3 , "dload_3" , "b" , NULL , T_DOUBLE , 2, false);
def(_aload_0 , "aload_0" , "b" , NULL , T_OBJECT , 1, true ); // rewriting in interpreter
def(_aload_1 , "aload_1" , "b" , NULL , T_OBJECT , 1, false);
def(_aload_2 , "aload_2" , "b" , NULL , T_OBJECT , 1, false);
def(_aload_3 , "aload_3" , "b" , NULL , T_OBJECT , 1, false);
def(_iaload , "iaload" , "b" , NULL , T_INT , -1, true );
def(_laload , "laload" , "b" , NULL , T_LONG , 0, true );
def(_faload , "faload" , "b" , NULL , T_FLOAT , -1, true );
def(_daload , "daload" , "b" , NULL , T_DOUBLE , 0, true );
def(_aaload , "aaload" , "b" , NULL , T_OBJECT , -1, true );
def(_baload , "baload" , "b" , NULL , T_INT , -1, true );
def(_caload , "caload" , "b" , NULL , T_INT , -1, true );
def(_saload , "saload" , "b" , NULL , T_INT , -1, true );
def(_istore , "istore" , "bi" , "wbii" , T_VOID , -1, false);
def(_lstore , "lstore" , "bi" , "wbii" , T_VOID , -2, false);
def(_fstore , "fstore" , "bi" , "wbii" , T_VOID , -1, false);
def(_dstore , "dstore" , "bi" , "wbii" , T_VOID , -2, false);
def(_astore , "astore" , "bi" , "wbii" , T_VOID , -1, false);
def(_istore_0 , "istore_0" , "b" , NULL , T_VOID , -1, false);
def(_istore_1 , "istore_1" , "b" , NULL , T_VOID , -1, false);
def(_istore_2 , "istore_2" , "b" , NULL , T_VOID , -1, false);
def(_istore_3 , "istore_3" , "b" , NULL , T_VOID , -1, false);
def(_lstore_0 , "lstore_0" , "b" , NULL , T_VOID , -2, false);
def(_lstore_1 , "lstore_1" , "b" , NULL , T_VOID , -2, false);
def(_lstore_2 , "lstore_2" , "b" , NULL , T_VOID , -2, false);
def(_lstore_3 , "lstore_3" , "b" , NULL , T_VOID , -2, false);
def(_fstore_0 , "fstore_0" , "b" , NULL , T_VOID , -1, false);
def(_fstore_1 , "fstore_1" , "b" , NULL , T_VOID , -1, false);
def(_fstore_2 , "fstore_2" , "b" , NULL , T_VOID , -1, false);
def(_fstore_3 , "fstore_3" , "b" , NULL , T_VOID , -1, false);
def(_dstore_0 , "dstore_0" , "b" , NULL , T_VOID , -2, false);
def(_dstore_1 , "dstore_1" , "b" , NULL , T_VOID , -2, false);
def(_dstore_2 , "dstore_2" , "b" , NULL , T_VOID , -2, false);
def(_dstore_3 , "dstore_3" , "b" , NULL , T_VOID , -2, false);
def(_astore_0 , "astore_0" , "b" , NULL , T_VOID , -1, false);
def(_astore_1 , "astore_1" , "b" , NULL , T_VOID , -1, false);
def(_astore_2 , "astore_2" , "b" , NULL , T_VOID , -1, false);
def(_astore_3 , "astore_3" , "b" , NULL , T_VOID , -1, false);
def(_iastore , "iastore" , "b" , NULL , T_VOID , -3, true );
def(_lastore , "lastore" , "b" , NULL , T_VOID , -4, true );
def(_fastore , "fastore" , "b" , NULL , T_VOID , -3, true );
def(_dastore , "dastore" , "b" , NULL , T_VOID , -4, true );
def(_aastore , "aastore" , "b" , NULL , T_VOID , -3, true );
def(_bastore , "bastore" , "b" , NULL , T_VOID , -3, true );
def(_castore , "castore" , "b" , NULL , T_VOID , -3, true );
def(_sastore , "sastore" , "b" , NULL , T_VOID , -3, true );
def(_pop , "pop" , "b" , NULL , T_VOID , -1, false);
def(_pop2 , "pop2" , "b" , NULL , T_VOID , -2, false);
def(_dup , "dup" , "b" , NULL , T_VOID , 1, false);
def(_dup_x1 , "dup_x1" , "b" , NULL , T_VOID , 1, false);
def(_dup_x2 , "dup_x2" , "b" , NULL , T_VOID , 1, false);
def(_dup2 , "dup2" , "b" , NULL , T_VOID , 2, false);
def(_dup2_x1 , "dup2_x1" , "b" , NULL , T_VOID , 2, false);
def(_dup2_x2 , "dup2_x2" , "b" , NULL , T_VOID , 2, false);
def(_swap , "swap" , "b" , NULL , T_VOID , 0, false);
def(_iadd , "iadd" , "b" , NULL , T_INT , -1, false);
def(_ladd , "ladd" , "b" , NULL , T_LONG , -2, false);
def(_fadd , "fadd" , "b" , NULL , T_FLOAT , -1, false);
def(_dadd , "dadd" , "b" , NULL , T_DOUBLE , -2, false);
def(_isub , "isub" , "b" , NULL , T_INT , -1, false);
def(_lsub , "lsub" , "b" , NULL , T_LONG , -2, false);
def(_fsub , "fsub" , "b" , NULL , T_FLOAT , -1, false);
def(_dsub , "dsub" , "b" , NULL , T_DOUBLE , -2, false);
def(_imul , "imul" , "b" , NULL , T_INT , -1, false);
def(_lmul , "lmul" , "b" , NULL , T_LONG , -2, false);
def(_fmul , "fmul" , "b" , NULL , T_FLOAT , -1, false);
def(_dmul , "dmul" , "b" , NULL , T_DOUBLE , -2, false);
def(_idiv , "idiv" , "b" , NULL , T_INT , -1, true );
def(_ldiv , "ldiv" , "b" , NULL , T_LONG , -2, true );
def(_fdiv , "fdiv" , "b" , NULL , T_FLOAT , -1, false);
def(_ddiv , "ddiv" , "b" , NULL , T_DOUBLE , -2, false);
def(_irem , "irem" , "b" , NULL , T_INT , -1, true );
def(_lrem , "lrem" , "b" , NULL , T_LONG , -2, true );
def(_frem , "frem" , "b" , NULL , T_FLOAT , -1, false);
def(_drem , "drem" , "b" , NULL , T_DOUBLE , -2, false);
def(_ineg , "ineg" , "b" , NULL , T_INT , 0, false);
def(_lneg , "lneg" , "b" , NULL , T_LONG , 0, false);
def(_fneg , "fneg" , "b" , NULL , T_FLOAT , 0, false);
def(_dneg , "dneg" , "b" , NULL , T_DOUBLE , 0, false);
def(_ishl , "ishl" , "b" , NULL , T_INT , -1, false);
def(_lshl , "lshl" , "b" , NULL , T_LONG , -1, false);
def(_ishr , "ishr" , "b" , NULL , T_INT , -1, false);
def(_lshr , "lshr" , "b" , NULL , T_LONG , -1, false);
def(_iushr , "iushr" , "b" , NULL , T_INT , -1, false);
def(_lushr , "lushr" , "b" , NULL , T_LONG , -1, false);
def(_iand , "iand" , "b" , NULL , T_INT , -1, false);
def(_land , "land" , "b" , NULL , T_LONG , -2, false);
def(_ior , "ior" , "b" , NULL , T_INT , -1, false);
def(_lor , "lor" , "b" , NULL , T_LONG , -2, false);
def(_ixor , "ixor" , "b" , NULL , T_INT , -1, false);
def(_lxor , "lxor" , "b" , NULL , T_LONG , -2, false);
def(_iinc , "iinc" , "bic" , "wbiicc", T_VOID , 0, false);
def(_i2l , "i2l" , "b" , NULL , T_LONG , 1, false);
def(_i2f , "i2f" , "b" , NULL , T_FLOAT , 0, false);
def(_i2d , "i2d" , "b" , NULL , T_DOUBLE , 1, false);
def(_l2i , "l2i" , "b" , NULL , T_INT , -1, false);
def(_l2f , "l2f" , "b" , NULL , T_FLOAT , -1, false);
def(_l2d , "l2d" , "b" , NULL , T_DOUBLE , 0, false);
def(_f2i , "f2i" , "b" , NULL , T_INT , 0, false);
def(_f2l , "f2l" , "b" , NULL , T_LONG , 1, false);
def(_f2d , "f2d" , "b" , NULL , T_DOUBLE , 1, false);
def(_d2i , "d2i" , "b" , NULL , T_INT , -1, false);
def(_d2l , "d2l" , "b" , NULL , T_LONG , 0, false);
def(_d2f , "d2f" , "b" , NULL , T_FLOAT , -1, false);
def(_i2b , "i2b" , "b" , NULL , T_BYTE , 0, false);
def(_i2c , "i2c" , "b" , NULL , T_CHAR , 0, false);
def(_i2s , "i2s" , "b" , NULL , T_SHORT , 0, false);
def(_lcmp , "lcmp" , "b" , NULL , T_VOID , -3, false);
def(_fcmpl , "fcmpl" , "b" , NULL , T_VOID , -1, false);
def(_fcmpg , "fcmpg" , "b" , NULL , T_VOID , -1, false);
def(_dcmpl , "dcmpl" , "b" , NULL , T_VOID , -3, false);
def(_dcmpg , "dcmpg" , "b" , NULL , T_VOID , -3, false);
def(_ifeq , "ifeq" , "boo" , NULL , T_VOID , -1, false);
def(_ifne , "ifne" , "boo" , NULL , T_VOID , -1, false);
def(_iflt , "iflt" , "boo" , NULL , T_VOID , -1, false);
def(_ifge , "ifge" , "boo" , NULL , T_VOID , -1, false);
def(_ifgt , "ifgt" , "boo" , NULL , T_VOID , -1, false);
def(_ifle , "ifle" , "boo" , NULL , T_VOID , -1, false);
def(_if_icmpeq , "if_icmpeq" , "boo" , NULL , T_VOID , -2, false);
def(_if_icmpne , "if_icmpne" , "boo" , NULL , T_VOID , -2, false);
def(_if_icmplt , "if_icmplt" , "boo" , NULL , T_VOID , -2, false);
def(_if_icmpge , "if_icmpge" , "boo" , NULL , T_VOID , -2, false);
def(_if_icmpgt , "if_icmpgt" , "boo" , NULL , T_VOID , -2, false);
def(_if_icmple , "if_icmple" , "boo" , NULL , T_VOID , -2, false);
def(_if_acmpeq , "if_acmpeq" , "boo" , NULL , T_VOID , -2, false);
def(_if_acmpne , "if_acmpne" , "boo" , NULL , T_VOID , -2, false);
def(_goto , "goto" , "boo" , NULL , T_VOID , 0, false);
def(_jsr , "jsr" , "boo" , NULL , T_INT , 0, false);
def(_ret , "ret" , "bi" , "wbii" , T_VOID , 0, false);
def(_tableswitch , "tableswitch" , "" , NULL , T_VOID , -1, false); // may have backward branches
def(_lookupswitch , "lookupswitch" , "" , NULL , T_VOID , -1, false); // rewriting in interpreter
def(_ireturn , "ireturn" , "b" , NULL , T_INT , -1, true);
def(_lreturn , "lreturn" , "b" , NULL , T_LONG , -2, true);
def(_freturn , "freturn" , "b" , NULL , T_FLOAT , -1, true);
def(_dreturn , "dreturn" , "b" , NULL , T_DOUBLE , -2, true);
def(_areturn , "areturn" , "b" , NULL , T_OBJECT , -1, true);
def(_return , "return" , "b" , NULL , T_VOID , 0, true);
def(_getstatic , "getstatic" , "bJJ" , NULL , T_ILLEGAL, 1, true );
def(_putstatic , "putstatic" , "bJJ" , NULL , T_ILLEGAL, -1, true );
def(_getfield , "getfield" , "bJJ" , NULL , T_ILLEGAL, 0, true );
def(_putfield , "putfield" , "bJJ" , NULL , T_ILLEGAL, -2, true );
def(_invokevirtual , "invokevirtual" , "bJJ" , NULL , T_ILLEGAL, -1, true);
def(_invokespecial , "invokespecial" , "bJJ" , NULL , T_ILLEGAL, -1, true);
def(_invokestatic , "invokestatic" , "bJJ" , NULL , T_ILLEGAL, 0, true);
def(_invokeinterface , "invokeinterface" , "bJJ__", NULL , T_ILLEGAL, -1, true);
def(_invokedynamic , "invokedynamic" , "bJJJJ", NULL , T_ILLEGAL, 0, true );
def(_new , "new" , "bkk" , NULL , T_OBJECT , 1, true );
def(_newarray , "newarray" , "bc" , NULL , T_OBJECT , 0, true );
def(_anewarray , "anewarray" , "bkk" , NULL , T_OBJECT , 0, true );
def(_arraylength , "arraylength" , "b" , NULL , T_VOID , 0, true );
def(_athrow , "athrow" , "b" , NULL , T_VOID , -1, true );
def(_checkcast , "checkcast" , "bkk" , NULL , T_OBJECT , 0, true );
def(_instanceof , "instanceof" , "bkk" , NULL , T_INT , 0, true );
def(_monitorenter , "monitorenter" , "b" , NULL , T_VOID , -1, true );
def(_monitorexit , "monitorexit" , "b" , NULL , T_VOID , -1, true );
def(_wide , "wide" , "" , NULL , T_VOID , 0, false);
def(_multianewarray , "multianewarray" , "bkkc" , NULL , T_OBJECT , 1, true );
def(_ifnull , "ifnull" , "boo" , NULL , T_VOID , -1, false);
def(_ifnonnull , "ifnonnull" , "boo" , NULL , T_VOID , -1, false);
def(_goto_w , "goto_w" , "boooo", NULL , T_VOID , 0, false);
def(_jsr_w , "jsr_w" , "boooo", NULL , T_INT , 0, false);
def(_breakpoint , "breakpoint" , "" , NULL , T_VOID , 0, true);
// JVM bytecodes 下面这些都是JVM扩展定义的字节码
// bytecode bytecode name format wide f. result tp stk traps std code
def(_fast_agetfield , "fast_agetfield" , "bJJ" , NULL , T_OBJECT , 0, true , _getfield );
def(_fast_bgetfield , "fast_bgetfield" , "bJJ" , NULL , T_INT , 0, true , _getfield );
def(_fast_cgetfield , "fast_cgetfield" , "bJJ" , NULL , T_CHAR , 0, true , _getfield );
def(_fast_dgetfield , "fast_dgetfield" , "bJJ" , NULL , T_DOUBLE , 0, true , _getfield );
def(_fast_fgetfield , "fast_fgetfield" , "bJJ" , NULL , T_FLOAT , 0, true , _getfield );
def(_fast_igetfield , "fast_igetfield" , "bJJ" , NULL , T_INT , 0, true , _getfield );
def(_fast_lgetfield , "fast_lgetfield" , "bJJ" , NULL , T_LONG , 0, true , _getfield );
def(_fast_sgetfield , "fast_sgetfield" , "bJJ" , NULL , T_SHORT , 0, true , _getfield );
def(_fast_aputfield , "fast_aputfield" , "bJJ" , NULL , T_OBJECT , 0, true , _putfield );
def(_fast_bputfield , "fast_bputfield" , "bJJ" , NULL , T_INT , 0, true , _putfield );
def(_fast_zputfield , "fast_zputfield" , "bJJ" , NULL , T_INT , 0, true , _putfield );
def(_fast_cputfield , "fast_cputfield" , "bJJ" , NULL , T_CHAR , 0, true , _putfield );
def(_fast_dputfield , "fast_dputfield" , "bJJ" , NULL , T_DOUBLE , 0, true , _putfield );
def(_fast_fputfield , "fast_fputfield" , "bJJ" , NULL , T_FLOAT , 0, true , _putfield );
def(_fast_iputfield , "fast_iputfield" , "bJJ" , NULL , T_INT , 0, true , _putfield );
def(_fast_lputfield , "fast_lputfield" , "bJJ" , NULL , T_LONG , 0, true , _putfield );
def(_fast_sputfield , "fast_sputfield" , "bJJ" , NULL , T_SHORT , 0, true , _putfield );
def(_fast_aload_0 , "fast_aload_0" , "b" , NULL , T_OBJECT , 1, true , _aload_0 );
def(_fast_iaccess_0 , "fast_iaccess_0" , "b_JJ" , NULL , T_INT , 1, true , _aload_0 );
def(_fast_aaccess_0 , "fast_aaccess_0" , "b_JJ" , NULL , T_OBJECT , 1, true , _aload_0 );
def(_fast_faccess_0 , "fast_faccess_0" , "b_JJ" , NULL , T_OBJECT , 1, true , _aload_0 );
def(_fast_iload , "fast_iload" , "bi" , NULL , T_INT , 1, false, _iload);
def(_fast_iload2 , "fast_iload2" , "bi_i" , NULL , T_INT , 2, false, _iload);
def(_fast_icaload , "fast_icaload" , "bi_" , NULL , T_INT , 0, false, _iload);
// Faster method invocation.
def(_fast_invokevfinal , "fast_invokevfinal" , "bJJ" , NULL , T_ILLEGAL, -1, true, _invokevirtual );
def(_fast_linearswitch , "fast_linearswitch" , "" , NULL , T_VOID , -1, false, _lookupswitch );
def(_fast_binaryswitch , "fast_binaryswitch" , "" , NULL , T_VOID , -1, false, _lookupswitch );
def(_return_register_finalizer , "return_register_finalizer" , "b" , NULL , T_VOID , 0, true, _return);
def(_invokehandle , "invokehandle" , "bJJ" , NULL , T_ILLEGAL, -1, true, _invokevirtual );
def(_fast_aldc , "fast_aldc" , "bj" , NULL , T_OBJECT, 1, true, _ldc );
def(_fast_aldc_w , "fast_aldc_w" , "bJJ" , NULL , T_OBJECT, 1, true, _ldc_w );
def(_shouldnotreachhere , "_shouldnotreachhere" , "b" , NULL , T_VOID , 0, false);
// platform specific JVM bytecodes
// 针对JVM字节码的平台特性操作,默认这个函数未做实现
pd_initialize();
// compare can_trap information for each bytecode with the
// can_trap information for the corresponding base bytecode
// (if a rewritten bytecode can trap, so must the base bytecode)
#ifdef ASSERT
{ for (int i = 0; i < number_of_codes; i++) {
// 遍历检查定义后的字节码
if (is_defined(i)) { // 判断是不是都定义了
Code code = cast(i); // 类型转成枚举Code
Code java = java_code(code);
// 通过前面的def定义函数可以了解到,这里的code和java是同一个东西,如果不同,那就是错误
if (can_trap(code) && !can_trap(java))
// 打印出错信息的文件和代码行数
fatal(err_msg("%s can trap => %s can trap, too", name(code),
name(java)));
}
}
}
#endif
// 标记初始化成功,防止重复初始化
_is_initialized = true;
}