use of org.jikesrvm.osr.OSRMapIterator in project JikesRVM by JikesRVM.
the class OptExecutionStateExtractor method getExecStateSequence.
private ExecutionState getExecStateSequence(RVMThread thread, byte[] stack, Offset ipOffset, Offset fpOffset, int cmid, Offset tsFPOffset, TempRegisters registers, EncodedOSRMap osrmap) {
// go through the stack frame and extract values
// In the variable value list, we keep the order as follows:
// L0, L1, ..., S0, S1, ....
/* go over osr map element, build list of VariableElement.
* assuming iterator has ordered element as
* L0, L1, ..., S0, S1, ...
*
* ThreadSwitch
* threadSwitchFromOsr
* FOO <-- fpOffset
*
* Also, all registers saved by threadSwitchFromDeopt method
* is restored in "registers", address for object is converted
* back to object references.
*
* This method should be called in non-GC critical section since
* it allocates many objects.
*/
// for 64-bit type values which have two int parts.
// this holds the high part.
int lvalue_one = 0;
int lvtype_one = 0;
// now recover execution states
OSRMapIterator iterator = osrmap.getOsrMapIteratorForMCOffset(ipOffset);
if (VM.VerifyAssertions)
VM._assert(iterator != null);
ExecutionState state = new ExecutionState(thread, fpOffset, cmid, iterator.getBcIndex(), tsFPOffset);
MethodReference mref = MemberReference.getMethodRef(iterator.getMethodId());
state.setMethod((NormalMethod) mref.peekResolvedMethod());
// this is not caller, but the callee, reverse it when outside
// of this function.
state.callerState = null;
if (VM.TraceOnStackReplacement) {
VM.sysWriteln("osr map table of " + state.meth.toString());
}
while (iterator.hasMore()) {
if (iterator.getMethodId() != state.meth.getId()) {
ExecutionState newstate = new ExecutionState(thread, fpOffset, cmid, iterator.getBcIndex(), tsFPOffset);
mref = MemberReference.getMethodRef(iterator.getMethodId());
newstate.setMethod((NormalMethod) mref.peekResolvedMethod());
// this is not caller, but the callee, reverse it when outside
// of this function.
newstate.callerState = state;
state = newstate;
if (VM.TraceOnStackReplacement) {
VM.sysWriteln("osr map table of " + state.meth.toString());
}
}
// create a VariableElement for it.
boolean kind = iterator.getKind();
char num = iterator.getNumber();
byte tcode = iterator.getTypeCode();
byte vtype = iterator.getValueType();
int value = iterator.getValue();
iterator.moveToNext();
if (VM.TraceOnStackReplacement) {
VM.sysWrite((kind == LOCAL) ? "L" : "S");
VM.sysWrite((int) num);
VM.sysWrite(" , ");
if (vtype == ICONST) {
VM.sysWrite("ICONST ");
VM.sysWrite(value);
} else if (vtype == PHYREG) {
VM.sysWrite("PHYREG ");
VM.sysWrite(GPR.lookup(value).toString());
} else if (vtype == SPILL) {
VM.sysWrite("SPILL ");
VM.sysWrite(value);
}
VM.sysWriteln();
}
switch(tcode) {
case INT:
{
int ibits = getIntBitsFrom(vtype, value, stack, fpOffset, registers);
state.add(new VariableElement(kind, num, tcode, ibits));
break;
}
case FLOAT:
{
float fv = (float) getDoubleFrom(vtype, value, stack, fpOffset, registers);
int ibits = Magic.floatAsIntBits(fv);
state.add(new VariableElement(kind, num, tcode, ibits));
break;
}
case HIGH_64BIT:
{
lvalue_one = value;
lvtype_one = vtype;
break;
}
case LONG:
{
long lbits = getLongBitsFrom(lvtype_one, lvalue_one, vtype, value, stack, fpOffset, registers);
lvalue_one = 0;
lvtype_one = 0;
state.add(new VariableElement(kind, num, LONG, lbits));
break;
}
case DOUBLE:
{
double dv = getDoubleFrom(vtype, value, stack, fpOffset, registers);
long lbits = Magic.doubleAsLongBits(dv);
state.add(new VariableElement(kind, num, tcode, lbits));
break;
}
// To be VERIFIED.
case RET_ADDR:
{
int bcIndex = getIntBitsFrom(vtype, value, stack, fpOffset, registers);
state.add(new VariableElement(kind, num, tcode, bcIndex));
break;
}
case WORD:
{
// KV:TODO
if (VM.BuildFor64Addr) {
if (VM.VerifyAssertions) {
VM._assert(VM.NOT_REACHED);
} else {
VM.sysFail("Case not yet implemented for 64-bit addresssing.");
}
}
int word = getIntBitsFrom(vtype, value, stack, fpOffset, registers);
state.add(new VariableElement(kind, num, tcode, word));
break;
}
case REF:
{
Object ref = getObjectFrom(vtype, value, stack, fpOffset, registers);
state.add(new VariableElement(kind, num, tcode, ref));
break;
}
default:
if (VM.VerifyAssertions)
VM._assert(VM.NOT_REACHED);
break;
}
// switch
}
return state;
}
use of org.jikesrvm.osr.OSRMapIterator in project JikesRVM by JikesRVM.
the class OptExecutionStateExtractor method getExecStateSequence.
private ExecutionState getExecStateSequence(RVMThread thread, byte[] stack, Offset ipOffset, Offset fpOffset, int cmid, Offset tsFPOffset, TempRegisters registers, EncodedOSRMap osrmap) {
// go through the stack frame and extract values
// In the variable value list, we keep the order as follows:
// L0, L1, ..., S0, S1, ....
/* go over osr map element, build list of VariableElement.
* assuming iterator has ordered element as
* L0, L1, ..., S0, S1, ...
*
* RVMThread.ThreadSwitch
* OptSaveVolatile.threadSwitchFromDeopt
* FOO <-- fpOffset
*
* Also, all registers saved by threadSwitchFromDeopt method
* is restored in "registers", address for object is converted
* back to object references.
*
* This method should be called in non-GC critical section since
* it allocates many objects.
*/
// for 64-bit type values which have two int parts.
// this holds the high part.
int lpart_one = 0;
// now recover execution states
OSRMapIterator iterator = osrmap.getOsrMapIteratorForMCOffset(ipOffset);
if (VM.VerifyAssertions)
VM._assert(iterator != null);
ExecutionState state = new ExecutionState(thread, fpOffset, cmid, iterator.getBcIndex(), tsFPOffset);
MethodReference mref = MemberReference.getMethodRef(iterator.getMethodId());
state.setMethod((NormalMethod) mref.peekResolvedMethod());
state.callerState = null;
while (iterator.hasMore()) {
if (iterator.getMethodId() != state.meth.getId()) {
ExecutionState newstate = new ExecutionState(thread, fpOffset, cmid, iterator.getBcIndex(), tsFPOffset);
mref = MemberReference.getMethodRef(iterator.getMethodId());
newstate.setMethod((NormalMethod) mref.peekResolvedMethod());
// this is not caller, but the callee, reverse it when outside
// of this function.
newstate.callerState = state;
state = newstate;
}
// create a VariableElement for it.
boolean kind = iterator.getKind();
int num = iterator.getNumber();
byte tcode = iterator.getTypeCode();
byte vtype = iterator.getValueType();
int value = iterator.getValue();
iterator.moveToNext();
switch(tcode) {
case INT:
{
int ibits = getIntBitsFrom(vtype, value, stack, fpOffset, registers);
state.add(new VariableElement(kind, num, tcode, ibits));
break;
}
case FLOAT:
{
float fv = (float) getDoubleFrom(vtype, value, stack, fpOffset, registers);
int ibits = Magic.floatAsIntBits(fv);
state.add(new VariableElement(kind, num, tcode, ibits));
break;
}
case HIGH_64BIT:
{
lpart_one = value;
break;
}
case LONG:
{
long lbits = getLongBitsFrom(vtype, lpart_one, value, stack, fpOffset, registers);
lpart_one = 0;
state.add(new // not use LONG2,
VariableElement(// not use LONG2,
kind, // not use LONG2,
num, // not use LONG2,
LONG, lbits));
break;
}
case DOUBLE:
{
double dv = getDoubleFrom(vtype, value, stack, fpOffset, registers);
long lbits = Magic.doubleAsLongBits(dv);
state.add(new VariableElement(kind, num, tcode, lbits));
break;
}
// To be VERIFIED.
case RET_ADDR:
{
int bcIndex = getIntBitsFrom(vtype, value, stack, fpOffset, registers);
state.add(new VariableElement(kind, num, tcode, bcIndex));
break;
}
case REF:
{
Object ref = getObjectFrom(vtype, value, stack, fpOffset, registers);
state.add(new VariableElement(kind, num, tcode, ref));
break;
}
case WORD:
{
if (VM.BuildFor32Addr) {
int word = getIntBitsFrom(vtype, value, stack, fpOffset, registers);
state.add(new VariableElement(kind, num, tcode, word));
} else {
long word = getLongBitsFrom(vtype, lpart_one, value, stack, fpOffset, registers);
lpart_one = 0;
state.add(new VariableElement(kind, num, tcode, word));
}
break;
}
default:
if (VM.VerifyAssertions)
VM._assert(VM.NOT_REACHED);
break;
}
// switch
}
return state;
}
Aggregations