-
Notifications
You must be signed in to change notification settings - Fork 76
Typed access to metadata #647
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
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
729d990
Use u64 instead usize for 8bytes side metadata
qinsoon 1d1a9bc
Merge branch 'master' into fix-side-metadata-usize
qinsoon 4a0d8ff
Use u64 instead usize for 8bytes side metadata
qinsoon 76debb8
Apply same change to header metadata
qinsoon 39fb2c1
MetadataValue Prototype
qinsoon 241c6df
Refactor side metadata methods with MetadataValue
qinsoon 5079d01
Refactor Metadata and HeaderMetadata with MetadataValue
qinsoon 4296583
Provide a default impl for header metadata access in ObjectModel
qinsoon 5c28dc2
Tidy up side metadata sanity: use verify_update instead verify_<op>
qinsoon c432b50
Add fetch_and/or/update
qinsoon ec838ab
Fix current tests
qinsoon 4b63bf2
Move a few methods to SideMetadata
qinsoon 4078e90
WIP: Add some tests
qinsoon b19e242
WIP: more tests
qinsoon 44a21c0
More tests on SideMetadata
qinsoon cf3d204
Metadata ops should call ObjectModel methods
qinsoon 967fe5f
Add test for header metadata
qinsoon fe11527
Separate atomic/non-atomic load/store for metadata and header metadata
qinsoon 21ba305
Fix test/style
qinsoon 9ecb707
Use u64 for side metadata sanity map
qinsoon 01054e7
Remove code that was commented out
qinsoon 43188f4
Merge branch 'master' into fix-side-metadata-usize
qinsoon 067d6e5
Fix build and test on 32 bits
qinsoon d07d7e8
Clean up
qinsoon 3b6d365
Merge branch 'master' into fix-side-metadata-usize
qinsoon 53a568d
inline(always) for a few places
qinsoon 8526afc
Use atomic load for object barrier
qinsoon 0c6ff4a
Move return description to the end of the description.
qinsoon ed6e905
Outdated comments
qinsoon 7c51e72
Assert input value for side metadata access. Allow serial_test lock
qinsoon 9e58b7b
Use fetch_update for atomic_store and fetch_ops for bits. Use
qinsoon 32355d2
Use fetch_update for fetch_update_atomic of bits. cargo fmt
qinsoon ff95893
Use fetch_update over compare_and_exchange on header metadata as well.
qinsoon 02d7b99
Use fetch_update for HeaderMetadataSpec.fetch_ops_on_bits.
qinsoon 06d6395
compare_exchange returns Result
qinsoon 1c4cc86
Merge branch 'master' into fix-side-metadata-usize
qinsoon 99a9840
Use relaxed atomic load for mark sweep trace_object. Use Option.map for
qinsoon 24bb41b
Use explicit type parameter for fetch_update
qinsoon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,8 @@ use crate::util::heap::HeapMeta; | |
use crate::util::heap::PageResource; | ||
use crate::util::heap::VMRequest; | ||
use crate::util::linear_scan::{Region, RegionIterator}; | ||
use crate::util::metadata::side_metadata::{self, *}; | ||
use crate::util::metadata::{ | ||
self, compare_exchange_metadata, load_metadata, store_metadata, MetadataSpec, | ||
}; | ||
use crate::util::metadata::side_metadata::{SideMetadataContext, SideMetadataSpec}; | ||
use crate::util::metadata::{self, MetadataSpec}; | ||
use crate::util::object_forwarding as ForwardingWord; | ||
use crate::util::{Address, ObjectReference}; | ||
use crate::vm::*; | ||
|
@@ -509,25 +507,26 @@ impl<VM: VMBinding> ImmixSpace<VM> { | |
#[inline(always)] | ||
fn attempt_mark(&self, object: ObjectReference, mark_state: u8) -> bool { | ||
loop { | ||
let old_value = load_metadata::<VM>( | ||
&VM::VMObjectModel::LOCAL_MARK_BIT_SPEC, | ||
let old_value = VM::VMObjectModel::LOCAL_MARK_BIT_SPEC.load_atomic::<VM, u8>( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Depending on |
||
object, | ||
None, | ||
Some(Ordering::SeqCst), | ||
) as u8; | ||
Ordering::SeqCst, | ||
); | ||
if old_value == mark_state { | ||
return false; | ||
} | ||
|
||
if compare_exchange_metadata::<VM>( | ||
&VM::VMObjectModel::LOCAL_MARK_BIT_SPEC, | ||
object, | ||
old_value as usize, | ||
mark_state as usize, | ||
None, | ||
Ordering::SeqCst, | ||
Ordering::SeqCst, | ||
) { | ||
if VM::VMObjectModel::LOCAL_MARK_BIT_SPEC | ||
.compare_exchange_metadata::<VM, u8>( | ||
object, | ||
old_value, | ||
mark_state, | ||
None, | ||
Ordering::SeqCst, | ||
Ordering::SeqCst, | ||
) | ||
.is_ok() | ||
{ | ||
break; | ||
} | ||
} | ||
|
@@ -537,12 +536,11 @@ impl<VM: VMBinding> ImmixSpace<VM> { | |
/// Check if an object is marked. | ||
#[inline(always)] | ||
fn is_marked(&self, object: ObjectReference, mark_state: u8) -> bool { | ||
let old_value = load_metadata::<VM>( | ||
&VM::VMObjectModel::LOCAL_MARK_BIT_SPEC, | ||
let old_value = VM::VMObjectModel::LOCAL_MARK_BIT_SPEC.load_atomic::<VM, u8>( | ||
object, | ||
None, | ||
Some(Ordering::SeqCst), | ||
) as u8; | ||
Ordering::SeqCst, | ||
); | ||
old_value == mark_state | ||
} | ||
|
||
|
@@ -618,7 +616,7 @@ impl<VM: VMBinding> PrepareBlockState<VM> { | |
#[inline(always)] | ||
fn reset_object_mark(chunk: Chunk) { | ||
if let MetadataSpec::OnSide(side) = *VM::VMObjectModel::LOCAL_MARK_BIT_SPEC { | ||
side_metadata::bzero_metadata(&side, chunk.start(), Chunk::BYTES); | ||
side.bzero_metadata(chunk.start(), Chunk::BYTES); | ||
} | ||
} | ||
} | ||
|
@@ -689,12 +687,11 @@ impl<VM: VMBinding> PolicyCopyContext for ImmixCopyContext<VM> { | |
#[inline(always)] | ||
fn post_copy(&mut self, obj: ObjectReference, _bytes: usize) { | ||
// Mark the object | ||
store_metadata::<VM>( | ||
&VM::VMObjectModel::LOCAL_MARK_BIT_SPEC, | ||
VM::VMObjectModel::LOCAL_MARK_BIT_SPEC.store_atomic::<VM, u8>( | ||
obj, | ||
self.get_space().mark_state as usize, | ||
self.get_space().mark_state, | ||
None, | ||
Some(Ordering::SeqCst), | ||
Ordering::SeqCst, | ||
); | ||
// Mark the line | ||
if !super::MARK_LINE_AT_SCAN_TIME { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Usually cmpxchg returns the old value regardless of success or failure, so it should not be necessary to load again. Consider changing the API of cmpxchg.
Alternatively, try
fetch_and_atomic
. It should be faster on architectures that has special instructions that never fails.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.
This is the "redundant load" I was talking about. This can be replaced by the return value of the cmpxchg.
We may fix this in another PR.
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.
Yeah, I will do it in another PR.