proj_name
stringclasses 131
values | relative_path
stringlengths 30
228
| class_name
stringlengths 1
68
| func_name
stringlengths 1
48
| masked_class
stringlengths 78
9.82k
| func_body
stringlengths 46
9.61k
| len_input
int64 29
2.01k
| len_output
int64 14
1.94k
| total
int64 55
2.05k
| relevant_context
stringlengths 0
38.4k
|
|---|---|---|---|---|---|---|---|---|---|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/pointer/nativemethods/JavaNetInetAddressImplNative.java
|
JavaNetInetAddressImplNative
|
simulateMethod
|
class JavaNetInetAddressImplNative extends NativeMethodClass {
public JavaNetInetAddressImplNative(NativeHelper helper) {
super(helper);
}
/**
* Implements the abstract method simulateMethod. It distributes the request to the corresponding methods by signatures.
*/
public void simulateMethod(SootMethod method, ReferenceVariable thisVar, ReferenceVariable returnVar,
ReferenceVariable params[]) {<FILL_FUNCTION_BODY>}
/************************ java.net.InetAddressImpl *****************/
/**
* Returns a variable pointing to a string constant
*
* I am not sure if repeated calls of methods in this class will return the same object or not. A conservative approach
* would say YES, for definitely points-to, but NO for may points-to.
*
* We should avoid analyzing these unsafe native methods.
*
* native java.lang.String getLocalHostName() throws java.net.UnknownHostException;
*/
public void java_net_InetAddressImpl_getLocalHostName(SootMethod method, ReferenceVariable thisVar,
ReferenceVariable returnVar, ReferenceVariable params[]) {
helper.assignObjectTo(returnVar, Environment.v().getStringObject());
}
/**
* Create a string object
*
* native java.lang.String getHostByAddr(int) throws java.net.UnknownHostException;
*/
public void java_net_InetAddressImpl_getHostByAddr(SootMethod method, ReferenceVariable thisVar,
ReferenceVariable returnVar, ReferenceVariable params[]) {
helper.assignObjectTo(returnVar, Environment.v().getStringObject());
}
/**
* NO side effects. native void makeAnyLocalAddress(java.net.InetAddress); native byte
* lookupAllHostAddr(java.lang.String)[][] throws java.net.UnknownHostException; native int getInetFamily();
*
* @see default(...)
*/
}
|
String subSignature = method.getSubSignature();
if (subSignature.equals("java.lang.String getLocalHostName()")) {
java_net_InetAddressImpl_getLocalHostName(method, thisVar, returnVar, params);
return;
} else if (subSignature.equals("java.lang.String getHostByAddress(int)")) {
java_net_InetAddressImpl_getHostByAddr(method, thisVar, returnVar, params);
return;
} else {
defaultMethod(method, thisVar, returnVar, params);
return;
}
| 482
| 153
| 635
|
<methods>public void <init>(soot.jimple.toolkits.pointer.util.NativeHelper) ,public static void defaultMethod(soot.SootMethod, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable[]) ,public abstract void simulateMethod(soot.SootMethod, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable[]) <variables>private static final boolean DEBUG,protected soot.jimple.toolkits.pointer.util.NativeHelper helper,private static final org.slf4j.Logger logger
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/pointer/nativemethods/JavaSecurityAccessControllerNative.java
|
JavaSecurityAccessControllerNative
|
simulateMethod
|
class JavaSecurityAccessControllerNative extends NativeMethodClass {
public JavaSecurityAccessControllerNative(NativeHelper helper) {
super(helper);
}
/**
* Implements the abstract method simulateMethod. It distributes the request to the corresponding methods by signatures.
*/
public void simulateMethod(SootMethod method, ReferenceVariable thisVar, ReferenceVariable returnVar,
ReferenceVariable params[]) {<FILL_FUNCTION_BODY>}
/************************ java.security.AccessController ************/
/*
* The return value of doPrivileged depends on the implementation.
*
* public static native java.lang.Object doPrivileged(java.security.PrivilegedAction);
*
* public static native java.lang.Object doPrivileged(java.security.PrivilegedExceptionAction) throws
* java.security.PrivilegedActionException;
*
* public static native java.lang.Object doPrivileged(java.security.PrivilegedAction, java.security.AccessControlContext);
*
* public static native java.lang.Object doPrivileged(java.security.PrivilegedExceptionAction,
* java.security.AccessControlContext) throws java.security.PrivilegedActionException;
*/
public void java_security_AccessController_doPrivileged(SootMethod method, ReferenceVariable thisVar,
ReferenceVariable returnVar, ReferenceVariable params[]) {
// No longer necessary since Spark handles it itself in a more precise
// way.
// helper.assignObjectTo(returnVar, Environment.v().getLeastObject());
helper.throwException(Environment.v().getPrivilegedActionExceptionObject());
}
/**
* Creates an access control context object.
*
* private static native java.security.AccessControlContext getStackAccessControlContext();
*/
public void java_security_AccessController_getStackAccessControlContext(SootMethod method, ReferenceVariable thisVar,
ReferenceVariable returnVar, ReferenceVariable params[]) {
helper.assignObjectTo(returnVar, Environment.v().getAccessControlContext());
}
/**
* NOTE: not documented and not called by anyone
*
* static native java.security.AccessControlContext getInheritedAccessControlContext();
*/
public void java_security_AccessController_getInheritedAccessControlContext(SootMethod method, ReferenceVariable thisVar,
ReferenceVariable returnVar, ReferenceVariable params[]) {
helper.assignObjectTo(returnVar, Environment.v().getAccessControlContext());
}
}
|
String subSignature = method.getSubSignature();
if (subSignature.equals("java.lang.Object doPrivileged(java.security.PrivilegedAction)")) {
java_security_AccessController_doPrivileged(method, thisVar, returnVar, params);
return;
} else if (subSignature.equals("java.lang.Object doPrivileged(java.security.PrivilegedExceptionAction)")) {
java_security_AccessController_doPrivileged(method, thisVar, returnVar, params);
return;
} else if (subSignature
.equals("java.lang.Object doPrivileged(java.security.PrivilegedAction,java.security.AccessControlContext)")) {
java_security_AccessController_doPrivileged(method, thisVar, returnVar, params);
return;
} else if (subSignature.equals(
"java.lang.Object doPrivileged(java.security.PrivilegedExceptionAction,java.security.AccessControlContext)")) {
java_security_AccessController_doPrivileged(method, thisVar, returnVar, params);
return;
} else if (subSignature.equals("java.security.AccessControlContext getStackAccessControlContext()")) {
java_security_AccessController_getStackAccessControlContext(method, thisVar, returnVar, params);
return;
} else if (subSignature.equals("java.security.AccessControlContext getInheritedAccessControlContext()")) {
java_security_AccessController_getInheritedAccessControlContext(method, thisVar, returnVar, params);
return;
} else {
defaultMethod(method, thisVar, returnVar, params);
return;
}
| 630
| 436
| 1,066
|
<methods>public void <init>(soot.jimple.toolkits.pointer.util.NativeHelper) ,public static void defaultMethod(soot.SootMethod, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable[]) ,public abstract void simulateMethod(soot.SootMethod, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable[]) <variables>private static final boolean DEBUG,protected soot.jimple.toolkits.pointer.util.NativeHelper helper,private static final org.slf4j.Logger logger
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/pointer/nativemethods/JavaUtilJarJarFileNative.java
|
JavaUtilJarJarFileNative
|
simulateMethod
|
class JavaUtilJarJarFileNative extends NativeMethodClass {
public JavaUtilJarJarFileNative(NativeHelper helper) {
super(helper);
}
/**
* Implements the abstract method simulateMethod. It distributes the request to the corresponding methods by signatures.
*/
public void simulateMethod(SootMethod method, ReferenceVariable thisVar, ReferenceVariable returnVar,
ReferenceVariable params[]) {<FILL_FUNCTION_BODY>}
/*********************** java.util.jar.JarFile ******************/
/**
* The methods returns an array of strings.
*
* @return = new String[]
*
* private native java.lang.String getMetaInfEntryNames()[];
*/
public void java_util_jar_JarFile_getMetaInfoEntryNames(SootMethod method, ReferenceVariable thisVar,
ReferenceVariable returnVar, ReferenceVariable params[]) {
helper.assignObjectTo(returnVar, Environment.v().getStringObject());
}
}
|
String subSignature = method.getSubSignature();
if (subSignature.equals("java.lang.String[] getMetaInfoEntryNames()")) {
java_util_jar_JarFile_getMetaInfoEntryNames(method, thisVar, returnVar, params);
return;
} else {
defaultMethod(method, thisVar, returnVar, params);
return;
}
| 249
| 101
| 350
|
<methods>public void <init>(soot.jimple.toolkits.pointer.util.NativeHelper) ,public static void defaultMethod(soot.SootMethod, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable[]) ,public abstract void simulateMethod(soot.SootMethod, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable[]) <variables>private static final boolean DEBUG,protected soot.jimple.toolkits.pointer.util.NativeHelper helper,private static final org.slf4j.Logger logger
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/pointer/nativemethods/JavaUtilZipCRC32Native.java
|
JavaUtilZipCRC32Native
|
simulateMethod
|
class JavaUtilZipCRC32Native extends NativeMethodClass {
public JavaUtilZipCRC32Native(NativeHelper helper) {
super(helper);
}
/**
* Implements the abstract method simulateMethod. It distributes the request to the corresponding methods by signatures.
*/
public void simulateMethod(SootMethod method, ReferenceVariable thisVar, ReferenceVariable returnVar,
ReferenceVariable params[]) {<FILL_FUNCTION_BODY>}
/*********************** java.util.zip.CRC32 *********************/
/**
* NO side effects.
*
* private static native int update(int, int); private static native int updateBytes(int, byte[], int, int);
*
* @see default(...)
*/
}
|
String subSignature = method.getSubSignature();
/* TODO */
{
defaultMethod(method, thisVar, returnVar, params);
return;
}
| 195
| 48
| 243
|
<methods>public void <init>(soot.jimple.toolkits.pointer.util.NativeHelper) ,public static void defaultMethod(soot.SootMethod, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable[]) ,public abstract void simulateMethod(soot.SootMethod, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable[]) <variables>private static final boolean DEBUG,protected soot.jimple.toolkits.pointer.util.NativeHelper helper,private static final org.slf4j.Logger logger
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/pointer/nativemethods/JavaUtilZipZipEntryNative.java
|
JavaUtilZipZipEntryNative
|
simulateMethod
|
class JavaUtilZipZipEntryNative extends NativeMethodClass {
public JavaUtilZipZipEntryNative(NativeHelper helper) {
super(helper);
}
/**
* Implements the abstract method simulateMethod. It distributes the request to the corresponding methods by signatures.
*/
public void simulateMethod(SootMethod method, ReferenceVariable thisVar, ReferenceVariable returnVar,
ReferenceVariable params[]) {<FILL_FUNCTION_BODY>}
}
|
String subSignature = method.getSubSignature();
{
defaultMethod(method, thisVar, returnVar, params);
return;
}
| 115
| 43
| 158
|
<methods>public void <init>(soot.jimple.toolkits.pointer.util.NativeHelper) ,public static void defaultMethod(soot.SootMethod, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable[]) ,public abstract void simulateMethod(soot.SootMethod, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable[]) <variables>private static final boolean DEBUG,protected soot.jimple.toolkits.pointer.util.NativeHelper helper,private static final org.slf4j.Logger logger
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/pointer/nativemethods/NativeMethodClass.java
|
NativeMethodClass
|
defaultMethod
|
class NativeMethodClass {
private static final Logger logger = LoggerFactory.getLogger(NativeMethodClass.class);
private static final boolean DEBUG = false;
protected NativeHelper helper;
public NativeMethodClass(NativeHelper helper) {
this.helper = helper;
}
/*
* If a native method has no side effect, call this method. Currently, it does nothing.
*/
public static void defaultMethod(SootMethod method, ReferenceVariable thisVar, ReferenceVariable returnVar,
ReferenceVariable params[]) {<FILL_FUNCTION_BODY>}
/* To be implemented by individual classes */
public abstract void simulateMethod(SootMethod method, ReferenceVariable thisVar, ReferenceVariable returnVar,
ReferenceVariable params[]);
}
|
if (DEBUG) {
logger.debug("No side effects : " + method.toString());
}
| 186
| 29
| 215
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/pointer/nativemethods/SunMiscUnsafeNative.java
|
SunMiscUnsafeNative
|
simulateMethod
|
class SunMiscUnsafeNative extends NativeMethodClass {
public SunMiscUnsafeNative(NativeHelper helper) {
super(helper);
}
/**
* Implements the abstract method simulateMethod. It distributes the request to the corresponding methods by signatures.
*/
public void simulateMethod(SootMethod method, ReferenceVariable thisVar, ReferenceVariable returnVar,
ReferenceVariable params[]) {<FILL_FUNCTION_BODY>}
public void sun_misc_Unsafe_allocateInstance(SootMethod method, ReferenceVariable thisVar, ReferenceVariable returnVar,
ReferenceVariable params[]) {
ReferenceVariable instanceVar = helper.newInstanceOf(thisVar);
helper.assign(returnVar, instanceVar);
}
}
|
String subSignature = method.getSubSignature();
if (subSignature.equals("java.lang.Object allocateInstance(java.lang.Class)")) {
sun_misc_Unsafe_allocateInstance(method, thisVar, returnVar, params);
return;
}
{
defaultMethod(method, thisVar, returnVar, params);
return;
}
| 182
| 101
| 283
|
<methods>public void <init>(soot.jimple.toolkits.pointer.util.NativeHelper) ,public static void defaultMethod(soot.SootMethod, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable[]) ,public abstract void simulateMethod(soot.SootMethod, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable, soot.jimple.toolkits.pointer.representations.ReferenceVariable[]) <variables>private static final boolean DEBUG,protected soot.jimple.toolkits.pointer.util.NativeHelper helper,private static final org.slf4j.Logger logger
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/pointer/util/NativeMethodDriver.java
|
NativeMethodDriver
|
process
|
class NativeMethodDriver {
private static final Logger logger = LoggerFactory.getLogger(NativeMethodDriver.class);
public NativeMethodDriver(NativeHelper helper) {
cnameToSim.put("java.lang.Object", new JavaLangObjectNative(helper));
cnameToSim.put("java.lang.System", new JavaLangSystemNative(helper));
cnameToSim.put("java.lang.Runtime", new JavaLangRuntimeNative(helper));
cnameToSim.put("java.lang.Shutdown", new JavaLangShutdownNative(helper));
cnameToSim.put("java.lang.String", new JavaLangStringNative(helper));
cnameToSim.put("java.lang.Float", new JavaLangFloatNative(helper));
cnameToSim.put("java.lang.Double", new JavaLangDoubleNative(helper));
cnameToSim.put("java.lang.StrictMath", new JavaLangStrictMathNative(helper));
cnameToSim.put("java.lang.Throwable", new JavaLangThrowableNative(helper));
cnameToSim.put("java.lang.Class", new JavaLangClassNative(helper));
cnameToSim.put("java.lang.Package", new JavaLangPackageNative(helper));
cnameToSim.put("java.lang.Thread", new JavaLangThreadNative(helper));
cnameToSim.put("java.lang.ClassLoader", new JavaLangClassLoaderNative(helper));
cnameToSim.put("java.lang.ClassLoader$NativeLibrary", new JavaLangClassLoaderNativeLibraryNative(helper));
cnameToSim.put("java.lang.SecurityManager", new JavaLangSecurityManagerNative(helper));
cnameToSim.put("java.lang.reflect.Field", new JavaLangReflectFieldNative(helper));
cnameToSim.put("java.lang.reflect.Array", new JavaLangReflectArrayNative(helper));
cnameToSim.put("java.lang.reflect.Method", new JavaLangReflectMethodNative(helper));
cnameToSim.put("java.lang.reflect.Constructor", new JavaLangReflectConstructorNative(helper));
cnameToSim.put("java.lang.reflect.Proxy", new JavaLangReflectProxyNative(helper));
cnameToSim.put("java.io.FileInputStream", new JavaIoFileInputStreamNative(helper));
cnameToSim.put("java.io.FileOutputStream", new JavaIoFileOutputStreamNative(helper));
cnameToSim.put("java.io.ObjectInputStream", new JavaIoObjectInputStreamNative(helper));
cnameToSim.put("java.io.ObjectOutputStream", new JavaIoObjectOutputStreamNative(helper));
cnameToSim.put("java.io.ObjectStreamClass", new JavaIoObjectStreamClassNative(helper));
cnameToSim.put("java.io.FileSystem", new JavaIoFileSystemNative(helper));
cnameToSim.put("java.io.FileDescriptor", new JavaIoFileDescriptorNative(helper));
cnameToSim.put("java.util.ResourceBundle", new JavaUtilResourceBundleNative(helper));
cnameToSim.put("java.util.TimeZone", new JavaUtilTimeZoneNative(helper));
cnameToSim.put("java.util.jar.JarFile", new JavaUtilJarJarFileNative(helper));
cnameToSim.put("java.util.zip.CRC32", new JavaUtilZipCRC32Native(helper));
cnameToSim.put("java.util.zip.Inflater", new JavaUtilZipInflaterNative(helper));
cnameToSim.put("java.util.zip.ZipFile", new JavaUtilZipZipFileNative(helper));
cnameToSim.put("java.util.zip.ZipEntry", new JavaUtilZipZipEntryNative(helper));
cnameToSim.put("java.security.AccessController", new JavaSecurityAccessControllerNative(helper));
cnameToSim.put("java.net.InetAddress", new JavaNetInetAddressNative(helper));
cnameToSim.put("java.net.InetAddressImpl", new JavaNetInetAddressImplNative(helper));
cnameToSim.put("sun.misc.Signal", new SunMiscSignalNative(helper));
cnameToSim.put("sun.misc.NativeSignalHandler", new SunMiscSignalHandlerNative(helper));
cnameToSim.put("sun.misc.Unsafe", new SunMiscUnsafeNative(helper));
}
protected final HashMap<String, NativeMethodClass> cnameToSim = new HashMap<String, NativeMethodClass>(100);
private final boolean DEBUG = false;
/**
* The entry point of native method simulation.
*
* @param method,
* must be a native method
* @param thisVar,
* the variable represent @this, it can be null if the method is static
* @param returnVar,
* the variable represent @return it is null if the method has no return
* @param params,
* array of parameters.
*/
public boolean process(SootMethod method, ReferenceVariable thisVar, ReferenceVariable returnVar,
ReferenceVariable params[]) {<FILL_FUNCTION_BODY>}
}
|
String cname = method.getDeclaringClass().getName();
NativeMethodClass clsSim = cnameToSim.get(cname);
// logger.debug(""+method.toString());
if (clsSim == null) {
// logger.warn("it is unsafe to simulate the method ");
// logger.debug(" "+method.toString());
// throw new NativeMethodNotSupportedException(method);
return false;
} else {
try {
clsSim.simulateMethod(method, thisVar, returnVar, params);
return true;
} catch (NativeMethodNotSupportedException e) {
if (DEBUG) {
logger.warn("it is unsafe to simulate the method ");
logger.debug(" " + method.toString());
}
}
return false;
}
| 1,318
| 207
| 1,525
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/reflection/ConstantInvokeMethodBaseTransformer.java
|
ConstantInvokeMethodBaseTransformer
|
internalTransform
|
class ConstantInvokeMethodBaseTransformer extends SceneTransformer {
private static final Logger logger = LoggerFactory.getLogger(ConstantInvokeMethodBaseTransformer.class);
private final static String INVOKE_SIG
= "<java.lang.reflect.Method: java.lang.Object invoke(java.lang.Object,java.lang.Object[])>";
public ConstantInvokeMethodBaseTransformer(Singletons.Global g) {
}
public static ConstantInvokeMethodBaseTransformer v() {
return G.v().soot_jimple_toolkits_reflection_ConstantInvokeMethodBaseTransformer();
}
@Override
protected void internalTransform(String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}
|
final boolean verbose = options.containsKey("verbose");
final Jimple jimp = Jimple.v();
for (SootClass sootClass : Scene.v().getApplicationClasses()) {
// In some rare cases we will have application classes that are not resolved due to being located in excluded packages
// (e.g., the ServiceConnection class constructed by FlowDroid:
// soot.jimple.infoflow.cfg.LibraryClassPatcher#patchServiceConnection)
if (sootClass.resolvingLevel() < SootClass.BODIES) {
continue;
}
for (SootMethod sootMethod : sootClass.getMethods()) {
Body body = sootMethod.retrieveActiveBody();
final Chain<Local> locals = body.getLocals();
final Chain<Unit> units = body.getUnits();
for (Iterator<Unit> iterator = units.snapshotIterator(); iterator.hasNext();) {
Stmt s = (Stmt) iterator.next();
if (s.containsInvokeExpr()) {
InvokeExpr invokeExpr = s.getInvokeExpr();
if (INVOKE_SIG.equals(invokeExpr.getMethod().getSignature())) {
Value arg0 = invokeExpr.getArg(0);
if (arg0 instanceof StringConstant) {
Local newLocal = jimp.newLocal("sc" + locals.size(), arg0.getType());
locals.add(newLocal);
units.insertBefore(jimp.newAssignStmt(newLocal, (StringConstant) arg0), s);
invokeExpr.setArg(0, newLocal);
if (verbose) {
logger.debug("Replaced constant base object of Method.invoke() by local in: " + sootMethod.toString());
}
}
}
}
}
}
}
| 198
| 462
| 660
|
<methods>public non-sealed void <init>() ,public final void transform(java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(java.lang.String) ,public final void transform() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/AbstractStaticnessCorrector.java
|
AbstractStaticnessCorrector
|
isTypeLoaded
|
class AbstractStaticnessCorrector extends BodyTransformer {
protected static boolean isClassLoaded(SootClass sc) {
return sc.resolvingLevel() >= SootClass.SIGNATURES;
}
protected static boolean isTypeLoaded(Type tp) {<FILL_FUNCTION_BODY>}
}
|
if (tp instanceof RefType) {
RefType rt = (RefType) tp;
if (rt.hasSootClass()) {
return isClassLoaded(rt.getSootClass());
}
}
return false;
| 82
| 65
| 147
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/ConditionalBranchFolder.java
|
ConditionalBranchFolder
|
internalTransform
|
class ConditionalBranchFolder extends BodyTransformer {
private static final Logger logger = LoggerFactory.getLogger(ConditionalBranchFolder.class);
public ConditionalBranchFolder(Singletons.Global g) {
}
public static ConditionalBranchFolder v() {
return G.v().soot_jimple_toolkits_scalar_ConditionalBranchFolder();
}
@Override
protected void internalTransform(Body body, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>} // foldBranches
}
|
StmtBody stmtBody = (StmtBody) body;
if (Options.v().verbose()) {
logger.debug("[" + stmtBody.getMethod().getName() + "] Folding conditional branches...");
}
int numTrue = 0, numFalse = 0;
Chain<Unit> units = stmtBody.getUnits();
for (Iterator<Unit> it = units.snapshotIterator(); it.hasNext();) {
Unit stmt = it.next();
if (stmt instanceof IfStmt) {
IfStmt ifs = (IfStmt) stmt;
// check for constant-valued conditions
Value cond = Evaluator.getConstantValueOf(ifs.getCondition());
if (cond != null) {
assert (cond instanceof IntConstant);
if (((IntConstant) cond).value == 1) {
// if condition always true, convert if to goto
units.swapWith(stmt, Jimple.v().newGotoStmt(ifs.getTarget()));
numTrue++;
} else {
// if condition is always false, just remove it
assert (((IntConstant) cond).value == 0);// only true/false
units.remove(stmt);
numFalse++;
}
}
}
}
if (Options.v().verbose()) {
logger.debug(
"[" + stmtBody.getMethod().getName() + "] Folded " + numTrue + " true, " + numFalse + " conditional branches");
}
| 147
| 383
| 530
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/ConstantPropagatorAndFolder.java
|
ConstantPropagatorAndFolder
|
internalTransform
|
class ConstantPropagatorAndFolder extends BodyTransformer {
private static final Logger logger = LoggerFactory.getLogger(ConstantPropagatorAndFolder.class);
public ConstantPropagatorAndFolder(Singletons.Global g) {
}
public static ConstantPropagatorAndFolder v() {
return G.v().soot_jimple_toolkits_scalar_ConstantPropagatorAndFolder();
}
@Override
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}
|
int numFolded = 0;
int numPropagated = 0;
if (Options.v().verbose()) {
logger.debug("[" + b.getMethod().getName() + "] Propagating and folding constants...");
}
UnitGraph g = ExceptionalUnitGraphFactory.createExceptionalUnitGraph(b);
LocalDefs localDefs = G.v().soot_toolkits_scalar_LocalDefsFactory().newLocalDefs(g);
// Perform a constant/local propagation pass.
// go through each use box in each statement
for (Unit u : (new PseudoTopologicalOrderer<Unit>()).newList(g, false)) {
// propagation pass
for (ValueBox useBox : u.getUseBoxes()) {
Value value = useBox.getValue();
if (value instanceof Local) {
Local local = (Local) value;
List<Unit> defsOfUse = localDefs.getDefsOfAt(local, u);
if (defsOfUse.size() == 1) {
DefinitionStmt defStmt = (DefinitionStmt) defsOfUse.get(0);
Value rhs = defStmt.getRightOp();
if (rhs instanceof NumericConstant || rhs instanceof StringConstant || rhs instanceof NullConstant) {
if (useBox.canContainValue(rhs)) {
useBox.setValue(rhs);
numPropagated++;
}
} else if (rhs instanceof CastExpr) {
CastExpr ce = (CastExpr) rhs;
if (ce.getCastType() instanceof RefType && ce.getOp() instanceof NullConstant) {
defStmt.getRightOpBox().setValue(NullConstant.v());
numPropagated++;
}
}
}
}
}
// folding pass
for (ValueBox useBox : u.getUseBoxes()) {
Value value = useBox.getValue();
if (!(value instanceof Constant)) {
if (Evaluator.isValueConstantValued(value)) {
Value constValue = Evaluator.getConstantValueOf(value);
if (useBox.canContainValue(constValue)) {
useBox.setValue(constValue);
numFolded++;
}
}
}
}
}
if (Options.v().verbose()) {
logger.debug("[" + b.getMethod().getName() + "] Propagated: " + numPropagated + ", Folded: " + numFolded);
}
| 147
| 645
| 792
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/DefaultLocalCreation.java
|
DefaultLocalCreation
|
newLocal
|
class DefaultLocalCreation extends LocalCreation {
/** if no prefix is given, this one's used */
public static final String DEFAULT_PREFIX = "soot";
private final Set<String> locals;
private int counter;
/**
* all actions are done on the given locals-chain. as prefix the <code>DEFAULT-PREFIX</code> will be used.
*
* @param locals
* the locals-chain of a Jimple-body
*/
public DefaultLocalCreation(Collection<Local> locals) {
this(locals, DEFAULT_PREFIX);
}
/**
* whenever <code>newLocal(type)</code> will be called, the given prefix is used.
*
* @param locals
* the locals-chain of a Jimple-body
* @param prefix
* prefix overrides the DEFAULT-PREFIX
*/
public DefaultLocalCreation(Collection<Local> locals, String prefix) {
super(locals, prefix);
this.locals = new HashSet<String>(locals.size());
for (Local l : locals) {
this.locals.add(l.getName());
}
this.counter = 0; // try the first one with suffix 0.
}
@Override
public Local newLocal(Type type) {
return newLocal(this.prefix, type);
}
@Override
public Local newLocal(String prefix, Type type) {<FILL_FUNCTION_BODY>}
}
|
int suffix = prefix.equals(this.prefix) ? this.counter : 0;
while (this.locals.contains(prefix + suffix)) {
suffix++;
}
if (prefix.equals(this.prefix)) {
this.counter = suffix + 1;
}
String newName = prefix + suffix;
Local newLocal = Jimple.v().newLocal(newName, type);
this.localChain.add(newLocal);
this.locals.add(newName);
return newLocal;
| 382
| 133
| 515
|
<methods>public void <init>(Collection<soot.Local>, java.lang.String) ,public abstract soot.Local newLocal(soot.Type) ,public abstract soot.Local newLocal(java.lang.String, soot.Type) <variables>protected final non-sealed Collection<soot.Local> localChain,protected final non-sealed java.lang.String prefix
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/EmptySwitchEliminator.java
|
EmptySwitchEliminator
|
internalTransform
|
class EmptySwitchEliminator extends BodyTransformer {
public EmptySwitchEliminator(Singletons.Global g) {
}
public static EmptySwitchEliminator v() {
return G.v().soot_jimple_toolkits_scalar_EmptySwitchEliminator();
}
@Override
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}
|
final Chain<Unit> units = b.getUnits();
for (Iterator<Unit> it = units.snapshotIterator(); it.hasNext();) {
Unit u = it.next();
if (u instanceof LookupSwitchStmt) {
LookupSwitchStmt sw = (LookupSwitchStmt) u;
if (sw.getTargetCount() == 0) {
Unit defaultTarget = sw.getDefaultTarget();
if (defaultTarget != null) {
units.swapWith(sw, Jimple.v().newGotoStmt(defaultTarget));
}
}
}
}
| 121
| 154
| 275
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/EqualLocalsAnalysis.java
|
EqualLocalsAnalysis
|
flowThrough
|
class EqualLocalsAnalysis extends ForwardFlowAnalysis<Unit, FlowSet<Object>> {
protected Local l = null;
protected Stmt s = null;
public EqualLocalsAnalysis(UnitGraph g) {
super(g);
// analysis is done on-demand, not now
}
/** Returns a list of EquivalentValue wrapped Locals and Refs that must always be equal to l at s */
public List<Object> getCopiesOfAt(Local l, Stmt s) {
this.l = l;
this.s = s;
doAnalysis();
FlowSet<Object> fs = (FlowSet<Object>) getFlowBefore(s);
ArrayList<Object> aliasList = new ArrayList<Object>(fs.size());
for (Object o : fs) {
aliasList.add(o);
}
if (!aliasList.contains(new EquivalentValue(l))) {
aliasList.clear();
aliasList.trimToSize();
}
return aliasList;
}
@Override
protected void flowThrough(FlowSet<Object> in, Unit unit, FlowSet<Object> out) {<FILL_FUNCTION_BODY>}
@Override
protected void merge(FlowSet<Object> in1, FlowSet<Object> in2, FlowSet<Object> out) {
in1.intersection(in2, out);
}
@Override
protected void copy(FlowSet<Object> source, FlowSet<Object> dest) {
source.copy(dest);
}
@Override
protected FlowSet<Object> entryInitialFlow() {
return new ArraySparseSet<Object>();
}
@Override
protected FlowSet<Object> newInitialFlow() {
return new ArraySparseSet<Object>();
}
}
|
in.copy(out);
// get list of definitions at this unit
List<EquivalentValue> newDefs = new ArrayList<EquivalentValue>();
for (ValueBox next : unit.getDefBoxes()) {
newDefs.add(new EquivalentValue(next.getValue()));
}
// If the local of interest was defined in this statement, then we must
// generate a new list of aliases to it starting here
if (newDefs.contains(new EquivalentValue(l))) {
List<Stmt> existingDefStmts = new ArrayList<Stmt>();
for (Object o : out) {
if (o instanceof Stmt) {
existingDefStmts.add((Stmt) o);
}
}
out.clear();
for (EquivalentValue next : newDefs) {
out.add(next);
}
if (unit instanceof DefinitionStmt) {
DefinitionStmt du = (DefinitionStmt) unit;
if (!du.containsInvokeExpr() && !(unit instanceof IdentityStmt)) {
out.add(new EquivalentValue(du.getRightOp()));
}
}
for (Stmt def : existingDefStmts) {
List<Value> sNewDefs = new ArrayList<Value>();
for (ValueBox next : def.getDefBoxes()) {
sNewDefs.add(next.getValue());
}
if (def instanceof DefinitionStmt) {
if (out.contains(new EquivalentValue(((DefinitionStmt) def).getRightOp()))) {
for (Value v : sNewDefs) {
out.add(new EquivalentValue(v));
}
} else {
for (Value v : sNewDefs) {
out.remove(new EquivalentValue(v));
}
}
}
}
} else {
if (unit instanceof DefinitionStmt) {
if (out.contains(new EquivalentValue(l))) {
if (out.contains(new EquivalentValue(((DefinitionStmt) unit).getRightOp()))) {
for (EquivalentValue ev : newDefs) {
out.add(ev);
}
} else {
for (EquivalentValue ev : newDefs) {
out.remove(ev);
}
}
} else {
// before finding a def for l, just keep track of all definition statements
// note that if l is redefined, then we'll miss existing values that then
// become equal to l. It is suboptimal but correct to miss these values.
out.add(unit);
}
}
}
| 456
| 659
| 1,115
|
<methods>public void <init>(DirectedGraph<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/Evaluator.java
|
Evaluator
|
getConstantValueOf
|
class Evaluator {
public static boolean isValueConstantValued(Value op) {
if (op instanceof Constant) {
return true;
} else if (op instanceof UnopExpr) {
Value innerOp = ((UnopExpr) op).getOp();
if (innerOp == NullConstant.v()) {
// operations on null will throw an exception and the operation
// is therefore not considered constant-valued; see posting on Soot list
// on 18 September 2007 14:36
return false;
}
if (isValueConstantValued(innerOp)) {
return true;
}
} else if (op instanceof BinopExpr) {
final BinopExpr binExpr = (BinopExpr) op;
final Value op1 = binExpr.getOp1();
final Value op2 = binExpr.getOp2();
// Only evaluate these checks once, and use the result multiple times
final boolean isOp1Constant = isValueConstantValued(op1);
final boolean isOp2Constant = isValueConstantValued(op2);
/* Handle weird cases. */
if (op instanceof DivExpr || op instanceof RemExpr) {
if (!isOp1Constant || !isOp2Constant) {
return false;
}
/* check for a 0 value. If so, punt. */
Value c2 = getConstantValueOf(op2);
if ((c2 instanceof IntConstant && ((IntConstant) c2).value == 0)
|| (c2 instanceof LongConstant && ((LongConstant) c2).value == 0)) {
return false;
}
}
if (isOp1Constant && isOp2Constant) {
return true;
}
}
return false;
} // isValueConstantValued
/**
* Returns the constant value of <code>op</code> if it is easy to find the constant value; else returns <code>null</code>.
*/
public static Value getConstantValueOf(Value op) {<FILL_FUNCTION_BODY>} // getConstantValueOf
}
|
if (!isValueConstantValued(op)) {
return null;
}
if (op instanceof Constant) {
return op;
} else if (op instanceof UnopExpr) {
Value c = getConstantValueOf(((UnopExpr) op).getOp());
if (op instanceof NegExpr) {
return ((NumericConstant) c).negate();
}
} else if (op instanceof BinopExpr) {
final BinopExpr binExpr = (BinopExpr) op;
final Value c1 = getConstantValueOf(binExpr.getOp1());
final Value c2 = getConstantValueOf(binExpr.getOp2());
if (op instanceof AddExpr) {
return ((NumericConstant) c1).add((NumericConstant) c2);
} else if (op instanceof SubExpr) {
return ((NumericConstant) c1).subtract((NumericConstant) c2);
} else if (op instanceof MulExpr) {
return ((NumericConstant) c1).multiply((NumericConstant) c2);
} else if (op instanceof DivExpr) {
return ((NumericConstant) c1).divide((NumericConstant) c2);
} else if (op instanceof RemExpr) {
return ((NumericConstant) c1).remainder((NumericConstant) c2);
} else if (op instanceof EqExpr || op instanceof NeExpr) {
if (c1 instanceof NumericConstant) {
if (!(c2 instanceof NumericConstant)) {
return IntConstant.v(0);
} else if (op instanceof EqExpr) {
return ((NumericConstant) c1).equalEqual((NumericConstant) c2);
} else if (op instanceof NeExpr) {
return ((NumericConstant) c1).notEqual((NumericConstant) c2);
}
} else if (c1 instanceof StringConstant || c1 instanceof NullConstant || c1 instanceof ClassConstant) {
boolean equality = c1.equals(c2);
boolean truth = (op instanceof EqExpr) ? equality : !equality;
return IntConstant.v(truth ? 1 : 0);
}
throw new RuntimeException("constant neither numeric nor string");
} else if (op instanceof GtExpr) {
return ((NumericConstant) c1).greaterThan((NumericConstant) c2);
} else if (op instanceof GeExpr) {
return ((NumericConstant) c1).greaterThanOrEqual((NumericConstant) c2);
} else if (op instanceof LtExpr) {
return ((NumericConstant) c1).lessThan((NumericConstant) c2);
} else if (op instanceof LeExpr) {
return ((NumericConstant) c1).lessThanOrEqual((NumericConstant) c2);
} else if (op instanceof AndExpr) {
return ((ArithmeticConstant) c1).and((ArithmeticConstant) c2);
} else if (op instanceof OrExpr) {
return ((ArithmeticConstant) c1).or((ArithmeticConstant) c2);
} else if (op instanceof XorExpr) {
return ((ArithmeticConstant) c1).xor((ArithmeticConstant) c2);
} else if (op instanceof ShlExpr) {
return ((ArithmeticConstant) c1).shiftLeft((ArithmeticConstant) c2);
} else if (op instanceof ShrExpr) {
return ((ArithmeticConstant) c1).shiftRight((ArithmeticConstant) c2);
} else if (op instanceof UshrExpr) {
return ((ArithmeticConstant) c1).unsignedShiftRight((ArithmeticConstant) c2);
} else if (op instanceof CmpExpr) {
if ((c1 instanceof LongConstant) && (c2 instanceof LongConstant)) {
return ((LongConstant) c1).cmp((LongConstant) c2);
} else {
throw new IllegalArgumentException("CmpExpr: LongConstant(s) expected");
}
} else if ((op instanceof CmpgExpr) || (op instanceof CmplExpr)) {
if ((c1 instanceof RealConstant) && (c2 instanceof RealConstant)) {
if (op instanceof CmpgExpr) {
return ((RealConstant) c1).cmpg((RealConstant) c2);
} else if (op instanceof CmplExpr) {
return ((RealConstant) c1).cmpl((RealConstant) c2);
}
} else {
throw new IllegalArgumentException("CmpExpr: RealConstant(s) expected");
}
} else {
throw new RuntimeException("unknown binop: " + op);
}
}
throw new RuntimeException("couldn't getConstantValueOf of: " + op);
| 521
| 1,152
| 1,673
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/FastAvailableExpressionsAnalysis.java
|
FastAvailableExpressionsAnalysis
|
flowThrough
|
class FastAvailableExpressionsAnalysis extends ForwardFlowAnalysis<Unit, FlowSet<Value>> {
protected final FlowSet<Value> emptySet = new ToppedSet<Value>(new ArraySparseSet<Value>());
protected final SideEffectTester st;
/** maps an rhs to its containing stmt. object equality in rhs. */
protected final Map<Value, Unit> rhsToContainingStmt;
protected final Map<Unit, FlowSet<Value>> unitToGenerateSet;
public FastAvailableExpressionsAnalysis(DirectedGraph<Unit> dg, SootMethod m, SideEffectTester st) {
super(dg);
this.st = st;
this.rhsToContainingStmt = new HashMap<Value, Unit>();
this.unitToGenerateSet = new HashMap<Unit, FlowSet<Value>>(dg.size() * 2 + 1, 0.7f);
// Create generate sets
for (Unit s : dg) {
FlowSet<Value> genSet = this.emptySet.clone();
// In Jimple, expressions only occur as the RHS of an
// AssignStmt.
if (s instanceof AssignStmt) {
Value gen = ((AssignStmt) s).getRightOp();
if (gen instanceof Expr || gen instanceof FieldRef) {
this.rhsToContainingStmt.put(gen, s);
if (!(gen instanceof NewExpr || gen instanceof NewArrayExpr || gen instanceof NewMultiArrayExpr
|| gen instanceof InvokeExpr)) {
genSet.add(gen, genSet);
}
}
}
this.unitToGenerateSet.put(s, genSet);
}
doAnalysis();
}
@Override
protected FlowSet<Value> newInitialFlow() {
FlowSet<Value> newSet = emptySet.clone();
((ToppedSet<Value>) newSet).setTop(true);
return newSet;
}
@Override
protected FlowSet<Value> entryInitialFlow() {
return emptySet.clone();
}
@Override
protected void flowThrough(FlowSet<Value> in, Unit u, FlowSet<Value> out) {<FILL_FUNCTION_BODY>}
@Override
protected void merge(FlowSet<Value> inSet1, FlowSet<Value> inSet2, FlowSet<Value> outSet) {
inSet1.intersection(inSet2, outSet);
}
@Override
protected void copy(FlowSet<Value> sourceSet, FlowSet<Value> destSet) {
sourceSet.copy(destSet);
}
}
|
in.copy(out);
if (((ToppedSet<Value>) in).isTop()) {
return;
}
// Perform generation
out.union(unitToGenerateSet.get(u), out);
// Perform kill.
if (((ToppedSet<Value>) out).isTop()) {
throw new RuntimeException("trying to kill on topped set!");
}
// iterate over things (avail) in out set.
for (Value avail : new ArrayList<Value>(out.toList())) {
if (avail instanceof FieldRef) {
if (st.unitCanWriteTo(u, avail)) {
out.remove(avail, out);
}
} else {
for (ValueBox vb : avail.getUseBoxes()) {
Value use = vb.getValue();
if (st.unitCanWriteTo(u, use)) {
out.remove(avail, out);
}
}
}
}
| 663
| 254
| 917
|
<methods>public void <init>(DirectedGraph<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/FieldStaticnessCorrector.java
|
FieldStaticnessCorrector
|
internalTransform
|
class FieldStaticnessCorrector extends AbstractStaticnessCorrector {
public FieldStaticnessCorrector(Singletons.Global g) {
}
public static FieldStaticnessCorrector v() {
return G.v().soot_jimple_toolkits_scalar_FieldStaticnessCorrector();
}
@Override
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}
|
// Some apps reference static fields as instance fields. We need to fix
// this for not breaking the client analysis.
for (Unit u : b.getUnits()) {
if (u instanceof AssignStmt) {
AssignStmt assignStmt = (AssignStmt) u;
if (assignStmt.containsFieldRef()) {
FieldRef ref = assignStmt.getFieldRef();
// Make sure that the target class has already been loaded
if (isTypeLoaded(ref.getFieldRef().type())) {
try {
if (ref instanceof InstanceFieldRef) {
SootField fld = ref.getField();
if (fld != null && fld.isStatic()) {
if (assignStmt.getLeftOp() == ref) {
assignStmt.setLeftOp(Jimple.v().newStaticFieldRef(ref.getField().makeRef()));
} else if (assignStmt.getRightOp() == ref) {
assignStmt.setRightOp(Jimple.v().newStaticFieldRef(ref.getField().makeRef()));
}
}
}
} catch (ConflictingFieldRefException ex) {
// That field is broken, just don't touch it
}
}
}
}
}
| 125
| 322
| 447
|
<methods>public non-sealed void <init>() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/IdentityCastEliminator.java
|
IdentityCastEliminator
|
internalTransform
|
class IdentityCastEliminator extends BodyTransformer {
public IdentityCastEliminator(Singletons.Global g) {
}
public static IdentityCastEliminator v() {
return G.v().soot_jimple_toolkits_scalar_IdentityCastEliminator();
}
@Override
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}
|
for (Iterator<Unit> unitIt = b.getUnits().iterator(); unitIt.hasNext();) {
Unit curUnit = unitIt.next();
if (curUnit instanceof AssignStmt) {
final AssignStmt assignStmt = (AssignStmt) curUnit;
final Value leftOp = assignStmt.getLeftOp();
final Value rightOp = assignStmt.getRightOp();
if (leftOp instanceof Local && rightOp instanceof CastExpr) {
final CastExpr ce = (CastExpr) rightOp;
final Value castOp = ce.getOp();
// If this a cast such as a = (X) a, we can remove the whole line.
// Otherwise, if only the types match, we can replace the typecast
// with a normal assignment.
if (castOp.getType() == ce.getCastType()) {
if (leftOp == castOp) {
unitIt.remove();
} else {
assignStmt.setRightOp(castOp);
}
}
}
}
}
| 121
| 264
| 385
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/MethodStaticnessCorrector.java
|
MethodStaticnessCorrector
|
internalTransform
|
class MethodStaticnessCorrector extends AbstractStaticnessCorrector {
private static final Logger logger = LoggerFactory.getLogger(MethodStaticnessCorrector.class);
public MethodStaticnessCorrector(Singletons.Global g) {
}
public static MethodStaticnessCorrector v() {
return G.v().soot_jimple_toolkits_scalar_MethodStaticnessCorrector();
}
@Override
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
/**
* Checks whether the given method can be made static, i.e., does not reference the "this" object
*
* @param target
* The method to check
* @return True if the given method can be made static, otherwise false
*/
private boolean canBeMadeStatic(SootMethod target) {
if (!target.hasActiveBody()) {
return false;
}
Body body = target.getActiveBody();
Value thisLocal = body.getThisLocal();
for (Unit u : body.getUnits()) {
for (ValueBox vb : u.getUseBoxes()) {
if (vb.getValue() == thisLocal) {
return false;
}
}
}
return true;
}
}
|
for (Iterator<Unit> unitIt = b.getUnits().snapshotIterator(); unitIt.hasNext();) {
Unit u = unitIt.next();
if (u instanceof Stmt) {
Stmt s = (Stmt) u;
if (s.containsInvokeExpr()) {
InvokeExpr iexpr = s.getInvokeExpr();
if (iexpr instanceof StaticInvokeExpr) {
SootMethodRef methodRef = iexpr.getMethodRef();
if (isClassLoaded(methodRef.declaringClass())) {
SootMethod target = Scene.v().grabMethod(methodRef.getSignature());
if (target != null && !target.isStatic()) {
if (canBeMadeStatic(target)) {
// Remove the this-assignment to prevent
// 'this-assignment in a static method!' exception
Body targetBody = target.getActiveBody();
targetBody.getUnits().remove(targetBody.getThisUnit());
target.setModifiers(target.getModifiers() | Modifier.STATIC);
logger.warn(target.getName() + " changed into a static method");
}
}
}
}
}
}
}
| 342
| 305
| 647
|
<methods>public non-sealed void <init>() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/SlowAvailableExpressionsAnalysis.java
|
SlowAvailableExpressionsAnalysis
|
flowThrough
|
class SlowAvailableExpressionsAnalysis extends ForwardFlowAnalysis<Unit, FlowSet<Value>> {
protected final Map<Unit, BoundedFlowSet<Value>> unitToGenerateSet;
protected final Map<Unit, BoundedFlowSet<Value>> unitToPreserveSet;
/** maps an rhs to its containing stmt. object equality in rhs. */
protected final Map<Value, Stmt> rhsToContainingStmt;
protected final FlowSet<Value> emptySet;
/** maps a Value to its EquivalentValue */
private final HashMap<Value, EquivalentValue> valueToEquivValue;
public SlowAvailableExpressionsAnalysis(DirectedGraph<Unit> dg) {
super(dg);
this.valueToEquivValue = new HashMap<Value, EquivalentValue>();
this.rhsToContainingStmt = new HashMap<Value, Stmt>();
/* we need a universe of all of the expressions. */
HashSet<Value> exprs = new HashSet<Value>();
// Consider "a + b". containingExprs maps a and b (object equality) both to "a + b" (equivalence).
Map<EquivalentValue, Chain<EquivalentValue>> containingExprs = new HashMap<EquivalentValue, Chain<EquivalentValue>>();
Map<EquivalentValue, Chain<Value>> equivValToSiblingList = new HashMap<EquivalentValue, Chain<Value>>();
// Create the set of all expressions, and a map from values to their containing expressions.
final UnitGraph g = (UnitGraph) dg;
for (Unit u : g.getBody().getUnits()) {
Stmt s = (Stmt) u;
if (s instanceof AssignStmt) {
Value v = ((AssignStmt) s).getRightOp();
rhsToContainingStmt.put(v, s);
EquivalentValue ev = valueToEquivValue.get(v);
if (ev == null) {
valueToEquivValue.put(v, ev = new EquivalentValue(v));
}
Chain<Value> sibList = equivValToSiblingList.get(ev);
if (sibList == null) {
equivValToSiblingList.put(ev, sibList = new HashChain<Value>());
}
if (!sibList.contains(v)) {
sibList.add(v);
}
if (!(v instanceof Expr)) {
continue;
}
if (!exprs.contains(v)) {
exprs.add(v);
// Add map values for contained objects.
for (ValueBox vb : v.getUseBoxes()) {
Value o = vb.getValue();
EquivalentValue eo = valueToEquivValue.get(o);
if (eo == null) {
valueToEquivValue.put(o, eo = new EquivalentValue(o));
}
sibList = equivValToSiblingList.get(eo);
if (sibList == null) {
equivValToSiblingList.put(eo, sibList = new HashChain<Value>());
}
if (!sibList.contains(o)) {
sibList.add(o);
}
Chain<EquivalentValue> l = containingExprs.get(eo);
if (l == null) {
containingExprs.put(eo, l = new HashChain<EquivalentValue>());
}
if (!l.contains(ev)) {
l.add(ev);
}
}
}
}
}
FlowUniverse<Value> exprUniv = new ArrayFlowUniverse<Value>(exprs.toArray(new Value[exprs.size()]));
this.emptySet = new ArrayPackedSet<Value>(exprUniv);
// Create preserve sets.
this.unitToPreserveSet = new HashMap<Unit, BoundedFlowSet<Value>>(g.size() * 2 + 1, 0.7f);
for (Unit s : g) {
BoundedFlowSet<Value> killSet = new ArrayPackedSet<Value>(exprUniv);
// We need to do more! In particular handle invokeExprs, etc.
// For each def (say of x), kill the set of exprs containing x.
for (ValueBox box : s.getDefBoxes()) {
Chain<EquivalentValue> c = containingExprs.get(valueToEquivValue.get(box.getValue()));
if (c != null) {
for (EquivalentValue container : c) {
// Add all siblings of it.next().
for (Value sibVal : equivValToSiblingList.get(container)) {
killSet.add(sibVal);
}
}
}
}
// Store complement
killSet.complement(killSet);
unitToPreserveSet.put(s, killSet);
}
// Create generate sets
this.unitToGenerateSet = new HashMap<Unit, BoundedFlowSet<Value>>(g.size() * 2 + 1, 0.7f);
for (Unit s : g) {
BoundedFlowSet<Value> genSet = new ArrayPackedSet<Value>(exprUniv);
// In Jimple, expressions only occur as the RHS of an AssignStmt.
if (s instanceof AssignStmt) {
AssignStmt as = (AssignStmt) s;
Value gen = as.getRightOp();
if (gen instanceof Expr) {
if (!(gen instanceof NewExpr || gen instanceof NewArrayExpr || gen instanceof NewMultiArrayExpr
|| gen instanceof InvokeExpr)) {
genSet.add(gen);
}
}
}
// remove the kill set
genSet.intersection(unitToPreserveSet.get(s), genSet);
unitToGenerateSet.put(s, genSet);
}
doAnalysis();
}
@Override
protected FlowSet<Value> newInitialFlow() {
BoundedFlowSet<Value> out = (BoundedFlowSet<Value>) emptySet.clone();
out.complement(out);
return out;
}
@Override
protected FlowSet<Value> entryInitialFlow() {
return emptySet.clone();
}
@Override
protected void flowThrough(FlowSet<Value> in, Unit unit, FlowSet<Value> out) {<FILL_FUNCTION_BODY>}
@Override
protected void merge(FlowSet<Value> inSet1, FlowSet<Value> inSet2, FlowSet<Value> outSet) {
inSet1.intersection(inSet2, outSet);
}
@Override
protected void copy(FlowSet<Value> sourceSet, FlowSet<Value> destSet) {
sourceSet.copy(destSet);
}
}
|
// Perform kill
in.intersection(unitToPreserveSet.get(unit), out);
// Perform generation
out.union(unitToGenerateSet.get(unit));
| 1,747
| 51
| 1,798
|
<methods>public void <init>(DirectedGraph<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/pre/BusyCodeMotion.java
|
BusyCodeMotion
|
internalTransform
|
class BusyCodeMotion extends BodyTransformer {
private static final Logger logger = LoggerFactory.getLogger(BusyCodeMotion.class);
private static final String PREFIX = "$bcm";
public BusyCodeMotion(Singletons.Global g) {
}
public static BusyCodeMotion v() {
return G.v().soot_jimple_toolkits_scalar_pre_BusyCodeMotion();
}
/**
* performs the busy code motion.
*/
@Override
protected void internalTransform(Body b, String phaseName, Map<String, String> opts) {<FILL_FUNCTION_BODY>}
private Unit getFirstNonIdentityStmt(Body b) {
for (Unit u : b.getUnits()) {
if (!(u instanceof IdentityStmt)) {
return u;
}
}
return null;
}
}
|
final BCMOptions options = new BCMOptions(opts);
if (Options.v().verbose()) {
logger.debug("[" + b.getMethod().getName() + "] performing Busy Code Motion...");
}
CriticalEdgeRemover.v().transform(b, phaseName + ".cer");
UnitGraph graph = new BriefUnitGraph(b);
/* Map each unit to its RHS. Take only BinopExpr and ConcreteRef */
Map<Unit, EquivalentValue> unitToEquivRhs = new UnitMap<EquivalentValue>(b, graph.size() + 1, 0.7f) {
@Override
protected EquivalentValue mapTo(Unit unit) {
Value tmp = SootFilter.noInvokeRhs(unit);
Value tmp2 = SootFilter.binop(tmp);
if (tmp2 == null) {
tmp2 = SootFilter.concreteRef(tmp);
}
return SootFilter.equiVal(tmp2);
}
};
/* Same as before, but without exception-throwing expressions */
Map<Unit, EquivalentValue> unitToNoExceptionEquivRhs = new UnitMap<EquivalentValue>(b, graph.size() + 1, 0.7f) {
@Override
protected EquivalentValue mapTo(Unit unit) {
return SootFilter.equiVal(SootFilter.noExceptionThrowing(SootFilter.binopRhs(unit)));
}
};
final Scene sc = Scene.v();
/* if a more precise sideeffect-tester comes out, please change it here! */
final SideEffectTester sideEffect;
if (sc.hasCallGraph() && !options.naive_side_effect()) {
sideEffect = new PASideEffectTester();
} else {
sideEffect = new NaiveSideEffectTester();
}
sideEffect.newMethod(b.getMethod());
final UpSafetyAnalysis upSafe = new UpSafetyAnalysis(graph, unitToEquivRhs, sideEffect);
final DownSafetyAnalysis downSafe = new DownSafetyAnalysis(graph, unitToNoExceptionEquivRhs, sideEffect);
final EarliestnessComputation earliest = new EarliestnessComputation(graph, upSafe, downSafe, sideEffect);
final LocalCreation localCreation = sc.createLocalCreation(b.getLocals(), PREFIX);
final HashMap<EquivalentValue, Local> expToHelper = new HashMap<EquivalentValue, Local>();
Chain<Unit> unitChain = b.getUnits();
/* insert the computations at the earliest positions */
for (Iterator<Unit> unitIt = unitChain.snapshotIterator(); unitIt.hasNext();) {
Unit currentUnit = unitIt.next();
for (EquivalentValue equiVal : earliest.getFlowBefore(currentUnit)) {
/* get the unic helper-name for this expression */
Local helper = expToHelper.get(equiVal);
if (helper == null) {
helper = localCreation.newLocal(equiVal.getType());
expToHelper.put(equiVal, helper);
}
// Make sure not to place any stuff inside the identity block at
// the beginning of the method
if (currentUnit instanceof IdentityStmt) {
currentUnit = getFirstNonIdentityStmt(b);
}
/* insert a new Assignment-stmt before the currentUnit */
Value insertValue = Jimple.cloneIfNecessary(equiVal.getValue());
Unit firstComp = Jimple.v().newAssignStmt(helper, insertValue);
unitChain.insertBefore(firstComp, currentUnit);
}
}
/* replace old computations by the helper-vars */
for (Unit currentUnit : unitChain) {
EquivalentValue rhs = unitToEquivRhs.get(currentUnit);
if (rhs != null) {
Local helper = expToHelper.get(rhs);
if (helper != null) {
((AssignStmt) currentUnit).setRightOp(helper);
}
}
}
if (Options.v().verbose()) {
logger.debug("[" + b.getMethod().getName() + "] Busy Code Motion done!");
}
| 237
| 1,075
| 1,312
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/pre/DownSafetyAnalysis.java
|
DownSafetyAnalysis
|
flowThrough
|
class DownSafetyAnalysis extends BackwardFlowAnalysis<Unit, FlowSet<EquivalentValue>> {
private final SideEffectTester sideEffect;
private final Map<Unit, EquivalentValue> unitToGenerateMap;
private final BoundedFlowSet<EquivalentValue> set;
/**
* This constructor should not be used, and will throw a runtime-exception!
*/
@Deprecated
public DownSafetyAnalysis(DirectedGraph<Unit> dg) {
/* we have to add super(dg). otherwise Javac complains. */
super(dg);
throw new RuntimeException("Don't use this Constructor!");
}
/**
* This constructor automatically performs the DownSafety-analysis.<br>
* the result of the analysis is as usual in FlowBefore (getFlowBefore()) and FlowAfter (getFlowAfter()).<br>
*
* @param dg
* a ExceptionalUnitGraph.
* @param unitToGen
* the equivalentValue of each unit.
* @param sideEffect
* the SideEffectTester that performs kills.
*/
public DownSafetyAnalysis(DirectedGraph<Unit> dg, Map<Unit, EquivalentValue> unitToGen, SideEffectTester sideEffect) {
this(dg, unitToGen, sideEffect,
new ArrayPackedSet<EquivalentValue>(new CollectionFlowUniverse<EquivalentValue>(unitToGen.values())));
}
/**
* This constructor automatically performs the DownSafety-analysis.<br>
* the result of the analysis is as usual in FlowBefore (getFlowBefore()) and FlowAfter (getFlowAfter()).<br>
* as sets-operations are usually more efficient, if the original set comes from the same source, this allows to share
* sets.
*
* @param dg
* a ExceptionalUnitGraph.
* @param unitToGen
* the equivalentValue of each unit.
* @param sideEffect
* the SideEffectTester that performs kills.
* @param set
* the shared set.
*/
public DownSafetyAnalysis(DirectedGraph<Unit> dg, Map<Unit, EquivalentValue> unitToGen, SideEffectTester sideEffect,
BoundedFlowSet<EquivalentValue> set) {
super(dg);
this.sideEffect = sideEffect;
this.set = set;
this.unitToGenerateMap = unitToGen;
doAnalysis();
}
@Override
protected FlowSet<EquivalentValue> newInitialFlow() {
return set.topSet();
}
@Override
protected FlowSet<EquivalentValue> entryInitialFlow() {
return set.emptySet();
}
@Override
protected void flowThrough(FlowSet<EquivalentValue> in, Unit u, FlowSet<EquivalentValue> out) {<FILL_FUNCTION_BODY>}
@Override
protected void merge(FlowSet<EquivalentValue> in1, FlowSet<EquivalentValue> in2, FlowSet<EquivalentValue> out) {
in1.intersection(in2, out);
}
@Override
protected void copy(FlowSet<EquivalentValue> source, FlowSet<EquivalentValue> dest) {
source.copy(dest);
}
}
|
in.copy(out);
/* Perform kill */
// iterate over things (avail) in out set.
for (Iterator<EquivalentValue> outIt = out.iterator(); outIt.hasNext();) {
EquivalentValue equiVal = outIt.next();
Value avail = equiVal.getValue();
if (avail instanceof FieldRef) {
if (sideEffect.unitCanWriteTo(u, avail)) {
outIt.remove();
}
} else {
// iterate over uses in each avail.
for (ValueBox next : avail.getUseBoxes()) {
Value use = next.getValue();
if (sideEffect.unitCanWriteTo(u, use)) {
outIt.remove();
break;
}
}
}
}
// Perform generation
EquivalentValue add = unitToGenerateMap.get(u);
if (add != null) {
out.add(add, out);
}
| 831
| 250
| 1,081
|
<methods>public void <init>(DirectedGraph<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/pre/NotIsolatedAnalysis.java
|
NotIsolatedAnalysis
|
flowThrough
|
class NotIsolatedAnalysis extends BackwardFlowAnalysis<Unit, FlowSet<EquivalentValue>> {
private final LatestComputation unitToLatest;
private final Map<Unit, EquivalentValue> unitToGen;
private final FlowSet<EquivalentValue> set;
/**
* Automatically performs the Isolation-analysis on the graph <code>dg</code> using the Latest-computation
* <code>latest</code>.<br>
* the <code>equivRhsMap</code> is only here to avoid doing these things again...
*
* @param dg
* a ExceptionalUnitGraph
* @param latest
* the latest-computation of the same graph.
* @param equivRhsMap
* the rhs of each unit (if assignment-stmt).
*/
public NotIsolatedAnalysis(DirectedGraph<Unit> dg, LatestComputation latest, Map<Unit, EquivalentValue> equivRhsMap) {
this(dg, latest, equivRhsMap,
new ArrayPackedSet<EquivalentValue>(new CollectionFlowUniverse<EquivalentValue>(equivRhsMap.values())));
}
/**
* Automatically performs the Isolation-analysis on the graph <code>dg</code> using the Latest-computation
* <code>latest</code>.<br>
* the <code>equivRhsMap</code> is only here to avoid doing these things again...<br>
* the shared set allows more efficient set-operations, when this analysis is joined with other analyses/computations.
*
* @param dg
* a ExceptionalUnitGraph
* @param latest
* the latest-computation of the same graph.
* @param equivRhsMap
* the rhs of each unit (if assignment-stmt).
* @param set
* the shared set.
*/
public NotIsolatedAnalysis(DirectedGraph<Unit> dg, LatestComputation latest, Map<Unit, EquivalentValue> equivRhsMap,
BoundedFlowSet<EquivalentValue> set) {
super(dg);
this.set = set;
this.unitToGen = equivRhsMap;
this.unitToLatest = latest;
doAnalysis();
}
@Override
protected FlowSet<EquivalentValue> newInitialFlow() {
return set.emptySet();
}
@Override
protected FlowSet<EquivalentValue> entryInitialFlow() {
return newInitialFlow();
}
@Override
protected void flowThrough(FlowSet<EquivalentValue> in, Unit unit, FlowSet<EquivalentValue> out) {<FILL_FUNCTION_BODY>}
@Override
protected void merge(FlowSet<EquivalentValue> inSet1, FlowSet<EquivalentValue> inSet2, FlowSet<EquivalentValue> outSet) {
inSet1.union(inSet2, outSet);
}
@Override
protected void copy(FlowSet<EquivalentValue> sourceSet, FlowSet<EquivalentValue> destSet) {
sourceSet.copy(destSet);
}
}
|
in.copy(out);
// Perform generation
EquivalentValue rhs = (EquivalentValue) unitToGen.get(unit);
if (rhs != null) {
out.add(rhs);
}
// perform kill
FlowSet<EquivalentValue> latest = unitToLatest.getFlowBefore(unit);
out.difference(latest);
| 798
| 99
| 897
|
<methods>public void <init>(DirectedGraph<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/scalar/pre/UpSafetyAnalysis.java
|
UpSafetyAnalysis
|
flowThrough
|
class UpSafetyAnalysis extends ForwardFlowAnalysis<Unit, FlowSet<EquivalentValue>> {
private final SideEffectTester sideEffect;
private final Map<Unit, EquivalentValue> unitToGenerateMap;
private final BoundedFlowSet<EquivalentValue> set;
/**
* This constructor should not be used, and will throw a runtime-exception!
*/
@Deprecated
public UpSafetyAnalysis(DirectedGraph<Unit> dg) {
/* we have to add super(dg). otherwise Javac complains. */
super(dg);
throw new RuntimeException("Don't use this Constructor!");
}
/**
* This constructor automatically performs the UpSafety-analysis.<br>
* the result of the analysis is as usual in FlowBefore (getFlowBefore()) and FlowAfter (getFlowAfter()).<br>
*
* @param dg
* a ExceptionalUnitGraph
* @param unitToGen
* the EquivalentValue of each unit.
* @param sideEffect
* the SideEffectTester that will be used to perform kills.
*/
public UpSafetyAnalysis(DirectedGraph<Unit> dg, Map<Unit, EquivalentValue> unitToGen, SideEffectTester sideEffect) {
this(dg, unitToGen, sideEffect,
new ArrayPackedSet<EquivalentValue>(new CollectionFlowUniverse<EquivalentValue>(unitToGen.values())));
}
/**
* This constructor automatically performs the UpSafety-analysis.<br>
* the result of the analysis is as usual in FlowBefore (getFlowBefore()) and FlowAfter (getFlowAfter()).<br>
* As usually flowset-operations are more efficient if shared, this allows to share sets over several analyses.
*
* @param dg
* a ExceptionalUnitGraph
* @param unitToGen
* the EquivalentValue of each unit.
* @param sideEffect
* the SideEffectTester that will be used to perform kills.
* @param set
* a bounded flow-set.
*/
public UpSafetyAnalysis(DirectedGraph<Unit> dg, Map<Unit, EquivalentValue> unitToGen, SideEffectTester sideEffect,
BoundedFlowSet<EquivalentValue> set) {
super(dg);
this.sideEffect = sideEffect;
this.set = set;
this.unitToGenerateMap = unitToGen;
doAnalysis();
}
@Override
protected FlowSet<EquivalentValue> newInitialFlow() {
return set.topSet();
}
@Override
protected FlowSet<EquivalentValue> entryInitialFlow() {
return set.emptySet();
}
@Override
protected void flowThrough(FlowSet<EquivalentValue> in, Unit u, FlowSet<EquivalentValue> out) {<FILL_FUNCTION_BODY>}
@Override
protected void merge(FlowSet<EquivalentValue> inSet1, FlowSet<EquivalentValue> inSet2, FlowSet<EquivalentValue> outSet) {
inSet1.intersection(inSet2, outSet);
}
@Override
protected void copy(FlowSet<EquivalentValue> sourceSet, FlowSet<EquivalentValue> destSet) {
sourceSet.copy(destSet);
}
}
|
in.copy(out);
// Perform generation
EquivalentValue add = unitToGenerateMap.get(u);
if (add != null) {
out.add(add, out);
}
/* Perform kill */
// iterate over things (avail) in out set.
for (Iterator<EquivalentValue> outIt = out.iterator(); outIt.hasNext();) {
EquivalentValue equiVal = outIt.next();
Value avail = equiVal.getValue();
if (avail instanceof FieldRef) {
if (sideEffect.unitCanWriteTo(u, avail)) {
outIt.remove();
}
} else {
// iterate over uses in each avail.
for (ValueBox useBox : avail.getUseBoxes()) {
Value use = useBox.getValue();
if (sideEffect.unitCanWriteTo(u, use)) {
outIt.remove();
break;
}
}
}
}
| 844
| 252
| 1,096
|
<methods>public void <init>(DirectedGraph<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/EncapsulatedObjectAnalysis.java
|
EncapsulatedObjectAnalysis
|
isMethodPureOnObject
|
class EncapsulatedObjectAnalysis // extends ForwardFlowAnalysis
{
private static final Logger logger = LoggerFactory.getLogger(EncapsulatedObjectAnalysis.class);
List cachedClasses;
List<SootMethod> objectPureMethods;
List<SootMethod> objectPureInitMethods;
public EncapsulatedObjectAnalysis() {
cachedClasses = new ArrayList();
objectPureMethods = new ArrayList<SootMethod>();
objectPureInitMethods = new ArrayList<SootMethod>();
}
public boolean isMethodPureOnObject(SootMethod sm) {<FILL_FUNCTION_BODY>}
public boolean isInitMethodPureOnObject(SootMethod sm) {
// logger.debug("Testing Init Method Encapsulation: " + sm + " Encapsulated: ");
if (isMethodPureOnObject(sm)) {
boolean ret = objectPureInitMethods.contains(sm);
// logger.debug(""+ret);
return ret;
}
// logger.debug("false");
return false;
}
public List<SootMethod> getObjectPureMethodsSoFar() {
return objectPureMethods;
}
}
|
if (!cachedClasses.contains(sm.getDeclaringClass()) && sm.isConcrete()) // NOT A COMPLETE SOLUTION (ignores subclassing)
{
SootMethod initMethod = null;
Collection methods = sm.getDeclaringClass().getMethods();
Iterator methodsIt = methods.iterator();
List<SootMethod> mayBePureMethods = new ArrayList<SootMethod>(methods.size());
while (methodsIt.hasNext()) {
SootMethod method = (SootMethod) methodsIt.next();
if (method.isConcrete()) {
if (method.getSubSignature().startsWith("void <init>")) {
initMethod = method;
}
Body b = method.retrieveActiveBody();
EncapsulatedMethodAnalysis ema
= new EncapsulatedMethodAnalysis(ExceptionalUnitGraphFactory.createExceptionalUnitGraph(b));
if (ema.isPure()) {
mayBePureMethods.add(method);
}
}
}
if (mayBePureMethods.size() == methods.size()) {
objectPureMethods.addAll(mayBePureMethods);
} else if (initMethod != null) {
objectPureMethods.add(initMethod);
}
if (initMethod != null) {
objectPureInitMethods.add(initMethod);
}
}
return objectPureMethods.contains(sm);
| 297
| 361
| 658
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/mhp/CompactSequentNodes.java
|
CompactSequentNodes
|
compactStartChain
|
class CompactSequentNodes {
long compactNodes = 0;
long add = 0;
public CompactSequentNodes(PegGraph pg) {
Chain mainPegChain = pg.getMainPegChain();
compactGraph(mainPegChain, pg);
compactStartChain(pg);
// PegToDotFile printer = new PegToDotFile(pg, false, "sequence");
System.err.println("compact seq. node: " + compactNodes);
System.err.println("number of compacting seq. nodes: " + add);
}
private void compactGraph(Chain chain, PegGraph peg) {
Set canNotBeCompacted = peg.getCanNotBeCompacted();
List<List<Object>> list = computeSequentNodes(chain, peg);
// printSeq(list);
Iterator<List<Object>> it = list.iterator();
while (it.hasNext()) {
List s = it.next();
if (!checkIfContainsElemsCanNotBeCompacted(s, canNotBeCompacted)) {
add++;
compact(s, chain, peg);
}
}
}
private void compactStartChain(PegGraph graph) {<FILL_FUNCTION_BODY>}
private List<List<Object>> computeSequentNodes(Chain chain, PegGraph pg) {
Set<Object> gray = new HashSet<Object>();
List<List<Object>> sequentNodes = new ArrayList<List<Object>>();
Set canNotBeCompacted = pg.getCanNotBeCompacted();
TopologicalSorter ts = new TopologicalSorter(chain, pg);
ListIterator<Object> it = ts.sorter().listIterator();
while (it.hasNext()) {
Object node = it.next();
List<Object> list = new ArrayList<Object>();
if (!gray.contains(node)) {
visitNode(pg, node, list, canNotBeCompacted, gray);
if (list.size() > 1) {
gray.addAll(list);
sequentNodes.add(list);
}
}
}
return sequentNodes;
}
private void visitNode(PegGraph pg, Object node, List<Object> list, Set canNotBeCompacted, Set<Object> gray) {
// System.out.println("node is: "+node);
if (pg.getPredsOf(node).size() == 1 && pg.getSuccsOf(node).size() == 1 && !canNotBeCompacted.contains(node)
&& !gray.contains(node)) {
list.add(node);
Iterator it = pg.getSuccsOf(node).iterator();
while (it.hasNext()) {
Object o = it.next();
visitNode(pg, o, list, canNotBeCompacted, gray);
}
}
return;
}
private boolean checkIfContainsElemsCanNotBeCompacted(List list, Set canNotBeCompacted) {
Iterator sccIt = list.iterator();
while (sccIt.hasNext()) {
Object node = sccIt.next();
if (canNotBeCompacted.contains(node)) {
// System.out.println("find a syn method!!");
return true;
}
}
return false;
}
private void compact(List list, Chain chain, PegGraph peg) {
Iterator it = list.iterator();
FlowSet allNodes = peg.getAllNodes();
HashMap unitToSuccs = peg.getUnitToSuccs();
HashMap unitToPreds = peg.getUnitToPreds();
List<Object> newPreds = new ArrayList<Object>();
List<Object> newSuccs = new ArrayList<Object>();
while (it.hasNext()) {
Object s = it.next();
{
Iterator predsIt = peg.getPredsOf(s).iterator();
while (predsIt.hasNext()) {
Object pred = predsIt.next();
List succsOfPred = peg.getSuccsOf(pred);
succsOfPred.remove(s);
if (!list.contains(pred)) {
newPreds.add(pred);
succsOfPred.add(list);
}
}
}
{
Iterator succsIt = peg.getSuccsOf(s).iterator();
while (succsIt.hasNext()) {
Object succ = succsIt.next();
List predsOfSucc = peg.getPredsOf(succ);
predsOfSucc.remove(s);
if (!list.contains(succ)) {
newSuccs.add(succ);
predsOfSucc.add(list);
}
}
}
}
unitToSuccs.put(list, newSuccs);
// System.out.println("put list"+list+"\n"+ "newSuccs: "+newSuccs);
unitToPreds.put(list, newPreds);
allNodes.add(list);
chain.add(list);
updateMonitor(peg, list);
{
it = list.iterator();
while (it.hasNext()) {
Object s = it.next();
chain.remove(s);
allNodes.remove(s);
unitToSuccs.remove(s);
unitToPreds.remove(s);
}
}
// System.out.println("inside compactSCC");
// testListSucc(peg);
compactNodes += list.size();
}
// The compacted nodes may inside some monitors. We need to update monitor objects.
private void updateMonitor(PegGraph pg, List list) {
// System.out.println("=======update monitor===");
// add list to corresponding monitor objects sets
Set maps = pg.getMonitor().entrySet();
// System.out.println("---test list----");
// testList(list);
for (Iterator iter = maps.iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
FlowSet fs = (FlowSet) entry.getValue();
Iterator it = list.iterator();
while (it.hasNext()) {
Object obj = it.next();
if (fs.contains(obj)) {
fs.add(list);
// flag = true;
break;
// System.out.println("add list to monitor: "+entry.getKey());
}
}
}
// System.out.println("=======update monitor==end====");
}
}
|
Set maps = graph.getStartToThread().entrySet();
for (Iterator iter = maps.iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
List runMethodChainList = (List) entry.getValue();
Iterator it = runMethodChainList.iterator();
while (it.hasNext()) {
Chain chain = (Chain) it.next();
compactGraph(chain, graph);
}
}
| 1,707
| 119
| 1,826
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/mhp/CompactStronglyConnectedComponents.java
|
CompactStronglyConnectedComponents
|
compactGraph
|
class CompactStronglyConnectedComponents {
long compactNodes = 0;
long add = 0;
public CompactStronglyConnectedComponents(PegGraph pg) {
Chain mainPegChain = pg.getMainPegChain();
compactGraph(mainPegChain, pg);
compactStartChain(pg);
// PegToDotFile printer = new PegToDotFile(pg, false, "compact");
System.err.println("compact SCC nodes: " + compactNodes);
System.err.println(" number of compacting scc nodes: " + add);
}
private void compactGraph(Chain chain, PegGraph peg) {<FILL_FUNCTION_BODY>}
private void compactStartChain(PegGraph graph) {
Set maps = graph.getStartToThread().entrySet();
for (Iterator iter = maps.iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
List runMethodChainList = (List) entry.getValue();
Iterator it = runMethodChainList.iterator();
while (it.hasNext()) {
Chain chain = (Chain) it.next();
compactGraph(chain, graph);
}
}
}
private boolean checkIfContainsElemsCanNotBeCompacted(List list, Set canNotBeCompacted) {
Iterator sccIt = list.iterator();
// System.out.println("sccList: ");
while (sccIt.hasNext()) {
JPegStmt node = (JPegStmt) sccIt.next();
// System.out.println("elem of scc:");
if (canNotBeCompacted.contains(node)) {
// System.out.println("find a syn method!!");
return true;
}
}
return false;
}
private void compact(List list, Chain chain, PegGraph peg) {
Iterator it = list.iterator();
FlowSet allNodes = peg.getAllNodes();
HashMap unitToSuccs = peg.getUnitToSuccs();
HashMap unitToPreds = peg.getUnitToPreds();
List<Object> newPreds = new ArrayList<Object>();
List<Object> newSuccs = new ArrayList<Object>();
while (it.hasNext()) {
JPegStmt s = (JPegStmt) it.next();
// Replace the SCC with a list node.
{
Iterator predsIt = peg.getPredsOf(s).iterator();
while (predsIt.hasNext()) {
Object pred = predsIt.next();
List succsOfPred = peg.getSuccsOf(pred);
succsOfPred.remove(s);
if (!list.contains(pred)) {
newPreds.add(pred);
succsOfPred.add(list);
}
}
}
{
Iterator succsIt = peg.getSuccsOf(s).iterator();
while (succsIt.hasNext()) {
Object succ = succsIt.next();
List predsOfSucc = peg.getPredsOf(succ);
predsOfSucc.remove(s);
if (!list.contains(succ)) {
newSuccs.add(succ);
predsOfSucc.add(list);
}
}
}
}
unitToSuccs.put(list, newSuccs);
// System.out.println("put list"+list+"\n"+ "newSuccs: "+newSuccs);
unitToPreds.put(list, newPreds);
allNodes.add(list);
chain.add(list);
updateMonitor(peg, list);
{
it = list.iterator();
while (it.hasNext()) {
JPegStmt s = (JPegStmt) it.next();
chain.remove(s);
allNodes.remove(s);
unitToSuccs.remove(s);
unitToPreds.remove(s);
}
}
// System.out.println("inside compactSCC");
// testListSucc(peg);
// add for get experimental results
compactNodes += list.size();
}
private void updateMonitor(PegGraph pg, List list) {
// System.out.println("=======update monitor===");
// add list to corresponding monitor objects sets
Set maps = pg.getMonitor().entrySet();
// System.out.println("---test list----");
// testList(list);
for (Iterator iter = maps.iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
FlowSet fs = (FlowSet) entry.getValue();
Iterator it = list.iterator();
while (it.hasNext()) {
Object obj = it.next();
if (fs.contains(obj)) {
fs.add(list);
break;
// System.out.println("add list to monitor: "+entry.getKey());
}
}
}
// System.out.println("=======update monitor==end====");
}
}
|
Set canNotBeCompacted = peg.getCanNotBeCompacted();
// testCan(speg.getMainPegChain(), canNotBeCompacted);
// SCC scc = new SCC(chain, peg);
SCC scc = new SCC(chain.iterator(), peg);
List<List<Object>> sccList = scc.getSccList();
// testSCC(sccList);
Iterator<List<Object>> sccListIt = sccList.iterator();
while (sccListIt.hasNext()) {
List s = sccListIt.next();
if (s.size() > 1) {
// printSCC(s);
if (!checkIfContainsElemsCanNotBeCompacted(s, canNotBeCompacted)) {
add++;
compact(s, chain, peg);
}
}
}
// testListSucc(peg);
| 1,340
| 239
| 1,579
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/mhp/DfsForBackEdge.java
|
DfsForBackEdge
|
visitNode
|
class DfsForBackEdge {
private final Map<Object, Object> backEdges = new HashMap<Object, Object>();
private final Set<Object> gray = new HashSet<Object>();
private final Set<Object> black = new HashSet<Object>();
private final DominatorsFinder domFinder;
DfsForBackEdge(Chain chain, DirectedGraph peg) {
domFinder = new DominatorsFinder(chain, peg);
Iterator it = chain.iterator();
dfs(it, peg);
testBackEdge();
}
private void dfs(Iterator it, DirectedGraph g) {
// Visit each node
{
while (it.hasNext()) {
Object s = it.next();
if (!gray.contains(s)) {
visitNode(g, s);
}
}
}
}
private void visitNode(DirectedGraph g, Object s) {<FILL_FUNCTION_BODY>}
protected Map<Object, Object> getBackEdges() {
return backEdges;
}
private void testBackEdge() {
System.out.println("===test backEdges==");
Set maps = backEdges.entrySet();
for (Iterator iter = maps.iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
JPegStmt key = (JPegStmt) entry.getKey();
Tag tag = (Tag) key.getTags().get(0);
System.out.println("---key= " + tag + " " + key);
JPegStmt value = (JPegStmt) entry.getValue();
Tag tag1 = (Tag) value.getTags().get(0);
System.out.println("---value= " + tag1 + " " + value);
}
System.out.println("===test backEdges==end==");
}
}
|
// System.out.println("s is: "+ s);
gray.add(s);
Iterator it = g.getSuccsOf(s).iterator();
if (g.getSuccsOf(s).size() > 0) {
while (it.hasNext()) {
Object succ = it.next();
if (!gray.contains(succ)) {
visitNode(g, succ);
} else {
// if the color of the node is gray, then we found a retreating edge
if (gray.contains(succ) && !black.contains(succ)) {
/*
* If succ is in s's dominator list, then this retreating edge is a back edge.
*/
FlowSet dominators = domFinder.getDominatorsOf(s);
if (dominators.contains(succ)) {
System.out.println("s is " + s);
System.out.println("succ is " + succ);
backEdges.put(s, succ);
}
}
}
}
}
black.add(s);
| 495
| 281
| 776
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/mhp/LoopBodyFinder.java
|
LoopBodyFinder
|
findLoopBody
|
class LoopBodyFinder {
private final FastStack<Object> stack = new FastStack<Object>();
private final Set<Set<Object>> loops = new HashSet<Set<Object>>();
LoopBodyFinder(Map<Object, Object> backEdges, DirectedGraph g) {
findLoopBody(backEdges, g);
}
private void findLoopBody(Map<Object, Object> backEdges, DirectedGraph g) {<FILL_FUNCTION_BODY>}
private Set<Object> finder(Object tail, Object head, DirectedGraph g) {
Set<Object> loop = new HashSet<Object>();
loop.add(head);
insert(tail, loop);
while (!stack.empty()) {
Object p = stack.pop();
Iterator predsListIt = g.getPredsOf(p).iterator();
while (predsListIt.hasNext()) {
Object pred = predsListIt.next();
insert(pred, loop);
}
}
return loop;
}
private void insert(Object m, Set<Object> loop) {
if (!loop.contains(m)) {
loop.add(m);
stack.push(m);
}
}
public Set<Set<Object>> getLoopBody() {
return loops;
}
}
|
Set maps = backEdges.entrySet();
for (Iterator iter = maps.iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
Object tail = entry.getKey();
// Tag tag = (Tag)key.getTags().get(0);
// System.out.println("---key= "+tag+" "+key);
Object head = entry.getValue();
Set<Object> loopBody = finder(tail, head, g);
loops.add(loopBody);
}
| 339
| 138
| 477
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/mhp/LoopFinder.java
|
LoopFinder
|
testLoops
|
class LoopFinder {
private final Map<Chain, Set<Set<Object>>> chainToLoop = new HashMap<Chain, Set<Set<Object>>>();
LoopFinder(PegGraph peg) {
Chain chain = peg.getMainPegChain();
DfsForBackEdge dfsForBackEdge = new DfsForBackEdge(chain, peg);
Map<Object, Object> backEdges = dfsForBackEdge.getBackEdges();
LoopBodyFinder lbf = new LoopBodyFinder(backEdges, peg);
Set<Set<Object>> loopBody = lbf.getLoopBody();
testLoops(loopBody);
chainToLoop.put(chain, loopBody);
}
private void testLoops(Set<Set<Object>> loopBody) {<FILL_FUNCTION_BODY>}
}
|
System.out.println("====loops===");
Iterator<Set<Object>> it = loopBody.iterator();
while (it.hasNext()) {
Set loop = it.next();
Iterator loopIt = loop.iterator();
System.out.println("---loop---");
while (loopIt.hasNext()) {
JPegStmt o = (JPegStmt) loopIt.next();
Tag tag = (Tag) o.getTags().get(0);
System.out.println(tag + " " + o);
}
}
System.out.println("===end===loops===");
| 218
| 159
| 377
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/mhp/MethodExtentBuilder.java
|
MethodExtentBuilder
|
propagate
|
class MethodExtentBuilder {
// private List inlineSites = new ArrayList();
private final Set<Object> methodsNeedingInlining = new HashSet<Object>();
public MethodExtentBuilder(Body unitBody, PegCallGraph pcg, CallGraph cg) {
// testCallGraph(cg);
build(pcg, cg);
// checkMethodNeedExtent();
CheckRecursiveCalls crc = new CheckRecursiveCalls(pcg, methodsNeedingInlining);
// testMap();
// checkSccList(sccList, cg);
propagate(pcg);
// checkMethodNeedExtent();
}
public Set<Object> getMethodsNeedingInlining() {
return methodsNeedingInlining;
}
private void build(PegCallGraph pcg, CallGraph cg) {
Iterator it = pcg.iterator();
while (it.hasNext()) {
SootMethod method = (SootMethod) it.next();
computeForMethodInlining(method, cg);
}
}
private void computeForMethodInlining(SootMethod targetMethod, CallGraph cg) {
// System.out.println("method: "+targetMethod);
if (targetMethod.isSynchronized()) {
methodsNeedingInlining.add(targetMethod);
return;
}
Body mBody = targetMethod.getActiveBody();
Iterator bodyIt = mBody.getUnits().iterator();
while (bodyIt.hasNext()) {
Stmt stmt = (Stmt) bodyIt.next();
if (stmt instanceof MonitorStmt) {
// methodsNeedingInlining.put(targetMethod, new Boolean(true));
methodsNeedingInlining.add(targetMethod);
// System.out.println("put: "+targetMethod);
return;
// return true;
} else {
if (stmt.containsInvokeExpr()) {
// System.out.println("stmt is: "+stmt);
Value invokeExpr = (stmt).getInvokeExpr();
SootMethod method = ((InvokeExpr) invokeExpr).getMethod();
String name = method.getName();
if (name.equals("wait") || name.equals("notify") || name.equals("notifyAll")
|| ((name.equals("start") || name.equals("join") || name.equals("suspend") || name.equals("resume")
|| name.equals("destroy") || name.equals("stop"))
&& method.getDeclaringClass().getName().equals("java.lang.Thread"))) {
methodsNeedingInlining.add(targetMethod);
return;
} else {
if (method.isConcrete() && !method.getDeclaringClass().isLibraryClass()) {
Iterator it = cg.edgesOutOf(stmt);
TargetMethodsFinder tmd = new TargetMethodsFinder();
Iterator<SootMethod> targetIt = (tmd.find(stmt, cg, true, false)).iterator();
while (targetIt.hasNext()) {
SootMethod target = targetIt.next();
if (target.isSynchronized()) {
// System.out.println("method is synchronized: "+method);
methodsNeedingInlining.add(targetMethod);
return;
}
}
}
}
}
}
}
return;
}
protected void propagate(PegCallGraph cg) {<FILL_FUNCTION_BODY>}
private boolean visitNode(Object o, Set<Object> gray, PegCallGraph cg) {
// System.out.println("visit(in visit): "+o);
gray.add(o);
Iterator childIt = (cg.getSuccsOf(o)).iterator();
while (childIt.hasNext()) {
Object child = childIt.next();
if (methodsNeedingInlining.contains(child)) {
gray.add(child);
// methodsNeedingInlining.add(child);
// System.out.println("return true for: "+child);
return true;
} else {
if (!gray.contains(child)) {
if (visitNode(child, gray, cg)) {
methodsNeedingInlining.add(child);
// System.out.println("put: "+child+"in pro");
// System.out.println("return true for: "+child);
return true;
}
}
}
}
return false;
}
}
|
/*
* if a method is not in methodsNeedingInlining, use DFS to find out if it's parents need inlining. If so, add it to
* methodsNeedingInlining
*/
Set<Object> gray = new HashSet<Object>();
Iterator it = cg.iterator();
while (it.hasNext()) {
Object o = it.next();
if (methodsNeedingInlining.contains(o)) {
continue;
} else if (!gray.contains(o)) {
// System.out.println("visit: "+o);
if (visitNode(o, gray, cg)) {
methodsNeedingInlining.add(o);
// System.out.println("put: "+o+"in pro");
}
}
}
// System.out.println("======after pro========");
| 1,155
| 224
| 1,379
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/mhp/MonitorDepth.java
|
MonitorDepth
|
decreaseDepth
|
class MonitorDepth {
private String objName;
private int depth;
MonitorDepth(String s, int d) {
objName = s;
depth = d;
}
protected String getObjName() {
return objName;
}
protected void SetObjName(String s) {
objName = s;
}
protected int getDepth() {
return depth;
}
protected void setDepth(int d) {
depth = d;
}
protected void decreaseDepth() {<FILL_FUNCTION_BODY>}
protected void increaseDepth() {
depth++;
}
}
|
if (depth > 0) {
depth = depth - 1;
} else {
throw new RuntimeException("Error! You can not decrease a monitor depth of " + depth);
}
| 168
| 50
| 218
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/mhp/PegCallGraphToDot.java
|
PegCallGraphToDot
|
getNodeOrder
|
class PegCallGraphToDot {
/*
* make all control fields public, allow other soot class dump the graph in the middle
*/
public static boolean isBrief = false;
private static final Map<Object, String> listNodeName = new HashMap<Object, String>();
/* in one page or several pages of 8.5x11 */
public static boolean onepage = true;
public PegCallGraphToDot(DirectedGraph graph, boolean onepage, String name) {
PegCallGraphToDot.onepage = onepage;
toDotFile(name, graph, "PegCallGraph");
}
/*
* public PegToDotFile(PegGraph graph, boolean onepage, String name) { this.onepage = onepage; toDotFile(name,
* graph,"Simple graph"); }
*/
private static int nodecount = 0;
/**
* Generates a dot format file for a DirectedGraph
*
* @param methodname,
* the name of generated dot file
* @param graph,
* a directed control flow graph (UnitGraph, BlockGraph ...)
* @param graphname,
* the title of the graph
*/
public static void toDotFile(String methodname, DirectedGraph graph, String graphname) {
int sequence = 0;
// this makes the node name unique
nodecount = 0; // reset node counter first.
Hashtable nodeindex = new Hashtable(graph.size());
// file name is the method name + .dot
DotGraph canvas = new DotGraph(methodname);
// System.out.println("onepage is:"+onepage);
if (!onepage) {
canvas.setPageSize(8.5, 11.0);
}
canvas.setNodeShape(DotGraphConstants.NODE_SHAPE_BOX);
canvas.setGraphLabel(graphname);
Iterator nodesIt = graph.iterator();
{
while (nodesIt.hasNext()) {
Object node = nodesIt.next();
if (node instanceof List) {
String listName = "list" + (new Integer(sequence++)).toString();
String nodeName = makeNodeName(getNodeOrder(nodeindex, listName));
listNodeName.put(node, listName);
// System.out.println("put node: "+node +"into listNodeName");
}
}
}
nodesIt = graph.iterator();
while (nodesIt.hasNext()) {
Object node = nodesIt.next();
String nodeName = null;
if (node instanceof List) {
nodeName = makeNodeName(getNodeOrder(nodeindex, listNodeName.get(node)));
} else {
nodeName = makeNodeName(getNodeOrder(nodeindex, node));
}
Iterator succsIt = graph.getSuccsOf(node).iterator();
while (succsIt.hasNext()) {
Object s = succsIt.next();
String succName = null;
if (s instanceof List) {
succName = makeNodeName(getNodeOrder(nodeindex, listNodeName.get(s)));
} else {
Object succ = s;
// System.out.println("$$$$$$succ: "+succ);
// nodeName = makeNodeName(getNodeOrder(nodeindex, tag+" "+node));
succName = makeNodeName(getNodeOrder(nodeindex, succ));
// System.out.println("node is :" +node);
// System.out.println("find start node in pegtodotfile:"+node);
}
canvas.drawEdge(nodeName, succName);
}
}
// set node label
if (!isBrief) {
nodesIt = nodeindex.keySet().iterator();
while (nodesIt.hasNext()) {
Object node = nodesIt.next();
// System.out.println("node is:"+node);
if (node != null) {
// System.out.println("node: "+node);
String nodename = makeNodeName(getNodeOrder(nodeindex, node));
// System.out.println("nodename: "+ nodename);
DotGraphNode dotnode = canvas.getNode(nodename);
// System.out.println("dotnode: "+dotnode);
if (dotnode != null) {
dotnode.setLabel(node.toString());
}
}
}
}
canvas.plot("pecg.dot");
// clean up
listNodeName.clear();
}
private static int getNodeOrder(Hashtable<Object, Integer> nodeindex, Object node) {<FILL_FUNCTION_BODY>}
private static String makeNodeName(int index) {
return "N" + index;
}
}
|
Integer index = nodeindex.get(node);
if (index == null) {
index = new Integer(nodecount++);
nodeindex.put(node, index);
}
// System.out.println("order is:"+index.intValue());
return index.intValue();
| 1,234
| 76
| 1,310
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/mhp/RunMethodsPred.java
|
RunMethodsPred
|
want
|
class RunMethodsPred implements EdgePredicate {
/** Returns true iff the edge e is wanted. */
public boolean want(Edge e) {<FILL_FUNCTION_BODY>}
}
|
String tgtSubSignature = e.tgt().getSubSignature();
if (tgtSubSignature.equals("void run()")) {
return true;
}
return false;
| 48
| 50
| 98
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/mhp/findobject/MultiCalledMethods.java
|
MultiCalledMethods
|
finder2
|
class MultiCalledMethods {
Set<SootMethod> multiCalledMethods = new HashSet<SootMethod>();
MultiCalledMethods(PegCallGraph pcg, Set<SootMethod> mcm) {
multiCalledMethods = mcm;
byMCalledS0(pcg);
finder1(pcg);
finder2(pcg);
propagate(pcg);
}
private void byMCalledS0(PegCallGraph pcg) {
Iterator it = pcg.iterator();
while (it.hasNext()) {
SootMethod sm = (SootMethod) it.next();
UnitGraph graph = new CompleteUnitGraph(sm.getActiveBody());
CallGraph callGraph = Scene.v().getCallGraph();
MultiRunStatementsFinder finder = new MultiRunStatementsFinder(graph, sm, multiCalledMethods, callGraph);
FlowSet fs = finder.getMultiRunStatements();
}
}
private void propagate(PegCallGraph pcg) {
Set<SootMethod> visited = new HashSet();
List<SootMethod> reachable = new ArrayList<SootMethod>();
reachable.addAll(multiCalledMethods);
while (reachable.size() >= 1) {
SootMethod popped = reachable.remove(0);
if (visited.contains(popped)) {
continue;
}
if (!multiCalledMethods.contains(popped)) {
multiCalledMethods.add(popped);
}
visited.add(popped);
Iterator succIt = pcg.getSuccsOf(popped).iterator();
while (succIt.hasNext()) {
Object succ = succIt.next();
reachable.add((SootMethod) succ);
}
}
}
// Use breadth first search to find methods are called more than once in call graph
private void finder1(PegCallGraph pcg) {
Set clinitMethods = pcg.getClinitMethods();
Iterator it = pcg.iterator();
while (it.hasNext()) {
Object head = it.next();
// breadth first scan
Set<Object> gray = new HashSet<Object>();
LinkedList<Object> queue = new LinkedList<Object>();
queue.add(head);
while (queue.size() > 0) {
Object root = queue.getFirst();
Iterator succsIt = pcg.getSuccsOf(root).iterator();
while (succsIt.hasNext()) {
Object succ = succsIt.next();
if (!gray.contains(succ)) {
gray.add(succ);
queue.addLast(succ);
} else if (clinitMethods.contains(succ)) {
continue;
} else {
multiCalledMethods.add((SootMethod) succ);
}
}
queue.remove(root);
}
}
}
// Find multi called methods relavant to recusive method invocation
private void finder2(PegCallGraph pcg) {<FILL_FUNCTION_BODY>}
private void visitNode(SootMethod node, PegCallGraph pcg, Set<SootMethod> first, Set<SootMethod> second) {
if (first.contains(node)) {
second.add(node);
if (!multiCalledMethods.contains(node)) {
multiCalledMethods.add(node);
}
} else {
first.add(node);
}
Iterator it = pcg.getTrimSuccsOf(node).iterator();
while (it.hasNext()) {
SootMethod succ = (SootMethod) it.next();
if (!second.contains(succ)) {
visitNode(succ, pcg, first, second);
}
}
}
public Set<SootMethod> getMultiCalledMethods() {
return multiCalledMethods;
}
}
|
pcg.trim();
Set<SootMethod> first = new HashSet<SootMethod>();
Set<SootMethod> second = new HashSet<SootMethod>();
// Visit each node
Iterator it = pcg.iterator();
while (it.hasNext()) {
SootMethod s = (SootMethod) it.next();
if (!second.contains(s)) {
visitNode(s, pcg, first, second);
}
}
| 1,016
| 126
| 1,142
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/mhp/findobject/MultiRunStatementsFinder.java
|
MultiRunStatementsFinder
|
findMultiCalledMethodsIntra
|
class MultiRunStatementsFinder extends ForwardFlowAnalysis<Unit, BitSet> {
Set<Unit> multiRunStatements = new HashSet<Unit>();
protected Map<Object, Integer> nodeToIndex;
protected int lastIndex = 0;
// add soot method here just for debug
public MultiRunStatementsFinder(UnitGraph g, SootMethod sm, Set<SootMethod> multiCalledMethods, CallGraph cg) {
super(g);
nodeToIndex = new HashMap<Object, Integer>();
// System.out.println("===entering MultiObjectAllocSites==");
doAnalysis();
// testMultiObjSites(sm);
findMultiCalledMethodsIntra(multiCalledMethods, cg);
// testMultiObjSites(sm);
}
private void findMultiCalledMethodsIntra(Set<SootMethod> multiCalledMethods, CallGraph callGraph) {<FILL_FUNCTION_BODY>}
// STEP 4: Is the merge operator union or intersection?
// UNION
protected void merge(BitSet in1, BitSet in2, BitSet out) {
out.clear();
out.or(in1);
out.or(in2);
}
// STEP 5: Define flow equations.
// in(s) = ( out(s) minus defs(s) ) union uses(s)
//
protected void flowThrough(BitSet in, Unit unit, BitSet out) {
out.clear();
out.or(in);
if (!out.get(indexOf(unit))) {
out.set(indexOf(unit));
// System.out.println("add to out: "+unit);
} else {
multiRunStatements.add(unit);
}
// System.out.println("in: "+in);
// System.out.println("out: "+out);
}
protected void copy(BitSet source, BitSet dest) {
dest.clear();
dest.or(source);
}
// STEP 6: Determine value for start/end node, and
// initial approximation.
//
// start node: empty set
// initial approximation: empty set
protected BitSet entryInitialFlow() {
return new BitSet();
}
protected BitSet newInitialFlow() {
return new BitSet();
}
public FlowSet getMultiRunStatements() {
FlowSet res = new ArraySparseSet();
for (Unit u : multiRunStatements) {
res.add(u);
}
return res;
}
protected int indexOf(Object o) {
Integer index = nodeToIndex.get(o);
if (index == null) {
index = lastIndex;
nodeToIndex.put(o, index);
lastIndex++;
}
return index;
}
}
|
Iterator<Unit> it = multiRunStatements.iterator();
while (it.hasNext()) {
Stmt stmt = (Stmt) it.next();
if (stmt.containsInvokeExpr()) {
InvokeExpr invokeExpr = stmt.getInvokeExpr();
List<SootMethod> targetList = new ArrayList<SootMethod>();
SootMethod method = invokeExpr.getMethod();
if (invokeExpr instanceof StaticInvokeExpr) {
targetList.add(method);
} else if (invokeExpr instanceof InstanceInvokeExpr) {
if (method.isConcrete() && !method.getDeclaringClass().isLibraryClass()) {
TargetMethodsFinder tmd = new TargetMethodsFinder();
targetList = tmd.find(stmt, callGraph, true, true);
}
}
if (targetList != null) {
Iterator<SootMethod> iterator = targetList.iterator();
while (iterator.hasNext()) {
SootMethod obj = iterator.next();
if (!obj.isNative()) {
multiCalledMethods.add(obj);
}
}
}
}
}
| 730
| 298
| 1,028
|
<methods>public void <init>(DirectedGraph<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/mhp/stmt/JPegStmt.java
|
JPegStmt
|
testToString
|
class JPegStmt extends AbstractHost
// public class JPegStmt implements CommunicationStmt
// public class JPegStmt extends AbstractStmt implements CommunicationStm
// public class JPegStmt extends AbstractStm
{
protected String object;
protected String name;
protected String caller;
protected Unit unit = null;
protected UnitGraph unitGraph = null;
// add for build dot file
protected SootMethod sootMethod = null;
// end add for build dot file
protected JPegStmt() {
}
protected JPegStmt(String obj, String na, String ca) {
this.object = obj;
this.name = na;
this.caller = ca;
}
protected JPegStmt(String obj, String na, String ca, SootMethod sm) {
this.object = obj;
this.name = na;
this.caller = ca;
this.sootMethod = sm;
}
protected JPegStmt(String obj, String na, String ca, UnitGraph ug, SootMethod sm) {
this.object = obj;
this.name = na;
this.caller = ca;
this.unitGraph = ug;
this.sootMethod = sm;
}
protected JPegStmt(String obj, String na, String ca, Unit un, UnitGraph ug, SootMethod sm) {
this.object = obj;
this.name = na;
this.caller = ca;
this.unit = un;
this.unitGraph = ug;
this.sootMethod = sm;
}
protected void setUnit(Unit un) {
unit = un;
}
protected void setUnitGraph(UnitGraph ug) {
unitGraph = ug;
}
public UnitGraph getUnitGraph() {
if (!containUnitGraph()) {
throw new RuntimeException("This statement does not contain UnitGraph!");
}
return unitGraph;
}
public boolean containUnitGraph() {
if (unitGraph == null) {
return false;
} else {
return true;
}
}
public Unit getUnit() {
if (!containUnit()) {
throw new RuntimeException("This statement does not contain Unit!");
}
return unit;
}
public boolean containUnit() {
if (unit == null) {
return false;
} else {
return true;
}
}
public String getObject() {
return object;
}
protected void setObject(String ob) {
object = ob;
}
public String getName() {
return name;
}
protected void setName(String na) {
name = na;
}
public String getCaller() {
return caller;
}
protected void setCaller(String ca) {
caller = ca;
}
public SootMethod getMethod() {
return sootMethod;
}
/*
* public void apply(Switch sw) { ((StmtSwitch) sw).caseCommunicationStmt(this); }
*/
/*
* public Object clone() { if (containUnit()){ } return new JPegStmt(object,name,caller, ); }
*/
public String toString() {
if (sootMethod != null) {
return "(" + getObject() + ", " + getName() + ", " + getCaller() + "," + sootMethod + ")";
} else {
return "(" + getObject() + ", " + getName() + ", " + getCaller() + ")";
}
}
public String testToString() {<FILL_FUNCTION_BODY>}
}
|
if (containUnit()) {
if (sootMethod != null) {
return "(" + getObject() + ", " + getName() + ", " + getCaller() + ", " + getUnit() + "," + sootMethod + ")";
} else {
return "(" + getObject() + ", " + getName() + ", " + getCaller() + ", " + getUnit() + ")";
}
} else {
return "(" + getObject() + ", " + getName() + ", " + getCaller() + ")";
}
| 965
| 142
| 1,107
|
<methods>public non-sealed void <init>() ,public void addAllTagsOf(soot.tagkit.Host) ,public void addTag(soot.tagkit.Tag) ,public int getJavaSourceStartColumnNumber() ,public int getJavaSourceStartLineNumber() ,public soot.tagkit.Tag getTag(java.lang.String) ,public List<soot.tagkit.Tag> getTags() ,public boolean hasTag(java.lang.String) ,public void removeAllTags() ,public void removeTag(java.lang.String) <variables>protected int col,protected int line,protected List<soot.tagkit.Tag> mTagList
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/synchronization/CriticalSectionGroup.java
|
CriticalSectionGroup
|
mergeGroups
|
class CriticalSectionGroup implements Iterable<CriticalSection> {
int groupNum;
// Information about the group members
List<CriticalSection> criticalSections;
// Group read/write set
RWSet rwSet;
// Information about the selected lock(s)
public boolean isDynamicLock; // is lockObject actually dynamic? or is it a static ref?
public boolean useDynamicLock; // use one dynamic lock per tn
public Value lockObject;
public boolean useLocksets;
public CriticalSectionGroup(int groupNum) {
this.groupNum = groupNum;
this.criticalSections = new ArrayList<CriticalSection>();
this.rwSet = new CodeBlockRWSet();
this.isDynamicLock = false;
this.useDynamicLock = false;
this.lockObject = null;
this.useLocksets = false;
}
public int num() {
return groupNum;
}
public int size() {
return criticalSections.size();
}
public void add(CriticalSection tn) {
tn.setNumber = groupNum;
tn.group = this;
if (!criticalSections.contains(tn)) {
criticalSections.add(tn);
}
}
public boolean contains(CriticalSection tn) {
return criticalSections.contains(tn);
}
public Iterator<CriticalSection> iterator() {
return criticalSections.iterator();
}
public void mergeGroups(CriticalSectionGroup other) {<FILL_FUNCTION_BODY>}
}
|
if (other == this) {
return;
}
Iterator<CriticalSection> tnIt = other.criticalSections.iterator();
while (tnIt.hasNext()) {
CriticalSection tn = tnIt.next();
add(tn);
}
other.criticalSections.clear();
| 410
| 87
| 497
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/synchronization/DeadlockAvoidanceEdge.java
|
DeadlockAvoidanceEdge
|
equals
|
class DeadlockAvoidanceEdge extends NewStaticLock {
public DeadlockAvoidanceEdge(SootClass sc) {
super(sc);
}
/** Clones the object. */
public Object clone() {
return new DeadlockAvoidanceEdge(sc);
}
public boolean equals(Object c) {<FILL_FUNCTION_BODY>}
public String toString() {
return "dae<" + sc.toString() + ">";
}
}
|
if (c instanceof DeadlockAvoidanceEdge) {
return ((DeadlockAvoidanceEdge) c).idnum == idnum;
}
return false;
| 125
| 45
| 170
|
<methods>public void <init>(soot.SootClass) ,public void apply(soot.util.Switch) ,public java.lang.Object clone() ,public boolean equals(java.lang.Object) ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public soot.SootClass getLockClass() ,public soot.Type getType() ,public List<soot.ValueBox> getUseBoxes() ,public int hashCode() ,public void toString(soot.UnitPrinter) ,public java.lang.String toString() <variables>int idnum,static int nextidnum,soot.SootClass sc
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/synchronization/NewStaticLock.java
|
NewStaticLock
|
equals
|
class NewStaticLock implements Value {
SootClass sc; // The class to which to add a static lock.
static int nextidnum = 1;
int idnum;
public NewStaticLock(SootClass sc) {
this.sc = sc;
this.idnum = nextidnum++;
}
public SootClass getLockClass() {
return sc;
}
@Override
public List<ValueBox> getUseBoxes() {
return Collections.emptyList();
}
/** Clones the object. Not implemented here. */
public Object clone() {
return new NewStaticLock(sc);
}
/**
* Returns true if this object is structurally equivalent to c. AbstractDataSources are equal and equivalent if their
* sourcename is the same
*/
public boolean equivTo(Object c) {
return equals(c);
}
public boolean equals(Object c) {<FILL_FUNCTION_BODY>}
/** Returns a hash code consistent with structural equality for this object. */
public int equivHashCode() {
return hashCode();
}
public int hashCode() {
return idnum;
}
public void toString(UnitPrinter up) {
}
public Type getType() {
return NullType.v();
}
public void apply(Switch sw) {
throw new RuntimeException("Not Implemented");
}
public String toString() {
return "<new static lock in " + sc.toString() + ">";
}
}
|
if (c instanceof NewStaticLock) {
return ((NewStaticLock) c).idnum == idnum;
}
return false;
| 401
| 38
| 439
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/thread/synchronization/SynchronizedRegionFlowPair.java
|
SynchronizedRegionFlowPair
|
toString
|
class SynchronizedRegionFlowPair {
private static final Logger logger = LoggerFactory.getLogger(SynchronizedRegionFlowPair.class);
// Information about the transactional region
public CriticalSection tn;
public boolean inside;
SynchronizedRegionFlowPair(CriticalSection tn, boolean inside) {
this.tn = tn;
this.inside = inside;
}
SynchronizedRegionFlowPair(SynchronizedRegionFlowPair tfp) {
this.tn = tfp.tn;
this.inside = tfp.inside;
}
public void copy(SynchronizedRegionFlowPair tfp) {
tfp.tn = this.tn;
tfp.inside = this.inside;
}
public SynchronizedRegionFlowPair clone() {
return new SynchronizedRegionFlowPair(tn, inside);
}
public boolean equals(Object other) {
// logger.debug(".");
if (other instanceof SynchronizedRegionFlowPair) {
SynchronizedRegionFlowPair tfp = (SynchronizedRegionFlowPair) other;
if (this.tn.IDNum == tfp.tn.IDNum) {
return true;
}
}
return false;
}
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "[" + (inside ? "in," : "out,") + tn.toString() + "]";
| 337
| 31
| 368
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/typing/ClassHierarchy.java
|
ClassHierarchy
|
typeNode
|
class ClassHierarchy {
/** Map: Scene -> ClassHierarchy **/
public final TypeNode OBJECT;
public final TypeNode CLONEABLE;
public final TypeNode SERIALIZABLE;
public final TypeNode NULL;
public final TypeNode INT;
// public final TypeNode UNKNOWN;
// public final TypeNode ERROR;
/** All type node instances **/
private final List<TypeNode> typeNodeList = new ArrayList<TypeNode>();
/** Map: Type -> TypeNode **/
private final HashMap<Type, TypeNode> typeNodeMap = new HashMap<Type, TypeNode>();
/** Used to transform boolean, byte, short and char to int **/
private final ToInt transform = new ToInt();
/** Used to create TypeNode instances **/
private final ConstructorChooser make = new ConstructorChooser();
private ClassHierarchy(Scene scene) {
if (scene == null) {
throw new InternalTypingException();
}
G.v().ClassHierarchy_classHierarchyMap.put(scene, this);
this.NULL = typeNode(NullType.v());
this.OBJECT = typeNode(Scene.v().getObjectType());
// hack for J2ME library which does not have Cloneable and Serializable
// reported by Stephen Chen
if (!Options.v().j2me() && Options.v().src_prec() != Options.src_prec_dotnet) {
this.CLONEABLE = typeNode(RefType.v("java.lang.Cloneable"));
this.SERIALIZABLE = typeNode(RefType.v("java.io.Serializable"));
} else {
this.CLONEABLE = null;
this.SERIALIZABLE = null;
}
this.INT = typeNode(IntType.v());
}
/** Get the class hierarchy for the given scene. **/
public static ClassHierarchy classHierarchy(Scene scene) {
if (scene == null) {
throw new InternalTypingException();
}
ClassHierarchy classHierarchy = G.v().ClassHierarchy_classHierarchyMap.get(scene);
if (classHierarchy == null) {
classHierarchy = new ClassHierarchy(scene);
}
return classHierarchy;
}
/** Get the type node for the given type. **/
public TypeNode typeNode(Type type) {<FILL_FUNCTION_BODY>}
/** Returns a string representation of this object **/
@Override
public String toString() {
StringBuilder s = new StringBuilder("ClassHierarchy:{");
boolean colon = false;
for (TypeNode typeNode : typeNodeList) {
if (colon) {
s.append(',');
} else {
colon = true;
}
s.append(typeNode);
}
s.append('}');
return s.toString();
}
/**
* Transforms boolean, byte, short and char into int.
**/
private static class ToInt extends TypeSwitch<Type> {
private final Type intType = IntType.v();
/** Transform boolean, byte, short and char into int. **/
public Type toInt(Type type) {
type.apply(this);
return getResult();
}
@Override
public void caseBooleanType(BooleanType type) {
setResult(intType);
}
@Override
public void caseByteType(ByteType type) {
setResult(intType);
}
@Override
public void caseShortType(ShortType type) {
setResult(intType);
}
@Override
public void caseCharType(CharType type) {
setResult(intType);
}
@Override
public void defaultCase(Type type) {
setResult(type);
}
}
/**
* Creates new TypeNode instances usign the appropriate constructor.
**/
private static class ConstructorChooser extends TypeSwitch<TypeNode> {
private int id;
private ClassHierarchy hierarchy;
/** Create a new TypeNode instance for the type parameter. **/
public TypeNode typeNode(int id, Type type, ClassHierarchy hierarchy) {
if (type == null || hierarchy == null) {
throw new InternalTypingException();
}
this.id = id;
this.hierarchy = hierarchy;
type.apply(this);
return getResult();
}
@Override
public void caseRefType(RefType type) {
setResult(new TypeNode(id, type, hierarchy));
}
@Override
public void caseArrayType(ArrayType type) {
setResult(new TypeNode(id, type, hierarchy));
}
@Override
public void defaultCase(Type type) {
setResult(new TypeNode(id, type, hierarchy));
}
}
}
|
if (type == null) {
throw new InternalTypingException();
}
type = transform.toInt(type);
TypeNode typeNode = typeNodeMap.get(type);
if (typeNode == null) {
int id = typeNodeList.size();
typeNodeList.add(null);
typeNode = make.typeNode(id, type, this);
typeNodeList.set(id, typeNode);
typeNodeMap.put(type, typeNode);
}
return typeNode;
| 1,272
| 136
| 1,408
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/typing/ConstraintCheckerBV.java
|
RuntimeTypeException
|
handleInvokeExpr
|
class RuntimeTypeException extends RuntimeException {
RuntimeTypeException(String message) {
super(message);
}
}
static void error(String message) {
throw new RuntimeTypeException(message);
}
private void handleInvokeExpr(InvokeExpr ie, Stmt invokestmt) {<FILL_FUNCTION_BODY>
|
if (ie instanceof InterfaceInvokeExpr) {
InterfaceInvokeExpr invoke = (InterfaceInvokeExpr) ie;
SootMethodRef method = invoke.getMethodRef();
Value base = invoke.getBase();
if (base instanceof Local) {
Local local = (Local) base;
if (!hierarchy.typeNode(local.getType()).hasAncestorOrSelf(hierarchy.typeNode(method.declaringClass().getType()))) {
if (fix) {
invoke.setBase(insertCast(local, method.declaringClass().getType(), invokestmt));
} else {
error("Type Error(7): local " + local + " is of incompatible type " + local.getType());
}
}
}
int count = invoke.getArgCount();
for (int i = 0; i < count; i++) {
if (invoke.getArg(i) instanceof Local) {
Local local = (Local) invoke.getArg(i);
if (!hierarchy.typeNode(local.getType()).hasAncestorOrSelf(hierarchy.typeNode(method.parameterType(i)))) {
if (fix) {
invoke.setArg(i, insertCast(local, method.parameterType(i), invokestmt));
} else {
error("Type Error(8)");
}
}
}
}
} else if (ie instanceof SpecialInvokeExpr) {
SpecialInvokeExpr invoke = (SpecialInvokeExpr) ie;
SootMethodRef method = invoke.getMethodRef();
Value base = invoke.getBase();
if (base instanceof Local) {
Local local = (Local) base;
if (!hierarchy.typeNode(local.getType()).hasAncestorOrSelf(hierarchy.typeNode(method.declaringClass().getType()))) {
if (fix) {
invoke.setBase(insertCast(local, method.declaringClass().getType(), invokestmt));
} else {
error("Type Error(9)");
}
}
}
int count = invoke.getArgCount();
for (int i = 0; i < count; i++) {
if (invoke.getArg(i) instanceof Local) {
Local local = (Local) invoke.getArg(i);
if (!hierarchy.typeNode(local.getType()).hasAncestorOrSelf(hierarchy.typeNode(method.parameterType(i)))) {
if (fix) {
invoke.setArg(i, insertCast(local, method.parameterType(i), invokestmt));
} else {
error("Type Error(10)");
}
}
}
}
} else if (ie instanceof VirtualInvokeExpr) {
VirtualInvokeExpr invoke = (VirtualInvokeExpr) ie;
SootMethodRef method = invoke.getMethodRef();
Value base = invoke.getBase();
if (base instanceof Local) {
Local local = (Local) base;
if (!hierarchy.typeNode(local.getType()).hasAncestorOrSelf(hierarchy.typeNode(method.declaringClass().getType()))) {
if (fix) {
invoke.setBase(insertCast(local, method.declaringClass().getType(), invokestmt));
} else {
error("Type Error(13)");
}
}
}
int count = invoke.getArgCount();
for (int i = 0; i < count; i++) {
if (invoke.getArg(i) instanceof Local) {
Local local = (Local) invoke.getArg(i);
if (!hierarchy.typeNode(local.getType()).hasAncestorOrSelf(hierarchy.typeNode(method.parameterType(i)))) {
if (fix) {
invoke.setArg(i, insertCast(local, method.parameterType(i), invokestmt));
} else {
error("Type Error(14)");
}
}
}
}
} else if (ie instanceof StaticInvokeExpr) {
StaticInvokeExpr invoke = (StaticInvokeExpr) ie;
SootMethodRef method = invoke.getMethodRef();
int count = invoke.getArgCount();
for (int i = 0; i < count; i++) {
if (invoke.getArg(i) instanceof Local) {
Local local = (Local) invoke.getArg(i);
if (!hierarchy.typeNode(local.getType()).hasAncestorOrSelf(hierarchy.typeNode(method.parameterType(i)))) {
if (fix) {
invoke.setArg(i, insertCast(local, method.parameterType(i), invokestmt));
} else {
error("Type Error(15)");
}
}
}
}
} else {
throw new RuntimeException("Unhandled invoke expression type: " + ie.getClass());
}
| 90
| 1,272
| 1,362
|
<methods>public non-sealed void <init>() ,public void caseAssignStmt(soot.jimple.AssignStmt) ,public void caseBreakpointStmt(soot.jimple.BreakpointStmt) ,public void caseEnterMonitorStmt(soot.jimple.EnterMonitorStmt) ,public void caseExitMonitorStmt(soot.jimple.ExitMonitorStmt) ,public void caseGotoStmt(soot.jimple.GotoStmt) ,public void caseIdentityStmt(soot.jimple.IdentityStmt) ,public void caseIfStmt(soot.jimple.IfStmt) ,public void caseInvokeStmt(soot.jimple.InvokeStmt) ,public void caseLookupSwitchStmt(soot.jimple.LookupSwitchStmt) ,public void caseNopStmt(soot.jimple.NopStmt) ,public void caseRetStmt(soot.jimple.RetStmt) ,public void caseReturnStmt(soot.jimple.ReturnStmt) ,public void caseReturnVoidStmt(soot.jimple.ReturnVoidStmt) ,public void caseTableSwitchStmt(soot.jimple.TableSwitchStmt) ,public void caseThrowStmt(soot.jimple.ThrowStmt) ,public void defaultCase(java.lang.Object) ,public java.lang.Object getResult() ,public void setResult(java.lang.Object) <variables>java.lang.Object result
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/typing/Util.java
|
Util
|
findLastIdentityUnit
|
class Util {
/**
* A new "normal" statement cannot be inserted in the middle of special "identity statements" (a = @parameter or b = @this
* in Jimple).
*
* This method returns the last "identity statement" of the method.
*
* @param b
* @param s
* @return
*/
public static Unit findLastIdentityUnit(Body b, Stmt s) {<FILL_FUNCTION_BODY>}
/**
* Returns the first statement after all the "identity statements".
*
* @param b
* @param s
* @return
*/
public static Unit findFirstNonIdentityUnit(Body b, Stmt s) {
final Chain<Unit> units = b.getUnits();
Unit u1 = s;
while (u1 instanceof IdentityStmt) {
u1 = units.getSuccOf(u1);
}
return u1;
}
private Util() {
}
}
|
final Chain<Unit> units = b.getUnits();
Unit u2 = s;
for (Unit u1 = u2; u1 instanceof IdentityStmt;) {
u2 = u1;
u1 = units.getSuccOf(u1);
}
return u2;
| 254
| 79
| 333
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/typing/fast/AugEvalFunction.java
|
AugEvalFunction
|
eval_
|
class AugEvalFunction implements IEvalFunction {
private final JimpleBody jb;
public AugEvalFunction(JimpleBody jb) {
this.jb = jb;
}
public static Type eval_(Typing tg, Value expr, Stmt stmt, JimpleBody jb) {<FILL_FUNCTION_BODY>}
@Override
public Collection<Type> eval(Typing tg, Value expr, Stmt stmt) {
return Collections.<Type>singletonList(eval_(tg, expr, stmt, this.jb));
}
}
|
if (expr instanceof ThisRef) {
return ((ThisRef) expr).getType();
} else if (expr instanceof ParameterRef) {
return ((ParameterRef) expr).getType();
} else if (expr instanceof Local) {
// Changed to prevent null pointer exception in case of phantom classes where a null typing is
// encountered. -syed
return (tg == null) ? null : tg.get((Local) expr);
} else if (expr instanceof BinopExpr) {
BinopExpr be = (BinopExpr) expr;
Type tl = eval_(tg, be.getOp1(), stmt, jb), tr = eval_(tg, be.getOp2(), stmt, jb);
if (expr instanceof CmpExpr || expr instanceof CmpgExpr || expr instanceof CmplExpr) {
return ByteType.v();
} else if (expr instanceof GeExpr || expr instanceof GtExpr || expr instanceof LeExpr || expr instanceof LtExpr
|| expr instanceof EqExpr || expr instanceof NeExpr) {
return BooleanType.v();
} else if (expr instanceof ShlExpr || expr instanceof ShrExpr || expr instanceof UshrExpr) {
// In the JVM, there are op codes for integer and long only. In Java, the code
// {@code short s = 2; s = s << s;} does not compile, since s << s is an integer.
return (tl instanceof IntegerType) ? IntType.v() : tl;
} else if (expr instanceof AddExpr || expr instanceof SubExpr || expr instanceof MulExpr || expr instanceof DivExpr
|| expr instanceof RemExpr) {
return (tl instanceof IntegerType) ? IntType.v() : tl;
} else if (expr instanceof AndExpr || expr instanceof OrExpr || expr instanceof XorExpr) {
if (tl instanceof IntegerType && tr instanceof IntegerType) {
if (tl instanceof BooleanType) {
return (tr instanceof BooleanType) ? BooleanType.v() : tr;
} else if (tr instanceof BooleanType) {
return tl;
} else {
Collection<Type> rs = AugHierarchy.lcas_(tl, tr, false);
if (rs.isEmpty()) {
throw new RuntimeException();
} else {
// AugHierarchy.lcas_ is single-valued
assert (rs.size() == 1);
return rs.iterator().next();
}
}
} else {
return (tl instanceof RefLikeType) ? tr : tl;
}
} else {
throw new RuntimeException("Unhandled binary expression: " + expr);
}
} else if (expr instanceof NegExpr) {
Type t = eval_(tg, ((NegExpr) expr).getOp(), stmt, jb);
if (t instanceof IntegerType) {
// The "ineg" bytecode causes and implicit widening to int type and produces an int type.
return IntType.v();
} else {
return t;
}
} else if (expr instanceof CaughtExceptionRef) {
RefType throwableType = Scene.v().getBaseExceptionType();
RefType r = null;
for (RefType t : TrapManager.getExceptionTypesOf(stmt, jb)) {
if (t.getSootClass().isPhantom()) {
r = throwableType;
} else if (r == null) {
r = t;
} else {
/*
* In theory, we could have multiple exception types pointing here. The JLS requires the exception parameter be a
* *subclass* of Throwable, so we do not need to worry about multiple inheritance.
*/
r = BytecodeHierarchy.lcsc(r, t, throwableType);
}
}
if (r == null) {
throw new RuntimeException("Exception reference used other than as the first statement of an exception handler.");
}
return r;
} else if (expr instanceof ArrayRef) {
Type at = tg.get((Local) ((ArrayRef) expr).getBase());
if (at instanceof ArrayType) {
return ((ArrayType) at).getElementType();
} else if (at instanceof WeakObjectType) {
return at;
} else if (at instanceof RefType) {
String name = ((RefType) at).getSootClass().getName();
if (name.equals(Scene.v().getObjectType().toString())) {
return new WeakObjectType(name);
}
switch (name) {
case "java.lang.Cloneable":
case "java.lang.Object":
case "java.io.Serializable":
case DotnetBasicTypes.SYSTEM_ARRAY:
return new WeakObjectType(name);
default:
return BottomType.v();
}
} else {
return BottomType.v();
}
} else if (expr instanceof NewArrayExpr) {
return ((NewArrayExpr) expr).getBaseType().makeArrayType();
} else if (expr instanceof NewMultiArrayExpr) {
return ((NewMultiArrayExpr) expr).getBaseType();
} else if (expr instanceof CastExpr) {
return ((CastExpr) expr).getCastType();
} else if (expr instanceof InstanceOfExpr) {
return BooleanType.v();
} else if (expr instanceof LengthExpr) {
return IntType.v();
} else if (expr instanceof InvokeExpr) {
return ((InvokeExpr) expr).getMethodRef().getReturnType();
} else if (expr instanceof NewExpr) {
return ((NewExpr) expr).getBaseType();
} else if (expr instanceof FieldRef) {
return ((FieldRef) expr).getType();
} else if (expr instanceof DoubleConstant) {
return DoubleType.v();
} else if (expr instanceof FloatConstant) {
return FloatType.v();
} else if (expr instanceof IntConstant) {
int value = ((IntConstant) expr).value;
if (value >= 0 && value < 2) {
return Integer1Type.v();
} else if (value >= 2 && value < 128) {
return Integer127Type.v();
} else if (value >= -128 && value < 0) {
return ByteType.v();
} else if (value >= 128 && value < 32768) {
return Integer32767Type.v();
} else if (value >= -32768 && value < -128) {
return ShortType.v();
} else if (value >= 32768 && value < 65536) {
return CharType.v();
} else {
return IntType.v();
}
} else if (expr instanceof LongConstant) {
return LongType.v();
} else if (expr instanceof NullConstant) {
return NullType.v();
} else if (expr instanceof StringConstant) {
return RefType.v("java.lang.String");
} else if (expr instanceof ClassConstant) {
return RefType.v("java.lang.Class");
} else if (expr instanceof MethodHandle) {
return RefType.v("java.lang.invoke.MethodHandle");
} else if (expr instanceof MethodType) {
return RefType.v("java.lang.invoke.MethodType");
} else {
throw new RuntimeException("Unhandled expression: " + expr);
}
| 158
| 1,869
| 2,027
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/typing/fast/IntUtils.java
|
IntUtils
|
getTypeByWidth
|
class IntUtils {
/**
* Returns an appropriate integer for a given maximum element.
*
* Throws an exception in case of an unsupported size.
*
* @param maxValue
* the max value
* @return the integer
*/
public static IntegerType getTypeByWidth(int maxValue) {<FILL_FUNCTION_BODY>}
/**
* Returns the maximum value an integer type can have.
*
* @param t
* the integer type
* @return the maximum value
*/
public static int getMaxValue(IntegerType t) {
if (t instanceof Integer1Type || t instanceof BooleanType) {
return 1;
}
if (t instanceof Integer127Type || t instanceof ByteType) {
return 127;
}
if (t instanceof Integer32767Type || t instanceof ShortType || t instanceof CharType) {
return 32767;
}
if (t instanceof IntType) {
return Integer.MAX_VALUE;
}
throw new RuntimeException("Unsupported type: " + t);
}
}
|
switch (maxValue) {
case 1:
return Integer1Type.v();
case 127:
return Integer127Type.v();
case 32767:
return Integer32767Type.v();
case Integer.MAX_VALUE:
return IntType.v();
default:
throw new RuntimeException("Unsupported width: " + maxValue);
}
| 291
| 108
| 399
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/typing/fast/QueuedSet.java
|
QueuedSet
|
addLast
|
class QueuedSet<E> {
private final Set<E> hs;
private final LinkedList<E> ll;
public QueuedSet() {
this.hs = new HashSet<E>();
this.ll = new LinkedList<E>();
}
public QueuedSet(List<E> os) {
this();
for (E o : os) {
this.ll.addLast(o);
this.hs.add(o);
}
}
public QueuedSet(QueuedSet<E> qs) {
this(qs.ll);
}
public boolean isEmpty() {
return this.ll.isEmpty();
}
public boolean addLast(E o) {
boolean r = this.hs.contains(o);
if (!r) {
this.ll.addLast(o);
this.hs.add(o);
}
return r;
}
public int addLast(List<E> os) {<FILL_FUNCTION_BODY>}
public E removeFirst() {
E r = this.ll.removeFirst();
this.hs.remove(r);
return r;
}
}
|
int r = 0;
for (E o : os) {
if (this.addLast(o)) {
r++;
}
}
return r;
| 309
| 48
| 357
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/typing/fast/SingletonList.java
|
SingletonList
|
get
|
class SingletonList<E> extends AbstractList<E> {
private final E e;
public SingletonList(E e) {
this.e = e;
}
@Override
public E get(int index) {<FILL_FUNCTION_BODY>}
@Override
public int size() {
return 1;
}
}
|
if (index != 0) {
throw new IndexOutOfBoundsException();
} else {
return this.e;
}
| 96
| 38
| 134
|
<methods>public boolean add(E) ,public void add(int, E) ,public boolean addAll(int, Collection<? extends E>) ,public void clear() ,public boolean equals(java.lang.Object) ,public abstract E get(int) ,public int hashCode() ,public int indexOf(java.lang.Object) ,public Iterator<E> iterator() ,public int lastIndexOf(java.lang.Object) ,public ListIterator<E> listIterator() ,public ListIterator<E> listIterator(int) ,public E remove(int) ,public E set(int, E) ,public List<E> subList(int, int) <variables>protected transient int modCount
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/typing/fast/TypeResolver.java
|
TypeDecision
|
applyAssignmentConstraints
|
class TypeDecision {
// Record type decision for different type tuples.
List<TypeContainer> containers;
TypeDecision() {
containers = new ArrayList<>();
}
public void addTypeDecision(TypeContainer container) {
for (TypeContainer c : this.containers) {
if ((typesEqual(container.lType, c.lType) && typesEqual(container.rType, c.rType)
|| (typesEqual(container.lType, c.rType) && typesEqual(container.rType, c.lType)))) {
return;
}
}
this.containers.add(container);
}
public Type getTypeDecision(Type l, Type r) {
for (TypeContainer container : this.containers) {
if (typesEqual(container.lType, l) && typesEqual(container.rType, r)) {
return container.target;
}
if (typesEqual(container.lType, r) && typesEqual(container.rType, l)) {
return container.target;
}
}
return BottomType.v();
}
public TypeDecision copy() {
TypeDecision decision = new TypeDecision();
for (TypeContainer container : this.containers) {
decision.containers.add(new TypeContainer(container.lType, container.rType, container.target));
}
return decision;
}
public void removeLast() {
// Remove the last one.
if (!this.containers.isEmpty()) {
this.containers.remove(this.containers.size() - 1);
}
}
}
protected Collection<Typing> applyAssignmentConstraints(Typing tg, IEvalFunction ef, IHierarchy h) {<FILL_FUNCTION_BODY>
|
final int numAssignments = this.assignments.size();
if (numAssignments == 0) {
return Collections.emptyList();
}
ArrayDeque<WorklistElement> sigma = createSigmaQueue();
List<Typing> r = createResultList();
final ITypingStrategy typingStrategy = getTypingStrategy();
BitSet wl = new BitSet(numAssignments);
wl.set(0, numAssignments);
sigma.add(new WorklistElement(tg, wl, new TypeDecision()));
Set<Type> throwable = null;
while (!sigma.isEmpty()) {
WorklistElement element = sigma.element();
tg = element.typing;
wl = element.worklist;
TypeDecision ds = element.decision;
int defIdx = wl.nextSetBit(0);
if (defIdx == -1) {
// worklist is empty
r.add(tg);
sigma.remove();
} else {
// Get the next definition statement
wl.clear(defIdx);
final DefinitionStmt stmt = this.assignments.get(defIdx);
Value lhs = stmt.getLeftOp();
Local v = (lhs instanceof Local) ? (Local) lhs : (Local) ((ArrayRef) lhs).getBase();
Type told = tg.get(v);
boolean isFirstType = true;
for (Type t_ : ef.eval(tg, stmt.getRightOp(), stmt)) {
if (lhs instanceof ArrayRef) {
/*
* We only need to consider array references on the LHS of assignments where there is supertyping between array
* types, which is only for arrays of reference types and multidimensional arrays.
*/
if (!(t_ instanceof RefType || t_ instanceof ArrayType || t_ instanceof WeakObjectType)) {
continue;
}
t_ = t_.makeArrayType();
}
// Special handling for exception objects with phantom types
final Collection<Type> lcas;
if (!typesEqual(told, t_) && told instanceof RefType && t_ instanceof RefType
&& (((RefType) told).getSootClass().isPhantom() || ((RefType) t_).getSootClass().isPhantom())
&& (stmt.getRightOp() instanceof CaughtExceptionRef)) {
if (throwable == null) {
throwable = Collections.<Type>singleton(Scene.v().getBaseExceptionType());
}
lcas = throwable;
} else {
Type featureType = ds.getTypeDecision(told, t_);
if (!typesEqual(featureType, BottomType.v())) {
// Use feature type.
lcas = Collections.singleton(featureType);
} else {
lcas = h.lcas(told, t_, true);
}
}
boolean addFirstDecision = false;
for (Type t : lcas) {
if (!typesEqual(t, told)) {
BitSet dependsV = this.depends.get(v);
Typing tg_;
BitSet wl_;
TypeDecision ds_;
if (/* (eval.size() == 1 && lcas.size() == 1) || */isFirstType) {
// The types agree, we have a type we can directly use
tg_ = tg;
wl_ = wl;
ds_ = ds;
} else {
// The types do not agree, add all supertype candidates
tg_ = typingStrategy.createTyping(tg);
wl_ = (BitSet) wl.clone();
ds_ = ds.copy();
if (addFirstDecision) {
ds_.removeLast();
}
WorklistElement e = new WorklistElement(tg_, wl_, ds_);
sigma.add(e);
}
if (!typesEqual(told, BottomType.v()) && !typesEqual(t_, BottomType.v())) {
// 't' is base class of type 'told' & 't_';
// It will decide the feature type by target value.
TypeContainer container = new TypeContainer(told, t_, t);
ds_.addTypeDecision(container);
// At first type, we will modify the base feature type decisions, and at the next type it will
// copy the old feature type decisions and used the dirty data(so mark it and remove).
addFirstDecision = isFirstType;
}
tg_.set(v, t);
if (dependsV != null) {
wl_.or(dependsV);
}
}
isFirstType = false;
}
} // end for
}
}
typingStrategy.minimize(r, h);
return r;
| 458
| 1,231
| 1,689
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/toolkits/typing/fast/Typing.java
|
Typing
|
toString
|
class Typing {
protected HashMap<Local, Type> map;
public Typing(Collection<Local> vs) {
this.map = new HashMap<Local, Type>(vs.size());
}
public Typing(Typing tg) {
this.map = new HashMap<Local, Type>(tg.map);
}
public Map<Local, Type> getMap() {
return map;
}
public Type get(Local v) {
Type t = this.map.get(v);
return (t == null) ? BottomType.v() : t;
}
public Type set(Local v, Type t) {
return (t instanceof BottomType) ? null : this.map.put(v, t);
}
public Collection<Local> getAllLocals() {
return map.keySet();
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
StringBuilder sb = new StringBuilder();
sb.append('{');
for (Map.Entry<Local, Type> e : this.map.entrySet()) {
sb.append(e.getKey());
sb.append(':');
sb.append(e.getValue());
sb.append(',');
}
sb.append('}');
return sb.toString();
| 249
| 98
| 347
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/plugins/model/PhasePluginDescription.java
|
PhasePluginDescription
|
toString
|
class PhasePluginDescription extends PluginDescription {
/**
* Name of phase. Make sure it consists of '<pack>.<phase>'.
*/
private String phaseName;
/**
* Name of the plugin class that has to implement {@link SootPhasePlugin}.
*/
private String className;
@XmlAttribute(name = "class", required = true)
public String getClassName() {
return className;
}
public void setClassName(final String name) {
this.className = name;
}
@XmlAttribute(name = "phase", required = true)
public String getPhaseName() {
return phaseName;
}
public void setPhaseName(final String name) {
phaseName = name;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "<PhasePluginDescription name=" + getPhaseName() + " class= " + getClassName() + ">";
| 231
| 35
| 266
|
<methods>public non-sealed void <init>() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/rtlib/tamiflex/ReflectiveCalls.java
|
ReflectiveCalls
|
knownMethodInvoke
|
class ReflectiveCalls {
private final static Set<String> classForName = new HashSet<String>();
private final static Set<String> classNewInstance = new HashSet<String>();
private final static Set<String> constructorNewInstance = new HashSet<String>();
private final static Set<String> methodInvoke = new HashSet<String>();
private final static Set<String> fieldSet = new HashSet<String>();
private final static Set<String> fieldGet = new HashSet<String>();
static {
// soot will add initialization code here
}
public static void knownClassForName(int contextId, String className) {
if (!classForName.contains(contextId + className)) {
UnexpectedReflectiveCall.classForName(className);
}
}
public static void knownClassNewInstance(int contextId, Class<?> c) {
if (!classNewInstance.contains(contextId + c.getName())) {
UnexpectedReflectiveCall.classNewInstance(c);
}
}
public static void knownConstructorNewInstance(int contextId, Constructor<?> c) {
if (!constructorNewInstance.contains(contextId + SootSig.sootSignature(c))) {
UnexpectedReflectiveCall.constructorNewInstance(c);
}
}
public static void knownMethodInvoke(int contextId, Object o, Method m) {<FILL_FUNCTION_BODY>}
public static void knownFieldSet(int contextId, Object o, Field f) {
if (!fieldSet.contains(contextId + SootSig.sootSignature(f))) {
UnexpectedReflectiveCall.fieldSet(o, f);
}
}
public static void knownFieldGet(int contextId, Object o, Field f) {
if (!fieldGet.contains(contextId + SootSig.sootSignature(f))) {
UnexpectedReflectiveCall.fieldGet(o, f);
}
}
}
|
if (!methodInvoke.contains(contextId + SootSig.sootSignature(o, m))) {
UnexpectedReflectiveCall.methodInvoke(o, m);
}
| 506
| 51
| 557
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/rtlib/tamiflex/SootSig.java
|
SootSig
|
sootSignature
|
class SootSig {
private static final Logger logger = LoggerFactory.getLogger(SootSig.class);
// TODO should be a map with soft keys, actually
private static Map<Constructor<?>, String> constrCache = new ConcurrentHashMap<Constructor<?>, String>();
// TODO should be a map with soft keys, actually
private static Map<Method, String> methodCache = new ConcurrentHashMap<Method, String>();
public static String sootSignature(Constructor<?> c) {
String res = constrCache.get(c);
if (res == null) {
String[] paramTypes = classesToTypeNames(c.getParameterTypes());
res = sootSignature(c.getDeclaringClass().getName(), "void", "<init>", paramTypes);
constrCache.put(c, res);
}
return res;
}
public static String sootSignature(Object receiver, Method m) {<FILL_FUNCTION_BODY>}
private static String[] classesToTypeNames(Class<?>[] params) {
String[] paramTypes = new String[params.length];
int i = 0;
for (Class<?> type : params) {
paramTypes[i] = getTypeName(type);
i++;
}
return paramTypes;
}
private static String getTypeName(Class<?> type) {
// copied from java.lang.reflect.Field.getTypeName(Class)
if (type.isArray()) {
try {
Class<?> cl = type;
int dimensions = 0;
while (cl.isArray()) {
dimensions++;
cl = cl.getComponentType();
}
StringBuilder sb = new StringBuilder();
sb.append(cl.getName());
for (int i = 0; i < dimensions; i++) {
sb.append("[]");
}
return sb.toString();
} catch (Throwable e) {
/* FALLTHRU */ }
}
return type.getName();
}
private static String sootSignature(String declaringClass, String returnType, String name, String... paramTypes) {
StringBuilder b = new StringBuilder();
b.append('<');
b.append(declaringClass);
b.append(": ");
b.append(returnType);
b.append(' ');
b.append(name);
b.append('(');
int i = 0;
for (String type : paramTypes) {
i++;
b.append(type);
if (i < paramTypes.length) {
b.append(',');
}
}
b.append(")>");
return b.toString();
}
public static String sootSignature(Field f) {
StringBuilder b = new StringBuilder();
b.append('<');
b.append(getTypeName(f.getDeclaringClass()));
b.append(": ");
b.append(getTypeName(f.getType()));
b.append(' ');
b.append(f.getName());
b.append('>');
return b.toString();
}
}
|
Class<?> receiverClass = Modifier.isStatic(m.getModifiers()) ? m.getDeclaringClass() : receiver.getClass();
try {
// resolve virtual call
Method resolved = null;
Class<?> c = receiverClass;
do {
try {
resolved = c.getDeclaredMethod(m.getName(), m.getParameterTypes());
} catch (NoSuchMethodException e) {
c = c.getSuperclass();
}
} while (resolved == null && c != null);
if (resolved == null) {
Error error = new Error("Method not found : " + m + " in class " + receiverClass + " and super classes.");
logger.error(error.getMessage(), error);
}
String res = methodCache.get(resolved);
if (res == null) {
String[] paramTypes = classesToTypeNames(resolved.getParameterTypes());
res = sootSignature(resolved.getDeclaringClass().getName(), getTypeName(resolved.getReturnType()),
resolved.getName(), paramTypes);
methodCache.put(resolved, res);
}
return res;
} catch (Exception e) {
throw new RuntimeException(e);
}
| 800
| 303
| 1,103
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/shimple/DefaultShimpleFactory.java
|
DefaultShimpleFactory
|
getReverseDominanceFrontier
|
class DefaultShimpleFactory implements ShimpleFactory {
protected final Body body;
protected UnitGraph ug;
protected BlockGraph bg;
protected DominatorsFinder<Block> dFinder;
protected DominatorTree<Block> dTree;
protected DominanceFrontier<Block> dFrontier;
protected GlobalValueNumberer gvn;
protected ReversibleGraph<Block> rbg;
protected DominatorsFinder<Block> rdFinder;
protected DominatorTree<Block> rdTree;
protected DominanceFrontier<Block> rdFrontier;
public DefaultShimpleFactory(Body body) {
this.body = body;
}
@Override
public void clearCache() {
this.ug = null;
this.bg = null;
this.dFinder = null;
this.dTree = null;
this.dFrontier = null;
this.gvn = null;
this.rbg = null;
this.rdFinder = null;
this.rdTree = null;
this.rdFrontier = null;
}
public Body getBody() {
Body body = this.body;
if (body == null) {
throw new RuntimeException("Assertion failed: Call setBody() first.");
}
return body;
}
@Override
public ReversibleGraph<Block> getReverseBlockGraph() {
ReversibleGraph<Block> rbg = this.rbg;
if (rbg == null) {
rbg = new HashReversibleGraph<Block>(getBlockGraph());
rbg.reverse();
this.rbg = rbg;
}
return rbg;
}
@Override
public DominatorsFinder<Block> getReverseDominatorsFinder() {
DominatorsFinder<Block> rdFinder = this.rdFinder;
if (rdFinder == null) {
rdFinder = new SimpleDominatorsFinder<Block>(getReverseBlockGraph());
this.rdFinder = rdFinder;
}
return rdFinder;
}
@Override
public DominatorTree<Block> getReverseDominatorTree() {
DominatorTree<Block> rdTree = this.rdTree;
if (rdTree == null) {
rdTree = new DominatorTree<Block>(getReverseDominatorsFinder());
this.rdTree = rdTree;
}
return rdTree;
}
@Override
public DominanceFrontier<Block> getReverseDominanceFrontier() {<FILL_FUNCTION_BODY>}
@Override
public BlockGraph getBlockGraph() {
BlockGraph bg = this.bg;
if (bg == null) {
bg = new ExceptionalBlockGraph((ExceptionalUnitGraph) getUnitGraph());
BlockGraphConverter.addStartStopNodesTo(bg);
this.bg = bg;
}
return bg;
}
@Override
public UnitGraph getUnitGraph() {
UnitGraph ug = this.ug;
if (ug == null) {
Body body = getBody();
UnreachableCodeEliminator.v().transform(body);
ug = ExceptionalUnitGraphFactory.createExceptionalUnitGraph(body);
this.ug = ug;
}
return ug;
}
@Override
public DominatorsFinder<Block> getDominatorsFinder() {
DominatorsFinder<Block> dFinder = this.dFinder;
if (dFinder == null) {
dFinder = new SimpleDominatorsFinder<Block>(getBlockGraph());
this.dFinder = dFinder;
}
return dFinder;
}
@Override
public DominatorTree<Block> getDominatorTree() {
DominatorTree<Block> dTree = this.dTree;
if (dTree == null) {
dTree = new DominatorTree<Block>(getDominatorsFinder());
this.dTree = dTree;
}
return dTree;
}
@Override
public DominanceFrontier<Block> getDominanceFrontier() {
DominanceFrontier<Block> dFrontier = this.dFrontier;
if (dFrontier == null) {
dFrontier = new CytronDominanceFrontier<Block>(getDominatorTree());
this.dFrontier = dFrontier;
}
return dFrontier;
}
@Override
public GlobalValueNumberer getGlobalValueNumberer() {
GlobalValueNumberer gvn = this.gvn;
if (gvn == null) {
gvn = new SimpleGlobalValueNumberer(getBlockGraph());
this.gvn = gvn;
}
return gvn;
}
}
|
DominanceFrontier<Block> rdFrontier = this.rdFrontier;
if (rdFrontier == null) {
rdFrontier = new CytronDominanceFrontier<Block>(getReverseDominatorTree());
this.rdFrontier = rdFrontier;
}
return rdFrontier;
| 1,265
| 96
| 1,361
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/shimple/ShimpleTransformer.java
|
ShimpleTransformer
|
internalTransform
|
class ShimpleTransformer extends SceneTransformer {
private static final Logger logger = LoggerFactory.getLogger(ShimpleTransformer.class);
public ShimpleTransformer(Singletons.Global g) {
}
public static ShimpleTransformer v() {
return G.v().soot_shimple_ShimpleTransformer();
}
@Override
protected void internalTransform(String phaseName, Map options) {<FILL_FUNCTION_BODY>}
}
|
if (Options.v().verbose()) {
logger.debug("Transforming all classes in the Scene to Shimple...");
}
// *** FIXME: Add debug output to indicate which class/method is being shimplified.
// *** FIXME: Is ShimpleTransformer the right solution? The call graph may deem
// some classes unreachable.
for (SootClass sClass : Scene.v().getClasses()) {
if (!sClass.isPhantom()) {
for (SootMethod method : sClass.getMethods()) {
if (method.isConcrete()) {
if (method.hasActiveBody()) {
Body body = method.getActiveBody();
ShimpleBody sBody;
if (body instanceof ShimpleBody) {
sBody = (ShimpleBody) body;
if (!sBody.isSSA()) {
sBody.rebuild();
}
} else {
sBody = Shimple.v().newBody(body);
}
method.setActiveBody(sBody);
} else {
method.setSource(new ShimpleMethodSource(method.getSource()));
}
}
}
}
}
| 128
| 309
| 437
|
<methods>public non-sealed void <init>() ,public final void transform(java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(java.lang.String) ,public final void transform() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/shimple/internal/SPiExpr.java
|
SPiExpr
|
equivTo
|
class SPiExpr implements PiExpr {
protected ValueUnitPair argBox;
protected Object targetKey;
public SPiExpr(Value v, Unit u, Object o) {
this.argBox = new SValueUnitPair(v, u);
this.targetKey = o;
}
@Override
public ValueUnitPair getArgBox() {
return argBox;
}
@Override
public Value getValue() {
return argBox.getValue();
}
@Override
public Unit getCondStmt() {
return argBox.getUnit();
}
@Override
public Object getTargetKey() {
return targetKey;
}
@Override
public void setValue(Value value) {
argBox.setValue(value);
}
@Override
public void setCondStmt(Unit pred) {
argBox.setUnit(pred);
}
@Override
public void setTargetKey(Object targetKey) {
this.targetKey = targetKey;
}
@Override
public List<UnitBox> getUnitBoxes() {
return Collections.<UnitBox>singletonList(argBox);
}
@Override
public void clearUnitBoxes() {
argBox.setUnit(null);
}
@Override
public boolean equivTo(Object o) {<FILL_FUNCTION_BODY>}
@Override
public int equivHashCode() {
return getArgBox().equivHashCode() * 17;
}
@Override
public void apply(Switch sw) {
// *** FIXME:
throw new RuntimeException("Not Yet Implemented.");
}
@Override
public Object clone() {
return new SPiExpr(getValue(), getCondStmt(), getTargetKey());
}
@Override
public String toString() {
return Shimple.PI + "(" + getValue() + ")";
}
@Override
public void toString(UnitPrinter up) {
up.literal(Shimple.PI);
up.literal("(");
argBox.toString(up);
up.literal(" [");
up.literal(targetKey.toString());
up.literal("])");
}
@Override
public Type getType() {
return getValue().getType();
}
@Override
public List<ValueBox> getUseBoxes() {
return Collections.<ValueBox>singletonList(argBox);
}
}
|
if (o instanceof SPiExpr) {
return getArgBox().equivTo(((SPiExpr) o).getArgBox());
} else {
return false;
}
| 648
| 48
| 696
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/shimple/toolkits/scalar/SConstantPropagatorAndFolder.java
|
SConstantPropagatorAndFolder
|
internalTransform
|
class SConstantPropagatorAndFolder extends BodyTransformer {
private static final Logger logger = LoggerFactory.getLogger(SConstantPropagatorAndFolder.class);
public SConstantPropagatorAndFolder(Singletons.Global g) {
}
public static SConstantPropagatorAndFolder v() {
return G.v().soot_shimple_toolkits_scalar_SConstantPropagatorAndFolder();
}
protected ShimpleBody sb;
protected boolean debug;
@Override
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
/**
* Propagates constants to the definition and uses of the relevant locals given a mapping. Notice that we use the Shimple
* implementation of LocalDefs and LocalUses.
**/
protected void propagateResults(Map<Local, Constant> localToConstant) {
ShimpleLocalDefs localDefs = new ShimpleLocalDefs(sb);
ShimpleLocalUses localUses = new ShimpleLocalUses(sb);
for (Local local : sb.getLocals()) {
Constant constant = localToConstant.get(local);
if (constant instanceof MetaConstant) {
continue;
}
// update definition
{
DefinitionStmt stmt = (DefinitionStmt) localDefs.getDefsOf(local).get(0);
ValueBox defSrcBox = stmt.getRightOpBox();
Value defSrcOld = defSrcBox.getValue();
if (defSrcBox.canContainValue(constant)) {
defSrcBox.setValue(constant);
// remove dangling pointers
if (defSrcOld instanceof UnitBoxOwner) {
((UnitBoxOwner) defSrcOld).clearUnitBoxes();
}
} else if (debug) {
logger.warn("Couldn't propagate constant " + constant + " to box " + defSrcBox.getValue() + " in unit " + stmt);
}
}
// update uses
for (UnitValueBoxPair pair : localUses.getUsesOf(local)) {
ValueBox useBox = pair.getValueBox();
if (useBox.canContainValue(constant)) {
useBox.setValue(constant);
} else if (debug) {
logger.warn(
"Couldn't propagate constant " + constant + " to box " + useBox.getValue() + " in unit " + pair.getUnit());
}
}
}
}
/**
* Removes the given list of fall through IfStmts from the body.
**/
protected void removeStmts(List<IfStmt> deadStmts) {
Chain<Unit> units = sb.getUnits();
for (IfStmt dead : deadStmts) {
units.remove(dead);
dead.clearUnitBoxes();
}
}
/**
* Replaces conditional branches by unconditional branches as given by the mapping.
**/
protected void replaceStmts(Map<Stmt, GotoStmt> stmtsToReplace) {
Chain<Unit> units = sb.getUnits();
for (Map.Entry<Stmt, GotoStmt> e : stmtsToReplace.entrySet()) {
// important not to call clearUnitBoxes() on key since
// replacement uses the same UnitBox
units.swapWith(e.getKey(), e.getValue());
}
}
}
|
if (!(b instanceof ShimpleBody)) {
throw new RuntimeException("SConstantPropagatorAndFolder requires a ShimpleBody.");
}
ShimpleBody castBody = (ShimpleBody) b;
if (!castBody.isSSA()) {
throw new RuntimeException("ShimpleBody is not in proper SSA form as required by SConstantPropagatorAndFolder. "
+ "You may need to rebuild it or use ConstantPropagatorAndFolder instead.");
}
this.sb = castBody;
this.debug = Options.v().debug() || castBody.getOptions().debug();
if (Options.v().verbose()) {
logger.debug("[" + castBody.getMethod().getName() + "] Propagating and folding constants (SSA)...");
}
// *** FIXME: What happens when Shimple is built with another UnitGraph?
SCPFAnalysis scpf = new SCPFAnalysis(ExceptionalUnitGraphFactory.createExceptionalUnitGraph(castBody));
propagateResults(scpf.getResults());
if (PhaseOptions.getBoolean(options, "prune-cfg")) {
removeStmts(scpf.getDeadStmts());
replaceStmts(scpf.getStmtsToReplace());
}
| 892
| 322
| 1,214
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/shimple/toolkits/scalar/SEvaluator.java
|
SEvaluator
|
getFuzzyConstantValueOf
|
class SEvaluator {
/**
* Returns true if given value is determined to be constant valued, false otherwise
**/
public static boolean isValueConstantValued(Value op) {
if (op instanceof PhiExpr) {
Constant firstConstant = null;
for (Value arg : ((PhiExpr) op).getValues()) {
if (!(arg instanceof Constant)) {
return false;
}
if (firstConstant == null) {
firstConstant = (Constant) arg;
} else if (!firstConstant.equals(arg)) {
return false;
}
}
return true;
}
return Evaluator.isValueConstantValued(op);
}
/**
* Returns the constant value of <code>op</code> if it is easy to find the constant value; else returns <code>null</code>.
**/
public static Value getConstantValueOf(Value op) {
if (op instanceof PhiExpr) {
return isValueConstantValued(op) ? ((PhiExpr) op).getValue(0) : null;
} else {
return Evaluator.getConstantValueOf(op);
}
}
/**
* If a normal expression contains Bottom, always return Bottom. Otherwise, if a normal expression contains Top, returns
* Top. Else determine the constant value of the expression if possible, if not return Bottom.
*
* <p>
* If a Phi expression contains Bottom, always return Bottom. Otherwise, if all the constant arguments are the same
* (ignoring Top and locals) return that constant or Top if no concrete constant is present, else return Bottom.
*
* @see SEvaluator.TopConstant
* @see SEvaluator.BottomConstant
**/
public static Constant getFuzzyConstantValueOf(Value v) {
if (v instanceof Constant) {
return (Constant) v;
} else if (v instanceof Local) {
return BottomConstant.v();
} else if (!(v instanceof Expr)) {
return BottomConstant.v();
}
Constant constant = null;
if (v instanceof PhiExpr) {
PhiExpr phi = (PhiExpr) v;
for (Value arg : phi.getValues()) {
if (!(arg instanceof Constant) || (arg instanceof TopConstant)) {
continue;
}
if (constant == null) {
constant = (Constant) arg;
} else if (!constant.equals(arg)) {
constant = BottomConstant.v();
break;
}
}
if (constant == null) {
constant = TopConstant.v();
}
} else {
for (ValueBox name : v.getUseBoxes()) {
Value value = name.getValue();
if (value instanceof BottomConstant) {
constant = BottomConstant.v();
break;
}
if (value instanceof TopConstant) {
constant = TopConstant.v();
}
}
if (constant == null) {
constant = (Constant) getConstantValueOf(v);
}
if (constant == null) {
constant = BottomConstant.v();
}
}
return constant;
}
/**
* Get the constant value of the expression given the assumptions in the localToConstant map (may contain Top and Bottom).
* Does not change expression.
*
* @see SEvaluator.TopConstant
* @see SEvaluator.BottomConstant
**/
public static Constant getFuzzyConstantValueOf(Value v, Map<Local, Constant> localToConstant) {<FILL_FUNCTION_BODY>}
/**
* Head of a new hierarchy of constants -- Top and Bottom.
**/
public static abstract class MetaConstant extends Constant {
}
/**
* Top i.e. assumed to be a constant, but of unknown value.
**/
public static class TopConstant extends MetaConstant {
private static final TopConstant constant = new TopConstant();
private TopConstant() {
}
public static Constant v() {
return constant;
}
@Override
public Type getType() {
return UnknownType.v();
}
@Override
public void apply(Switch sw) {
throw new RuntimeException("Not implemented.");
}
}
/**
* Bottom i.e. known not to be a constant.
**/
public static class BottomConstant extends MetaConstant {
private static final BottomConstant constant = new BottomConstant();
private BottomConstant() {
}
public static Constant v() {
return constant;
}
@Override
public Type getType() {
return UnknownType.v();
}
@Override
public void apply(Switch sw) {
throw new RuntimeException("Not implemented.");
}
}
}
|
if (v instanceof Constant) {
return (Constant) v;
} else if (v instanceof Local) {
return localToConstant.get((Local) v);
} else if (!(v instanceof Expr)) {
return BottomConstant.v();
}
/* clone expr and update the clone with our assumptions */
Expr expr = (Expr) v.clone();
for (ValueBox useBox : expr.getUseBoxes()) {
Value use = useBox.getValue();
if (use instanceof Local) {
Constant constant = localToConstant.get((Local) use);
if (useBox.canContainValue(constant)) {
useBox.setValue(constant);
}
}
}
// oops -- clear spurious pointers to the unit chain!
if (expr instanceof UnitBoxOwner) {
((UnitBoxOwner) expr).clearUnitBoxes();
}
/* evaluate the expression */
return getFuzzyConstantValueOf(expr);
| 1,228
| 252
| 1,480
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/shimple/toolkits/scalar/ShimpleLocalDefs.java
|
ShimpleLocalDefs
|
getDefsOfAt
|
class ShimpleLocalDefs implements LocalDefs {
protected Map<Value, List<Unit>> localToDefs;
/**
* Build a LocalDefs interface from a ShimpleBody. Proper SSA form is required, otherwise correct behaviour is not
* guaranteed.
**/
public ShimpleLocalDefs(ShimpleBody sb) {
// Instead of rebuilding the ShimpleBody without the
// programmer's knowledge, throw a RuntimeException
if (!sb.isSSA()) {
throw new RuntimeException("ShimpleBody is not in proper SSA form as required by ShimpleLocalDefs. "
+ "You may need to rebuild it or use SimpleLocalDefs instead.");
}
// build localToDefs map simply by iterating through all the
// units in the body and saving the unique definition site for
// each local -- no need for fancy analysis
Chain<Unit> unitsChain = sb.getUnits();
this.localToDefs = new HashMap<Value, List<Unit>>(unitsChain.size() * 2 + 1, 0.7f);
for (Unit unit : unitsChain) {
for (ValueBox vb : unit.getDefBoxes()) {
Value value = vb.getValue();
// only map locals
if (value instanceof Local) {
localToDefs.put(value, Collections.<Unit>singletonList(unit));
}
}
}
}
/**
* Unconditionally returns the definition site of a local (as a singleton list).
**/
@Override
public List<Unit> getDefsOf(Local l) {
List<Unit> defs = localToDefs.get(l);
if (defs == null) {
throw new RuntimeException("Local not found in Body.");
}
return defs;
}
/**
* Returns the definition site for a Local at a certain point (Unit) in a method as a singleton list.
*
* @param l
* the Local in question.
* @param s
* a unit that specifies the method context (location) to query for the definitions of the Local.
* @return a singleton list containing the definition site.
**/
@Override
public List<Unit> getDefsOfAt(Local l, Unit s) {<FILL_FUNCTION_BODY>}
}
|
// For consistency with SimpleLocalDefs, check that the local is indeed used
// in the given Unit. This neatly sidesteps the problem of checking whether
// the local is actually defined at the given point in the program.
{
boolean defined = false;
for (ValueBox vb : s.getUseBoxes()) {
if (vb.getValue().equals(l)) {
defined = true;
break;
}
}
if (!defined) {
throw new RuntimeException("Illegal LocalDefs query; local " + l + " is not being used at " + s);
}
}
return getDefsOf(l);
| 595
| 167
| 762
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/sootify/TypeTemplatePrinter.java
|
TypeTemplatePrinter
|
caseArrayType
|
class TypeTemplatePrinter extends TypeSwitch {
private String varName;
private final TemplatePrinter p;
public void printAssign(String v, Type t) {
String oldName = varName;
varName = v;
t.apply(this);
varName = oldName;
}
public TypeTemplatePrinter(TemplatePrinter p) {
this.p = p;
}
public void setVariableName(String name) {
this.varName = name;
}
private void emit(String rhs) {
p.println("Type " + varName + " = " + rhs + ';');
}
private void emitSpecial(String type, String rhs) {
p.println(type + ' ' + varName + " = " + rhs + ';');
}
@Override
public void caseAnySubType(AnySubType t) {
throw new IllegalArgumentException("cannot print this type");
}
@Override
public void caseArrayType(ArrayType t) {<FILL_FUNCTION_BODY>}
@Override
public void caseBooleanType(BooleanType t) {
emit("BooleanType.v()");
}
@Override
public void caseByteType(ByteType t) {
emit("ByteType.v()");
}
@Override
public void caseCharType(CharType t) {
emit("CharType.v()");
}
@Override
public void defaultCase(Type t) {
throw new IllegalArgumentException("cannot print this type");
}
@Override
public void caseDoubleType(DoubleType t) {
emit("DoubleType.v()");
}
@Override
public void caseErroneousType(ErroneousType t) {
throw new IllegalArgumentException("cannot print this type");
}
@Override
public void caseFloatType(FloatType t) {
emit("FloatType.v()");
}
@Override
public void caseIntType(IntType t) {
emit("IntType.v()");
}
@Override
public void caseLongType(LongType t) {
emit("LongType.v()");
}
@Override
public void caseNullType(NullType t) {
emit("NullType.v()");
}
@Override
public void caseRefType(RefType t) {
emitSpecial("RefType", "RefType.v(\"" + t.getClassName() + "\")");
}
@Override
public void caseShortType(ShortType t) {
emit("ShortType.v()");
}
@Override
public void caseStmtAddressType(StmtAddressType t) {
throw new IllegalArgumentException("cannot print this type");
}
@Override
public void caseUnknownType(UnknownType t) {
throw new IllegalArgumentException("cannot print this type");
}
@Override
public void caseVoidType(VoidType t) {
emit("VoidType.v()");
}
}
|
printAssign("baseType", t.getElementType());
p.println("int numDimensions=" + t.numDimensions + ';');
emit("ArrayType.v(baseType, numDimensions)");
| 774
| 58
| 832
|
<methods>public non-sealed void <init>() ,public void caseAnySubType(soot.AnySubType) ,public void caseArrayType(soot.ArrayType) ,public void caseBooleanType(soot.BooleanType) ,public void caseByteType(soot.ByteType) ,public void caseCharType(soot.CharType) ,public void caseDefault(soot.Type) ,public void caseDoubleType(soot.DoubleType) ,public void caseErroneousType(soot.ErroneousType) ,public void caseFloatType(soot.FloatType) ,public void caseIntType(soot.IntType) ,public void caseLongType(soot.LongType) ,public void caseNullType(soot.NullType) ,public void caseRefType(soot.RefType) ,public void caseShortType(soot.ShortType) ,public void caseStmtAddressType(soot.StmtAddressType) ,public void caseUnknownType(soot.UnknownType) ,public void caseVoidType(soot.VoidType) ,public void defaultCase(soot.Type) ,public java.lang.Object getResult() ,public void setResult(java.lang.Object) <variables>java.lang.Object result
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/AnnotationClassElem.java
|
AnnotationClassElem
|
equals
|
class AnnotationClassElem extends AnnotationElem {
private final String desc;
/**
*
* @param typeName
* type name
* @param elementName
* name of element
*/
public AnnotationClassElem(String typeName, String elementName) {
this(typeName, 'c', elementName);
}
public AnnotationClassElem(String s, char kind, String name) {
super(kind, name);
this.desc = s;
}
@Override
public String toString() {
return super.toString() + " decription: " + desc;
}
public String getDesc() {
return desc;
}
@Override
public void apply(Switch sw) {
((IAnnotationElemTypeSwitch) sw).caseAnnotationClassElem(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((desc == null) ? 0 : desc.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
}
|
if (this == obj) {
return true;
}
if (!super.equals(obj) || (this.getClass() != obj.getClass())) {
return false;
}
AnnotationClassElem other = (AnnotationClassElem) obj;
if (this.desc == null) {
if (other.desc != null) {
return false;
}
} else if (!this.desc.equals(other.desc)) {
return false;
}
return true;
| 309
| 131
| 440
|
<methods>public void <init>(char, java.lang.String) ,public boolean equals(java.lang.Object) ,public char getKind() ,public java.lang.String getName() ,public int hashCode() ,public void setName(java.lang.String) ,public java.lang.String toString() <variables>private final non-sealed char kind,private java.lang.String name
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/AnnotationDoubleElem.java
|
AnnotationDoubleElem
|
hashCode
|
class AnnotationDoubleElem extends AnnotationElem {
private final double value;
public AnnotationDoubleElem(double v, String name) {
this(v, 'D', name);
}
public AnnotationDoubleElem(double v, char kind, String name) {
super(kind, name);
this.value = v;
}
@Override
public String toString() {
return super.toString() + " value: " + value;
}
public double getValue() {
return value;
}
@Override
public void apply(Switch sw) {
((IAnnotationElemTypeSwitch) sw).caseAnnotationDoubleElem(this);
}
@Override
public int hashCode() {<FILL_FUNCTION_BODY>}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj) || (this.getClass() != obj.getClass())) {
return false;
}
AnnotationDoubleElem other = (AnnotationDoubleElem) obj;
return Double.doubleToLongBits(this.value) == Double.doubleToLongBits(other.value);
}
}
|
final int prime = 31;
int result = super.hashCode();
long temp = Double.doubleToLongBits(value);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
| 317
| 64
| 381
|
<methods>public void <init>(char, java.lang.String) ,public boolean equals(java.lang.Object) ,public char getKind() ,public java.lang.String getName() ,public int hashCode() ,public void setName(java.lang.String) ,public java.lang.String toString() <variables>private final non-sealed char kind,private java.lang.String name
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/AnnotationFloatElem.java
|
AnnotationFloatElem
|
equals
|
class AnnotationFloatElem extends AnnotationElem {
private final float value;
public AnnotationFloatElem(float v, String name) {
this(v, 'F', name);
}
public AnnotationFloatElem(float v, char kind, String name) {
super(kind, name);
this.value = v;
}
@Override
public String toString() {
return super.toString() + " value: " + value;
}
public float getValue() {
return value;
}
@Override
public void apply(Switch sw) {
((IAnnotationElemTypeSwitch) sw).caseAnnotationFloatElem(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + Float.floatToIntBits(value);
return result;
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
}
|
if (this == obj) {
return true;
}
if (!super.equals(obj) || (this.getClass() != obj.getClass())) {
return false;
}
AnnotationFloatElem other = (AnnotationFloatElem) obj;
return Float.floatToIntBits(this.value) == Float.floatToIntBits(other.value);
| 265
| 100
| 365
|
<methods>public void <init>(char, java.lang.String) ,public boolean equals(java.lang.Object) ,public char getKind() ,public java.lang.String getName() ,public int hashCode() ,public void setName(java.lang.String) ,public java.lang.String toString() <variables>private final non-sealed char kind,private java.lang.String name
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/AnnotationIntElem.java
|
AnnotationIntElem
|
equals
|
class AnnotationIntElem extends AnnotationElem {
private final int value;
/**
* Annotation int element
*
* @param v
* value of type int
* @param kind
* I: int; B: byte; Z: boolean; C: char; S: short;
* @param name
*/
public AnnotationIntElem(int v, char kind, String name) {
super(kind, name);
this.value = v;
}
public AnnotationIntElem(int v, String name) {
this(v, 'I', name);
}
public AnnotationIntElem(Byte v, String name) {
this(v, 'B', name);
}
public AnnotationIntElem(Character v, String name) {
this(v, 'C', name);
}
public AnnotationIntElem(Short v, String name) {
this(v, 'S', name);
}
@Override
public String toString() {
return super.toString() + " value: " + value;
}
public int getValue() {
return value;
}
@Override
public void apply(Switch sw) {
((IAnnotationElemTypeSwitch) sw).caseAnnotationIntElem(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + value;
return result;
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
}
|
if (this == obj) {
return true;
}
if (!super.equals(obj) || (this.getClass() != obj.getClass())) {
return false;
}
AnnotationIntElem other = (AnnotationIntElem) obj;
return this.value == other.value;
| 416
| 81
| 497
|
<methods>public void <init>(char, java.lang.String) ,public boolean equals(java.lang.Object) ,public char getKind() ,public java.lang.String getName() ,public int hashCode() ,public void setName(java.lang.String) ,public java.lang.String toString() <variables>private final non-sealed char kind,private java.lang.String name
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/AnnotationLongElem.java
|
AnnotationLongElem
|
equals
|
class AnnotationLongElem extends AnnotationElem {
private final long value;
public AnnotationLongElem(long v, String name) {
this(v, 'J', name);
}
public AnnotationLongElem(long v, char kind, String name) {
super(kind, name);
this.value = v;
}
@Override
public String toString() {
return super.toString() + " value: " + value;
}
public long getValue() {
return value;
}
@Override
public void apply(Switch sw) {
((IAnnotationElemTypeSwitch) sw).caseAnnotationLongElem(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + (int) (value ^ (value >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
}
|
if (this == obj) {
return true;
}
if (!super.equals(obj) || (this.getClass() != obj.getClass())) {
return false;
}
AnnotationLongElem other = (AnnotationLongElem) obj;
return this.value == other.value;
| 268
| 81
| 349
|
<methods>public void <init>(char, java.lang.String) ,public boolean equals(java.lang.Object) ,public char getKind() ,public java.lang.String getName() ,public int hashCode() ,public void setName(java.lang.String) ,public java.lang.String toString() <variables>private final non-sealed char kind,private java.lang.String name
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/AnnotationStringElem.java
|
AnnotationStringElem
|
equals
|
class AnnotationStringElem extends AnnotationElem {
private final String value;
public AnnotationStringElem(String s, String name) {
this(s, 's', name);
}
public AnnotationStringElem(String s, char kind, String name) {
super(kind, name);
this.value = s;
}
@Override
public String toString() {
return super.toString() + " value: " + value;
}
public String getValue() {
return value;
}
@Override
public void apply(Switch sw) {
((IAnnotationElemTypeSwitch) sw).caseAnnotationStringElem(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
}
|
if (this == obj) {
return true;
}
if (!super.equals(obj) || (this.getClass() != obj.getClass())) {
return false;
}
AnnotationStringElem other = (AnnotationStringElem) obj;
if (this.value == null) {
if (other.value != null) {
return false;
}
} else if (!this.value.equals(other.value)) {
return false;
}
return true;
| 268
| 131
| 399
|
<methods>public void <init>(char, java.lang.String) ,public boolean equals(java.lang.Object) ,public char getKind() ,public java.lang.String getName() ,public int hashCode() ,public void setName(java.lang.String) ,public java.lang.String toString() <variables>private final non-sealed char kind,private java.lang.String name
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/Base64.java
|
Base64
|
decode
|
class Base64 {
//
// code characters for values 0..63
//
private static final char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".toCharArray();
//
// lookup table for converting base64 characters to value in range 0..63
//
private static final byte[] codes = new byte[256];
static {
for (int i = 0; i < 256; i++) {
codes[i] = -1;
}
for (int i = 'A'; i <= 'Z'; i++) {
codes[i] = (byte) (i - 'A');
}
for (int i = 'a'; i <= 'z'; i++) {
codes[i] = (byte) (26 + i - 'a');
}
for (int i = '0'; i <= '9'; i++) {
codes[i] = (byte) (52 + i - '0');
}
codes['+'] = 62;
codes['/'] = 63;
}
/**
* returns an array of base64-encoded characters to represent the passed data array.
*
* @param data
* the array of bytes to encode
* @return base64-coded character array.
*/
public static char[] encode(byte[] data) {
char[] out = new char[((data.length + 2) / 3) * 4];
//
// 3 bytes encode to 4 chars. Output is always an even
// multiple of 4 characters.
//
for (int i = 0, index = 0; i < data.length; i += 3, index += 4) {
boolean quad = false;
boolean trip = false;
int val = (0xFF & data[i]);
val <<= 8;
if ((i + 1) < data.length) {
val |= (0xFF & data[i + 1]);
trip = true;
}
val <<= 8;
if ((i + 2) < data.length) {
val |= (0xFF & data[i + 2]);
quad = true;
}
out[index + 3] = alphabet[(quad ? (val & 0x3F) : 64)];
val >>= 6;
out[index + 2] = alphabet[(trip ? (val & 0x3F) : 64)];
val >>= 6;
out[index + 1] = alphabet[val & 0x3F];
val >>= 6;
out[index + 0] = alphabet[val & 0x3F];
}
return out;
}
/**
* Decodes a BASE-64 encoded stream to recover the original data. White space before and after will be trimmed away, but no
* other manipulation of the input will be performed.
*
* As of version 1.2 this method will properly handle input containing junk characters (newlines and the like) rather than
* throwing an error. It does this by pre-parsing the input and generating from that a count of VALID input characters.
**/
public static byte[] decode(char[] data) {<FILL_FUNCTION_BODY>}
}
|
// as our input could contain non-BASE64 data (newlines,
// whitespace of any sort, whatever) we must first adjust
// our count of USABLE data so that...
// (a) we don't misallocate the output array, and
// (b) think that we miscalculated our data length
// just because of extraneous throw-away junk
int tempLen = data.length;
for (char element : data) {
if ((element > 255) || codes[element] < 0) {
--tempLen; // ignore non-valid chars and padding
}
}
// calculate required length:
// -- 3 bytes for every 4 valid base64 chars
// -- plus 2 bytes if there are 3 extra base64 chars,
// or plus 1 byte if there are 2 extra.
int len = (tempLen / 4) * 3;
if ((tempLen % 4) == 3) {
len += 2;
}
if ((tempLen % 4) == 2) {
len += 1;
}
byte[] out = new byte[len];
int shift = 0; // # of excess bits stored in accum
int accum = 0; // excess bits
int index = 0;
for (char element : data) {
int value = (element > 255) ? -1 : codes[element];
if (value >= 0) // skip over non-code
{
accum <<= 6; // bits shift up by 6 each time thru
shift += 6; // loop, with new bits being put in
accum |= value; // at the bottom.
if (shift >= 8) // whenever there are 8 or more shifted in,
{
shift -= 8; // write them out (from the top, leaving any
out[index++] = // excess at the bottom for next iteration.
(byte) ((accum >> shift) & 0xff);
}
}
// we will also have skipped processing a padding null byte ('=') here;
// these are used ONLY for padding to an even length and do not legally
// occur as encoded data. for this reason we can ignore the fact that
// no index++ operation occurs in that special case: the out[] array is
// initialized to all-zero bytes to start with and that works to our
// advantage in this combination.
}
// if there is STILL something wrong we just have to throw up now!
if (index != out.length) {
throw new Error("Miscalculated data length (wrote " + index + " instead of " + out.length + ")");
}
return out;
| 859
| 665
| 1,524
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/BytecodeOffsetTag.java
|
BytecodeOffsetTag
|
getValue
|
class BytecodeOffsetTag implements Tag {
public static final String NAME = "BytecodeOffsetTag";
/**
* The index of the last byte-code instruction.
*/
protected final int offset;
/**
* Constructs a tag from the index offset.
*/
public BytecodeOffsetTag(int offset) {
this.offset = offset;
}
@Override
public String getName() {
return NAME;
}
/**
* Returns the offset in a four byte array.
*/
@Override
public byte[] getValue() {<FILL_FUNCTION_BODY>}
/**
* Returns the offset as an int.
*/
public int getBytecodeOffset() {
return offset;
}
/**
* Returns the offset in a string.
*/
@Override
public String toString() {
return Integer.toString(offset);
}
}
|
byte[] v = new byte[4];
v[0] = (byte) ((offset >> 24) % 256);
v[1] = (byte) ((offset >> 16) % 256);
v[2] = (byte) ((offset >> 8) % 256);
v[3] = (byte) (offset % 256);
return v;
| 235
| 105
| 340
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/ConstantValueTag.java
|
ConstantValueTag
|
equals
|
class ConstantValueTag implements Tag {
protected final byte[] bytes; // encoded constant
protected ConstantValueTag(byte[] bytes) {
this.bytes = bytes;
}
@Override
public byte[] getValue() {
return bytes;
}
public abstract Constant getConstant();
@Override
public abstract String toString();
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(bytes);
return result;
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
}
|
if (this == obj) {
return true;
}
if (obj == null || this.getClass() != obj.getClass()) {
return false;
}
ConstantValueTag other = (ConstantValueTag) obj;
return Arrays.equals(bytes, other.bytes);
| 170
| 77
| 247
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/DoubleConstantValueTag.java
|
DoubleConstantValueTag
|
equals
|
class DoubleConstantValueTag extends ConstantValueTag {
public static final String NAME = "DoubleConstantValueTag";
private final double value;
public DoubleConstantValueTag(double val) {
super(null);
this.value = val;
}
public double getDoubleValue() {
return value;
}
@Override
public String getName() {
return NAME;
}
@Override
public String toString() {
return "ConstantValue: " + Double.toString(value);
}
@Override
public DoubleConstant getConstant() {
return DoubleConstant.v(value);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
long temp = Double.doubleToLongBits(value);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
}
|
if (this == obj) {
return true;
}
if (!super.equals(obj) || (this.getClass() != obj.getClass())) {
return false;
}
DoubleConstantValueTag other = (DoubleConstantValueTag) obj;
return Double.doubleToLongBits(this.value) == Double.doubleToLongBits(other.value);
| 267
| 97
| 364
|
<methods>public boolean equals(java.lang.Object) ,public abstract soot.jimple.Constant getConstant() ,public byte[] getValue() ,public int hashCode() ,public abstract java.lang.String toString() <variables>protected final non-sealed byte[] bytes
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/FloatConstantValueTag.java
|
FloatConstantValueTag
|
equals
|
class FloatConstantValueTag extends ConstantValueTag {
public static final String NAME = "FloatConstantValueTag";
private final float value;
public FloatConstantValueTag(float value) {
super(null);
this.value = value;
}
public float getFloatValue() {
return value;
}
@Override
public String getName() {
return NAME;
}
@Override
public String toString() {
return "ConstantValue: " + Float.toString(value);
}
@Override
public FloatConstant getConstant() {
return FloatConstant.v(value);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + Float.floatToIntBits(value);
return result;
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
}
|
if (this == obj) {
return true;
}
if (!super.equals(obj) || (this.getClass() != obj.getClass())) {
return false;
}
FloatConstantValueTag other = (FloatConstantValueTag) obj;
return Float.floatToIntBits(this.value) == Float.floatToIntBits(other.value);
| 254
| 100
| 354
|
<methods>public boolean equals(java.lang.Object) ,public abstract soot.jimple.Constant getConstant() ,public byte[] getValue() ,public int hashCode() ,public abstract java.lang.String toString() <variables>protected final non-sealed byte[] bytes
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/ImportantTagAggregator.java
|
ImportantTagAggregator
|
considerTag
|
class ImportantTagAggregator extends TagAggregator {
/** Decide whether this tag should be aggregated by this aggregator. */
@Override
public void considerTag(Tag t, Unit u, LinkedList<Tag> tags, LinkedList<Unit> units) {<FILL_FUNCTION_BODY>}
}
|
Inst i = (Inst) u;
if (i.containsInvokeExpr() || i.containsFieldRef() || i.containsArrayRef() || i.containsNewExpr()) {
units.add(u);
tags.add(t);
}
| 77
| 65
| 142
|
<methods>public non-sealed void <init>() ,public abstract java.lang.String aggregatedName() ,public abstract void considerTag(soot.tagkit.Tag, soot.Unit, LinkedList<soot.tagkit.Tag>, LinkedList<soot.Unit>) ,public void fini() ,public abstract boolean wantTag(soot.tagkit.Tag) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/InnerClassAttribute.java
|
InnerClassAttribute
|
add
|
class InnerClassAttribute implements Tag {
public static final String NAME = "InnerClassAttribute";
private ArrayList<InnerClassTag> list;
public InnerClassAttribute() {
this.list = null;
}
public InnerClassAttribute(ArrayList<InnerClassTag> list) {
this.list = list;
}
public String getClassSpecs() {
if (list == null) {
return "";
} else {
StringBuilder sb = new StringBuilder();
for (InnerClassTag ict : list) {
sb.append(".inner_class_spec_attr ");
sb.append(ict.getInnerClass());
sb.append(' ');
sb.append(ict.getOuterClass());
sb.append(' ');
sb.append(ict.getShortName());
sb.append(' ');
sb.append(ict.getAccessFlags());
sb.append(' ');
sb.append(".end .inner_class_spec_attr ");
}
return sb.toString();
}
}
@Override
public String getName() {
return NAME;
}
@Override
public byte[] getValue() throws AttributeValueException {
return new byte[1];
}
public List<InnerClassTag> getSpecs() {
return list == null ? Collections.<InnerClassTag>emptyList() : list;
}
public void add(InnerClassTag newt) {<FILL_FUNCTION_BODY>}
}
|
ArrayList<InnerClassTag> this_list = this.list;
if (this_list == null) {
this.list = this_list = new ArrayList<InnerClassTag>();
} else {
String newt_inner = newt.getInnerClass();
int newt_accessFlags = newt.getAccessFlags();
for (InnerClassTag ict : this_list) {
if (newt_inner.equals(ict.getInnerClass())) {
int ict_accessFlags = ict.getAccessFlags();
if (ict_accessFlags != 0 && newt_accessFlags > 0 && ict_accessFlags != newt_accessFlags) {
throw new RuntimeException("Error: trying to add an InnerClassTag twice with different access flags! ("
+ ict_accessFlags + " and " + newt_accessFlags + ")");
}
if (ict_accessFlags == 0 && newt_accessFlags != 0) {
// The Dalvik parser may find an InnerClass annotation without accessFlags in the outer class
// and then an annotation with the accessFlags in the inner class.
// When we have more information about the accessFlags we update the InnerClassTag.
this_list.remove(ict);
this_list.add(newt);
}
return;
}
}
}
this_list.add(newt);
| 382
| 342
| 724
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/InnerClassTagAggregator.java
|
InnerClassTagAggregator
|
internalTransform
|
class InnerClassTagAggregator extends SceneTransformer {
public InnerClassTagAggregator(Singletons.Global g) {
}
public static InnerClassTagAggregator v() {
return G.v().soot_tagkit_InnerClassTagAggregator();
}
public String aggregatedName() {
return "InnerClasses";
}
@Override
public void internalTransform(String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}
|
for (SootClass nextSc : Scene.v().getApplicationClasses()) {
ArrayList<InnerClassTag> list = new ArrayList<InnerClassTag>();
for (Tag t : nextSc.getTags()) {
if (t instanceof InnerClassTag) {
list.add((InnerClassTag) t);
}
}
if (!list.isEmpty()) {
nextSc.addTag(new InnerClassAttribute(list));
}
}
| 131
| 116
| 247
|
<methods>public non-sealed void <init>() ,public final void transform(java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(java.lang.String) ,public final void transform() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/LineNumberTag.java
|
LineNumberTag
|
getValue
|
class LineNumberTag implements Tag {
public static final String NAME = "LineNumberTag";
/* it is a u2 value representing line number. */
protected int line_number;
public LineNumberTag(int ln) {
this.line_number = ln;
}
@Override
public String getName() {
return NAME;
}
@Override
public byte[] getValue() {<FILL_FUNCTION_BODY>}
public int getLineNumber() {
return line_number;
}
public void setLineNumber(int value) {
line_number = value;
}
@Override
public String toString() {
return String.valueOf(line_number);
}
}
|
byte[] v = new byte[2];
v[0] = (byte) (line_number / 256);
v[1] = (byte) (line_number % 256);
return v;
| 193
| 59
| 252
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/LongConstantValueTag.java
|
LongConstantValueTag
|
equals
|
class LongConstantValueTag extends ConstantValueTag {
public static final String NAME = "LongConstantValueTag";
private final long value;
public LongConstantValueTag(long value) {
super(new byte[] { (byte) ((value >> 56) & 0xff), (byte) ((value >> 48) & 0xff), (byte) ((value >> 40) & 0xff),
(byte) ((value >> 32) & 0xff), (byte) ((value >> 24) & 0xff), (byte) ((value >> 16) & 0xff),
(byte) ((value >> 8) & 0xff), (byte) ((value) & 0xff) });
this.value = value;
}
public long getLongValue() {
return value;
}
@Override
public String getName() {
return NAME;
}
@Override
public String toString() {
return "ConstantValue: " + Long.toString(value);
}
@Override
public LongConstant getConstant() {
return LongConstant.v(value);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + (int) (value ^ (value >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
}
|
if (this == obj) {
return true;
}
if (!super.equals(obj) || (this.getClass() != obj.getClass())) {
return false;
}
LongConstantValueTag other = (LongConstantValueTag) obj;
return this.value == other.value;
| 382
| 80
| 462
|
<methods>public boolean equals(java.lang.Object) ,public abstract soot.jimple.Constant getConstant() ,public byte[] getValue() ,public int hashCode() ,public abstract java.lang.String toString() <variables>protected final non-sealed byte[] bytes
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/PositionTag.java
|
PositionTag
|
toString
|
class PositionTag implements Tag {
public static final String NAME = "PositionTag";
/* it is a value representing end offset. */
private final int endOffset;
/* it is a value representing start offset. */
private final int startOffset;
public PositionTag(int start, int end) {
this.startOffset = start;
this.endOffset = end;
}
public int getEndOffset() {
return endOffset;
}
public int getStartOffset() {
return startOffset;
}
@Override
public String getName() {
return NAME;
}
@Override
public byte[] getValue() {
return new byte[2];
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "Jimple pos tag: spos: " + startOffset + " epos: " + endOffset;
| 208
| 30
| 238
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/SourceLnPosTag.java
|
SourceLnPosTag
|
getValue
|
class SourceLnPosTag implements Tag {
public static final String NAME = "SourceLnPosTag";
private final int startLn;
private final int endLn;
private final int startPos;
private final int endPos;
public SourceLnPosTag(int sline, int eline, int spos, int epos) {
this.startLn = sline;
this.endLn = eline;
this.startPos = spos;
this.endPos = epos;
}
public int startLn() {
return startLn;
}
public int endLn() {
return endLn;
}
public int startPos() {
return startPos;
}
public int endPos() {
return endPos;
}
@Override
public String getName() {
return NAME;
}
@Override
public byte[] getValue() {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Source Line Pos Tag: ");
sb.append("sline: ").append(startLn);
sb.append(" eline: ").append(endLn);
sb.append(" spos: ").append(startPos);
sb.append(" epos: ").append(endPos);
return sb.toString();
}
}
|
byte[] v = new byte[2];
v[0] = (byte) (startLn / 256);
v[1] = (byte) (startLn % 256);
return v;
| 369
| 59
| 428
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/StringConstantValueTag.java
|
StringConstantValueTag
|
equals
|
class StringConstantValueTag extends ConstantValueTag {
public static final String NAME = "StringConstantValueTag";
private final String value;
public StringConstantValueTag(String value) {
super(AsmUtil.toUtf8(value));
this.value = value;
}
public String getStringValue() {
return value;
}
@Override
public String getName() {
return NAME;
}
@Override
public String toString() {
return "ConstantValue: " + value;
}
@Override
public StringConstant getConstant() {
return StringConstant.v(value);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
}
|
if (this == obj) {
return true;
}
if (!super.equals(obj) || (this.getClass() != obj.getClass())) {
return false;
}
StringConstantValueTag other = (StringConstantValueTag) obj;
if (this.value == null) {
if (other.value != null) {
return false;
}
} else if (!this.value.equals(other.value)) {
return false;
}
return true;
| 257
| 130
| 387
|
<methods>public boolean equals(java.lang.Object) ,public abstract soot.jimple.Constant getConstant() ,public byte[] getValue() ,public int hashCode() ,public abstract java.lang.String toString() <variables>protected final non-sealed byte[] bytes
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/TagAggregator.java
|
TagAggregator
|
internalTransform
|
class TagAggregator extends BodyTransformer {
/** Decide whether this tag should be aggregated by this aggregator. */
public abstract boolean wantTag(Tag t);
/** Aggregate the given tag assigned to the given unit */
public abstract void considerTag(Tag t, Unit u, LinkedList<Tag> tags, LinkedList<Unit> units);
/** Return name of the resulting aggregated tag. */
public abstract String aggregatedName();
@Override
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
/** Called after all tags for a method have been aggregated. */
public void fini() {
}
}
|
BafBody body = (BafBody) b;
LinkedList<Tag> tags = new LinkedList<Tag>();
LinkedList<Unit> units = new LinkedList<Unit>();
/* aggregate all tags */
for (Unit unit : body.getUnits()) {
for (Tag tag : unit.getTags()) {
if (wantTag(tag)) {
considerTag(tag, unit, tags, units);
}
}
}
if (units.size() > 0) {
b.addTag(new CodeAttribute(aggregatedName(), new LinkedList<Unit>(units), new LinkedList<Tag>(tags)));
}
fini();
| 178
| 174
| 352
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/tagkit/TagManager.java
|
TagManager
|
getTagFor
|
class TagManager {
public TagManager(Singletons.Global g) {
}
public static TagManager v() {
return G.v().soot_tagkit_TagManager();
}
private TagPrinter tagPrinter = new StdTagPrinter();
/**
* Returns the Tag class with the given name.
*
* (This does not seem to be necessary.)
*/
public Tag getTagFor(String tagName) {<FILL_FUNCTION_BODY>}
/** Sets the default tag printer. */
public void setTagPrinter(TagPrinter p) {
tagPrinter = p;
}
/** Prints the given Tag, assuming that it belongs to the given class and field or method. */
public String print(String aClassName, String aFieldOrMtdSignature, Tag aTag) {
return tagPrinter.print(aClassName, aFieldOrMtdSignature, aTag);
}
}
|
try {
Class<?> cc = Class.forName("soot.tagkit." + tagName);
return (Tag) cc.newInstance();
} catch (ClassNotFoundException e) {
return null;
} catch (IllegalAccessException e) {
throw new RuntimeException();
} catch (InstantiationException e) {
throw new RuntimeException(e.toString());
}
| 241
| 102
| 343
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/ConstantVisitor.java
|
ConstantVisitor
|
defaultCase
|
class ConstantVisitor extends AbstractConstantSwitch {
private StmtVisitor stmtV;
private Register destinationReg;
private Stmt origStmt;
public ConstantVisitor(StmtVisitor stmtV) {
this.stmtV = stmtV;
}
public void setDestination(Register destinationReg) {
this.destinationReg = destinationReg;
}
public void setOrigStmt(Stmt stmt) {
this.origStmt = stmt;
}
@Override
public void defaultCase(Object o) {<FILL_FUNCTION_BODY>}
@Override
public void caseStringConstant(StringConstant s) {
StringReference ref = new ImmutableStringReference(s.value);
stmtV.addInsn(new Insn21c(Opcode.CONST_STRING, destinationReg, ref), origStmt);
}
@Override
public void caseClassConstant(ClassConstant c) {
TypeReference referencedClass = new ImmutableTypeReference(c.getValue());
stmtV.addInsn(new Insn21c(Opcode.CONST_CLASS, destinationReg, referencedClass), origStmt);
}
@Override
public void caseLongConstant(LongConstant l) {
long constant = l.value;
stmtV.addInsn(buildConstWideInsn(constant), origStmt);
}
private Insn buildConstWideInsn(long literal) {
if (SootToDexUtils.fitsSigned16(literal)) {
return new Insn21s(Opcode.CONST_WIDE_16, destinationReg, (short) literal);
} else if (SootToDexUtils.fitsSigned32(literal)) {
return new Insn31i(Opcode.CONST_WIDE_32, destinationReg, (int) literal);
} else {
return new Insn51l(Opcode.CONST_WIDE, destinationReg, literal);
}
}
@Override
public void caseDoubleConstant(DoubleConstant d) {
long longBits = Double.doubleToLongBits(d.value);
stmtV.addInsn(buildConstWideInsn(longBits), origStmt);
}
@Override
public void caseFloatConstant(FloatConstant f) {
int intBits = Float.floatToIntBits(f.value);
stmtV.addInsn(buildConstInsn(intBits), origStmt);
}
private Insn buildConstInsn(int literal) {
if (SootToDexUtils.fitsSigned4(literal)) {
return new Insn11n(Opcode.CONST_4, destinationReg, (byte) literal);
} else if (SootToDexUtils.fitsSigned16(literal)) {
return new Insn21s(Opcode.CONST_16, destinationReg, (short) literal);
} else {
return new Insn31i(Opcode.CONST, destinationReg, literal);
}
}
@Override
public void caseIntConstant(IntConstant i) {
stmtV.addInsn(buildConstInsn(i.value), origStmt);
}
@Override
public void caseNullConstant(NullConstant v) {
// dex bytecode spec says: "In terms of bitwise representation, (Object)
// null == (int) 0."
stmtV.addInsn(buildConstInsn(0), origStmt);
}
}
|
// const* opcodes not used since there seems to be no point in doing so:
// CONST_HIGH16, CONST_WIDE_HIGH16
throw new Error("unknown Object (" + o.getClass() + ") as Constant: " + o);
| 903
| 69
| 972
|
<methods>public non-sealed void <init>() ,public void caseClassConstant(soot.jimple.ClassConstant) ,public void caseDoubleConstant(soot.jimple.DoubleConstant) ,public void caseFloatConstant(soot.jimple.FloatConstant) ,public void caseIntConstant(soot.jimple.IntConstant) ,public void caseLongConstant(soot.jimple.LongConstant) ,public void caseMethodHandle(soot.jimple.MethodHandle) ,public void caseMethodType(soot.jimple.MethodType) ,public void caseNullConstant(soot.jimple.NullConstant) ,public void caseStringConstant(soot.jimple.StringConstant) ,public void defaultCase(java.lang.Object) ,public java.lang.Object getResult() ,public void setResult(java.lang.Object) <variables>java.lang.Object result
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/Debug.java
|
Debug
|
printDbg
|
class Debug {
public static boolean TODEX_DEBUG;
public static void printDbg(String s, Object... objects) {<FILL_FUNCTION_BODY>}
public static void printDbg(boolean c, String s, Object... objects) {
if (c) {
printDbg(s, objects);
}
}
}
|
TODEX_DEBUG = Options.v().verbose();
if (TODEX_DEBUG) {
for (Object o : objects) {
s += o.toString();
}
System.out.println(s);
}
| 90
| 62
| 152
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/FastDexTrapTightener.java
|
FastDexTrapTightener
|
internalTransform
|
class FastDexTrapTightener extends BodyTransformer {
public FastDexTrapTightener(Singletons.Global g) {
}
public static FastDexTrapTightener v() {
return soot.G.v().soot_toDex_FastDexTrapTightener();
}
@Override
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
private boolean isDexInstruction(Unit unit) {
if (unit instanceof IdentityStmt) {
IdentityStmt is = (IdentityStmt) unit;
return !(is.getRightOp() instanceof ThisRef || is.getRightOp() instanceof ParameterRef);
}
return true;
}
}
|
for (Iterator<Trap> trapIt = b.getTraps().snapshotIterator(); trapIt.hasNext();) {
Trap t = trapIt.next();
Unit beginUnit;
while (!isDexInstruction(beginUnit = t.getBeginUnit()) && t.getBeginUnit() != t.getEndUnit()) {
t.setBeginUnit(b.getUnits().getSuccOf(beginUnit));
}
// If the trap is empty, we remove it
if (t.getBeginUnit() == t.getEndUnit()) {
trapIt.remove();
}
}
| 206
| 156
| 362
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/Register.java
|
Register
|
equals
|
class Register implements Cloneable {
public static final int MAX_REG_NUM_UNCONSTRAINED = 65535;
public static final int MAX_REG_NUM_SHORT = 255;
public static final int MAX_REG_NUM_BYTE = 15;
public static final Register EMPTY_REGISTER = new Register(IntType.v(), 0);
private static boolean fitsInto(int regNumber, int maxNumber, boolean isWide) {
if (isWide) {
// reg occupies number and number + 1, hence the "<"
return regNumber >= 0 && regNumber < maxNumber;
}
return regNumber >= 0 && regNumber <= maxNumber;
}
public static boolean fitsUnconstrained(int regNumber, boolean isWide) {
return fitsInto(regNumber, MAX_REG_NUM_UNCONSTRAINED, isWide);
}
public static boolean fitsShort(int regNumber, boolean isWide) {
return fitsInto(regNumber, MAX_REG_NUM_SHORT, isWide);
}
public static boolean fitsByte(int regNumber, boolean isWide) {
return fitsInto(regNumber, MAX_REG_NUM_BYTE, isWide);
}
private final Type type;
private int number;
public Register(Type type, int number) {
this.type = type;
this.number = number;
}
public boolean isEmptyReg() {
return this == EMPTY_REGISTER;
}
public boolean isWide() {
return SootToDexUtils.isWide(type);
}
public boolean isObject() {
return SootToDexUtils.isObject(type);
}
public boolean isFloat() {
return type instanceof FloatType;
}
public boolean isDouble() {
return type instanceof DoubleType;
}
public Type getType() {
return type;
}
public String getTypeString() {
return type.toString();
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
if (isEmptyReg()) {
// number of empty register stays at zero - that's part of its purpose
return;
}
this.number = number;
}
private boolean fitsInto(int maxNumber) {
if (isEmptyReg()) {
// empty reg fits into anything
return true;
}
return fitsInto(number, maxNumber, isWide());
}
public boolean fitsUnconstrained() {
return fitsInto(MAX_REG_NUM_UNCONSTRAINED);
}
public boolean fitsShort() {
return fitsInto(MAX_REG_NUM_SHORT);
}
public boolean fitsByte() {
return fitsInto(MAX_REG_NUM_BYTE);
}
@Override
public Register clone() {
return new Register(this.type, this.number);
}
@Override
public String toString() {
if (isEmptyReg()) {
return "the empty reg";
}
return "reg(" + number + "):" + type.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + number;
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
}
|
if (this == obj) {
return true;
}
if ((obj == null) || (getClass() != obj.getClass())) {
return false;
}
Register other = (Register) obj;
if (number != other.number) {
return false;
}
if (type == null) {
if (other.type != null) {
return false;
}
} else if (!type.equals(other.type)) {
return false;
}
return true;
| 928
| 136
| 1,064
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/TemporaryRegisterLocal.java
|
TemporaryRegisterLocal
|
equivHashCode
|
class TemporaryRegisterLocal implements Local {
private static final long serialVersionUID = 1L;
private Type type;
public TemporaryRegisterLocal(Type regType) {
setType(regType);
}
public Local clone() {
throw new RuntimeException("Not implemented");
}
@Override
public final List<ValueBox> getUseBoxes() {
return Collections.emptyList();
}
@Override
public Type getType() {
return type;
}
@Override
public void toString(UnitPrinter up) {
throw new RuntimeException("Not implemented.");
}
@Override
public void apply(Switch sw) {
((JimpleValueSwitch) sw).caseLocal(this);
}
@Override
public boolean equivTo(Object o) {
return this.equals(o);
}
@Override
public int equivHashCode() {<FILL_FUNCTION_BODY>}
@Override
public void setNumber(int number) {
throw new RuntimeException("Not implemented.");
}
@Override
public int getNumber() {
throw new RuntimeException("Not implemented.");
}
@Override
public String getName() {
throw new RuntimeException("Not implemented.");
}
@Override
public void setName(String name) {
throw new RuntimeException("Not implemented.");
}
@Override
public void setType(Type t) {
this.type = t;
}
@Override
public boolean isStackLocal() {
throw new RuntimeException("Not implemented.");
}
}
|
final int prime = 31;
int result = 1;
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
| 415
| 46
| 461
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/instructions/AbstractInsn.java
|
AbstractInsn
|
getMinimumRegsNeeded
|
class AbstractInsn implements Insn {
protected Opcode opc;
protected List<Register> regs;
public AbstractInsn(Opcode opc) {
if (opc == null) {
throw new IllegalArgumentException("opcode must not be null");
}
this.opc = opc;
regs = new ArrayList<Register>();
}
public Opcode getOpcode() {
return opc;
}
public List<Register> getRegs() {
return regs;
}
public BitSet getIncompatibleRegs() {
return new BitSet(0);
}
public boolean hasIncompatibleRegs() {
return getIncompatibleRegs().cardinality() > 0;
}
public int getMinimumRegsNeeded() {<FILL_FUNCTION_BODY>}
@Override
public BuilderInstruction getRealInsn(LabelAssigner assigner) {
if (hasIncompatibleRegs()) {
throw new RuntimeException("the instruction still has incompatible registers: " + getIncompatibleRegs());
}
return getRealInsn0(assigner);
}
protected abstract BuilderInstruction getRealInsn0(LabelAssigner assigner);
@Override
public String toString() {
return opc.toString() + " " + regs;
}
public int getSize() {
return opc.format.size / 2; // the format size is in byte count, we need word count
}
}
|
BitSet incompatRegs = getIncompatibleRegs();
int resultNeed = 0;
int miscRegsNeed = 0;
boolean hasResult = opc.setsRegister();
if (hasResult && incompatRegs.get(0)) {
resultNeed = SootToDexUtils.getDexWords(regs.get(0).getType());
}
for (int i = hasResult ? 1 : 0; i < regs.size(); i++) {
if (incompatRegs.get(i)) {
miscRegsNeed += SootToDexUtils.getDexWords(regs.get(i).getType());
}
}
// The /2addr instruction format takes two operands and overwrites the
// first operand register with the result. The result register is thus
// not free to overlap as we still need to provide input data in it.
// add-long/2addr r0 r0 -> 2 registers
// add-int r0 r0 r2 -> 2 registers, re-use result register
if (opc.name.endsWith("/2addr")) {
return resultNeed + miscRegsNeed;
} else {
return Math.max(resultNeed, miscRegsNeed);
}
| 386
| 318
| 704
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/instructions/Insn11x.java
|
Insn11x
|
getIncompatibleRegs
|
class Insn11x extends AbstractInsn implements OneRegInsn {
public Insn11x(Opcode opc, Register regA) {
super(opc);
regs.add(regA);
}
public Register getRegA() {
return regs.get(REG_A_IDX);
}
@Override
protected BuilderInstruction getRealInsn0(LabelAssigner assigner) {
return new BuilderInstruction11x(opc, (short) getRegA().getNumber());
}
@Override
public BitSet getIncompatibleRegs() {<FILL_FUNCTION_BODY>}
}
|
BitSet incompatRegs = new BitSet(1);
if (!getRegA().fitsShort()) {
incompatRegs.set(REG_A_IDX);
}
return incompatRegs;
| 168
| 57
| 225
|
<methods>public void <init>(org.jf.dexlib2.Opcode) ,public java.util.BitSet getIncompatibleRegs() ,public int getMinimumRegsNeeded() ,public org.jf.dexlib2.Opcode getOpcode() ,public org.jf.dexlib2.builder.BuilderInstruction getRealInsn(soot.toDex.LabelAssigner) ,public List<soot.toDex.Register> getRegs() ,public int getSize() ,public boolean hasIncompatibleRegs() ,public java.lang.String toString() <variables>protected org.jf.dexlib2.Opcode opc,protected List<soot.toDex.Register> regs
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/instructions/Insn12x.java
|
Insn12x
|
getIncompatibleRegs
|
class Insn12x extends AbstractInsn implements TwoRegInsn {
public Insn12x(Opcode opc, Register regA, Register regB) {
super(opc);
regs.add(regA);
regs.add(regB);
}
public Register getRegA() {
return regs.get(REG_A_IDX);
}
public Register getRegB() {
return regs.get(REG_B_IDX);
}
@Override
protected BuilderInstruction getRealInsn0(LabelAssigner assigner) {
return new BuilderInstruction12x(opc, (byte) getRegA().getNumber(), (byte) getRegB().getNumber());
}
@Override
public BitSet getIncompatibleRegs() {<FILL_FUNCTION_BODY>}
}
|
BitSet incompatRegs = new BitSet(2);
if (!getRegA().fitsByte()) {
incompatRegs.set(REG_A_IDX);
}
if (!getRegB().fitsByte()) {
incompatRegs.set(REG_B_IDX);
}
return incompatRegs;
| 220
| 88
| 308
|
<methods>public void <init>(org.jf.dexlib2.Opcode) ,public java.util.BitSet getIncompatibleRegs() ,public int getMinimumRegsNeeded() ,public org.jf.dexlib2.Opcode getOpcode() ,public org.jf.dexlib2.builder.BuilderInstruction getRealInsn(soot.toDex.LabelAssigner) ,public List<soot.toDex.Register> getRegs() ,public int getSize() ,public boolean hasIncompatibleRegs() ,public java.lang.String toString() <variables>protected org.jf.dexlib2.Opcode opc,protected List<soot.toDex.Register> regs
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/instructions/Insn21c.java
|
Insn21c
|
getIncompatibleRegs
|
class Insn21c extends AbstractInsn implements OneRegInsn {
private Reference referencedItem;
public Insn21c(Opcode opc, Register regA, Reference referencedItem) {
super(opc);
regs.add(regA);
this.referencedItem = referencedItem;
}
public Register getRegA() {
return regs.get(REG_A_IDX);
}
@Override
protected BuilderInstruction getRealInsn0(LabelAssigner assigner) {
return new BuilderInstruction21c(opc, (short) getRegA().getNumber(), referencedItem);
}
@Override
public BitSet getIncompatibleRegs() {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
return super.toString() + " ref: " + referencedItem;
}
}
|
BitSet incompatRegs = new BitSet(1);
if (!getRegA().fitsShort()) {
incompatRegs.set(REG_A_IDX);
}
return incompatRegs;
| 227
| 57
| 284
|
<methods>public void <init>(org.jf.dexlib2.Opcode) ,public java.util.BitSet getIncompatibleRegs() ,public int getMinimumRegsNeeded() ,public org.jf.dexlib2.Opcode getOpcode() ,public org.jf.dexlib2.builder.BuilderInstruction getRealInsn(soot.toDex.LabelAssigner) ,public List<soot.toDex.Register> getRegs() ,public int getSize() ,public boolean hasIncompatibleRegs() ,public java.lang.String toString() <variables>protected org.jf.dexlib2.Opcode opc,protected List<soot.toDex.Register> regs
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/instructions/Insn21s.java
|
Insn21s
|
getIncompatibleRegs
|
class Insn21s extends AbstractInsn implements OneRegInsn {
private short litB;
public Insn21s(Opcode opc, Register regA, short litB) {
super(opc);
regs.add(regA);
this.litB = litB;
}
public Register getRegA() {
return regs.get(REG_A_IDX);
}
public short getLitB() {
return litB;
}
@Override
protected BuilderInstruction getRealInsn0(LabelAssigner assigner) {
return new BuilderInstruction21s(opc, (short) getRegA().getNumber(), getLitB());
}
@Override
public BitSet getIncompatibleRegs() {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
return super.toString() + " lit: " + getLitB();
}
}
|
BitSet incompatRegs = new BitSet(1);
if (!getRegA().fitsShort()) {
incompatRegs.set(REG_A_IDX);
}
return incompatRegs;
| 249
| 57
| 306
|
<methods>public void <init>(org.jf.dexlib2.Opcode) ,public java.util.BitSet getIncompatibleRegs() ,public int getMinimumRegsNeeded() ,public org.jf.dexlib2.Opcode getOpcode() ,public org.jf.dexlib2.builder.BuilderInstruction getRealInsn(soot.toDex.LabelAssigner) ,public List<soot.toDex.Register> getRegs() ,public int getSize() ,public boolean hasIncompatibleRegs() ,public java.lang.String toString() <variables>protected org.jf.dexlib2.Opcode opc,protected List<soot.toDex.Register> regs
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/instructions/Insn21t.java
|
Insn21t
|
getIncompatibleRegs
|
class Insn21t extends InsnWithOffset implements OneRegInsn {
public Insn21t(Opcode opc, Register regA) {
super(opc);
regs.add(regA);
}
public Register getRegA() {
return regs.get(REG_A_IDX);
}
@Override
protected BuilderInstruction getRealInsn0(LabelAssigner assigner) {
return new BuilderInstruction21t(opc, (short) getRegA().getNumber(), assigner.getOrCreateLabel(target));
}
@Override
public BitSet getIncompatibleRegs() {<FILL_FUNCTION_BODY>}
@Override
public int getMaxJumpOffset() {
return Short.MAX_VALUE;
}
}
|
BitSet incompatRegs = new BitSet(1);
if (!getRegA().fitsShort()) {
incompatRegs.set(REG_A_IDX);
}
return incompatRegs;
| 208
| 57
| 265
|
<methods>public void <init>(org.jf.dexlib2.Opcode) ,public abstract int getMaxJumpOffset() ,public soot.jimple.Stmt getTarget() ,public void setTarget(soot.jimple.Stmt) <variables>protected soot.jimple.Stmt target
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/instructions/Insn22b.java
|
Insn22b
|
getIncompatibleRegs
|
class Insn22b extends AbstractInsn implements TwoRegInsn {
private byte litC;
public Insn22b(Opcode opc, Register regA, Register regB, byte litC) {
super(opc);
regs.add(regA);
regs.add(regB);
this.litC = litC;
}
public Register getRegA() {
return regs.get(REG_A_IDX);
}
public Register getRegB() {
return regs.get(REG_B_IDX);
}
public byte getLitC() {
return litC;
}
@Override
protected BuilderInstruction getRealInsn0(LabelAssigner assigner) {
return new BuilderInstruction22b(opc, (short) getRegA().getNumber(), (short) getRegB().getNumber(), getLitC());
}
@Override
public BitSet getIncompatibleRegs() {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
return super.toString() + " lit: " + getLitC();
}
}
|
BitSet incompatRegs = new BitSet(2);
if (!getRegA().fitsShort()) {
incompatRegs.set(REG_A_IDX);
}
if (!getRegB().fitsShort()) {
incompatRegs.set(REG_B_IDX);
}
return incompatRegs;
| 301
| 88
| 389
|
<methods>public void <init>(org.jf.dexlib2.Opcode) ,public java.util.BitSet getIncompatibleRegs() ,public int getMinimumRegsNeeded() ,public org.jf.dexlib2.Opcode getOpcode() ,public org.jf.dexlib2.builder.BuilderInstruction getRealInsn(soot.toDex.LabelAssigner) ,public List<soot.toDex.Register> getRegs() ,public int getSize() ,public boolean hasIncompatibleRegs() ,public java.lang.String toString() <variables>protected org.jf.dexlib2.Opcode opc,protected List<soot.toDex.Register> regs
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/instructions/Insn22s.java
|
Insn22s
|
getIncompatibleRegs
|
class Insn22s extends AbstractInsn implements TwoRegInsn {
private short litC;
public Insn22s(Opcode opc, Register regA, Register regB, short litC) {
super(opc);
regs.add(regA);
regs.add(regB);
this.litC = litC;
}
public Register getRegA() {
return regs.get(REG_A_IDX);
}
public Register getRegB() {
return regs.get(REG_B_IDX);
}
public short getLitC() {
return litC;
}
@Override
protected BuilderInstruction getRealInsn0(LabelAssigner assigner) {
return new BuilderInstruction22s(opc, (byte) getRegA().getNumber(), (byte) getRegB().getNumber(), getLitC());
}
@Override
public BitSet getIncompatibleRegs() {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
return super.toString() + " lit: " + getLitC();
}
}
|
BitSet incompatRegs = new BitSet(2);
if (!getRegA().fitsByte()) {
incompatRegs.set(REG_A_IDX);
}
if (!getRegB().fitsByte()) {
incompatRegs.set(REG_B_IDX);
}
return incompatRegs;
| 301
| 88
| 389
|
<methods>public void <init>(org.jf.dexlib2.Opcode) ,public java.util.BitSet getIncompatibleRegs() ,public int getMinimumRegsNeeded() ,public org.jf.dexlib2.Opcode getOpcode() ,public org.jf.dexlib2.builder.BuilderInstruction getRealInsn(soot.toDex.LabelAssigner) ,public List<soot.toDex.Register> getRegs() ,public int getSize() ,public boolean hasIncompatibleRegs() ,public java.lang.String toString() <variables>protected org.jf.dexlib2.Opcode opc,protected List<soot.toDex.Register> regs
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/instructions/Insn22x.java
|
Insn22x
|
getIncompatibleRegs
|
class Insn22x extends AbstractInsn implements TwoRegInsn {
public Insn22x(Opcode opc, Register regA, Register regB) {
super(opc);
regs.add(regA);
regs.add(regB);
}
public Register getRegA() {
return regs.get(REG_A_IDX);
}
public Register getRegB() {
return regs.get(REG_B_IDX);
}
protected BuilderInstruction getRealInsn0(LabelAssigner assigner) {
return new BuilderInstruction22x(opc, (short) getRegA().getNumber(), getRegB().getNumber());
}
@Override
public BitSet getIncompatibleRegs() {<FILL_FUNCTION_BODY>}
}
|
BitSet incompatRegs = new BitSet(2);
if (!getRegA().fitsShort()) {
incompatRegs.set(REG_A_IDX);
}
if (!getRegB().fitsUnconstrained()) {
incompatRegs.set(REG_B_IDX);
}
return incompatRegs;
| 213
| 90
| 303
|
<methods>public void <init>(org.jf.dexlib2.Opcode) ,public java.util.BitSet getIncompatibleRegs() ,public int getMinimumRegsNeeded() ,public org.jf.dexlib2.Opcode getOpcode() ,public org.jf.dexlib2.builder.BuilderInstruction getRealInsn(soot.toDex.LabelAssigner) ,public List<soot.toDex.Register> getRegs() ,public int getSize() ,public boolean hasIncompatibleRegs() ,public java.lang.String toString() <variables>protected org.jf.dexlib2.Opcode opc,protected List<soot.toDex.Register> regs
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/instructions/Insn23x.java
|
Insn23x
|
getIncompatibleRegs
|
class Insn23x extends AbstractInsn implements ThreeRegInsn {
public Insn23x(Opcode opc, Register regA, Register regB, Register regC) {
super(opc);
regs.add(regA);
regs.add(regB);
regs.add(regC);
}
public Register getRegA() {
return regs.get(REG_A_IDX);
}
public Register getRegB() {
return regs.get(REG_B_IDX);
}
public Register getRegC() {
return regs.get(REG_C_IDX);
}
@Override
protected BuilderInstruction getRealInsn0(LabelAssigner assigner) {
return new BuilderInstruction23x(opc, (short) getRegA().getNumber(), (short) getRegB().getNumber(),
(short) getRegC().getNumber());
}
@Override
public BitSet getIncompatibleRegs() {<FILL_FUNCTION_BODY>}
}
|
BitSet incompatRegs = new BitSet(3);
if (!getRegA().fitsShort()) {
incompatRegs.set(REG_A_IDX);
}
if (!getRegB().fitsShort()) {
incompatRegs.set(REG_B_IDX);
}
if (!getRegC().fitsShort()) {
incompatRegs.set(REG_C_IDX);
}
return incompatRegs;
| 274
| 119
| 393
|
<methods>public void <init>(org.jf.dexlib2.Opcode) ,public java.util.BitSet getIncompatibleRegs() ,public int getMinimumRegsNeeded() ,public org.jf.dexlib2.Opcode getOpcode() ,public org.jf.dexlib2.builder.BuilderInstruction getRealInsn(soot.toDex.LabelAssigner) ,public List<soot.toDex.Register> getRegs() ,public int getSize() ,public boolean hasIncompatibleRegs() ,public java.lang.String toString() <variables>protected org.jf.dexlib2.Opcode opc,protected List<soot.toDex.Register> regs
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/instructions/Insn31i.java
|
Insn31i
|
getIncompatibleRegs
|
class Insn31i extends AbstractInsn implements OneRegInsn {
private int litB;
public Insn31i(Opcode opc, Register regA, int litB) {
super(opc);
regs.add(regA);
this.litB = litB;
}
public Register getRegA() {
return regs.get(REG_A_IDX);
}
public int getLitB() {
return litB;
}
@Override
protected BuilderInstruction getRealInsn0(LabelAssigner assigner) {
return new BuilderInstruction31i(opc, (short) getRegA().getNumber(), getLitB());
}
@Override
public BitSet getIncompatibleRegs() {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
return super.toString() + " lit: " + getLitB();
}
}
|
BitSet incompatRegs = new BitSet(1);
if (!getRegA().fitsShort()) {
incompatRegs.set(REG_A_IDX);
}
return incompatRegs;
| 249
| 57
| 306
|
<methods>public void <init>(org.jf.dexlib2.Opcode) ,public java.util.BitSet getIncompatibleRegs() ,public int getMinimumRegsNeeded() ,public org.jf.dexlib2.Opcode getOpcode() ,public org.jf.dexlib2.builder.BuilderInstruction getRealInsn(soot.toDex.LabelAssigner) ,public List<soot.toDex.Register> getRegs() ,public int getSize() ,public boolean hasIncompatibleRegs() ,public java.lang.String toString() <variables>protected org.jf.dexlib2.Opcode opc,protected List<soot.toDex.Register> regs
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/instructions/Insn31t.java
|
Insn31t
|
getIncompatibleRegs
|
class Insn31t extends InsnWithOffset implements OneRegInsn {
public AbstractPayload payload = null;
public Insn31t(Opcode opc, Register regA) {
super(opc);
regs.add(regA);
}
public Register getRegA() {
return regs.get(REG_A_IDX);
}
public void setPayload(AbstractPayload payload) {
this.payload = payload;
}
@Override
protected BuilderInstruction getRealInsn0(LabelAssigner assigner) {
return new BuilderInstruction31t(opc, (short) getRegA().getNumber(), assigner.getOrCreateLabel(payload));
}
@Override
public BitSet getIncompatibleRegs() {<FILL_FUNCTION_BODY>}
@Override
public int getMaxJumpOffset() {
return Short.MAX_VALUE;
}
}
|
BitSet incompatRegs = new BitSet(1);
if (!getRegA().fitsShort()) {
incompatRegs.set(REG_A_IDX);
}
return incompatRegs;
| 247
| 57
| 304
|
<methods>public void <init>(org.jf.dexlib2.Opcode) ,public abstract int getMaxJumpOffset() ,public soot.jimple.Stmt getTarget() ,public void setTarget(soot.jimple.Stmt) <variables>protected soot.jimple.Stmt target
|
soot-oss_soot
|
soot/src/main/java/soot/toDex/instructions/Insn32x.java
|
Insn32x
|
getIncompatibleRegs
|
class Insn32x extends AbstractInsn implements TwoRegInsn {
public Insn32x(Opcode opc, Register regA, Register regB) {
super(opc);
regs.add(regA);
regs.add(regB);
}
public Register getRegA() {
return regs.get(REG_A_IDX);
}
public Register getRegB() {
return regs.get(REG_B_IDX);
}
@Override
protected BuilderInstruction getRealInsn0(LabelAssigner assigner) {
return new BuilderInstruction32x(opc, getRegA().getNumber(), getRegB().getNumber());
}
@Override
public BitSet getIncompatibleRegs() {<FILL_FUNCTION_BODY>}
}
|
BitSet incompatRegs = new BitSet(2);
if (!getRegA().fitsUnconstrained()) {
incompatRegs.set(REG_A_IDX);
}
if (!getRegB().fitsUnconstrained()) {
incompatRegs.set(REG_B_IDX);
}
return incompatRegs;
| 214
| 92
| 306
|
<methods>public void <init>(org.jf.dexlib2.Opcode) ,public java.util.BitSet getIncompatibleRegs() ,public int getMinimumRegsNeeded() ,public org.jf.dexlib2.Opcode getOpcode() ,public org.jf.dexlib2.builder.BuilderInstruction getRealInsn(soot.toDex.LabelAssigner) ,public List<soot.toDex.Register> getRegs() ,public int getSize() ,public boolean hasIncompatibleRegs() ,public java.lang.String toString() <variables>protected org.jf.dexlib2.Opcode opc,protected List<soot.toDex.Register> regs
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.