File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,9 @@ default = ["builtin_env_logger"]
7373# See `crate::util::logger` for more details.
7474builtin_env_logger = [" dep:env_logger" ]
7575
76+ # Enable this feature if you want to use nightly features and compiler
77+ nightly = []
78+
7679# This feature is only supported on x86-64 for now
7780# It's manually added to CI scripts
7881perf_counter = [" dep:pfm" ]
Original file line number Diff line number Diff line change 77// to me - considering it will break our API and all the efforts for all the developers to make the change, it may
88// not worth it.
99#![ allow( clippy:: upper_case_acronyms) ]
10+ // Use the `{likely, unlikely}` provided by compiler when using nightly
11+ #![ cfg_attr( feature = "nightly" , feature( core_intrinsics) ) ]
1012
1113//! Memory Management ToolKit (MMTk) is a portable and high performance memory manager
1214//! that includes various garbage collection algorithms and provides clean and efficient
Original file line number Diff line number Diff line change @@ -14,24 +14,27 @@ pub const fn min_of_usize(a: usize, b: usize) -> usize {
1414 }
1515}
1616
17- #[ rustversion :: nightly]
17+ #[ cfg ( feature = " nightly" ) ]
1818pub use core:: intrinsics:: { likely, unlikely} ;
1919
2020// likely() and unlikely() compiler hints in stable Rust
2121// [1]: https://github.com/rust-lang/hashbrown/blob/a41bd76de0a53838725b997c6085e024c47a0455/src/raw/mod.rs#L48-L70
2222// [2]: https://users.rust-lang.org/t/compiler-hint-for-unlikely-likely-for-if-branches/62102/3
23- #[ rustversion:: not( nightly) ]
23+ #[ cfg( not( feature = "nightly" ) ) ]
24+ #[ inline]
2425#[ cold]
2526fn cold ( ) { }
2627
27- #[ rustversion:: not( nightly) ]
28+ #[ cfg( not( feature = "nightly" ) ) ]
29+ #[ inline]
2830pub fn likely ( b : bool ) -> bool {
2931 if !b {
3032 cold ( ) ;
3133 }
3234 b
3335}
34- #[ rustversion:: not( nightly) ]
36+ #[ cfg( not( feature = "nightly" ) ) ]
37+ #[ inline]
3538pub fn unlikely ( b : bool ) -> bool {
3639 if b {
3740 cold ( ) ;
You can’t perform that action at this time.
0 commit comments