-
Notifications
You must be signed in to change notification settings - Fork 78
Remove NULL ObjectReference #1064
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
Conversation
0d1c7d3 to
a5035a2
Compare
|
Here are some preliminary benchmark results. Two builds:
I ran it with From the data, the impact on total time is between -0.5% to +0.5%, and the error bar is large. Interestingly, it always shows slowdown on shrew, and always speed-up on vole. For STW time, "shrew 2.5x" has a slow-down of 1%, and "vole 3x" has a speed-up of 1.5%, but their error bars are too large. I think the result of forcing |
|
binding-refs |
|
This PR is now ready for review. Associated PRs for the bindings: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. There are some minor points.
Also a quick check: is there any change that may affect performance for OpenJDK and MMTk since the evaluation in #1064 (comment)?
| #[repr(transparent)] | ||
| #[derive(Copy, Clone, Eq, Hash, PartialOrd, Ord, PartialEq, NoUninit)] | ||
| pub struct ObjectReference(usize); | ||
| pub struct ObjectReference(NonZeroUsize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments for the type should note that ObjectReference cannot be null, and for places where we may have an invalid object reference, we use Option<ObjectReference>. NonZeroUsize makes sure that Option<ObjectReference> has the same length as ObjectReference.
src/util/mod.rs
Outdated
| // This module is made public so the binding could implement allocator slowpaths if they would like to. | ||
| pub mod alloc; | ||
| /// Helpers for making native APIs. | ||
| pub mod apiutils; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use the name api_util to be consistent with other existing modules such as rust_util/test_util.
I don't think so, but I'll re-run the benchmarks just to be safe. |
|
I re-ran the benchmarks with the same setting as in #1064 (comment) Total time: (geomens of build2 are between 99.5% to 100.2% of build1, varying among Other time: (99.6% to 100.1%) STW time: (99.2% to 100.8%) The differences are within 1%. This result is consistent with the last evaluation. |
There were a few comments that still mentioned null ObjectReference. They have been removed.
Parent PR: mmtk/mmtk-core#1064 --------- Co-authored-by: mmtkgc-bot <mmtkgc.bot@gmail.com>
Parent PR: mmtk/mmtk-core#1064 --------- Co-authored-by: mmtkgc-bot <mmtkgc.bot@gmail.com>
Upstream PR: mmtk/mmtk-core#1064 --------- Co-authored-by: mmtkgc-bot <mmtkgc.bot@gmail.com>
Upstream PR: mmtk/mmtk-core#1064 --------- Co-authored-by: mmtkgc-bot <mmtkgc.bot@gmail.com>
Parent PR: mmtk/mmtk-core#1064 --------- Co-authored-by: mmtkgc-bot <mmtkgc.bot@gmail.com>
Parent PR: mmtk/mmtk-core#1064 --------- Co-authored-by: mmtkgc-bot <mmtkgc.bot@gmail.com>







We changed
ObjectReferenceso that it is backed byNonZeroUsize, and can no longer represent a NULL reference. For cases where anObjectReferencesmay or may not exist,Option<ObjectReference>should be used instead.This is an API-breaking change.
ObjectReference::NULLandObjectReference::is_null()are removed.ObjectReference::from_raw_address()now returnsOption<ObjectReference>. The unsafe methodObjectReference::from_raw_address_unchecked()assumes the address is not zero, and returnsObjectReference.ObjectReferencenow returnOption<ObjectReference>. Examples includeEdge::load()andReferenceGlue::get_referent().If a VM binding needs to expose
Option<ObjectReference>to native (C/C++) programs, a convenient typecrate::util::api_util::NullableObjectReferenceis provided.Fixes: #1043