public AvailableExpression find(Instruction inst){
  Operator opr=inst.operator();
  Operand[] ops=null;
  LocationOperand location=null;
switch (inst.operator().format) {
case InstructionFormat.GetField_format:
    if (VM.VerifyAssertions)     VM._assert(doMemory);
  ops=new Operand[]{GetField.getRef(inst)};
location=GetField.getLocation(inst);
break;
case InstructionFormat.GetStatic_format:
if (VM.VerifyAssertions) VM._assert(doMemory);
location=GetStatic.getLocation(inst);
break;
case InstructionFormat.PutField_format:
if (VM.VerifyAssertions) VM._assert(doMemory);
ops=new Operand[]{PutField.getRef(inst)};
location=PutField.getLocation(inst);
break;
case InstructionFormat.PutStatic_format:
if (VM.VerifyAssertions) VM._assert(doMemory);
location=PutStatic.getLocation(inst);
break;
case InstructionFormat.Unary_format:
ops=new Operand[]{Unary.getVal(inst)};
break;
case InstructionFormat.GuardedUnary_format:
ops=new Operand[]{GuardedUnary.getVal(inst)};
break;
case InstructionFormat.Binary_format:
ops=new Operand[]{Binary.getVal1(inst),Binary.getVal2(inst)};
break;
case InstructionFormat.GuardedBinary_format:
ops=new Operand[]{GuardedBinary.getVal1(inst),GuardedBinary.getVal2(inst)};
break;
case InstructionFormat.Move_format:
ops=new Operand[]{Move.getVal(inst)};
break;
case InstructionFormat.NullCheck_format:
ops=new Operand[]{NullCheck.getRef(inst)};
break;
case InstructionFormat.ZeroCheck_format:
ops=new Operand[]{ZeroCheck.getValue(inst)};
break;
case InstructionFormat.BoundsCheck_format:
ops=new Operand[]{BoundsCheck.getRef(inst),BoundsCheck.getIndex(inst)};
break;
case InstructionFormat.TrapIf_format:
ops=new Operand[]{TrapIf.getVal1(inst),TrapIf.getVal2(inst),TrapIf.getTCode(inst)};
break;
case InstructionFormat.TypeCheck_format:
ops=new Operand[]{TypeCheck.getRef(inst),TypeCheck.getType(inst)};
break;
case InstructionFormat.InstanceOf_format:
ops=new Operand[]{InstanceOf.getRef(inst),InstanceOf.getType(inst)};
break;
case InstructionFormat.Call_format:
int numParams=Call.getNumberOfParams(inst);
ops=new Operand[numParams + 2];
ops[0]=Call.getAddress(inst);
ops[1]=Call.getMethod(inst);
for (int i=0; i < numParams; i++) {
ops[i + 2]=Call.getParam(inst,i);
}
break;
default :
throw new OptimizingCompilerException("Unsupported type " + inst);
}
AvailableExpression ae=new AvailableExpression(inst,opr,ops,location,null);
int index=cache.indexOf(ae);
if (index == -1) {
return null;
}
return cache.get(index);
}

public AvailableExpression find ( Instruction inst ) { Operator opr = inst . operator ( ) ; Operand [ ] ops = null ; LocationOperand location = null ; switch ( inst . operator ( ) . format ) { case InstructionFormat . GetField_format : if ( VM . VerifyAssertions ) VM . _assert ( doMemory ) ; ops = new Operand [ ] { GetField . getRef ( inst ) } ; location = GetField . getLocation ( inst ) ; break ; case InstructionFormat . GetStatic_format : if ( VM . VerifyAssertions ) VM . _assert ( doMemory ) ; location = GetStatic . getLocation ( inst ) ; break ; case InstructionFormat . PutField_format : if ( VM . VerifyAssertions ) VM . _assert ( doMemory ) ; ops = new Operand [ ] { PutField . getRef ( inst ) } ; location = PutField . getLocation ( inst ) ; break ; case InstructionFormat . PutStatic_format : if ( VM . VerifyAssertions ) VM . _assert ( doMemory ) ; location = PutStatic . getLocation ( inst ) ; break ; case InstructionFormat . Unary_format : ops = new Operand [ ] { Unary . getVal ( inst ) } ; break ; case InstructionFormat . GuardedUnary_format : ops = new Operand [ ] { GuardedUnary . getVal ( inst ) } ; break ; case InstructionFormat . Binary_format : ops = new Operand [ ] { Binary . getVal1 ( inst ) , Binary . getVal2 ( inst ) } ; break ; case InstructionFormat . GuardedBinary_format : ops = new Operand [ ] { GuardedBinary . getVal1 ( inst ) , GuardedBinary . getVal2 ( inst ) } ; break ; case InstructionFormat . Move_format : ops = new Operand [ ] { Move . getVal ( inst ) } ; break ; case InstructionFormat . NullCheck_format : ops = new Operand [ ] { NullCheck . getRef ( inst ) } ; break ; case InstructionFormat . ZeroCheck_format : ops = new Operand [ ] { ZeroCheck . getValue ( inst ) } ; break ; case InstructionFormat . BoundsCheck_format : ops = new Operand [ ] { BoundsCheck . getRef ( inst ) , BoundsCheck . getIndex ( inst ) } ; break ; case InstructionFormat . TrapIf_format : ops = new Operand [ ] { TrapIf . getVal1 ( inst ) , TrapIf . getVal2 ( inst ) , TrapIf . getTCode ( inst ) } ; break ; case InstructionFormat . TypeCheck_format : ops = new Operand [ ] { TypeCheck . getRef ( inst ) , TypeCheck . getType ( inst ) } ; break ; case InstructionFormat . InstanceOf_format : ops = new Operand [ ] { InstanceOf . getRef ( inst ) , InstanceOf . getType ( inst ) } ; break ; case InstructionFormat . Call_format : int numParams = Call . getNumberOfParams ( inst ) ; ops = new Operand [ numParams + 2 ] ; ops [ 0 ] = Call . getAddress ( inst ) ; ops [ 1 ] = Call . getMethod ( inst ) ; for ( int i = 0 ; i < numParams ; i ++ ) { ops [ i + 2 ] = Call . getParam ( inst , i ) ; } break ; default : throw new OptimizingCompilerException ( "Unsupported type " + inst ) ; } AvailableExpression ae = new AvailableExpression ( inst , opr , ops , location , null ) ; int index = cache . indexOf ( ae ) ; if ( index == - 1 ) { return null ; } return cache . get ( index ) ; }
find and return a matching available expression .
