• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SSAInstruction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.ibm.wala.ssa.SSAInstruction的典型用法代码示例。如果您正苦于以下问题:Java SSAInstruction类的具体用法?Java SSAInstruction怎么用?Java SSAInstruction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SSAInstruction类属于com.ibm.wala.ssa包,在下文中一共展示了SSAInstruction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getLineNumbers

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
/**
     * Get source code line number for each instruction
     * @param sgNodes
     * @param print
     * @return
     */
    public static HashMap<SSAInstructionKey, Integer> getLineNumbers(HashMap<Integer,BasicBlockInContext<IExplodedBasicBlock>> sgNodes) {
        log.debug("** get source code line number for each instruction");
        HashMap<SSAInstructionKey, Integer> map = new HashMap<SSAInstructionKey, Integer>();
        for(BasicBlockInContext<IExplodedBasicBlock> bbic : sgNodes.values()) {
            SSAInstruction inst = bbic.getLastInstruction();
            if(inst == null) {
                continue;
            }
//            ConcreteJavaMethod method = (ConcreteJavaMethod) bbic.getMethod();
            IMethod method =  bbic.getMethod();
            int lineNumber = method.getLineNumber(bbic.getLastInstructionIndex());
            map.put(new SSAInstructionKey(inst), lineNumber);
            log.debug(lineNumber + ". " + inst);
        }
        return map;
    }
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:23,代码来源:AnalysisUtil.java


示例2: getSSAInstruction

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
public static SSAInstruction getSSAInstruction(CallGraph cg, String methodSignature, int iindex) {
	SSACFG cfg = getSSACFG(methodSignature, cg);
	if (cfg == null) {
		logger.warn("getSSAInstruction:: Did not find SSACFG for " + methodSignature);			
	} else {
		BasicBlock block = cfg.getBlockForInstruction(iindex);
		if (block != null) {
			for (Iterator<SSAInstruction> it = block.iterateNormalInstructions(); it.hasNext();) {
				SSAInstruction ins = it.next();
				if (ins.iindex == iindex) {
					return ins;
				}
			}
			logger.warn("getSSAInstruction:: Did not find iindex " + iindex + " in SSACFG (" + methodSignature + ")");
		} else
			logger.warn("getSSAInstruction:: Did not find basic block for iindex " + iindex + " in SSACFG (" + methodSignature + ")");
	}
	return null;
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:20,代码来源:WalaUtils.java


示例3: collectInitialSeeds

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
/**
 * collect the putstatic instructions in the call graph as {@link PathEdge} seeds for the analysis
 */
private Collection<PathEdge<BasicBlockInContext<IExplodedBasicBlock>>> collectInitialSeeds() {
  Collection<PathEdge<BasicBlockInContext<IExplodedBasicBlock>>> result = HashSetFactory.make();
  for (BasicBlockInContext<IExplodedBasicBlock> bb : supergraph) {
    IExplodedBasicBlock ebb = bb.getDelegate();
    SSAInstruction instruction = ebb.getInstruction();
    if (instruction instanceof SSAPutInstruction) {
      SSAPutInstruction putInstr = (SSAPutInstruction) instruction;
      if (putInstr.isStatic()) {
        final CGNode cgNode = bb.getNode();
        Pair<CGNode, Integer> fact = Pair.make(cgNode, ebb.getFirstInstructionIndex());
        int factNum = domain.add(fact);
        BasicBlockInContext<IExplodedBasicBlock> fakeEntry = getFakeEntry(cgNode);
        // note that the fact number used for the source of this path edge doesn't really matter
        result.add(PathEdge.createPathEdge(fakeEntry, factNum, bb, factNum));

      }
    }
  }
  return result;
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:24,代码来源:ContextSensitiveReachingDefs.java


示例4: getTransferSitesBetween

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
private Set<TransferSite> getTransferSitesBetween(CGNode src, CGNode dest)
{
    Set<TransferSite> transfersBetween = new HashSet<TransferSite>();
    Set<SSAInstruction> instructionsBetween = getInstructionsBetween(src, dest);

    // Find that subset of this node's relevant transfer sites which are invocations from
    // the `src` node to the `dest` node.
    for (TransferSite transferSite : ta.getRelevantSites(src))
    {
        // No `RETURN` kind transfer site will be an invocation from `src` to `dest`.
        if (transferSite.getKind() == Kind.RETURN) {
            continue;
        }
        
        for (SSAInstruction instr : instructionsBetween)
        {
            if (transferSite.getInstruction().equals(instr)) {
                transfersBetween.add(transferSite);
                break;
            }
        }
    }

    return transfersBetween;
}
 
开发者ID:paninij,项目名称:paninij,代码行数:26,代码来源:CallGraphLiveAnalysis.java


示例5: getInstructionsBetween

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
private Set<SSAInstruction> getInstructionsBetween(CGNode src, CGNode dest)
{
    Set<SSAInstruction> between = new HashSet<SSAInstruction>();

    Iterator<CallSiteReference> callSiteIter = cga.getCallGraph().getPossibleSites(src, dest);
    IR nodeIR = src.getIR();
    while (callSiteIter.hasNext())
    {
        CallSiteReference callSite = callSiteIter.next();
        SSAAbstractInvokeInstruction[] callSiteInstructions = nodeIR.getCalls(callSite);
        assert callSiteInstructions.length == 1;
        between.add(callSiteInstructions[0]);
    } 
    
    return between;
}
 
开发者ID:paninij,项目名称:paninij,代码行数:17,代码来源:CallGraphLiveAnalysis.java


示例6: getDefs

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
/**
 * Get corresponding instruction for the definition of each SSA value
 * @param sgNodes
 * @return
 */
public static HashMap<Integer, SSAInstruction> getDefs(HashMap<Integer,BasicBlockInContext<IExplodedBasicBlock>> sgNodes) {
    log.debug("** get definition instruction for each SSA value");
    HashMap<Integer, SSAInstruction> map = new HashMap<Integer, SSAInstruction>();
    for(BasicBlockInContext<IExplodedBasicBlock> bbic : sgNodes.values()) {
        SymbolTable symbolTable = bbic.getNode().getIR().getSymbolTable();
        DefUse du = bbic.getNode().getDU();

        for (int i = 0; i <= symbolTable.getMaxValueNumber(); i++) {
            log.debug(i + " [" + symbolTable.getValueString(i) + "] " + du.getDef(i));
            map.put(i, du.getDef(i));
        }
        break; // there are the same definitions in each basic block, iff there is only one method FIXME: read different scopes, if multiple methods are required
    }
    return map;
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:21,代码来源:AnalysisUtil.java


示例7: makeInitialFieldNumbers

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
private ObjectArrayMapping makeInitialFieldNumbers(IR ir) {
   Set fields = new LinkedHashSet();
   for(Iterator is = iterateInstructions(ir); is.hasNext(); ) {
     SSAInstruction i = (SSAInstruction)is.next();
     if (i == null) continue;

     PointerKey[] defs = fieldAccesses.getDefs(i);
     for(int f = 0; f < defs.length; f++) {
fields.add( defs[f] );
     }

     PointerKey[] uses = fieldAccesses.getUses(i);
     for(int f = 0; f < uses.length; f++) {
fields.add( uses[f] );
     }
   }

   return new ObjectArrayMapping(
     fields.toArray(new PointerKey[ fields.size() ])
   );
 }
 
开发者ID:wala,项目名称:MemSAT,代码行数:22,代码来源:FieldNameSSAConversion.java


示例8: makeValueNumbers

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
private Map makeValueNumbers(IR ir) {
   Map vns = new LinkedHashMap();
   for(Iterator is = iterateInstructions(ir); is.hasNext(); ) {
     SSAInstruction inst = (SSAInstruction)is.next();
     if (inst == null) continue;

     PointerKey[] uses = fieldAccesses.getUses(inst);
     int[] useValueNumbers = new int[ uses.length ];
     for(int j = 0; j < uses.length; j++) {
useValueNumbers[j] = getInitialFieldNumber( uses[j] );
     }
     vns.put(Pair.make(inst, USES), useValueNumbers);
     
     PointerKey[] defs = fieldAccesses.getDefs(inst);
     int[] defValueNumbers = new int[ defs.length ];
     for(int j = 0; j < defs.length; j++) {
defValueNumbers[j] = getInitialFieldNumber( defs[j] );
     }
     vns.put(Pair.make(inst, DEFS), defValueNumbers);
   }
   
   return vns;
 }
 
开发者ID:wala,项目名称:MemSAT,代码行数:24,代码来源:FieldNameSSAConversion.java


示例9: getInstructions

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
protected Iterator getInstructions(final CGNode node) {
	final PDG pdg = sdg.getPDG(node);
	final IR ir = node.getIR();
	final Map indicesMap = PDG.computeInstructionIndices(ir);
	return new FilterIterator(
			node.getIR().iterateAllInstructions(), new Predicate() {
				private boolean sliceContainsInstruction(
						SSAInstruction s) {
					return slice.contains(PDG
							.ssaInstruction2Statement(node, s,
									indicesMap, ir));
				}

				public boolean test(Object o) {
					return sliceContainsInstruction((SSAInstruction) o);
				}
			});
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:19,代码来源:WalaInformationImpl.java


示例10: GuardHandler

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
/**
 * Creates a GuardHandler for the translation of env.top().callInfo().cgNode().
 * Any warnings generated during guard computation will be stored in the provided set.
 * @effects  this.methodEntryGuard' = entryGuard and this.frame' = env.top and 
 * this.node = this.frame'.callInfo.cgNode
 */
GuardHandler(Formula entryGuard, Environment env, Set<TranslationWarning> warnings) {
	this.methodEntryGuard = entryGuard;
	this.env = env;
	this.warnings = warnings;
	this.node = env.top().callInfo().cgNode();
	this.fieldSSA = env.top().callInfo().fieldSSA();
	this.blockEntryGuards = new LinkedHashMap<SSACFG.BasicBlock, Formula>();
	this.callExitGuards = new LinkedHashMap<SSAAbstractInvokeInstruction, Formula>();
	this.instructionToBlock = new LinkedHashMap<SSAInstruction, SSACFG.BasicBlock>();
	this.nonNullGuards = new LinkedHashMap<Expression, Formula>();
	this.nil = env.factory().constants().nil();
	
	for(Iterator<ISSABasicBlock> bbs = node.getIR().getControlFlowGraph().iterator(); bbs.hasNext(); ) {
		SSACFG.BasicBlock bb = (SSACFG.BasicBlock)bbs.next();
		for(Iterator<SSAInstruction> insts = bb.iterator(); insts.hasNext(); ) {
			instructionToBlock.put(insts.next(), bb);
		}
		for(Iterator<SSAPhiInstruction> insts = fieldSSA.getPhiNodes(bb); insts.hasNext(); ) {
			instructionToBlock.put(insts.next(), bb);
		}
	}
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:29,代码来源:GuardHandler.java


示例11: phiUseGuards

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
/**
 * Returns relative guards for each use of the given phi instruction.
 * In particular, the ith Formula in the return array stores the 
 * guard for inst.getUse(i).
 * @requires inst in this.node.getIR().getInstructions()
 * @return relative guards for each use of the given phi instruction
 */
final Formula[] phiUseGuards(SSAPhiInstruction inst) { 
	final Formula[] ret = new Formula[inst.getNumberOfUses()];
	final SSACFG.BasicBlock bb = blockFor(inst);
	final EdgeType type = bb.isExitBlock()? EdgeType.NORMAL: EdgeType.NOT_APPLICABLE;
	final ControlFlowGraph<SSAInstruction, ISSABasicBlock> cfg = node.getIR().getControlFlowGraph();
	for(Iterator<? extends IBasicBlock<SSAInstruction>> itr = cfg.getPredNodes(bb); itr.hasNext();) { 
		SSACFG.BasicBlock pb = (SSACFG.BasicBlock)itr.next();
		int which = com.ibm.wala.cast.ir.cfg.Util.whichPred(cfg, bb, pb);
		if (cfg.getSuccNodeCount(pb) > 1) { 
			ret[which] = edgeGuard(pb,bb,type).and(relativeEntryGuard(pb));
		} else {
			ret[which] = relativeEntryGuard(pb);
		}
	}
	//TODO: need both normal & exceptional edge to exit for the same block.
	return ret;
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:25,代码来源:GuardHandler.java


示例12: visitThrower

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
/** @effects updates exceptionPhi with [[exception]] if the block
 * holding the given instruction is an exit block; otherwise, updates the
 * defs of relevant SSAGetCaughtExceptionInstruction(s) */
private final void visitThrower(SSAInstruction inst, Expression exception) { 
	final SSACFG.BasicBlock block = guardHandler.blockFor(inst);
	final Formula guard = guardHandler.relativeEntryGuard(block);
	for(IBasicBlock<?> SB : node.getIR().getControlFlowGraph().getExceptionalSuccessors(block)) {
		if (SB.isExitBlock()) { 
			exceptionPhi.add(guard, exception);
		} else {
			SSAGetCaughtExceptionInstruction catcher = (SSAGetCaughtExceptionInstruction)((SSACFG.ExceptionHandlerBasicBlock)SB).getCatchInstruction();
			PhiExpression<Expression> catcherPhi = catcherPhis.get(catcher);
			if (catcherPhi==null) { 
				catcherPhi = factory.valuePhi(IRType.OBJECT);
				catcherPhis.put(catcher, catcherPhi);
			}
			catcherPhi.add(guard, exception);
		}
	}
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:21,代码来源:Translator.java


示例13: valueAtoms

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
/**
 * Returns a tupleset containing the set of atoms that describe the values that the
 * given read/write instruction may read or write.
 * @requires inst in this.insts
 * @requires this.atoms() in factory.universe.atoms[int]
 * @requires inst.action in NORMAL_READ + NORMAL_WRITE + VOLATILE_READ + VOLATILE_WRITE
 * @return a tupleset containing the set of atoms that describe the values that the
 * given read/write instruction may read or write.
 */
public final TupleSet valueAtoms(TupleFactory tuples, InlinedInstruction inst) { 	
	final ConstantFactory constants = base.constants();
	final Set<InstanceKey> rangeKeys = valueFor(base.info(), inst);
	if (!rangeKeys.isEmpty()) { 
		final TupleSet val = constants.instanceAtoms(tuples, rangeKeys);
		val.add(tuples.tuple(constants.nil()));
		return val;
	} else {
		final IRType type;
		final SSAInstruction delegate = inst.instruction();
		if (delegate instanceof SSAFieldAccessInstruction) { 
			type = IRType.convert(((SSAFieldAccessInstruction) delegate).getDeclaredFieldType());
		} else {
			type = IRType.convert(((SSAArrayReferenceInstruction) delegate).getElementType());
		}
		if (type.equals( IRType.OBJECT )) {
			// empty range for object type, which must
			// mean these objects are never created.  thus
			// null is the only valid object
			return tuples.setOf(constants.nil());
		} else {
			return constants.constantAtoms(tuples, type);
		}
	}
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:35,代码来源:ConcurrentFactory.java


示例14: getIndexFor

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
/**
 * @param instruction
 * @return the bytecode index in the WALA parsed method body
 */
public Integer getIndexFor(SSAInstruction instruction) {

	LOG.trace("get bytecode index");

	if (instruction instanceof SSAPhiInstruction) {
		return getIndexForPhi((SSAPhiInstruction) instruction);
	} else {
		if (instructionToIndexMap == null) {
			LOG.trace("creating instruction index map");
			instructionToIndexMap = IRUtil.createInstructionToIndexMap(ir);
		}
		return instructionToIndexMap.get(instruction);
	}

}
 
开发者ID:wondee,项目名称:faststring,代码行数:20,代码来源:AnalyzedMethod.java


示例15: check

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
@Override
public int check(SSAInstruction ins) {
	
	if (ins != null) {
		if (ins instanceof SSAAbstractInvokeInstruction) {
			SSAAbstractInvokeInstruction invokeIns = (SSAAbstractInvokeInstruction) ins;
			MethodReference target = invokeIns.getDeclaredTarget();
			if (methods().contains(target) && 
					!invokeIns.isStatic() ) {
				return invokeIns.getReceiver();
			}
		}
	
	}
	return -1;
}
 
开发者ID:wondee,项目名称:faststring,代码行数:17,代码来源:BaseTypeLabel.java


示例16: createInstructionToIndexMap

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
public static Map<SSAInstruction, Integer> createInstructionToIndexMap(IR ir) {

		Map<SSAInstruction, Integer> map = Maps.newHashMap();

		for (int i = 0; i < ir.getInstructions().length; i++) {
			SSAInstruction instruction = ir.getInstructions()[i];
			if (instruction != null) {
				Integer old = map.put(instruction, i);
				if (old != null) {
					throw new IllegalStateException("instruction was set before: actual index = " + i +
							"; old index = " + old + "; instruction = " + instruction);
				}
			}
		}

		return map;
	}
 
开发者ID:wondee,项目名称:faststring,代码行数:18,代码来源:IRUtil.java


示例17: checkLocalsForDef

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
private void checkLocalsForDef(SSAInstruction instruction, InstructionNode result, Integer index) {
	if (instruction.hasDef()) {
		int def = instruction.getDef();

		result.addLocalVariableIndices(def, method.getLocalForDef(index, def));

		LOG.debug("determine store instruction for v={} at {}", def, instruction);

		LocalInfo store = method.getStoreFor(0, 1, (instruction instanceof SSAPhiInstruction) && index > 0 ? index - 1 : index);
		if (store != null) {
			if (store.local() != -1) {
				result.addLocalVariableIndices(def, Arrays.asList(store.local()));
			}
			result.setStore(store.local(), store.bcIndex());
		}

	}
}
 
开发者ID:wondee,项目名称:faststring,代码行数:19,代码来源:InstructionNodeFactory.java


示例18: checkLocalsForUses

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
private void checkLocalsForUses(SSAInstruction instruction, InstructionNode result, Integer index) {
	List<Integer> vs = IRUtil.getUses(instruction);

	for (int i = 0; i < vs.size(); i++) {
		int v = vs.get(i);

		result.addLocalVariableIndices(v, method.getLocalForUse(index, v));
		LOG.debug("determine load instruction for v={} at {}", v, instruction);
		LocalInfo load = method.getLoadFor(i, vs.size(), index);
		if (load != null) {
			if (load.local() != -1) {
				result.addLocalVariableIndices(v, Arrays.asList(load.local()));
			}
			result.addLoad(i, load.bcIndex());
		}
	}
}
 
开发者ID:wondee,项目名称:faststring,代码行数:18,代码来源:InstructionNodeFactory.java


示例19: checkMethodSignature

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
/**
 * Checks whether some instruction is both an {@link com.ibm.wala.ssa.SSAInvokeInstruction} and if its signature
 * matches a given signature
 * @param ins  an {@link com.ibm.wala.ssa.SSAInstruction}
 * @param methodSignature a method signature to check against
 * @return
 */
public static boolean checkMethodSignature(final SSAInstruction ins, final String methodSignature) {
	if (ins instanceof SSAInvokeInstruction) {
		final SSAInvokeInstruction inv = (SSAInvokeInstruction) ins;
		return inv.getDeclaredTarget().getSignature().equals(methodSignature);
	}
	return false;
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:15,代码来源:WalaUtils.java


示例20: make

import com.ibm.wala.ssa.SSAInstruction; //导入依赖的package包/类
/**
 * @param node          The call graph node in which this transfer
 * @param transferInstr The instruction (from the SSA IR of `node`) which performs the transfer.
 * @param transfers     A set of value numbers (from the SSA IR of `node`) which are
 *                      transferred at this transfer site. If there are no transfers, then that
 *                      should be represented by passing `null`.
 */
public static TransferSite make(CGNode node, IntSet transfers, SSAInstruction transferInstr)
{
    switch (Kind.fromSSAInstruction(transferInstr)) {
    case INVOKE:
    case RETURN:
        return new ReturnTransferSite(node, transfers, transferInstr);
    default:
        String msg = "Cannot make a transfer site because `transferInstr` kind is unknown.";
        throw new RuntimeException(msg);
    }
}
 
开发者ID:paninij,项目名称:paninij,代码行数:19,代码来源:TransferSite.java



注:本文中的com.ibm.wala.ssa.SSAInstruction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DenseInstance类代码示例发布时间:2022-05-22
下一篇:
Java Chunk类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap