< prev index next >

src/hotspot/share/oops/compressedOops.cpp

Print this page

 31 #include "oops/compressedOops.hpp"
 32 #include "gc/shared/collectedHeap.hpp"
 33 #include "runtime/arguments.hpp"
 34 #include "runtime/globals.hpp"
 35 
 36 // For UseCompressedOops.
 37 address CompressedOops::_base = nullptr;
 38 int CompressedOops::_shift = 0;
 39 bool CompressedOops::_use_implicit_null_checks = true;
 40 MemRegion CompressedOops::_heap_address_range;
 41 
 42 // Choose the heap base address and oop encoding mode
 43 // when compressed oops are used:
 44 // Unscaled  - Use 32-bits oops without encoding when
 45 //     NarrowOopHeapBaseMin + heap_size < 4Gb
 46 // ZeroBased - Use zero based compressed oops with encoding when
 47 //     NarrowOopHeapBaseMin + heap_size < 32Gb
 48 // HeapBased - Use compressed oops with heap base + encoding.
 49 void CompressedOops::initialize(const ReservedHeapSpace& heap_space) {
 50 #ifdef _LP64




 51   // Subtract a page because something can get allocated at heap base.
 52   // This also makes implicit null checking work, because the
 53   // memory+1 page below heap_base needs to cause a signal.
 54   // See needs_explicit_null_check.
 55   // Only set the heap base for compressed oops because it indicates
 56   // compressed oops for pstack code.
 57   if ((uint64_t)heap_space.end() > UnscaledOopHeapMax) {
 58     // Didn't reserve heap below 4Gb.  Must shift.
 59     set_shift(LogMinObjAlignmentInBytes);
 60   }
 61   if ((uint64_t)heap_space.end() <= OopEncodingHeapMax) {
 62     // Did reserve heap below 32Gb. Can use base == 0;
 63     set_base(nullptr);
 64   } else {
 65     set_base((address)heap_space.compressed_oop_base());
 66   }

 67 
 68   _heap_address_range = MemRegion((HeapWord*)heap_space.base(), (HeapWord*)heap_space.end());
 69 
 70   LogTarget(Debug, gc, heap, coops) lt;
 71   if (lt.is_enabled()) {
 72     ResourceMark rm;
 73     LogStream ls(lt);
 74     print_mode(&ls);
 75   }
 76 
 77   // Tell tests in which mode we run.
 78   Arguments::PropertyList_add(new SystemProperty("java.vm.compressedOopsMode",
 79                                                  mode_to_string(mode()),
 80                                                  false));
 81 
 82   // base() is one page below the heap.
 83   assert((intptr_t)base() <= ((intptr_t)_heap_address_range.start() - (intptr_t)os::vm_page_size()) ||
 84          base() == nullptr, "invalid value");
 85   assert(shift() == LogMinObjAlignmentInBytes ||
 86          shift() == 0, "invalid value");

 31 #include "oops/compressedOops.hpp"
 32 #include "gc/shared/collectedHeap.hpp"
 33 #include "runtime/arguments.hpp"
 34 #include "runtime/globals.hpp"
 35 
 36 // For UseCompressedOops.
 37 address CompressedOops::_base = nullptr;
 38 int CompressedOops::_shift = 0;
 39 bool CompressedOops::_use_implicit_null_checks = true;
 40 MemRegion CompressedOops::_heap_address_range;
 41 
 42 // Choose the heap base address and oop encoding mode
 43 // when compressed oops are used:
 44 // Unscaled  - Use 32-bits oops without encoding when
 45 //     NarrowOopHeapBaseMin + heap_size < 4Gb
 46 // ZeroBased - Use zero based compressed oops with encoding when
 47 //     NarrowOopHeapBaseMin + heap_size < 32Gb
 48 // HeapBased - Use compressed oops with heap base + encoding.
 49 void CompressedOops::initialize(const ReservedHeapSpace& heap_space) {
 50 #ifdef _LP64
 51  if (UseCompatibleCompressedOops) {
 52     set_shift(LogMinObjAlignmentInBytes);
 53     set_base((address)heap_space.compressed_oop_base());
 54  } else {
 55   // Subtract a page because something can get allocated at heap base.
 56   // This also makes implicit null checking work, because the
 57   // memory+1 page below heap_base needs to cause a signal.
 58   // See needs_explicit_null_check.
 59   // Only set the heap base for compressed oops because it indicates
 60   // compressed oops for pstack code.
 61   if ((uint64_t)heap_space.end() > UnscaledOopHeapMax) {
 62     // Didn't reserve heap below 4Gb.  Must shift.
 63     set_shift(LogMinObjAlignmentInBytes);
 64   }
 65   if ((uint64_t)heap_space.end() <= OopEncodingHeapMax) {
 66     // Did reserve heap below 32Gb. Can use base == 0;
 67     set_base(nullptr);
 68   } else {
 69     set_base((address)heap_space.compressed_oop_base());
 70   }
 71  }
 72 
 73   _heap_address_range = MemRegion((HeapWord*)heap_space.base(), (HeapWord*)heap_space.end());
 74 
 75   LogTarget(Debug, gc, heap, coops) lt;
 76   if (lt.is_enabled()) {
 77     ResourceMark rm;
 78     LogStream ls(lt);
 79     print_mode(&ls);
 80   }
 81 
 82   // Tell tests in which mode we run.
 83   Arguments::PropertyList_add(new SystemProperty("java.vm.compressedOopsMode",
 84                                                  mode_to_string(mode()),
 85                                                  false));
 86 
 87   // base() is one page below the heap.
 88   assert((intptr_t)base() <= ((intptr_t)_heap_address_range.start() - (intptr_t)os::vm_page_size()) ||
 89          base() == nullptr, "invalid value");
 90   assert(shift() == LogMinObjAlignmentInBytes ||
 91          shift() == 0, "invalid value");
< prev index next >