Skip to content

Commit 8fc4ae5

Browse files
fixcompilation
1 parent 6b6afbd commit 8fc4ae5

7 files changed

+30
-51
lines changed

jbmc/src/java_bytecode/convert_java_nondet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ static goto_programt::targett insert_nondet_init_code(
9393
source_loc,
9494
true,
9595
allocation_typet::DYNAMIC,
96-
nullable,
9796
object_factory_parameters,
9897
update_in_placet::NO_UPDATE_IN_PLACE);
9998

jbmc/src/java_bytecode/java_bytecode_language.h

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -59,50 +59,13 @@ Author: Daniel Kroening, [email protected]
5959
" the purpose of lazy method loading\n" /* NOLINT(*) */ \
6060
" A '.*' wildcard is allowed to specify all class members\n"
6161

62-
#define MAX_NONDET_ARRAY_LENGTH_DEFAULT 5
63-
#define MAX_NONDET_STRING_LENGTH std::numeric_limits<std::int32_t>::max()
64-
#define MAX_NONDET_TREE_DEPTH 5
65-
#define MAX_NONNULL_TREE_DEPTH 0
66-
6762
class symbolt;
6863

6964
enum lazy_methods_modet
7065
{
7166
LAZY_METHODS_MODE_EAGER,
7267
LAZY_METHODS_MODE_CONTEXT_INSENSITIVE,
73-
LAZY_METHODS_MODE_CONTEXT_SENSITIVE
74-
};
75-
76-
struct object_factory_parameterst final
77-
{
78-
/// Maximum value for the non-deterministically-chosen length of an array.
79-
size_t max_nondet_array_length=MAX_NONDET_ARRAY_LENGTH_DEFAULT;
80-
81-
/// Maximum value for the non-deterministically-chosen length of a string.
82-
size_t max_nondet_string_length=MAX_NONDET_STRING_LENGTH;
83-
84-
/// Maximum depth for object hierarchy on input.
85-
/// Used to prevent object factory to loop infinitely during the
86-
/// generation of code that allocates/initializes data structures of recursive
87-
/// data types or unbounded depth. We bound the maximum number of times we
88-
/// dereference a pointer using a 'depth counter'. We set a pointer to null if
89-
/// such depth becomes >= than this maximum value.
90-
size_t max_nondet_tree_depth=MAX_NONDET_TREE_DEPTH;
91-
92-
/// To force a certain depth of non-null objects.
93-
/// The default is that objects are 'maybe null' up to the nondet tree depth.
94-
/// Examples:
95-
/// * max_nondet_tree_depth=0, max_nonnull_tree_depth irrelevant
96-
/// pointer initialized to null
97-
/// * max_nondet_tree_depth=n, max_nonnull_tree_depth=0
98-
/// pointer and children up to depth n maybe-null, beyond n null
99-
/// * max_nondet_tree_depth=n >=m, max_nonnull_tree_depth=m
100-
/// pointer and children up to depth m initialized to non-null,
101-
/// children up to n maybe-null, beyond n null
102-
size_t max_nonnull_tree_depth=MAX_NONNULL_TREE_DEPTH;
103-
104-
/// Force string content to be ASCII printable characters when set to true.
105-
bool string_printable = false;
68+
LAZY_METHODS_MODE_EXTERNAL_DRIVER
10669
};
10770

10871
class java_bytecode_languaget:public languaget

