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.Constants;
00006 import de.fub.bytecode.generic.ConstantPoolGen;
00007 import de.fub.bytecode.generic.InstructionHandle;
00008 import gov.nasa.arc.ase.util.Debug;
00009
00010 import gov.nasa.arc.ase.jpf.jvm.runtime.*;
00011
00012
00013 public class PUTSTATIC extends AbstractInstruction {
00014 private de.fub.bytecode.generic.PUTSTATIC peer;
00015
00016
00017
00018 private void ANALYZE_execute(ThreadInfo th, StaticArea sa,
00019 ConstantPoolGen cpg, long value){
00020 if (Analyze.on()){
00021 String className = peer.getClassName(cpg);
00022 String fieldName = peer.getFieldName(cpg);
00023 ClassRef classref = new ClassRef(StaticMap.getEntry(className));
00024 LockStatus lock_status = sa.getLockStatus(className, fieldName);
00025 Analyze.debugPreAccess(th, className, fieldName, classref, "PUTSTATIC", value, lock_status);
00026 lock_status.checkWrite(th, className, fieldName);
00027 Analyze.debugPostAccess(lock_status);
00028 }
00029 }
00030 private void DEPEND_execute(ThreadInfo th, ConstantPoolGen cpg){
00031 if (Depend.on()){
00032 String className = peer.getClassName(cpg);
00033 ClassRef classref = new ClassRef(StaticMap.getEntry(className));
00034 Depend.addWrite(th, classref);
00035 }
00036 }
00037 public InstructionHandle execute(SystemState ss, KernelState ks, ThreadInfo th) {
00038 StaticArea sa = ks.static_area;
00039 ConstantPoolGen cpg = th.getCPG();
00040
00041
00042 String classname = peer.getClassName(cpg);
00043
00044
00045 JPFVM jpfvm = JPFVM.getJPFVM();
00046 ClassInfo ci = jpfvm.getClass(classname);
00047 if (!ks.static_area.hasClass(classname)) {
00048 ks.static_area.addClass(ci);
00049 return ci.initialize(ss, ks, th);
00050 }
00051
00052 int size = peer.consumeStack(cpg);
00053 long value;
00054
00055
00056 if(size == 1)
00057 value = th.peek();
00058 else
00059 value = th.peek2();
00060
00061 sa.setValue(peer.getClassName(cpg), peer.getFieldName(cpg), value);
00062 th.pop(size);
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 ANALYZE_execute(th, sa, cpg, value);
00074 DEPEND_execute(th, cpg);
00075
00076
00077 return th.getPC().getNext();
00078 }
00079 public void setPeer(de.fub.bytecode.generic.Instruction i) {
00080 peer = (de.fub.bytecode.generic.PUTSTATIC)i;
00081 }
00082 }