Path: blob/master/src/java.base/share/classes/jdk/internal/misc/UnsafeConstants.java
41159 views
/*1* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2019, Red Hat Inc. All rights reserved.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation. Oracle designates this8* particular file as subject to the "Classpath" exception as provided9* by Oracle in the LICENSE file that accompanied this code.10*11* This code is distributed in the hope that it will be useful, but WITHOUT12* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or13* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License14* version 2 for more details (a copy is included in the LICENSE file that15* accompanied this code).16*17* You should have received a copy of the GNU General Public License version18* 2 along with this work; if not, write to the Free Software Foundation,19* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.20*21* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA22* or visit www.oracle.com if you need additional information or have any23* questions.24*/2526package jdk.internal.misc;2728/**29* A class used to expose details of the underlying hardware that30* configure the operation of class Unsafe. This class is31* package-private as the only intended client is class Unsafe.32* All fields in this class must be static final constants.33*34* @since 1335*36* @implNote37*38* The JVM injects hardware-specific values into all the static fields39* of this class during JVM initialization. The static initialization40* block is executed when the class is initialized then JVM injection41* updates the fields with the correct constants. The static block42* is required to prevent the fields from being considered constant43* variables, so the field values will be not be compiled directly into44* any class that uses them.45*/4647final class UnsafeConstants {4849/**50* This constructor is private because the class is not meant to51* be instantiated.52*/53private UnsafeConstants() {}5455/**56* The size in bytes of a native pointer, as stored via {@link57* #putAddress}. This value will be either 4 or 8. Note that the58* sizes of other primitive types (as stored in native memory59* blocks) is determined fully by their information content.60*61* @implNote62* The actual value for this field is injected by the JVM.63*/6465static final int ADDRESS_SIZE0;6667/**68* The size in bytes of a native memory page (whatever that is).69* This value will always be a power of two.70*71* @implNote72* The actual value for this field is injected by the JVM.73*/7475static final int PAGE_SIZE;7677/**78* Flag whose value is true if and only if the native endianness79* of this platform is big.80*81* @implNote82* The actual value for this field is injected by the JVM.83*/8485static final boolean BIG_ENDIAN;8687/**88* Flag whose value is true if and only if the platform can89* perform unaligned accesses90*91* @implNote92* The actual value for this field is injected by the JVM.93*/9495static final boolean UNALIGNED_ACCESS;9697/**98* The size of an L1 data cache line which will be either a power99* of two or zero.100*101* <p>A non-zero value indicates that writeback to memory is102* enabled for the current processor. The value defines the103* natural alignment and size of any data cache line committed to104* memory by a single writeback operation. If data cache line105* writeback is not enabled for the current hardware the field106* will have value 0.107*108* @implNote109* The actual value for this field is injected by the JVM.110*/111112static final int DATA_CACHE_LINE_FLUSH_SIZE;113114static {115ADDRESS_SIZE0 = 0;116PAGE_SIZE = 0;117BIG_ENDIAN = false;118UNALIGNED_ACCESS = false;119DATA_CACHE_LINE_FLUSH_SIZE = 0;120}121}122123124