gpt4 book ai didi

com.ibm.wala.ipa.callgraph.propagation.cfa.ZeroXInstanceKeys类的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 05:18:49 27 4
gpt4 key购买 nike

本文整理了Java中com.ibm.wala.ipa.callgraph.propagation.cfa.ZeroXInstanceKeys类的一些代码示例,展示了ZeroXInstanceKeys类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZeroXInstanceKeys类的具体详情如下:
包路径:com.ibm.wala.ipa.callgraph.propagation.cfa.ZeroXInstanceKeys
类名称:ZeroXInstanceKeys

ZeroXInstanceKeys介绍

[英]Flexible class to create InstanceKeys depending on various policies ranging from class-based (i.e. 0-CFA) to allocation-site-based (0-1-CFA variants).
[中]灵活的类,根据从基于类(即0-CFA)到基于分配站点(0-1-CFA变体)的各种策略创建InstanceKey。

代码示例

代码示例来源:origin: com.ibm.wala/com.ibm.wala.cast.java

protected ZeroXInstanceKeys makeInstanceKeys(IClassHierarchy cha, AnalysisOptions options,
  SSAContextInterpreter contextInterpreter) {
 ZeroXInstanceKeys zik = new ZeroXInstanceKeys(options, cha, contextInterpreter, ZeroXInstanceKeys.ALLOCATIONS
   | ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS | ZeroXInstanceKeys.SMUSH_STRINGS | ZeroXInstanceKeys.SMUSH_MANY
   | ZeroXInstanceKeys.SMUSH_THROWABLES);
 return zik;
}

代码示例来源:origin: wala/WALA

/**
 * A class is "interesting" iff we distinguish instances of the class
 */
public boolean isInteresting(IClass C) {
 if (!allocationPolicy()) {
  return false;
 } else {
  if (smushStrings() && isStringish(C)) {
   return false;
  } else if (smushThrowables() && (isThrowable(C) || isStackTraceElement(C))) {
   return false;
  } else if (smushPrimHolders() && allFieldsArePrimitive(C)) {
   return false;
  }
  return true;
 }
}

代码示例来源:origin: wala/WALA

@Override
public <T> InstanceKey getInstanceKeyForConstant(TypeReference type, T S) {
 if (type == null) {
  throw new IllegalArgumentException("null type");
 }
 if (disambiguateConstants() || isReflectiveType(type)) {
  return new ConstantKey<>(S, getClassHierarchy().lookupClass(type));
 } else {
  return classBased.getInstanceKeyForConstant(type, S);
 }
}

代码示例来源:origin: wala/WALA

@Override
public InstanceKey getInstanceKeyForAllocation(CGNode node, NewSiteReference allocation) {
 if (allocation == null) {
  throw new IllegalArgumentException("allocation is null");
 }
 TypeReference t = allocation.getDeclaredType();
 IClass C = cha.lookupClass(t);
 if (C != null && isInteresting(C)) {
  if (smushMany()) {
   if (exceedsSmushLimit(C, node)) {
    return smushed.getInstanceKeyForAllocation(node, allocation);
   } else {
    return siteBased.getInstanceKeyForAllocation(node, allocation);
   }
  } else {
   return siteBased.getInstanceKeyForAllocation(node, allocation);
  }
 } else {
  return classBased.getInstanceKeyForAllocation(node, allocation);
 }
}

代码示例来源:origin: wala/WALA

@Override
public InstanceKey getInstanceKeyForMultiNewArray(CGNode node, NewSiteReference allocation, int dim) {
 if (allocationPolicy()) {
  return siteBased.getInstanceKeyForMultiNewArray(node, allocation, dim);
 } else {
  return classBased.getInstanceKeyForMultiNewArray(node, allocation, dim);
 }
}

代码示例来源:origin: wala/WALA

public ZeroXInstanceKeys(AnalysisOptions options, IClassHierarchy cha, RTAContextInterpreter contextInterpreter, int policy) {
 if (options == null) {
  throw new IllegalArgumentException("null options");
 }
 this.policy = policy;
 if (disambiguateConstants()) {
  // this is an ugly hack. TODO: clean it all up.
  options.setUseConstantSpecificKeys(true);
 }
 classBased = new ClassBasedInstanceKeys(options, cha);
 siteBased = new AllocationSiteInNodeFactory(options, cha);
 smushed = new SmushedAllocationSiteInstanceKeys(options, cha);
 this.cha = cha;
 this.contextInterpreter = contextInterpreter;
}

