Skip to content

Java object factory: allocate fixed length arrays #839

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

Merged

Conversation

smowton
Copy link
Contributor

@smowton smowton commented Apr 18, 2017

This replaces the variable-length arrays produced by the Java object factory with fixed-length ones annotated with a variable length member. This allows the backend to use the much cheaper fixed-length array lowering rather than the full variable-length array theory, while retaining the ability for the effective length to vary. In effect this creates a bounded-length array construct.

Fixes #746

This replaces the variable-length arrays produced by the Java object
factory with fixed-length ones annotated with a variable length member.
This allows the backend to use the much cheaper fixed-length array lowering
rather than the full variable-length array theory, while retaining the
ability for the effective length to vary. In effect this creates a bounded-
length array construct.

Fixes diffblue#746
@@ -386,6 +386,7 @@ void java_object_factoryt::gen_nondet_array_init(

side_effect_exprt java_new_array(ID_java_new_array, expr.type());
java_new_array.copy_to_operands(length_sym_expr);
java_new_array.set(ID_length_upper_bound, max_length_expr);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Couldn't we then also get rid of other bits of code using max_length_expr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

length_sym_expr? No, the idea is that length_sym_expr is the actual size of the array and max_length_expr is the upper bound on that length. The actual size is used to initialise the array with NONDET members, and the bound is used to allocate the storage and provide a bound on the initialisation loop.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants