Skip to content

Introduce temporary stack variables for getfield/-static and ?load #931

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

Closed
2 changes: 1 addition & 1 deletion regression/cbmc-java/LocalVarTable5/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test.class
dead anonlocal::1i
dead anonlocal::2i
dead anonlocal::3a
dead new_tmp0
dead new_tmp[0123456789]+
^EXIT=0$
^SIGNAL=0$
--
2 changes: 1 addition & 1 deletion regression/cbmc-java/destructor1/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Break.class
^SIGNAL=0$
dead i;
--
GOTO 10
GOTO 11
9 changes: 9 additions & 0 deletions regression/cbmc-java/stack_var1/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This regression test is created from the .j file with the jasmin assembler.
https://github.com/Sable/jasmin
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add as many details as possible, such as the precise command line? This is information that you've now got right at hand, but it will be much more work to reproduce later on. Memory is weak, git is strong!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-) it is actually jasmin $FILE.j but I'll add this to the READMEs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some comments about jasmin, how to get it and how to use it on .j files

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!


On Ubuntu, it is available as jasmin-sable. To convert a .j file, it is
sufficient to do

> jasmin $FILE.j

and it will create the corresponding $FILE.class file.
Binary file added regression/cbmc-java/stack_var1/stack_test.class
Binary file not shown.
7 changes: 7 additions & 0 deletions regression/cbmc-java/stack_var1/stack_test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class stack_test {
public static void main(String[] args) {
stack_var1 s = new stack_var1();
int n = s.f(1);
assert(n==0);
}
}
Binary file added regression/cbmc-java/stack_var1/stack_var1.class
Binary file not shown.
22 changes: 22 additions & 0 deletions regression/cbmc-java/stack_var1/stack_var1.j
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.class public stack_var1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this file (and the other .j files) included?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are the source files I used to create the classes. This is very bytecode specific, in particular the dup2_x? are very rare, so I used the jasmin assembler to create the regression tests.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, cool. Would you mind adding information in either the commit message or some extra readme file so that these steps become reproducible? I had naively thought that the .class files had been produced from the accompanying .java.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will do, the stack_test.java is always the entry point and creates an object instance of the class created via jasmin.

.super java/lang/Object

.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method

.method public f(I)I
.limit stack 2
.limit locals 2

;; copy of arg on stack
iload_1
;; increment arg
iinc 1 1
;; incremented copy on stack
iload_1
isub
ireturn
.end method
9 changes: 9 additions & 0 deletions regression/cbmc-java/stack_var1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
stack_test.class

^EXIT=10$
^SIGNAL=0$
^.*assertion at file stack_test.java line 5 function.*: FAILURE$
^VERIFICATION FAILED$
--
^warning: ignoring
9 changes: 9 additions & 0 deletions regression/cbmc-java/stack_var2/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This regression test is created from the .j file with the jasmin assembler.
https://github.com/Sable/jasmin

On Ubuntu, it is available as jasmin-sable. To convert a .j file, it is
sufficient to do

> jasmin $FILE.j

and it will create the corresponding $FILE.class file.
Binary file added regression/cbmc-java/stack_var2/stack_test.class
Binary file not shown.
7 changes: 7 additions & 0 deletions regression/cbmc-java/stack_var2/stack_test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class stack_test {
public static void main(String[] args) {
stack_var2 s = new stack_var2();
int n = s.f(1);
assert(n==0);
}
}
Binary file added regression/cbmc-java/stack_var2/stack_var2.class
Binary file not shown.
25 changes: 25 additions & 0 deletions regression/cbmc-java/stack_var2/stack_var2.j
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.class public stack_var2
.super java/lang/Object

.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method

.method public f(I)I
.limit stack 3
.limit locals 2

;; push local var1
iload_1
;; duplicate
dup
;; increment local var1
iinc 1 1
;; push local var1
iload_1
isub
;; incremented copy on stack
ireturn
.end method
9 changes: 9 additions & 0 deletions regression/cbmc-java/stack_var2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
stack_test.class

^EXIT=10$
^SIGNAL=0$
^.*assertion at file stack_test.java line 5 function.*: FAILURE$
^VERIFICATION FAILED$
--
^warning: ignoring
9 changes: 9 additions & 0 deletions regression/cbmc-java/stack_var3/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This regression test is created from the .j file with the jasmin assembler.
https://github.com/Sable/jasmin

On Ubuntu, it is available as jasmin-sable. To convert a .j file, it is
sufficient to do

> jasmin $FILE.j

and it will create the corresponding $FILE.class file.
Binary file added regression/cbmc-java/stack_var3/stack_test.class
Binary file not shown.
7 changes: 7 additions & 0 deletions regression/cbmc-java/stack_var3/stack_test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class stack_test {
public static void main(String[] args) {
stack_var3 s = new stack_var3();
int n = s.f();
assert(n==0);
}
}
Binary file added regression/cbmc-java/stack_var3/stack_var3.class
Binary file not shown.
33 changes: 33 additions & 0 deletions regression/cbmc-java/stack_var3/stack_var3.j
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.class public stack_var3
.super java/lang/Object

.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method

.method public f()I
.limit stack 5
.limit locals 3

;; 1->var1
;; 0->var2
iconst_1
istore_1
iconst_0
istore_2
;; push local var2 / var1
iload_2
iload_1
;; dup var1
dup_x1
;; sub one from var1
iinc 1 -1
;; pop first var1
pop
;; sub
isub
;; incremented copy on stack
ireturn
.end method
9 changes: 9 additions & 0 deletions regression/cbmc-java/stack_var3/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
stack_test.class

^EXIT=10$
^SIGNAL=0$
^.*assertion at file stack_test.java line 5 function.*: FAILURE$
^VERIFICATION FAILED$
--
^warning: ignoring
9 changes: 9 additions & 0 deletions regression/cbmc-java/stack_var4/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This regression test is created from the .j file with the jasmin assembler.
https://github.com/Sable/jasmin

On Ubuntu, it is available as jasmin-sable. To convert a .j file, it is
sufficient to do

> jasmin $FILE.j

and it will create the corresponding $FILE.class file.
Binary file added regression/cbmc-java/stack_var4/stack_test.class
Binary file not shown.
7 changes: 7 additions & 0 deletions regression/cbmc-java/stack_var4/stack_test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class stack_test {
public static void main(String[] args) {
stack_var4 s = new stack_var4();
int n = s.f();
assert(n==0);
}
}
Binary file added regression/cbmc-java/stack_var4/stack_var4.class
Binary file not shown.
37 changes: 37 additions & 0 deletions regression/cbmc-java/stack_var4/stack_var4.j
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.class public stack_var4
.super java/lang/Object

.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method

.method public f()I
.limit stack 5
.limit locals 4

;; 0->var1
;; 1->var2
;; 2->var3
iconst_0
istore_1
iconst_1
istore_2
iconst_2
istore_3

;; push local var3 / var2 / var1
iload_3
iload_2
iload_1
;; push var1 in front of var3
dup_x2
;; add one to local var 1
iinc 1 1
pop
pop
pop
;; incremented copy on stack
ireturn
.end method
10 changes: 10 additions & 0 deletions regression/cbmc-java/stack_var4/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
stack_test.class

^EXIT=0$
^SIGNAL=0$
^.*assertion at file stack_test.java line 5 function.*: SUCCESS
$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
9 changes: 9 additions & 0 deletions regression/cbmc-java/stack_var5/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This regression test is created from the .j file with the jasmin assembler.
https://github.com/Sable/jasmin

On Ubuntu, it is available as jasmin-sable. To convert a .j file, it is
sufficient to do

> jasmin $FILE.j

and it will create the corresponding $FILE.class file.
Binary file added regression/cbmc-java/stack_var5/stack_test.class
Binary file not shown.
7 changes: 7 additions & 0 deletions regression/cbmc-java/stack_var5/stack_test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class stack_test {
public static void main(String[] args) {
stack_var5 s = new stack_var5();
int n = s.f();
assert(n==1);
}
}
Binary file added regression/cbmc-java/stack_var5/stack_var5.class
Binary file not shown.
33 changes: 33 additions & 0 deletions regression/cbmc-java/stack_var5/stack_var5.j
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.class public stack_var5
.super java/lang/Object

.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method

.method public f()I
.limit stack 4
.limit locals 4

;; 1->var1
;; 2->var2
iconst_1
istore_1
iconst_2
istore_2

;; push local var2 / var1
iload_2
iload_1

;; duplicate var2 / var1
dup2
;; add one to local var 1
iinc 1 1
;; sub
isub
;; incremented copy on stack
ireturn
.end method
10 changes: 10 additions & 0 deletions regression/cbmc-java/stack_var5/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
stack_test.class

^EXIT=0$
^SIGNAL=0$
^.*assertion at file stack_test.java line 5 function.*: SUCCESS
$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
9 changes: 9 additions & 0 deletions regression/cbmc-java/stack_var6/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This regression test is created from the .j file with the jasmin assembler.
https://github.com/Sable/jasmin

On Ubuntu, it is available as jasmin-sable. To convert a .j file, it is
sufficient to do

> jasmin $FILE.j

and it will create the corresponding $FILE.class file.
Binary file added regression/cbmc-java/stack_var6/stack_test.class
Binary file not shown.
7 changes: 7 additions & 0 deletions regression/cbmc-java/stack_var6/stack_test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class stack_test {
public static void main(String[] args) {
stack_var6 s = new stack_var6();
int n = s.f(1,2,4);
assert(n==-2);
}
}
Binary file added regression/cbmc-java/stack_var6/stack_var6.class
Binary file not shown.
25 changes: 25 additions & 0 deletions regression/cbmc-java/stack_var6/stack_var6.j
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.class public stack_var6
.super java/lang/Object

.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method

.method public f(III)I
.limit stack 8
.limit locals 5

;; push local var3 / var2 / var1
iload_1
iload_2
iload_3
dup2_x1
;; add one to local var 2
iinc 2 1
;; sub
isub
;; incremented copy on stack
ireturn
.end method
10 changes: 10 additions & 0 deletions regression/cbmc-java/stack_var6/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
stack_test.class

^EXIT=0$
^SIGNAL=0$
^.*assertion at file stack_test.java line 5 function.*: SUCCESS
$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
9 changes: 9 additions & 0 deletions regression/cbmc-java/stack_var7/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This regression test is created from the .j file with the jasmin assembler.
https://github.com/Sable/jasmin

On Ubuntu, it is available as jasmin-sable. To convert a .j file, it is
sufficient to do

> jasmin $FILE.j

and it will create the corresponding $FILE.class file.
Binary file added regression/cbmc-java/stack_var7/stack_test.class
Binary file not shown.
7 changes: 7 additions & 0 deletions regression/cbmc-java/stack_var7/stack_test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class stack_test {
public static void main(String[] args) {
stack_var7 s = new stack_var7();
int n = s.f();
assert(n==1);
}
}
Binary file added regression/cbmc-java/stack_var7/stack_var7.class
Binary file not shown.
Loading