Skip to content

Share a common class_hierarchyt instance across multiple users #3216

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 Oct 22, 2018

This is an alternative to #3204, see that PR for details.

@smowton
Copy link
Contributor Author

smowton commented Oct 22, 2018

@thk123 note this breaks test-gen; the fix is to mirror the change made in jbmc_parse_options.cpp (owning a class_hierarchyt instance which is then passed to remove_exceptions / remove_instanceof).

@tautschnig
Copy link
Collaborator

Would it be possible to have the first four commits in a separate PR? It seems those should go in without debate and wouldn't break TG either. Only the last one is really what #3204 was about?!

@smowton
Copy link
Contributor Author

smowton commented Oct 22, 2018

@tautschnig they're just incidental cleanups in the immediate vicinity of the main change, which I split into their own commits to avoid dirtying the main functional ones. I don't think they're significant enough to bother making their own PR.

@smowton smowton changed the title Smowton/feature/shared class hierarchy Share a common class_hierarchyt instance across multiple users Oct 22, 2018
@tautschnig
Copy link
Collaborator

Up to you, but I think we might become better at getting changes merged if we were to arrive at a one-commit-per-PR model. There's a cost in rebasing changes to PR authors and re-reviewing to reviewers.

@smowton smowton force-pushed the smowton/feature/shared-class-hierarchy branch from f32775c to fff81e8 Compare October 23, 2018 07:13
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

This PR failed Diffblue compatibility checks (cbmc commit: fff81e8).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88804165
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

Copy link
Member

@peterschrammel peterschrammel left a comment

Choose a reason for hiding this comment

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

Looks good, but needs a TG bump, @thk123.

Copy link
Contributor

@thk123 thk123 left a comment

Choose a reason for hiding this comment

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

This is in place of the analysis cache I assume? Will make a TG bump now. Otherwise LGTM.

@@ -529,6 +529,9 @@ int jbmc_parse_optionst::doit()
*this, options, get_message_handler());
lazy_goto_model.initialize(cmdline, options);

class_hierarchy = util_make_unique<class_hierarchyt>();
(*class_hierarchy)(lazy_goto_model.symbol_table);
Copy link
Contributor

Choose a reason for hiding this comment

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

😕 Can't think of a better way to write this, but is a bit of a head scratcher. 💡 Perhaps pull into a static method in class_hierachy.h: std::unique_ptr<class_hierachyt> create_hierachy(const symbol_tablet &)`?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added an extra constructor, take another look?

@smowton
Copy link
Contributor Author

smowton commented Oct 23, 2018

@smowton smowton force-pushed the smowton/feature/shared-class-hierarchy branch from fff81e8 to 5b71f90 Compare October 23, 2018 09:17
@smowton smowton force-pushed the smowton/feature/shared-class-hierarchy branch 2 times, most recently from 9998ed8 to 734dedf Compare October 23, 2018 09:24
Copy link
Contributor

@thk123 thk123 left a comment

Choose a reason for hiding this comment

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

Thanks for making the TG bump

@@ -57,6 +57,10 @@ class class_hierarchyt
void operator()(const symbol_tablet &);

class_hierarchyt() = default;
explicit class_hierarchyt(const symbol_tablet &symbol_table)
Copy link
Contributor

Choose a reason for hiding this comment

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

💚 Why even have the default constructor + operator? This is perfect!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for cases where the user wants to allocate it in advance, e.g. as a member of another class that won't have access to the symbol table until its own operator(), so I won't kill the no-arg constructor. However agreed this is better when possible.

@@ -606,12 +609,13 @@ int jbmc_parse_optionst::get_goto_program(
*this, options, get_message_handler());
lazy_goto_model.initialize(cmdline, options);

class_hierarchy = util_make_unique<class_hierarchyt>();
Copy link
Contributor

Choose a reason for hiding this comment

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

⛏️ Use the new constructor

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

This PR failed Diffblue compatibility checks (cbmc commit: 9998ed8).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88821470
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

This PR failed Diffblue compatibility checks (cbmc commit: 734dedf).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88824136
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

@smowton smowton force-pushed the smowton/feature/shared-class-hierarchy branch from 734dedf to 1b43a8a Compare October 23, 2018 11:16
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

This PR failed Diffblue compatibility checks (cbmc commit: 1b43a8a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88835479
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

class_hierarchyt hierarchy;
hierarchy(lazy_goto_model.symbol_table);
show_class_hierarchy(hierarchy, ui_message_handler);
show_class_hierarchy((*class_hierarchy), ui_message_handler);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the extra brackets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, fixed

@smowton smowton force-pushed the smowton/feature/shared-class-hierarchy branch from 1b43a8a to cf4c264 Compare October 23, 2018 15:49
@smowton
Copy link
Contributor Author

smowton commented Oct 23, 2018

Merging blocked for now because test-gen can't be validated due to problems with a previous PR merged against cbmc/develop.

Allows alloc-and-init in one go.
The class hierarchy never changes once the symbol table is computed. By sharing one instance
owned by the driver program, particularly across function passes, we can avoid many potentially
expensive recomputations.
To pacify clang-format. All hail clang-format.
@smowton smowton force-pushed the smowton/feature/shared-class-hierarchy branch from cf4c264 to 5e9aba8 Compare October 24, 2018 09:32
@smowton
Copy link
Contributor Author

smowton commented Oct 24, 2018

Rebased on fixed cbmc/develop

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

This PR failed Diffblue compatibility checks (cbmc commit: 5e9aba8).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88984909
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

@smowton smowton merged commit af06d4e into diffblue:develop Oct 24, 2018
@@ -552,6 +552,9 @@ int jbmc_parse_optionst::doit()
*this, options, get_message_handler());
lazy_goto_model.initialize(cmdline, options);

class_hierarchy =
util_make_unique<class_hierarchyt>(lazy_goto_model.symbol_table);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed here?

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

Successfully merging this pull request may close these issues.

6 participants