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"]
73
73
# See `crate::util::logger` for more details.
74
74
builtin_env_logger = [" dep:env_logger" ]
75
75
76
+ # Enable this feature if you want to use nightly features and compiler
77
+ nightly = []
78
+
76
79
# This feature is only supported on x86-64 for now
77
80
# It's manually added to CI scripts
78
81
perf_counter = [" dep:pfm" ]
Original file line number Diff line number Diff line change 7
7
// to me - considering it will break our API and all the efforts for all the developers to make the change, it may
8
8
// not worth it.
9
9
#![ allow( clippy:: upper_case_acronyms) ]
10
+ // Use the `{likely, unlikely}` provided by compiler when using nightly
11
+ #![ cfg_attr( feature = "nightly" , feature( core_intrinsics) ) ]
10
12
11
13
//! Memory Management ToolKit (MMTk) is a portable and high performance memory manager
12
14
//! 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 {
14
14
}
15
15
}
16
16
17
- #[ rustversion :: nightly]
17
+ #[ cfg ( feature = " nightly" ) ]
18
18
pub use core:: intrinsics:: { likely, unlikely} ;
19
19
20
20
// likely() and unlikely() compiler hints in stable Rust
21
21
// [1]: https://github.com/rust-lang/hashbrown/blob/a41bd76de0a53838725b997c6085e024c47a0455/src/raw/mod.rs#L48-L70
22
22
// [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]
24
25
#[ cold]
25
26
fn cold ( ) { }
26
27
27
- #[ rustversion:: not( nightly) ]
28
+ #[ cfg( not( feature = "nightly" ) ) ]
29
+ #[ inline]
28
30
pub fn likely ( b : bool ) -> bool {
29
31
if !b {
30
32
cold ( ) ;
31
33
}
32
34
b
33
35
}
34
- #[ rustversion:: not( nightly) ]
36
+ #[ cfg( not( feature = "nightly" ) ) ]
37
+ #[ inline]
35
38
pub fn unlikely ( b : bool ) -> bool {
36
39
if b {
37
40
cold ( ) ;
You can’t perform that action at this time.
0 commit comments