Skip to content

Commit 00fb335

Browse files
author
Daniel Kroening
committed
construct Java primitive types only once
The primitive Java types are fixed, and used frequently. Computing them once saves time and enables sharing the ireps used for them.
1 parent ca9cb4a commit 00fb335

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

jbmc/src/java_bytecode/java_types.cpp

+21-10
Original file line numberDiff line numberDiff line change
@@ -31,50 +31,59 @@ std::vector<typet> parse_list_types(
3131

3232
signedbv_typet java_int_type()
3333
{
34-
return signedbv_typet(32);
34+
static const auto result = signedbv_typet(32);
35+
return result;
3536
}
3637

3738
void_typet java_void_type()
3839
{
39-
return void_typet();
40+
static const auto result = void_typet();
41+
return result;
4042
}
4143

4244
signedbv_typet java_long_type()
4345
{
44-
return signedbv_typet(64);
46+
static const auto result = signedbv_typet(64);
47+
return result;
4548
}
4649

4750
signedbv_typet java_short_type()
4851
{
49-
return signedbv_typet(16);
52+
static const auto result = signedbv_typet(16);
53+
return result;
5054
}
5155

5256
signedbv_typet java_byte_type()
5357
{
54-
return signedbv_typet(8);
58+
static const auto result = signedbv_typet(8);
59+
return result;
5560
}
5661

5762
unsignedbv_typet java_char_type()
5863
{
59-
return unsignedbv_typet(16);
64+
static const auto result = unsignedbv_typet(16);
65+
return result;
6066
}
6167

6268
floatbv_typet java_float_type()
6369
{
64-
return ieee_float_spect::single_precision().to_type();
70+
static const auto result = ieee_float_spect::single_precision().to_type();
71+
return result;
6572
}
6673

6774
floatbv_typet java_double_type()
6875
{
69-
return ieee_float_spect::double_precision().to_type();
76+
static const auto result = ieee_float_spect::double_precision().to_type();
77+
return result;
7078
}
7179

7280
c_bool_typet java_boolean_type()
7381
{
7482
// The Java standard doesn't really prescribe the width
7583
// of a boolean. However, JNI suggests that it's 8 bits.
7684
// http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html
77-
return c_bool_typet(8);
85+
static const auto result = c_bool_typet(8);
86+
return result;
7887
}
7988

8089
reference_typet java_reference_type(const typet &subtype)
@@ -84,7 +93,9 @@ reference_typet java_reference_type(const typet &subtype)
8493

8594
reference_typet java_lang_object_type()
8695
{
87-
return java_reference_type(struct_tag_typet("java::java.lang.Object"));
96+
static const auto result =
97+
java_reference_type(struct_tag_typet("java::java.lang.Object"));
98+
return result;
8899
}
89100

90101
/// Construct an array pointer type. It is a pointer to a symbol with identifier

0 commit comments

Comments
 (0)