-
Notifications
You must be signed in to change notification settings - Fork 76
Global allocation bit #390
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
20 commits
Select commit
Hold shift + click to select a range
e66413c
add alloc_bit module
a973d85
make alloc_bit global
ea9258f
add global_alloc_bit feature
a6b7331
set alloc bit
f472a3d
unset alloc bit
5ccff85
fix copyspace unset alloc bit
da2a137
clean
298da1d
reset alloc bit in copyspace
46fd071
merge master resolve conflict
9c1402e
fix metadata offset in 32-bit
703e50b
fix metadata offset in 32-bit
95a7c7b
clean warnings
028f441
format
09efea3
debug
1b31e9d
merge master
77113bc
Merge branch 'master' into dev-allocbit
YiluoWei 74702b6
Merge branch 'master' of https://github.com/mmtk/mmtk-core into dev-a…
80d4202
better comment
3261fcc
update
bf3e038
add assertions;support Immix
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
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
use crate::util::alloc_bit; | ||
use crate::util::heap::layout::vm_layout_constants::{BYTES_IN_CHUNK, LOG_BYTES_IN_CHUNK}; | ||
use crate::util::metadata::load_metadata; | ||
use crate::util::metadata::side_metadata; | ||
use crate::util::metadata::side_metadata::SideMetadataContext; | ||
use crate::util::metadata::side_metadata::SideMetadataOffset; | ||
use crate::util::metadata::side_metadata::SideMetadataSpec; | ||
use crate::util::metadata::side_metadata::GLOBAL_SIDE_METADATA_BASE_OFFSET; | ||
use crate::util::metadata::side_metadata::LOCAL_SIDE_METADATA_BASE_OFFSET; | ||
use crate::util::metadata::store_metadata; | ||
use crate::util::Address; | ||
|
@@ -38,25 +38,11 @@ lazy_static! { | |
/// overwriting the previous mapping. | ||
pub(crate) const ACTIVE_CHUNK_METADATA_SPEC: SideMetadataSpec = SideMetadataSpec { | ||
is_global: true, | ||
offset: GLOBAL_SIDE_METADATA_BASE_OFFSET, | ||
offset: SideMetadataOffset::layout_after(&crate::util::alloc_bit::ALLOC_SIDE_METADATA_SPEC), | ||
log_num_of_bits: 3, | ||
log_min_obj_size: LOG_BYTES_IN_CHUNK as usize, | ||
}; | ||
|
||
/// This is the metadata spec for the alloc-bit. | ||
/// | ||
/// An alloc-bit is required per min-object-size aligned address, rather than per object, and can only exist as side metadata. | ||
/// | ||
/// The other metadata used by MallocSpace is mark-bit, which is per-object and can be kept in object header if the VM allows it. | ||
/// Thus, mark-bit is vm-dependant and is part of each VM's ObjectModel. | ||
/// | ||
pub(crate) const ALLOC_SIDE_METADATA_SPEC: SideMetadataSpec = SideMetadataSpec { | ||
is_global: false, | ||
offset: LOCAL_SIDE_METADATA_BASE_OFFSET, | ||
log_num_of_bits: 0, | ||
log_min_obj_size: constants::LOG_MIN_OBJECT_SIZE as usize, | ||
}; | ||
|
||
/// Metadata spec for the active page byte | ||
/// | ||
/// The active page metadata is used to accurately track the total number of pages that have | ||
|
@@ -69,7 +55,7 @@ pub(crate) const ALLOC_SIDE_METADATA_SPEC: SideMetadataSpec = SideMetadataSpec { | |
// how many pages are active in this metadata spec. Explore SIMD vectorization with 8-bit integers | ||
pub(crate) const ACTIVE_PAGE_METADATA_SPEC: SideMetadataSpec = SideMetadataSpec { | ||
is_global: false, | ||
offset: SideMetadataOffset::layout_after(&ALLOC_SIDE_METADATA_SPEC), | ||
offset: LOCAL_SIDE_METADATA_BASE_OFFSET, | ||
log_num_of_bits: 3, | ||
log_min_obj_size: constants::LOG_BYTES_IN_PAGE as usize, | ||
}; | ||
|
@@ -153,11 +139,11 @@ pub fn is_alloced(object: ObjectReference) -> bool { | |
} | ||
|
||
pub fn is_alloced_object(address: Address) -> bool { | ||
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. I feel most of these functions can be removed. You can directly call to |
||
side_metadata::load_atomic(&ALLOC_SIDE_METADATA_SPEC, address, Ordering::SeqCst) == 1 | ||
alloc_bit::is_alloced_object(address) | ||
} | ||
|
||
pub unsafe fn is_alloced_object_unsafe(address: Address) -> bool { | ||
side_metadata::load(&ALLOC_SIDE_METADATA_SPEC, address) == 1 | ||
alloc_bit::is_alloced_object_unsafe(address) | ||
} | ||
|
||
pub fn is_marked<VM: VMBinding>(object: ObjectReference, ordering: Option<Ordering>) -> bool { | ||
|
@@ -192,12 +178,7 @@ pub unsafe fn is_chunk_marked_unsafe(chunk_start: Address) -> bool { | |
} | ||
|
||
pub fn set_alloc_bit(object: ObjectReference) { | ||
side_metadata::store_atomic( | ||
&ALLOC_SIDE_METADATA_SPEC, | ||
object.to_address(), | ||
1, | ||
Ordering::SeqCst, | ||
); | ||
alloc_bit::set_alloc_bit(object); | ||
} | ||
|
||
pub fn set_mark_bit<VM: VMBinding>(object: ObjectReference, ordering: Option<Ordering>) { | ||
|
@@ -210,6 +191,11 @@ pub fn set_mark_bit<VM: VMBinding>(object: ObjectReference, ordering: Option<Ord | |
); | ||
} | ||
|
||
#[allow(unused)] | ||
pub fn unset_alloc_bit(object: ObjectReference) { | ||
alloc_bit::unset_alloc_bit(object); | ||
} | ||
|
||
pub(super) fn set_page_mark(page_addr: Address) { | ||
side_metadata::store_atomic(&ACTIVE_PAGE_METADATA_SPEC, page_addr, 1, Ordering::SeqCst); | ||
} | ||
|
@@ -224,9 +210,10 @@ pub(super) fn set_chunk_mark(chunk_start: Address) { | |
} | ||
|
||
pub unsafe fn unset_alloc_bit_unsafe(object: ObjectReference) { | ||
side_metadata::store(&ALLOC_SIDE_METADATA_SPEC, object.to_address(), 0); | ||
alloc_bit::unset_alloc_bit_unsafe(object); | ||
} | ||
|
||
#[allow(unused)] | ||
pub fn unset_mark_bit<VM: VMBinding>(object: ObjectReference, ordering: Option<Ordering>) { | ||
store_metadata::<VM>( | ||
&VM::VMObjectModel::LOCAL_MARK_BIT_SPEC, | ||
|
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.
Some comments are needed here because this looks counter-intuitive. Normally people will expect that, with
global_alloc_bit
, we need the alloc bit spec. But we are not adding the alloc bit spec forglobal_alloc_bit
, as in that case, the spec is already added to the global specs innew_global_specs()
.