-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into optimize/asmmethodsource_loop_unroll_remo…
…ve_necessity_to_reverse # Conflicts: # sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/AsmMethodSource.java
- Loading branch information
Showing
275 changed files
with
2,736 additions
and
1,484 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cff-version: 1.2.0 | ||
title: SootUp | ||
message: 'If you use SootUp, please cite it as below.' | ||
type: software | ||
authors: | ||
- given-names: Soot-oss | ||
repository-code: 'https://github.com/soot-oss/SootUp' | ||
version: 1.1.2 | ||
date-released: '2023-06-12' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import java.time.LocalDate; | ||
import java.time.Period; | ||
import java.util.stream.Stream; | ||
import java.util.stream.IntStream; | ||
|
||
/** conversion failed when there is a merge (here: after the if) and an invokedynamic followed */ | ||
class Indy{ | ||
public IntStream test(IntStream s) { | ||
int sign; | ||
if (s.isParallel()) { | ||
sign = 1; | ||
}else{ | ||
sign = -1; | ||
} | ||
return s.map(n -> n+42); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is not a class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this is a test file to check if it recognized as class |
Binary file modified
BIN
+169 Bytes
(120%)
shared-test-resources/jigsaw-examples/requires_exports/jar/modb.jar
Binary file not shown.
1 change: 1 addition & 0 deletions
1
shared-test-resources/jigsaw-examples/requires_exports/src/modb/pkgb/junkclass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this is a test file to check if it recognized as class |
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
shared-test-resources/miniTestSuite/java14/source/RecordTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
record RecordTest(int a, String b) { | ||
public RecordTest(int a, String b) { | ||
this.a = a; | ||
this.b = b; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is a fake java file |
128 changes: 128 additions & 0 deletions
128
sootup.analysis/src/main/java/sootup/analysis/interprocedural/icfg/ICFGDotExporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package sootup.analysis.interprocedural.icfg; | ||
|
||
import java.util.*; | ||
import java.util.stream.Collectors; | ||
import sootup.core.graph.BasicBlock; | ||
import sootup.core.graph.StmtGraph; | ||
import sootup.core.jimple.common.expr.JNewExpr; | ||
import sootup.core.jimple.common.stmt.JAssignStmt; | ||
import sootup.core.jimple.common.stmt.Stmt; | ||
import sootup.core.model.SootClass; | ||
import sootup.core.model.SootMethod; | ||
import sootup.core.signatures.MethodSignature; | ||
import sootup.core.signatures.MethodSubSignature; | ||
import sootup.core.typehierarchy.MethodDispatchResolver; | ||
import sootup.core.types.VoidType; | ||
import sootup.core.util.DotExporter; | ||
import sootup.core.views.View; | ||
|
||
public class ICFGDotExporter { | ||
|
||
public static String buildICFGGraph( | ||
Map<MethodSignature, StmtGraph> signatureToStmtGraph, View<? extends SootClass<?>> view) { | ||
final StringBuilder sb = new StringBuilder(); | ||
DotExporter.buildDiGraphObject(sb); | ||
Map<Integer, MethodSignature> calls; | ||
calls = computeCalls(signatureToStmtGraph, view); | ||
for (Map.Entry<MethodSignature, StmtGraph> entry : signatureToStmtGraph.entrySet()) { | ||
String graph = DotExporter.buildGraph(entry.getValue(), true, calls, entry.getKey()); | ||
sb.append(graph + "\n"); | ||
} | ||
sb.append("}"); | ||
return sb.toString(); | ||
} | ||
|
||
/** | ||
* This method finds out all the calls made in the given StmtGraphs, so it can be edged to other | ||
* methods. | ||
*/ | ||
public static Map<Integer, MethodSignature> computeCalls( | ||
Map<MethodSignature, StmtGraph> stmtGraphSet, View<? extends SootClass<?>> view) { | ||
Map<Integer, MethodSignature> calls = new HashMap<>(); | ||
for (StmtGraph stmtGraph : stmtGraphSet.values()) { | ||
Collection<? extends BasicBlock<?>> blocks; | ||
try { | ||
blocks = stmtGraph.getBlocksSorted(); | ||
} catch (Exception e) { | ||
blocks = stmtGraph.getBlocks(); | ||
} | ||
for (BasicBlock<?> block : blocks) { | ||
List<Stmt> stmts = block.getStmts(); | ||
for (Stmt stmt : stmts) { | ||
if (stmt.containsInvokeExpr()) { | ||
MethodSignature methodSignature = stmt.getInvokeExpr().getMethodSignature(); | ||
int hashCode = stmt.hashCode(); | ||
calls.put(hashCode, methodSignature); | ||
// compute all the classes that are made to the subclasses as well | ||
connectEdgesToSubClasses(methodSignature, view, calls); | ||
} else if (stmt instanceof JAssignStmt) { | ||
JAssignStmt jAssignStmt = (JAssignStmt) stmt; | ||
Integer currentHashCode = stmt.hashCode(); | ||
if (jAssignStmt.getRightOp() instanceof JNewExpr) { | ||
// if the statement is a new expression, then there will be calls to its static | ||
// initializers (init and clinit), so need to compute calls to them as well | ||
for (MethodSignature methodSignature : stmtGraphSet.keySet()) { | ||
SootMethod clintMethod = | ||
view.getMethod(methodSignature.getDeclClassType().getStaticInitializer()) | ||
.orElse(null); | ||
if (clintMethod != null) { | ||
if (!calls.containsKey(stmt.hashCode())) { | ||
calls.put(stmt.hashCode(), methodSignature); | ||
} else { | ||
MethodSignature secondInitMethodSignature = calls.get(currentHashCode); | ||
currentHashCode = | ||
stmtGraphSet.get(secondInitMethodSignature).getStartingStmt().hashCode(); | ||
calls.put(currentHashCode, methodSignature); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return calls; | ||
} | ||
|
||
public static Set<MethodSignature> getMethodSignatureInSubClass( | ||
MethodSignature targetMethodSignature, View<? extends SootClass<?>> view) { | ||
try { | ||
return MethodDispatchResolver.resolveAllDispatches(view, targetMethodSignature).stream() | ||
.map( | ||
methodSignature -> | ||
MethodDispatchResolver.resolveConcreteDispatch(view, methodSignature)) | ||
.filter(Optional::isPresent) | ||
.map(Optional::get) | ||
.collect(Collectors.toSet()); | ||
} catch (Exception e) { | ||
return null; | ||
} | ||
} | ||
|
||
public static void connectEdgesToSubClasses( | ||
MethodSignature methodSignature, | ||
View<? extends SootClass<?>> view, | ||
Map<Integer, MethodSignature> calls) { | ||
Set<MethodSignature> methodSignatureInSubClass = | ||
getMethodSignatureInSubClass(methodSignature, view); | ||
if (methodSignatureInSubClass != null) { | ||
methodSignatureInSubClass.forEach( | ||
subclassmethodSignature -> { | ||
Optional<? extends SootMethod> method = view.getMethod(methodSignature); | ||
MethodSignature initMethod = | ||
new MethodSignature( | ||
subclassmethodSignature.getDeclClassType(), | ||
new MethodSubSignature( | ||
"<init>", Collections.emptyList(), VoidType.getInstance())); | ||
if (method.isPresent() | ||
&& !subclassmethodSignature.toString().equals(initMethod.toString())) { | ||
if (method.get().hasBody()) { | ||
calls.put( | ||
method.get().getBody().getStmtGraph().getStartingStmt().hashCode(), | ||
subclassmethodSignature); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.