hotspot/src/share/vm/gc/g1/g1BiasedArray.hpp
changeset 33105 294e48b4f704
parent 31592 43f48e165466
child 43407 f6dc40ed6ce9
equal deleted inserted replaced
33104:a7c0f60a1294 33105:294e48b4f704
    54   // Initialize the members of this class. The biased start address of this array
    54   // Initialize the members of this class. The biased start address of this array
    55   // is the bias (in elements) multiplied by the element size.
    55   // is the bias (in elements) multiplied by the element size.
    56   void initialize_base(address base, size_t length, size_t bias, size_t elem_size, uint shift_by) {
    56   void initialize_base(address base, size_t length, size_t bias, size_t elem_size, uint shift_by) {
    57     assert(base != NULL, "just checking");
    57     assert(base != NULL, "just checking");
    58     assert(length > 0, "just checking");
    58     assert(length > 0, "just checking");
    59     assert(shift_by < sizeof(uintptr_t) * 8, err_msg("Shifting by %u, larger than word size?", shift_by));
    59     assert(shift_by < sizeof(uintptr_t) * 8, "Shifting by %u, larger than word size?", shift_by);
    60     _base = base;
    60     _base = base;
    61     _length = length;
    61     _length = length;
    62     _biased_base = base - (bias * elem_size);
    62     _biased_base = base - (bias * elem_size);
    63     _bias = bias;
    63     _bias = bias;
    64     _shift_by = shift_by;
    64     _shift_by = shift_by;
    67   // Allocate and initialize this array to cover the heap addresses in the range
    67   // Allocate and initialize this array to cover the heap addresses in the range
    68   // of [bottom, end).
    68   // of [bottom, end).
    69   void initialize(HeapWord* bottom, HeapWord* end, size_t target_elem_size_in_bytes, size_t mapping_granularity_in_bytes) {
    69   void initialize(HeapWord* bottom, HeapWord* end, size_t target_elem_size_in_bytes, size_t mapping_granularity_in_bytes) {
    70     assert(mapping_granularity_in_bytes > 0, "just checking");
    70     assert(mapping_granularity_in_bytes > 0, "just checking");
    71     assert(is_power_of_2(mapping_granularity_in_bytes),
    71     assert(is_power_of_2(mapping_granularity_in_bytes),
    72       err_msg("mapping granularity must be power of 2, is %zd", mapping_granularity_in_bytes));
    72            "mapping granularity must be power of 2, is %zd", mapping_granularity_in_bytes);
    73     assert((uintptr_t)bottom % mapping_granularity_in_bytes == 0,
    73     assert((uintptr_t)bottom % mapping_granularity_in_bytes == 0,
    74       err_msg("bottom mapping area address must be a multiple of mapping granularity %zd, is  " PTR_FORMAT,
    74            "bottom mapping area address must be a multiple of mapping granularity %zd, is  " PTR_FORMAT,
    75         mapping_granularity_in_bytes, p2i(bottom)));
    75            mapping_granularity_in_bytes, p2i(bottom));
    76     assert((uintptr_t)end % mapping_granularity_in_bytes == 0,
    76     assert((uintptr_t)end % mapping_granularity_in_bytes == 0,
    77       err_msg("end mapping area address must be a multiple of mapping granularity %zd, is " PTR_FORMAT,
    77            "end mapping area address must be a multiple of mapping granularity %zd, is " PTR_FORMAT,
    78         mapping_granularity_in_bytes, p2i(end)));
    78            mapping_granularity_in_bytes, p2i(end));
    79     size_t num_target_elems = pointer_delta(end, bottom, mapping_granularity_in_bytes);
    79     size_t num_target_elems = pointer_delta(end, bottom, mapping_granularity_in_bytes);
    80     idx_t bias = (uintptr_t)bottom / mapping_granularity_in_bytes;
    80     idx_t bias = (uintptr_t)bottom / mapping_granularity_in_bytes;
    81     address base = create_new_base_array(num_target_elems, target_elem_size_in_bytes);
    81     address base = create_new_base_array(num_target_elems, target_elem_size_in_bytes);
    82     initialize_base(base, num_target_elems, bias, target_elem_size_in_bytes, log2_intptr(mapping_granularity_in_bytes));
    82     initialize_base(base, num_target_elems, bias, target_elem_size_in_bytes, log2_intptr(mapping_granularity_in_bytes));
    83   }
    83   }