src/hotspot/cpu/aarch64/gc/z/zGlobals_aarch64.cpp
author tschatzl
Fri, 22 Nov 2019 10:03:38 +0100
changeset 59221 cc3a82fc7bcb
parent 58787 32d39d9525f9
permissions -rw-r--r--
8233702: Introduce helper function to clamp value to range Reviewed-by: sjohanss, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55379
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
     1
/*
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
     2
 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
     4
 *
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
     7
 * published by the Free Software Foundation.
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
     8
 *
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    13
 * accompanied this code).
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    14
 *
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    18
 *
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    21
 * questions.
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    22
 */
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    23
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    24
#include "precompiled.hpp"
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    25
#include "gc/z/zGlobals.hpp"
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    26
#include "gc/z/zUtils.inline.hpp"
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    27
#include "runtime/globals.hpp"
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    28
#include "utilities/globalDefinitions.hpp"
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    29
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    30
//
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    31
// The heap can have three different layouts, depending on the max heap size.
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    32
//
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    33
// Address Space & Pointer Layout 1
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    34
// --------------------------------
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    35
//
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    36
//  +--------------------------------+ 0x00007FFFFFFFFFFF (127TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    37
//  .                                .
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    38
//  .                                .
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    39
//  .                                .
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    40
//  +--------------------------------+ 0x0000014000000000 (20TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    41
//  |         Remapped View          |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    42
//  +--------------------------------+ 0x0000010000000000 (16TB)
58453
ca80b8395923 8231776: ZGC: Fix incorrect address space description
pliden
parents: 58294
diff changeset
    43
//  .                                .
55379
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    44
//  +--------------------------------+ 0x00000c0000000000 (12TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    45
//  |         Marked1 View           |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    46
//  +--------------------------------+ 0x0000080000000000 (8TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    47
//  |         Marked0 View           |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    48
//  +--------------------------------+ 0x0000040000000000 (4TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    49
//  .                                .
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    50
//  +--------------------------------+ 0x0000000000000000
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    51
//
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    52
//   6                  4 4  4 4
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    53
//   3                  6 5  2 1                                             0
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    54
//  +--------------------+----+-----------------------------------------------+
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    55
//  |00000000 00000000 00|1111|11 11111111 11111111 11111111 11111111 11111111|
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    56
//  +--------------------+----+-----------------------------------------------+
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    57
//  |                    |    |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    58
//  |                    |    * 41-0 Object Offset (42-bits, 4TB address space)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    59
//  |                    |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    60
//  |                    * 45-42 Metadata Bits (4-bits)  0001 = Marked0      (Address view 4-8TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    61
//  |                                                    0010 = Marked1      (Address view 8-12TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    62
//  |                                                    0100 = Remapped     (Address view 16-20TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    63
//  |                                                    1000 = Finalizable  (Address view N/A)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    64
//  |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    65
//  * 63-46 Fixed (18-bits, always zero)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    66
//
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    67
//
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    68
// Address Space & Pointer Layout 2
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    69
// --------------------------------
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    70
//
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    71
//  +--------------------------------+ 0x00007FFFFFFFFFFF (127TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    72
//  .                                .
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    73
//  .                                .
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    74
//  .                                .
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    75
//  +--------------------------------+ 0x0000280000000000 (40TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    76
//  |         Remapped View          |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    77
//  +--------------------------------+ 0x0000200000000000 (32TB)
58453
ca80b8395923 8231776: ZGC: Fix incorrect address space description
pliden
parents: 58294
diff changeset
    78
