@@ -4,6 +4,7 @@ use super::mock_test_prelude::*;
4
4
use super :: mock_test_vm_layout_default:: test_with_vm_layout;
5
5
use crate :: util:: conversions:: * ;
6
6
use crate :: util:: heap:: vm_layout:: VMLayout ;
7
+ use crate :: util:: heap:: vm_layout:: BYTES_IN_CHUNK ;
7
8
use crate :: util:: Address ;
8
9
9
10
// This test only run on 64bits.
@@ -13,21 +14,18 @@ fn test_vm_layout_compressed_pointer() {
13
14
with_mockvm (
14
15
default_setup,
15
16
|| {
16
- let start = if cfg ! ( target_os = "macos" ) {
17
- // Impossible to map 0x4000_0000 on maocOS. SO choose a different address.
18
- 0x60_0000_0000
19
- } else {
20
- 0x4000_0000
21
- } ;
22
17
let heap_size = 1024 * 1024 ;
23
- let end = match start + heap_size {
18
+ let start = crate :: util:: memory:: find_usable_address ( heap_size, BYTES_IN_CHUNK )
19
+ . expect ( "Cannot find usable address range" ) ;
20
+ println ! ( "Use {} as heap start" , start) ;
21
+ let end = match start. as_usize ( ) + heap_size {
24
22
end if end <= ( 4usize << 30 ) => 4usize << 30 ,
25
23
end if end <= ( 32usize << 30 ) => 32usize << 30 ,
26
- _ => start + ( 32usize << 30 ) ,
24
+ _ => start. as_usize ( ) + ( 32usize << 30 ) ,
27
25
} ;
28
26
let layout = VMLayout {
29
27
log_address_space : 35 ,
30
- heap_start : chunk_align_down ( unsafe { Address :: from_usize ( start) } ) ,
28
+ heap_start : start,
31
29
heap_end : chunk_align_up ( unsafe { Address :: from_usize ( end) } ) ,
32
30
log_space_extent : 31 ,
33
31
force_use_contiguous_spaces : false ,
0 commit comments