comparison src/share/vm/gc_implementation/g1/g1BiasedArray.hpp @ 18041:52b4284cb496

Merge with jdk8u20-b26
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 16:02:50 +0200
parents 4ca6dc0799b6 78bbf4d43a14
children
comparison
equal deleted inserted replaced
17606:45d7b2c7029d 18041:52b4284cb496
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.
23 */ 23 */
24 24
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1BIASEDARRAY_HPP 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1BIASEDARRAY_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1BIASEDARRAY_HPP 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1BIASEDARRAY_HPP
27 27
28 #include "memory/allocation.hpp"
28 #include "utilities/debug.hpp" 29 #include "utilities/debug.hpp"
29 #include "memory/allocation.inline.hpp"
30 30
31 // Implements the common base functionality for arrays that contain provisions 31 // Implements the common base functionality for arrays that contain provisions
32 // for accessing its elements using a biased index. 32 // for accessing its elements using a biased index.
33 // The element type is defined by the instantiating the template. 33 // The element type is defined by the instantiating the template.
34 class G1BiasedMappedArrayBase VALUE_OBJ_CLASS_SPEC { 34 class G1BiasedMappedArrayBase VALUE_OBJ_CLASS_SPEC {
46 46
47 G1BiasedMappedArrayBase() : _base(NULL), _length(0), _biased_base(NULL), 47 G1BiasedMappedArrayBase() : _base(NULL), _length(0), _biased_base(NULL),
48 _bias(0), _shift_by(0) { } 48 _bias(0), _shift_by(0) { }
49 49
50 // Allocate a new array, generic version. 50 // Allocate a new array, generic version.
51 static address create_new_base_array(size_t length, size_t elem_size) { 51 static address create_new_base_array(size_t length, size_t elem_size);
52 assert(length > 0, "just checking");
53 assert(elem_size > 0, "just checking");
54 return NEW_C_HEAP_ARRAY(u_char, length * elem_size, mtGC);
55 }
56 52
57 // 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
58 // is the bias (in elements) multiplied by the element size. 54 // is the bias (in elements) multiplied by the element size.
59 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) {
60 assert(base != NULL, "just checking"); 56 assert(base != NULL, "just checking");
61 assert(length > 0, "just checking"); 57 assert(length > 0, "just checking");
62 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 " SSIZE_FORMAT ", larger than word size?", (size_t) shift_by));
63 _base = base; 59 _base = base;
64 _length = length; 60 _length = length;
65 _biased_base = base - (bias * elem_size); 61 _biased_base = base - (bias * elem_size);
66 _bias = bias; 62 _bias = bias;
67 _shift_by = shift_by; 63 _shift_by = shift_by;
72 void initialize(HeapWord* bottom, HeapWord* end, size_t target_elem_size_in_bytes, size_t mapping_granularity_in_bytes) { 68 void initialize(HeapWord* bottom, HeapWord* end, size_t target_elem_size_in_bytes, size_t mapping_granularity_in_bytes) {
73 assert(mapping_granularity_in_bytes > 0, "just checking"); 69 assert(mapping_granularity_in_bytes > 0, "just checking");
74 assert(is_power_of_2(mapping_granularity_in_bytes), 70 assert(is_power_of_2(mapping_granularity_in_bytes),
75 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));
76 assert((uintptr_t)bottom % mapping_granularity_in_bytes == 0, 72 assert((uintptr_t)bottom % mapping_granularity_in_bytes == 0,
77 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,
78 mapping_granularity_in_bytes, bottom)); 74 mapping_granularity_in_bytes, p2i(bottom)));
79 assert((uintptr_t)end % mapping_granularity_in_bytes == 0, 75 assert((uintptr_t)end % mapping_granularity_in_bytes == 0,
80 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,
81 mapping_granularity_in_bytes, end)); 77 mapping_granularity_in_bytes, p2i(end)));
82 size_t num_target_elems = (end - bottom) / (mapping_granularity_in_bytes / HeapWordSize); 78 size_t num_target_elems = (end - bottom) / (mapping_granularity_in_bytes / HeapWordSize);
83 idx_t bias = (uintptr_t)bottom / mapping_granularity_in_bytes; 79 idx_t bias = (uintptr_t)bottom / mapping_granularity_in_bytes;
84 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);
85 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));
86 } 82 }