//  .                                .
55379
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    79
//  +--------------------------------+ 0x0000180000000000 (24TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    80
//  |         Marked1 View           |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    81
//  +--------------------------------+ 0x0000100000000000 (16TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    82
//  |         Marked0 View           |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    83
//  +--------------------------------+ 0x0000080000000000 (8TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    84
//  .                                .
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    85
//  +--------------------------------+ 0x0000000000000000
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    86
//
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    87
//   6                 4 4  4 4
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    88
//   3                 7 6  3 2                                              0
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    89
//  +------------------+-----+------------------------------------------------+
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    90
//  |00000000 00000000 0|1111|111 11111111 11111111 11111111 11111111 11111111|
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    91
//  +-------------------+----+------------------------------------------------+
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    92
//  |                   |    |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    93
//  |                   |    * 42-0 Object Offset (43-bits, 8TB address space)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    94
//  |                   |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    95
//  |                   * 46-43 Metadata Bits (4-bits)  0001 = Marked0      (Address view 8-16TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    96
//  |                                                   0010 = Marked1      (Address view 16-24TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    97
//  |                                                   0100 = Remapped     (Address view 32-40TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    98
//  |                                                   1000 = Finalizable  (Address view N/A)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
    99
//  |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   100
//  * 63-47 Fixed (17-bits, always zero)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   101
//
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   102
//
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   103
// Address Space & Pointer Layout 3
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   104
// --------------------------------
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   105
//
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   106
//  +--------------------------------+ 0x00007FFFFFFFFFFF (127TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   107
//  .                                .
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   108
//  .                                .
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   109
//  .                                .
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   110
//  +--------------------------------+ 0x0000500000000000 (80TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   111
//  |         Remapped View          |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   112
//  +--------------------------------+ 0x0000400000000000 (64TB)
58453
ca80b8395923 8231776: ZGC: Fix incorrect address space description
pliden
parents: 58294
diff changeset
   113
//  .                                .
55379
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   114
//  +--------------------------------+ 0x0000300000000000 (48TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   115
//  |         Marked1 View           |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   116
//  +--------------------------------+ 0x0000200000000000 (32TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   117
//  |         Marked0 View           |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   118
//  +--------------------------------+ 0x0000100000000000 (16TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   119
//  .                                .
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   120
//  +--------------------------------+ 0x0000000000000000
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   121
//
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   122
//   6               4  4  4 4
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   123
//   3               8  7  4 3                                               0
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   124
//  +------------------+----+-------------------------------------------------+
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   125
//  |00000000 00000000 |1111|1111 11111111 11111111 11111111 11111111 11111111|
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   126
//  +------------------+----+-------------------------------------------------+
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   127
//  |                  |    |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   128
//  |                  |    * 43-0 Object Offset (44-bits, 16TB address space)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   129
//  |                  |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   130
//  |                  * 47-44 Metadata Bits (4-bits)  0001 = Marked0      (Address view 16-32TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   131
//  |                                                  0010 = Marked1      (Address view 32-48TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   132
//  |                                                  0100 = Remapped     (Address view 64-80TB)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   133
//  |                                                  1000 = Finalizable  (Address view N/A)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   134
//  |
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   135
//  * 63-48 Fixed (16-bits, always zero)
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   136
//
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   137
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   138
uintptr_t ZPlatformAddressBase() {
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   139
  return 0;
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   140
}
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   141
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   142
size_t ZPlatformAddressOffsetBits() {
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   143
  const size_t min_address_offset_bits = 42; // 4TB
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   144
  const size_t max_address_offset_bits = 44; // 16TB
58787
32d39d9525f9 8231552: ZGC: Refine address space reservation
pliden
parents: 58453
diff changeset
   145
  const size_t address_offset = ZUtils::round_up_power_of_2(MaxHeapSize * ZVirtualToPhysicalRatio);
55379
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   146
  const size_t address_offset_bits = log2_intptr(address_offset);
59221
cc3a82fc7bcb 8233702: Introduce helper function to clamp value to range
tschatzl
parents: 58787
diff changeset
   147
  return clamp(address_offset_bits, min_address_offset_bits, max_address_offset_bits);
55379
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   148
}
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   149
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   150
size_t ZPlatformAddressMetadataShift() {
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   151
  return ZPlatformAddressOffsetBits();
865775b86780 8214527: ZGC for Aarch64
smonteith
parents:
diff changeset
   152
}