Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

NEW.java

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.classfile.ConstantPool;
00007 import de.fub.bytecode.classfile.Constant;
00008 import de.fub.bytecode.generic.InstructionHandle;
00009 import gov.nasa.arc.ase.util.Debug;
00010 
00011 public class NEW extends AbstractInstruction {
00012   private de.fub.bytecode.generic.NEW peer;
00013 
00014   public InstructionHandle execute(SystemState ss, KernelState ks, ThreadInfo th) {
00015     ConstantPoolGen cpg = th.getCPG();
00016     ConstantPool cp = cpg.getConstantPool();
00017     Constant constant = cp.getConstant(peer.getIndex());
00018 
00019     // gets the name of the class to create
00020     String classname =  cp.constantToString(constant);    
00021 
00022     // loads the class if it is needed
00023     JPFVM jpfvm = JPFVM.getJPFVM();
00024     ClassInfo ci = jpfvm.getClass(classname);
00025     if (!ks.static_area.hasClass(classname)) {
00026       ks.static_area.addClass(ci);
00027       return ci.initialize(ss, ks, th);
00028     }
00029 
00030     int objref = ks.dynamic_area.newObject(ci, th);
00031 
00032     // check if it's a thread
00033     if (ci.isThread()) {
00034       ThreadInfo nt = new ThreadInfo();
00035       nt.setClassInfo(ci);
00036       nt.setReference(new ObjRef(objref));
00037 // ifdef REFERENCE_COUNT
00038 
00039 //#endif REFERENCE_COUNT
00040 
00041       ks.newThread(nt);
00042     }
00043 
00044     // pushes the return value onto the stack
00045     th.push(objref);
00046 // ifdef MARK_N_SWEEP
00047     th.setOperandRef();
00048 //#endif MARK_N_SWEEP
00049 
00050     return th.getPC().getNext();
00051   }  
00052   public void setPeer(de.fub.bytecode.generic.Instruction i) {
00053     peer = (de.fub.bytecode.generic.NEW)i;
00054   }  
00055 }

Generated at Thu Feb 7 06:50:37 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001