Skip to content
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

Add option for strict write barriers #1008

Merged
merged 2 commits into from
Aug 10, 2018

Conversation

jechter
Copy link

@jechter jechter commented Aug 8, 2018

#958 added support for incremental Boehm GC by adding write barriers to mono.

Incremental Boehm requires only one write barrier call on any pointer within an object even if multiple references in the object have changed, as the object is then considered as dirty, and rescanned.

However, our technique for validating correct use of write barriers (by verifying that all found references have been set through a write barrier call) is not that tolerant (And potentially, neither are future Boehm replacements). So, to get a good test coverage for write barrier use to work, we need an option to set write barriers on all reference writes. Mono has some functions which touch whole blocks of managed memory (which may contain references). This PR adds a "strict write barrier" mode, which will set write barriers for each potential reference in those functions.

This needs to land in order to get test coverage on write barrier use in Unity to run.

@jechter jechter requested review from joncham and removed request for joncham August 8, 2018 12:20
@jechter jechter requested a review from joncham August 8, 2018 13:12
@@ -198,13 +198,15 @@ create_domain_objects (MonoDomain *domain)
mono_error_assert_ok (&error);
mono_field_static_set_value (string_vt, string_empty_fld, empty_str);
domain->empty_string = empty_str;
mono_gc_wbarrier_generic_nostore (&domain->empty_string);
Copy link
Member

Choose a reason for hiding this comment

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

Not sure it matters, but would replacing assignment above with mono_gc_wbarrier_generic_store be better?

Copy link
Author

Choose a reason for hiding this comment

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

yeah, guess that is nicer. Will change and then merge.

Copy link
Author

Choose a reason for hiding this comment

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

(This and the other instances)

Copy link
Member

Choose a reason for hiding this comment

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

It may make merge conflicts with upstream more frequent. Just wondering what practical difference is if anything.

Copy link
Author

Choose a reason for hiding this comment

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

there should be no practical difference

Copy link
Author

Choose a reason for hiding this comment

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

Looking at it, I decided not to change it. The functionality is identical, and the code did not look nicer by merging the assignment and the write barrier, as lines become very long. Merged as is.

@jechter jechter merged commit f7192b6 into unity-master Aug 10, 2018
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.

2 participants