< prev index next >

src/hotspot/cpu/riscv/compressedKlass_riscv.cpp

Print this page

39   //
40   // A "good" base is, in this order:
41   // 1) only bits in A; this would be an address < 4KB, which is unrealistic on normal Linux boxes since
42   //    the typical default for vm.mmap_min_address is 64KB. We ignore that.
43   // 2) only bits in B: a 12-bit-aligned address below 4GB. 12 bit = 4KB, but since mmap reserves at
44   //    page boundaries, we can ignore the alignment.
45   // 3) only bits in C: a 4GB-aligned address that is lower than 16TB.
46   // 4) only bits in D: a 16TB-aligned address.
47 
48   // First, attempt to allocate < 4GB. We do this unconditionally:
49   // - if can_optimize_for_zero_base, a <4GB mapping start would allow us to run unscaled (base = 0, shift = 0)
50   // - if !can_optimize_for_zero_base, a <4GB mapping start is still good, the resulting immediate can be encoded
51   //   with one instruction (2)
52   result = reserve_address_space_for_unscaled_encoding(size, aslr);
53 
54   // Failing that, attempt to reserve for base=zero shift>0
55   if (result == nullptr && optimize_for_zero_base) {
56     result = reserve_address_space_for_zerobased_encoding(size, aslr);
57   }
58 
59   // Failing that, optimize for case (3) - a base with only bits set between [33-44)
60   if (result == nullptr) {
61     const uintptr_t from = nth_bit(32 + (optimize_for_zero_base ? LogKlassAlignmentInBytes : 0));
62     constexpr uintptr_t to = nth_bit(44);
63     constexpr size_t alignment = nth_bit(32);
64     result = reserve_address_space_X(from, to, size, alignment, aslr);
65   }
66 
67   // Failing that, optimize for case (4) - a base with only bits set between [44-64)
68   if (result == nullptr) {
69     constexpr uintptr_t from = nth_bit(44);
70     constexpr uintptr_t to = UINT64_MAX;
71     constexpr size_t alignment = nth_bit(44);
72     result = reserve_address_space_X(from, to, size, alignment, aslr);
73   }
74 
75   return result;
76 }



39   //
40   // A "good" base is, in this order:
41   // 1) only bits in A; this would be an address < 4KB, which is unrealistic on normal Linux boxes since
42   //    the typical default for vm.mmap_min_address is 64KB. We ignore that.
43   // 2) only bits in B: a 12-bit-aligned address below 4GB. 12 bit = 4KB, but since mmap reserves at
44   //    page boundaries, we can ignore the alignment.
45   // 3) only bits in C: a 4GB-aligned address that is lower than 16TB.
46   // 4) only bits in D: a 16TB-aligned address.
47 
48   // First, attempt to allocate < 4GB. We do this unconditionally:
49   // - if can_optimize_for_zero_base, a <4GB mapping start would allow us to run unscaled (base = 0, shift = 0)
50   // - if !can_optimize_for_zero_base, a <4GB mapping start is still good, the resulting immediate can be encoded
51   //   with one instruction (2)
52   result = reserve_address_space_for_unscaled_encoding(size, aslr);
53 
54   // Failing that, attempt to reserve for base=zero shift>0
55   if (result == nullptr && optimize_for_zero_base) {
56     result = reserve_address_space_for_zerobased_encoding(size, aslr);
57   }
58 
59   // Failing that, optimize for case (3) - a base with only bits set between [32-44)
60   if (result == nullptr) {
61     const uintptr_t from = nth_bit(32);
62     constexpr uintptr_t to = nth_bit(44);
63     constexpr size_t alignment = nth_bit(32);
64     result = reserve_address_space_X(from, to, size, alignment, aslr);
65   }
66 
67   // Failing that, optimize for case (4) - a base with only bits set between [44-64)
68   if (result == nullptr) {
69     constexpr uintptr_t from = nth_bit(44);
70     constexpr uintptr_t to = UINT64_MAX;
71     constexpr size_t alignment = nth_bit(44);
72     result = reserve_address_space_X(from, to, size, alignment, aslr);
73   }
74 
75   return result;
76 }
77 
78 bool CompressedKlassPointers::pd_initialize(address addr, size_t len) { return false; }
< prev index next >