jbmc/src/java_bytecode/java_entry_point.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ exprt::operandst java_build_arguments(
192192
if(is_main)
193193
parameters.max_nonnull_tree_depth = 2;
194194

195-
object_factory_parameterst parameters = object_factory_parameters;
196195
parameters.function_id = goto_functionst::entry_point();
197196

198197
// generate code to allocate and non-deterministicaly initialize the

jbmc/src/java_bytecode/java_object_factory.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -833,11 +833,9 @@ void java_object_factoryt::gen_nondet_pointer_init(
833833
// and asign to `expr` the address of such object
834834
code_blockt non_null_inst;
835835

836-
bool string_init_failed = false;
837836
// Note string-type-specific initialization might fail, e.g. if java.lang.CharSequence does not
838837
// have the expected fields (typically this happens if --refine-strings was not passed). In this
839838
// case we fall back to normal pointer target init.
840-
841839
bool string_init_succeeded = false;
842840

843841
if(java_string_library_preprocesst::implements_java_char_sequence_pointer(
@@ -869,10 +867,6 @@ void java_object_factoryt::gen_nondet_pointer_init(
869867

870868
bool allow_null = depth > object_factory_parameters.max_nonnull_tree_depth;
871869

872-
// Determine whether the pointer can be null. In particular the pointers
873-
// inside the java.lang.Class class shall not be null
874-
const bool not_null = allow_nul || class_identifier == "java.lang.Class";
875-
876870
// Alternatively, if this is a void* we *must* initialise with null:
877871
// (This can currently happen for some cases of #exception_value)
878872
// Also, if the String model is not loaded then we can only

jbmc/src/java_bytecode/java_static_initializers.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,14 +786,19 @@ codet stub_global_initializer_factoryt::get_stub_initializer_body(
786786
{
787787
const symbol_exprt new_global_symbol =
788788
symbol_table.lookup_ref(it->second).symbol_expr();
789+
790+
parameters.max_nonnull_tree_depth =
791+
is_non_null_library_global(it->second) ?
792+
object_factory_parameters.max_nonnull_tree_depth + 1 :
793+
object_factory_parameters.max_nonnull_tree_depth;
794+
789795
gen_nondet_init(
790796
new_global_symbol,
791797
static_init_body,
792798
symbol_table,
793799
source_locationt(),
794800
false,
795801
allocation_typet::DYNAMIC,
796-
!is_non_null_library_global(it->second),
797802
parameters,
798803
pointer_type_selector,
799804
update_in_placet::NO_UPDATE_IN_PLACE);

jbmc/src/java_bytecode/object_factory_parameters.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Author: Daniel Kroening, [email protected]
1717
#define MAX_NONDET_ARRAY_LENGTH_DEFAULT 5
1818
#define MAX_NONDET_STRING_LENGTH std::numeric_limits<std::int32_t>::max()
1919
#define MAX_NONDET_TREE_DEPTH 5
20+
#define MAX_NONNULL_TREE_DEPTH 0
2021

2122
struct object_factory_parameterst final
2223
{
@@ -34,6 +35,18 @@ struct object_factory_parameterst final
3435
/// such depth becomes >= than this maximum value.
3536
size_t max_nondet_tree_depth=MAX_NONDET_TREE_DEPTH;
3637

38+
/// To force a certain depth of non-null objects.
39+
/// The default is that objects are 'maybe null' up to the nondet tree depth.
40+
/// Examples:
41+
/// * max_nondet_tree_depth=0, max_nonnull_tree_depth irrelevant
42+
/// pointer initialized to null
43+
/// * max_nondet_tree_depth=n, max_nonnull_tree_depth=0
44+
/// pointer and children up to depth n maybe-null, beyond n null
45+
/// * max_nondet_tree_depth=n >=m, max_nonnull_tree_depth=m
46+
/// pointer and children up to depth m initialized to non-null,
47+
/// children up to n maybe-null, beyond n null
48+
size_t max_nonnull_tree_depth=MAX_NONNULL_TREE_DEPTH;
49+
3750
/// Force string content to be ASCII printable characters when set to true.
3851
bool string_printable = false;
3952

jbmc/src/java_bytecode/simple_method_stubbing.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ void java_simple_method_stubst::create_method_stub_at(
106106
if(is_constructor)
107107
to_init = dereference_exprt(to_init, expected_base);
108108

109+
object_factory_parameterst parameters = object_factory_parameters;
110+
if(assume_non_null)
111+
parameters.max_nonnull_tree_depth++;
112+
109113
// Generate new instructions.
110114
code_blockt new_instructions;
111115
gen_nondet_init(
@@ -115,8 +119,7 @@ void java_simple_method_stubst::create_method_stub_at(
115119
loc,
116120
is_constructor,
117121
allocation_typet::DYNAMIC,
118-
!assume_non_null,
119-
object_factory_parameters,
122+
parameters,
120123
update_in_place ? update_in_placet::MUST_UPDATE_IN_PLACE
121124
: update_in_placet::NO_UPDATE_IN_PLACE);
122125

@@ -189,15 +192,18 @@ void java_simple_method_stubst::create_method_stub(symbolt &symbol)
189192
const exprt &to_return = to_return_symbol.symbol_expr();
190193
if(to_return_symbol.type.id() != ID_pointer)
191194
{
195+
object_factory_parameterst parameters = object_factory_parameters;
196+
if(assume_non_null)
197+
parameters.max_nonnull_tree_depth++;
198+
192199
gen_nondet_init(
193200
to_return,
194201
new_instructions,
195202
symbol_table,
196203
source_locationt(),
197204
false,
198205
allocation_typet::LOCAL, // Irrelevant as type is primitive
199-
!assume_non_null,
200-
object_factory_parameters,
206+
parameters,
201207
update_in_placet::NO_UPDATE_IN_PLACE);
202208
}
203209
else

0 commit comments

Comments
 (0)