Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method1: Use Intraprocedural results in Interprocedural for slight accuracy, stack ordering PR #15

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
.idea/
stava.iml
.DS_Store

out
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Launch Main",
"request": "launch",
"mainClass": "Main",
"projectName": "stava_862dc55b"
}
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"java.project.referencedLibraries": [
"lib/**/*.jar",
"soot/sootclasses-trunk-jar-with-dependencies.jar"
]
}
28 changes: 28 additions & 0 deletions examples/Case1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package examples;

public class Case1 {
public static void main(String[] args) {
Case1 obj = new Case1();
obj.m1();
}

// Consider Both A and B are in their respective function stack
public void m1() {
Node A = new Node(); // A is in lower function call stackframe
m2(A);
}

public void m2(Node A) {
Node B = new Node(); // B is in higher function call stackframe
// Thus B's lifetime is less than A
m3(A, B);
}

public void m3(Node A, Node B) {
A.f = B; // Object pointed to by B must escape as B's lifetime is less than A's
// lifetime Else, A.f will become undefined, and will not point to any
// object once m2's function stack is poped out.
}

// Object pointed to by B should be Heapified!
}
27 changes: 27 additions & 0 deletions examples/Case2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package examples;

public class Case2 {
public static void main(String[] args) {
Case1 obj = new Case1();
obj.m1();
}

// Consider Both A and B are in their respective function stack
public void m1() {
Node B = new Node(); // B is in lower function call stackframe
m2(B);
}

public void m2(Node B) {
Node A = new Node(); // A is in higher function call stackframe
// Thus B's lifetime is more than A
m3(A, B);
}

public void m3(Node A, Node B) {
A.f = B; // Object pointed to by B need not escape as B's lifetime is more than A's
// lifetime. So, if B will not be popped before A in anycase.
}

// Object pointed to by B need not be Heapified!
}
22 changes: 22 additions & 0 deletions examples/Case3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package examples;

public class Case3 {
public static void main(String[] args) {
Case1 obj = new Case1();
obj.m1();
}

// Consider Both A and B are in their respective function stack
public void m2() {
Node A = new Node();
Node B = new Node(); // A and B are in the same stack frame
m3(A, B);
}

public void m3(Node A, Node B) {
A.f = B; // Object pointed to by B need not escape as B's lifetime is equal to A's
// lifetime. So, A and B will be popped out at the same time.
}

// Object pointed to by B need not be Heapified!
}
30 changes: 30 additions & 0 deletions examples/Challenge1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package examples;

public class Challenge1 {
public static void main(String[] args) {
Challenge1 obj = new Challenge1();
obj.m1();
}

public void m1() {
int x = 3;
Node A = new Node();
Node B = new Node();

m2(A, B, x);
}

public void m2(Node p1, Node p2, int x) {
if (x == 0) return;

m3(p1, p2, x - 1);
p1.f = p2;
}

public void m3(Node p1, Node p2, int x) {
Node C = new Node();
Node D = new Node();

m2(C, D, x);
}
}
5 changes: 5 additions & 0 deletions examples/Node.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package examples;

public class Node {
public Node f;
}
2 changes: 1 addition & 1 deletion scripts/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Set the paths according to your installation. All paths must be full paths.
# Arguments: 1) name of benchmark
# Installed path of Java 8 JDK
java_install_path="/usr/lib/jvm/java-8-oracle/"
java_install_path="/usr/lib/jvm/java-8-openjdk-amd64/"
# java_install_path=""
# java_install_path="/wd/users/t17041/benchmarks/jdk-11.0.8/"
# Path to the directory containing all benchmarks. The subdirectories here must
Expand Down
12 changes: 9 additions & 3 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
# Sample script to be used to run the project on non-benchmark code.
# Set the paths according to your installation. All paths must be full paths.
# Instructions: ./run.sh ClassName

if [ -z "$1" ]; then
echo "No TestCase Number Provided";
exit
fi

# Installed path of Java 8 JDK
java_install_path="/usr/lib/jvm/java-8-oracle/"
java_install_path="/usr/lib/jvm/java-8-openjdk-amd64/"

# The soot jar to be used.
soot_path=`realpath ../soot/sootclasses-trunk-jar-with-dependencies.jar`
Expand All @@ -13,10 +19,10 @@ soot_path=`realpath ../soot/sootclasses-trunk-jar-with-dependencies.jar`
stava_path=`realpath ..`

# The directory to be analysed.
test_path=`realpath ../tests/test20/`
test_path=`realpath ../tests/test$1/`

# The directory inside which stava will output the results.
output_path=`realpath ../out/testcase/`
output_path=`realpath ../out/testcase$1/`

java_compiler="${java_install_path}/bin/javac"
java_vm="${java_install_path}/bin/java"
Expand Down
Loading