hotspot/src/share/vm/gc_implementation/g1/g1BiasedArray.hpp
changeset 24424 2658d7834c6e
parent 23458 947a3d680f3e
equal deleted inserted replaced
24358:8528b67f6562 24424:2658d7834c6e
     1 /*
     1 /*
     2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    53   // Initialize the members of this class. The biased start address of this array
    53   // Initialize the members of this class. The biased start address of this array
    54   // is the bias (in elements) multiplied by the element size.
    54   // is the bias (in elements) multiplied by the element size.
    55   void initialize_base(address base, size_t length, size_t bias, size_t elem_size, uint shift_by) {
    55   void initialize_base(address base, size_t length, size_t bias, size_t elem_size, uint shift_by) {
    56     assert(base != NULL, "just checking");
    56     assert(base != NULL, "just checking");
    57     assert(length > 0, "just checking");
    57     assert(length > 0, "just checking");
    58     assert(shift_by < sizeof(uintptr_t) * 8, err_msg("Shifting by %zd, larger than word size?", shift_by));
    58     assert(shift_by < sizeof(uintptr_t) * 8, err_msg("Shifting by %u, larger than word size?", shift_by));
    59     _base = base;
    59     _base = base;
    60     _length = length;
    60     _length = length;
    61     _biased_base = base - (bias * elem_size);
    61     _biased_base = base - (bias * elem_size);
    62     _bias = bias;
    62     _bias = bias;
    63     _shift_by = shift_by;
    63     _shift_by = shift_by;
    69     assert(mapping_granularity_in_bytes > 0, "just checking");
    69     assert(mapping_granularity_in_bytes > 0, "just checking");
    70     assert(is_power_of_2(mapping_granularity_in_bytes),
    70     assert(is_power_of_2(mapping_granularity_in_bytes),
    71       err_msg("mapping granularity must be power of 2, is %zd", mapping_granularity_in_bytes));
    71       err_msg("mapping granularity must be power of 2, is %zd", mapping_granularity_in_bytes));
    72     assert((uintptr_t)bottom % mapping_granularity_in_bytes == 0,
    72     assert((uintptr_t)bottom % mapping_granularity_in_bytes == 0,
    73       err_msg("bottom mapping area address must be a multiple of mapping granularity %zd, is "PTR_FORMAT,
    73       err_msg("bottom mapping area address must be a multiple of mapping granularity %zd, is "PTR_FORMAT,
    74         mapping_granularity_in_bytes, bottom));
    74         mapping_granularity_in_bytes, p2i(bottom)));
    75     assert((uintptr_t)end % mapping_granularity_in_bytes == 0,
    75     assert((uintptr_t)end % mapping_granularity_in_bytes == 0,
    76       err_msg("end mapping area address must be a multiple of mapping granularity %zd, is "PTR_FORMAT,
    76       err_msg("end mapping area address must be a multiple of mapping granularity %zd, is "PTR_FORMAT,
    77         mapping_granularity_in_bytes, end));
    77         mapping_granularity_in_bytes, p2i(end)));
    78     size_t num_target_elems = pointer_delta(end, bottom, mapping_granularity_in_bytes);
    78     size_t num_target_elems = pointer_delta(end, bottom, mapping_granularity_in_bytes);
    79     idx_t bias = (uintptr_t)bottom / mapping_granularity_in_bytes;
    79     idx_t bias = (uintptr_t)bottom / mapping_granularity_in_bytes;
    80     address base = create_new_base_array(num_target_elems, target_elem_size_in_bytes);
    80     address base = create_new_base_array(num_target_elems, target_elem_size_in_bytes);
    81     initialize_base(base, num_target_elems, bias, target_elem_size_in_bytes, log2_intptr(mapping_granularity_in_bytes));
    81     initialize_base(base, num_target_elems, bias, target_elem_size_in_bytes, log2_intptr(mapping_granularity_in_bytes));
    82   }
    82   }