Why is result type of arraylength bytecode declared as T_VOID in bytecodes.cpp?
Krystal Mok
rednaxelafx at gmail.com
Wed Aug 5 00:02:30 UTC 2015
Hi HotSpot team,
Digging through history again. Does anybody recall the reason for the
arraylength bytecode to be declared as having a result type of T_VOID in
bytecodes.cpp, e.g.
def(_arraylength , "arraylength" , "b" , NULL ,
T_VOID , 0, true );
...while the xaload family of bytecodes declare the result type as
appropriate, e.g.
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 );
Just curious if there's any peculiar history behind this difference.
This information can only be accessed through Bytecodes::result_type(code),
and it only used in 3 places: 2 of which are deoptimization related, and
the other is in C2's GraphKit::compute_stack_effects().
If Bytecodes::result_type(Bytecodes::_arraylength) returns T_INT, then the
special handling in C2's GraphKit::compute_stack_effects() wouldn't be
needed:
bool GraphKit::compute_stack_effects(int& inputs, int& depth) {
Bytecodes::Code code = java_bc();
if (code == Bytecodes::_wide) {
code = method()->java_code_at_bci(bci() + 1);
}
BasicType rtype = T_ILLEGAL;
int rsize = 0;
if (code != Bytecodes::_illegal) {
depth = Bytecodes::depth(code); // checkcast=0, athrow=-1
rtype = Bytecodes::result_type(code); // checkcast=P, athrow=V
if (rtype < T_CONFLICT)
rsize = type2size[rtype];
}
switch (code) {
// ...
case Bytecodes::_arraylength: inputs = 1; break; // special cased here
// ...
default:
// bytecode produces a typed result
inputs = rsize - depth; // but arraylength could be handled here if
rsize were correct
assert(inputs >= 0, "");
break;
}
return true;
}
Thanks,
Kris
More information about the hotspot-dev
mailing list