Skip to content

Small shared n-way pointer #4654

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
merged 1 commit into from
May 15, 2019

Conversation

danpoe
Copy link
Contributor

@danpoe danpoe commented May 14, 2019

This replaces small_shared_two_way_ptrt with small_shared_n_way_ptrt. The new shared pointer type allows more than two types for the managed objects. This can be useful e.g. for implementing graph data structures with sharing where there are more than two different node types.

This is in preparation for a sharing map improvement where a further node type will be introduced for leaf nodes that are not at the bottom of the tree (which will be possible once the variable-height tree PR #4641 has been merged).

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@danpoe danpoe force-pushed the feature/small-shared-n-way-ptr branch 5 times, most recently from a45b763 to c3720e9 Compare May 14, 2019 13:44
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.

✔️
Passed Diffblue compatibility checks (cbmc commit: c3720e9).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/111756419

return *this;
}

Num use_count() const
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we actually name this get_use_count to avoid the final underscore in use_count_? It would also seem a lot more consistent, because we have increment_use_count and decrement_use_count.


void increment_use_count()
{
PRECONDITION((use_count_ & use_count_mask) < use_count_mask);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit pick: use get_use_count()


void decrement_use_count()
{
PRECONDITION((use_count_ & use_count_mask) > 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit pick: use get_use_count()

{
PRECONDITION((use_count_ & use_count_mask) < use_count_mask);

use_count_++;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit pick: use pre-increment rather than having the compiler figure this out.

{
PRECONDITION((use_count_ & use_count_mask) > 0);

use_count_--;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit pick: use pre-decrement rather than making the compiler figure this out.

@danpoe danpoe force-pushed the feature/small-shared-n-way-ptr branch from c3720e9 to e2528e3 Compare May 15, 2019 10:11
This replaces small_shared_two_way_ptrt with small_shared_n_way_ptrt. The new
shared pointer type allows more than two types for the managed objects. This can
be useful e.g. for implementing graph data structures with sharing where there
are more than two different node types.
@danpoe danpoe force-pushed the feature/small-shared-n-way-ptr branch from e2528e3 to 922adf0 Compare May 15, 2019 10:14
@danpoe danpoe merged commit c1dae4a into diffblue:develop May 15, 2019
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.

✔️
Passed Diffblue compatibility checks (cbmc commit: 922adf0).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/111896232

@danpoe danpoe deleted the feature/small-shared-n-way-ptr branch June 2, 2020 17:08
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.

3 participants