代码示例来源:origin: wala/WALA

private boolean allFieldsArePrimitive(IClass c) {
 if (c.isArrayClass()) {
  TypeReference t = c.getReference().getArrayElementType();
  return t.isPrimitiveType();
 } else {
  if (c.getReference().equals(TypeReference.JavaLangObject)) {
   return true;
  } else {
   for (IField f : c.getDeclaredInstanceFields()) {
    if (f.getReference().getFieldType().isReferenceType()) {
     return false;
    }
   }
   return allFieldsArePrimitive(c.getSuperclass());
  }
 }
}

代码示例来源:origin: wala/WALA

/**
 * side effect: populates the smush map.
 * 
 * @return true iff the node contains too many allocation sites of type c
 */
private boolean exceedsSmushLimit(IClass c, CGNode node) {
 Set<IClass> s = smushMap.get(node);
 if (s == null) {
  Map<IClass, Integer> count = countAllocsByType(node);
  HashSet<IClass> smushees = HashSetFactory.make(5);
  for (Map.Entry<IClass, Integer> e : count.entrySet()) {
   Integer i = e.getValue();
   if (i.intValue() > SMUSH_LIMIT) {
    smushees.add(e.getKey());
   }
  }
  s = smushees.isEmpty() ? Collections.<IClass> emptySet() : smushees;
  smushMap.put(node, s);
 }
 return s.contains(c);
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

@Override
public InstanceKey getInstanceKeyForAllocation(CGNode node, NewSiteReference allocation) {
 if (allocation == null) {
  throw new IllegalArgumentException("allocation is null");
 }
 TypeReference t = allocation.getDeclaredType();
 IClass C = cha.lookupClass(t);
 if (C != null && isInteresting(C)) {
  if (smushMany()) {
   if (exceedsSmushLimit(C, node)) {
    return smushed.getInstanceKeyForAllocation(node, allocation);
   } else {
    return siteBased.getInstanceKeyForAllocation(node, allocation);
   }
  } else {
   return siteBased.getInstanceKeyForAllocation(node, allocation);
  }
 } else {
  return classBased.getInstanceKeyForAllocation(node, allocation);
 }
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

@Override
public InstanceKey getInstanceKeyForMultiNewArray(CGNode node, NewSiteReference allocation, int dim) {
 if (allocationPolicy()) {
  return siteBased.getInstanceKeyForMultiNewArray(node, allocation, dim);
 } else {
  return classBased.getInstanceKeyForMultiNewArray(node, allocation, dim);
 }
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

public ZeroXInstanceKeys(AnalysisOptions options, IClassHierarchy cha, RTAContextInterpreter contextInterpreter, int policy) {
 if (options == null) {
  throw new IllegalArgumentException("null options");
 }
 this.policy = policy;
 if (disambiguateConstants()) {
  // this is an ugly hack. TODO: clean it all up.
  options.setUseConstantSpecificKeys(true);
 }
 classBased = new ClassBasedInstanceKeys(options, cha);
 siteBased = new AllocationSiteInNodeFactory(options, cha);
 smushed = new SmushedAllocationSiteInstanceKeys(options, cha);
 this.cha = cha;
 this.contextInterpreter = contextInterpreter;
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

private boolean allFieldsArePrimitive(IClass c) {
 if (c.isArrayClass()) {
  TypeReference t = c.getReference().getArrayElementType();
  return t.isPrimitiveType();
 } else {
  if (c.getReference().equals(TypeReference.JavaLangObject)) {
   return true;
  } else {
   for (IField f : c.getDeclaredInstanceFields()) {
    if (f.getReference().getFieldType().isReferenceType()) {
     return false;
    }
   }
   return allFieldsArePrimitive(c.getSuperclass());
  }
 }
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

/**
 * side effect: populates the smush map.
 * 
 * @return true iff the node contains too many allocation sites of type c
 */
private boolean exceedsSmushLimit(IClass c, CGNode node) {
 Set<IClass> s = smushMap.get(node);
 if (s == null) {
  Map<IClass, Integer> count = countAllocsByType(node);
  HashSet<IClass> smushees = HashSetFactory.make(5);
  for (Map.Entry<IClass, Integer> e : count.entrySet()) {
   Integer i = e.getValue();
   if (i.intValue() > SMUSH_LIMIT) {
    smushees.add(e.getKey());
   }
  }
  s = smushees.isEmpty() ? Collections.<IClass> emptySet() : smushees;
  smushMap.put(node, s);
 }
 return s.contains(c);
}

代码示例来源:origin: wala/WALA

/**
 * subclasses can override as desired
 */
protected ZeroXInstanceKeys makeInstanceKeys(IClassHierarchy cha, AnalysisOptions options,
  SSAContextInterpreter contextInterpreter, int instancePolicy) {
 ZeroXInstanceKeys zik = new ZeroXInstanceKeys(options, cha, contextInterpreter, instancePolicy);
 return zik;
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

/**
 * A class is "interesting" iff we distinguish instances of the class
 */
public boolean isInteresting(IClass C) {
 if (!allocationPolicy()) {
  return false;
 } else {
  if (smushStrings() && isStringish(C)) {
   return false;
  } else if (smushThrowables() && (isThrowable(C) || isStackTraceElement(C))) {
   return false;
  } else if (smushPrimHolders() && allFieldsArePrimitive(C)) {
   return false;
  }
  return true;
 }
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

@Override
public <T> InstanceKey getInstanceKeyForConstant(TypeReference type, T S) {
 if (type == null) {
  throw new IllegalArgumentException("null type");
 }
 if (disambiguateConstants() || isReflectiveType(type)) {
  return new ConstantKey<>(S, getClassHierarchy().lookupClass(type));
 } else {
  return classBased.getInstanceKeyForConstant(type, S);
 }
}

代码示例来源:origin: wala/WALA

protected ZeroXInstanceKeys makeInstanceKeys(IClassHierarchy cha, AnalysisOptions options,
  SSAContextInterpreter contextInterpreter) {
 ZeroXInstanceKeys zik = new ZeroXInstanceKeys(options, cha, contextInterpreter, ZeroXInstanceKeys.ALLOCATIONS
   | ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS | ZeroXInstanceKeys.SMUSH_STRINGS | ZeroXInstanceKeys.SMUSH_MANY
   | ZeroXInstanceKeys.SMUSH_THROWABLES);
 return zik;
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

/**
 * subclasses can override as desired
 */
protected ZeroXInstanceKeys makeInstanceKeys(IClassHierarchy cha, AnalysisOptions options,
  SSAContextInterpreter contextInterpreter, int instancePolicy) {
 ZeroXInstanceKeys zik = new ZeroXInstanceKeys(options, cha, contextInterpreter, instancePolicy);
 return zik;
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.cast.js

public JSZeroOrOneXCFABuilder(IClassHierarchy cha, JSAnalysisOptions options, IAnalysisCacheView cache,
  ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter, int instancePolicy, boolean doOneCFA) {
 super(cha, options, cache);
 SSAContextInterpreter contextInterpreter = setupSSAContextInterpreter(cha, options, cache, appContextInterpreter);
 setupMethodTargetSelector(cha, options);
 setupContextSelector(options, appContextSelector, doOneCFA);
 setInstanceKeys(new JavaScriptScopeMappingInstanceKeys(cha, this, new JavaScriptConstructorInstanceKeys(new ZeroXInstanceKeys(
   options, cha, contextInterpreter, instancePolicy))));
}

代码示例来源:origin: wala/WALA

public JSZeroOrOneXCFABuilder(IClassHierarchy cha, JSAnalysisOptions options, IAnalysisCacheView cache,
  ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter, int instancePolicy, boolean doOneCFA) {
 super(cha, options, cache);
 SSAContextInterpreter contextInterpreter = setupSSAContextInterpreter(cha, options, cache, appContextInterpreter);
 setupMethodTargetSelector(cha, options);
 setupContextSelector(options, appContextSelector, doOneCFA);
 setInstanceKeys(new JavaScriptScopeMappingInstanceKeys(cha, this, new JavaScriptConstructorInstanceKeys(new ZeroXInstanceKeys(
   options, cha, contextInterpreter, instancePolicy))));
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com