Skip to content

Commit 0968e93

Browse files
committed
Regression tests: java method parameter detection
1 parent 9bb474d commit 0968e93

File tree

10 files changed

+330
-0
lines changed

10 files changed

+330
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
T=unexpected
3+
4+
all : $T.class
5+
6+
%.class : %.j
7+
jasmin $<
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
KNOWNBUG
2+
unexpected.class
3+
--verbosity 10 --show-symbol-table
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
--
8+
The LVT in the only method in unexpected.class does not satisfy the constraints
9+
expected by the bytecode to goto conversion algorithms. Namely, the live range
10+
of parameter x in that method is not preceeded by a store_i instruction, which
11+
is perfectly possibly as per the JVM specs but currently additionally required
12+
in CBMC.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.class public unexpected
2+
.super java/lang/Object
3+
4+
.method public static test1(I)I
5+
.limit stack 10
6+
.limit locals 20
7+
8+
; unexpected in previous code, as arg is the argument of the method and its
9+
; start_pc is != 0
10+
.var 0 is arg I from Label1 to Label2
11+
.var 1 is x I from Label1 to Label2
12+
13+
; say hello
14+
getstatic java/lang/System/out Ljava/io/PrintStream;
15+
ldc "Starting test1!"
16+
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
17+
18+
Label1:
19+
; x = arg + 3
20+
iload_0
21+
iconst_3
22+
iadd
23+
istore_1
24+
25+
; say bye
26+
getstatic java/lang/System/out Ljava/io/PrintStream;
27+
ldc "Returning from test1!"
28+
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
29+
30+
; return x
31+
iload_1
32+
ireturn
33+
Label2:
34+
.end method
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
class method_parameters
2+
{
3+
void test1()
4+
{}
5+
6+
void test2(boolean b)
7+
{}
8+
9+
void test3(byte b)
10+
{}
11+
12+
void test3a(char c)
13+
{}
14+
15+
void test4(int i)
16+
{}
17+
18+
void test5(float f)
19+
{}
20+
21+
void test6(String s)
22+
{}
23+
24+
void test7(long l)
25+
{}
26+
27+
void test8(double l)
28+
{}
29+
30+
void test9(int i, long l)
31+
{
32+
int local = 123;
33+
}
34+
35+
void test10(double i, String s)
36+
{
37+
int local = 123;
38+
}
39+
40+
void test11(int a[][])
41+
{}
42+
43+
double test12(double a[][], double d)
44+
{
45+
if (a.length < 1) return 0;
46+
if (a[0].length < 1) return 0;
47+
return d + a[0][0];
48+
}
49+
50+
void test12a(double a[][][], int i, double d)
51+
{}
52+
53+
double test12b(double a[][], double d)
54+
{
55+
return 123.123;
56+
}
57+
58+
void test12c(double a[][][], double d)
59+
{
60+
}
61+
62+
void test13(double d, int i, byte b, char c)
63+
{}
64+
65+
// Same as above but now static
66+
67+
static void ttest1()
68+
{}
69+
70+
static void ttest2(boolean b)
71+
{}
72+
73+
static void ttest3(byte b)
74+
{}
75+
76+
static void ttest3a(char c)
77+
{}
78+
79+
static void ttest4(int i)
80+
{}
81+
82+
static void ttest5(float f)
83+
{}
84+
85+
static void ttest6(String s)
86+
{}
87+
88+
static void ttest7(long l)
89+
{}
90+
91+
static void ttest8(double l)
92+
{}
93+
94+
static void ttest9(int i, long l)
95+
{
96+
int local = 123;
97+
}
98+
99+
static void ttest10(double i, String s)
100+
{
101+
int local = 123;
102+
}
103+
104+
static void ttest11(int a[][])
105+
{}
106+
107+
static double ttest12(double a[][], double d)
108+
{
109+
if (a.length < 1) return 0;
110+
if (a[0].length < 1) return 0;
111+
return d + a[0][0];
112+
}
113+
114+
static void ttest12a(double a[][][], int i, double d)
115+
{}
116+
117+
static double ttest12b(double a[][], double d)
118+
{
119+
return 123.123;
120+
}
121+
122+
static void ttest12c(double a[][][], double d)
123+
{
124+
}
125+
126+
static void ttest13(double d, int i, byte b, char c)
127+
{}
128+
129+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
method_parameters.class
3+
--verbosity 10 --show-symbol-table
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
--
8+
The purpose of the test is ensuring that the bytecode -> symbol table AST
9+
generation happens correctly. The generated .class file does not contain LVTs.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
class method_parameters
2+
{
3+
void test1()
4+
{}
5+
6+
void test2(boolean b)
7+
{}
8+
9+
void test3(byte b)
10+
{}
11+
12+
void test3a(char c)
13+
{}
14+
15+
void test4(int i)
16+
{}
17+
18+
void test5(float f)
19+
{}
20+
21+
void test6(String s)
22+
{}
23+
24+
void test7(long l)
25+
{}
26+
27+
void test8(double l)
28+
{}
29+
30+
void test9(int i, long l)
31+
{
32+
int local = 123;
33+
}
34+
35+
void test10(double i, String s)
36+
{
37+
int local = 123;
38+
}
39+
40+
void test11(int a[][])
41+
{}
42+
43+
double test12(double a[][], double d)
44+
{
45+
if (a.length < 1) return 0;
46+
if (a[0].length < 1) return 0;
47+
return d + a[0][0];
48+
}
49+
50+
void test12a(double a[][][], int i, double d)
51+
{}
52+
53+
double test12b(double a[][], double d)
54+
{
55+
return 123.123;
56+
}
57+
58+
void test12c(double a[][][], double d)
59+
{
60+
}
61+
62+
void test13(double d, int i, byte b, char c)
63+
{}
64+
65+
// Same as above but now static
66+
67+
static void ttest1()
68+
{}
69+
70+
static void ttest2(boolean b)
71+
{}
72+
73+
static void ttest3(byte b)
74+
{}
75+
76+
static void ttest3a(char c)
77+
{}
78+
79+
static void ttest4(int i)
80+
{}
81+
82+
static void ttest5(float f)
83+
{}
84+
85+
static void ttest6(String s)
86+
{}
87+
88+
static void ttest7(long l)
89+
{}
90+
91+
static void ttest8(double l)
92+
{}
93+
94+
static void ttest9(int i, long l)
95+
{
96+
int local = 123;
97+
}
98+
99+
static void ttest10(double i, String s)
100+
{
101+
int local = 123;
102+
}
103+
104+
static void ttest11(int a[][])
105+
{}
106+
107+
static double ttest12(double a[][], double d)
108+
{
109+
if (a.length < 1) return 0;
110+
if (a[0].length < 1) return 0;
111+
return d + a[0][0];
112+
}
113+
114+
static void ttest12a(double a[][][], int i, double d)
115+
{}
116+
117+
static double ttest12b(double a[][], double d)
118+
{
119+
return 123.123;
120+
}
121+
122+
static void ttest12c(double a[][][], double d)
123+
{
124+
}
125+
126+
static void ttest13(double d, int i, byte b, char c)
127+
{}
128+
129+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
method_parameters.class
3+
--verbosity 10 --show-symbol-table
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
--
8+
The purpose of the test is ensuring that the bytecode -> symbol table AST
9+
generation happens correctly. The generated .class file DOES contain LVTs, i.e.,
10+
it has been compiled with with "javac -g".

0 commit comments

Comments
 (0)