Package org.xmlvm.refcount

Examples of org.xmlvm.refcount.RegisterSet


  @SuppressWarnings("unchecked")
  public ReturnValue Process(List<CodePath> allCodePaths, Map<Element, InstructionActions> beenTo, Element codeElement) throws ReferenceCountingException, DataConversionException
  {
    ReturnValue toRet= new ReturnValue();
    // We want to identify all registers used.
    RegisterSet allRegs= new RegisterSet();
    for (CodePath curPath : allCodePaths)
    {
      for (OnePathInstructionRegisterContents curInst : curPath.path)
      {
        InstructionUseInfo useInfo= beenTo.get(curInst.instruction).useInfo;
        allRegs.orEq(useInfo.allWrites());
        allRegs.orEq(useInfo.usedReg());
      }
    }

    // Emit decl for each register
    for (int regId : allRegs)
    {
      Element initElem= new Element(InstructionProcessor.cmd_define_register, InstructionProcessor.vm);
      initElem.setAttribute("vartype", InstructionProcessor.cmd_define_register_attr_register);
      initElem.setAttribute("num", regId + "");
      toRet.functionInit.add(initElem);
    }

    // Find all the var elements, and add moves for them
    int argIdx= 1;
    for (Element curElem : (List<Element>) codeElement.getChildren())
    {
      if (curElem.getName().equals("var"))
      {
        Element moveArg= new Element(InstructionProcessor.cmd_move_argument, InstructionProcessor.vm);
        moveArg.setAttribute("vx", curElem.getAttributeValue("register"));
        moveArg.setAttribute("vx-type", curElem.getAttributeValue("type"));

        String sourceName= curElem.getAttributeValue("name");
        if (sourceName == "this")
        {
          moveArg.setAttribute("sourceArg", "self");
        }
        else
        {
          moveArg.setAttribute("sourceArg", argIdx + "");
          argIdx++;
        }
        toRet.functionInit.add(moveArg);
        allRegs.remove(curElem.getAttribute("register").getIntValue());

      }
    }

    RegisterSet hasObj= RegisterSet.none();
    for (CodePath curPath : allCodePaths)
    {
      // collect non obj writes
      for (OnePathInstructionRegisterContents curInst : curPath.path)
      {
        InstructionUseInfo useInfo= beenTo.get(curInst.instruction).useInfo;
        hasObj.orEq(useInfo.writesObj());
      }
    }

    allRegs.andEq(hasObj);
View Full Code Here


  {
    ReturnValue toRet= new ReturnValue();

    for (CodePath c : allCodePaths)
    {
      RegisterSet allRegs= new RegisterSet();
      for (OnePathInstructionRegisterContents curInst : c.path)
      {
        InstructionUseInfo useInfo= beenTo.get(curInst.instruction).useInfo;
        allRegs.orEq(useInfo.allWrites());
        allRegs.orEq(useInfo.usedReg());
      }

      // Look for a retain, no writes, then a release, and then get
      // rid of the symmetric retain / release

      for (int reg : allRegs)
      {
        List<PairUseInfoIndex> retains= new ArrayList<PairUseInfoIndex>();
        List<PairUseInfoIndex> releases= new ArrayList<PairUseInfoIndex>();

        int curIndex= 5;
        for (OnePathInstructionRegisterContents curInst : c.path)
        {
          InstructionActions act;
          act= beenTo.get(curInst.instruction);

          // changing the order of the next three ifs will screw
          // everything
          // up in unclear ways until you look at the output
          if (act.useInfo.willFree.has(reg))
          {
            releases.add(new PairUseInfoIndex(act.useInfo, curIndex));
            curIndex++;
          }

          RegisterSet allWrites= act.useInfo.allWrites();
          if (allWrites.has(reg))
          {
            eliminateExcessRetains(reg, retains, releases);
          }

          if (act.useInfo.requiresRetain.has(reg))
View Full Code Here

  public ReturnValue Process(List<CodePath> allCodePaths, Map<Element, InstructionActions> beenTo, Element codeElement) throws ReferenceCountingException, DataConversionException
  {

    ReturnValue toRet= new ReturnValue();

    RegisterSet allRegs= new RegisterSet();
    for (CodePath curPath : allCodePaths)
    {
      for (OnePathInstructionRegisterContents curInst : curPath.path)
      {
        InstructionUseInfo useInfo= beenTo.get(curInst.instruction).useInfo;
        allRegs.orEq(useInfo.allWrites());
        allRegs.orEq(useInfo.usedReg());
      }
    }

    for (CodePath c : allCodePaths)
    {
      // We start with as early as possible nulls. Now we switch to
      // as late as possible to prevent excess nulling
      RegisterSet needsNull= RegisterSet.none();
      InstructionActions act= null;
      OnePathInstructionRegisterContents last= null;
      for (OnePathInstructionRegisterContents curInst : c.path)
      {
        last= curInst;
        act= beenTo.get(curInst.instruction);
        needsNull.orEq(act.useInfo.willNull);
        act.useInfo.willNull= RegisterSet.none();
        needsNull.andEqNot(act.useInfo.allWrites());
      }
      if (act != null)
      {
        if (last.instruction.getName().startsWith("return"))
        {
View Full Code Here

TOP

Related Classes of org.xmlvm.refcount.RegisterSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.