00001 package gov.nasa.arc.ase.jpf.jvm.bytecode;
00002
00003 import gov.nasa.arc.ase.jpf.*;
00004 import gov.nasa.arc.ase.jpf.jvm.*;
00005 import de.fub.bytecode.generic.ConstantPoolGen;
00006 import de.fub.bytecode.generic.Type;
00007 import de.fub.bytecode.generic.InstructionHandle;
00008 import gov.nasa.arc.ase.util.Debug;
00009
00010 public class INVOKEVIRTUAL extends AbstractInstruction {
00011 private de.fub.bytecode.generic.INVOKEVIRTUAL peer;
00012
00013 public boolean examine(SystemState ss, KernelState ks, ThreadInfo th) {
00014 ConstantPoolGen cpg = th.getCPG();
00015
00016 String methodName = peer.getMethodName(cpg);
00017 String sig = peer.getSignature(cpg);
00018 String classname = peer.getClassName(cpg);
00019
00020
00021
00022
00023 ClassInfo ci;
00024 int objref = th.getCalleeThis(peer.consumeStack(cpg));
00025 if(objref == -1)
00026 ci = JPFVM.getJPFVM().getClass(classname);
00027 else
00028 ci = ks.dynamic_area.getClass(objref);
00029 MethodInfo mi = ci.getMethodInfo(methodName+sig);
00030
00031 return !mi.getClassInfo().isMethodDeterministic(ss, ks, th, methodName+sig);
00032 }
00033 public InstructionHandle execute(SystemState ss, KernelState ks, ThreadInfo th) {
00034 ConstantPoolGen cpg = th.getCPG();
00035
00036 String methodName = peer.getMethodName(cpg);
00037 String sig = peer.getSignature(cpg);
00038 String classname = peer.getClassName(cpg);
00039
00040
00041
00042
00043 ClassInfo ci;
00044 int objref = th.getCalleeThis(peer.consumeStack(cpg));
00045 if(objref == -1)
00046 ci = JPFVM.getJPFVM().getClass(classname);
00047 else
00048 ci = ks.dynamic_area.getClass(objref);
00049 MethodInfo mi = ci.getMethodInfo(methodName+sig);
00050
00051 return mi.getClassInfo().executeMethod(ss, ks, th, methodName+sig);
00052 }
00053 public boolean isExecutable(SystemState ss, KernelState ks, ThreadInfo th) {
00054 ConstantPoolGen cpg = th.getCPG();
00055
00056 String methodName = peer.getMethodName(cpg);
00057 String sig = peer.getSignature(cpg);
00058 String classname = peer.getClassName(cpg);
00059
00060
00061
00062
00063 ClassInfo ci;
00064 int objref = th.getCalleeThis(peer.consumeStack(cpg));
00065 if(objref == -1)
00066 ci = JPFVM.getJPFVM().getClass(classname);
00067 else
00068 ci = ks.dynamic_area.getClass(objref);
00069 MethodInfo mi = ci.getMethodInfo(methodName+sig);
00070
00071 return mi.getClassInfo().isMethodExecutable(ss, ks, th, methodName+sig);
00072 }
00073 public void setPeer(de.fub.bytecode.generic.Instruction i) {
00074 peer = (de.fub.bytecode.generic.INVOKEVIRTUAL)i;
00075 }
00076 }