mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8253500: [REDO] JDK-8253208 Move CDS related code to a separate class
Reviewed-by: mchung, iklam
This commit is contained in:
parent
bf442c5b9e
commit
89c5e49ba2
22 changed files with 103 additions and 99 deletions
|
@ -26,7 +26,7 @@
|
|||
package java.lang;
|
||||
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.CDS;
|
||||
|
||||
import java.lang.constant.Constable;
|
||||
import java.lang.constant.DynamicConstantDesc;
|
||||
|
@ -108,7 +108,7 @@ public final class Byte extends Number implements Comparable<Byte>, Constable {
|
|||
final int size = -(-128) + 127 + 1;
|
||||
|
||||
// Load and use the archived cache if it exists
|
||||
VM.initializeFromArchive(ByteCache.class);
|
||||
CDS.initializeFromArchive(ByteCache.class);
|
||||
if (archivedCache == null || archivedCache.length != size) {
|
||||
Byte[] c = new Byte[size];
|
||||
byte value = (byte)-128;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package java.lang;
|
||||
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.CDS;
|
||||
|
||||
import java.lang.constant.Constable;
|
||||
import java.lang.constant.DynamicConstantDesc;
|
||||
|
@ -8516,7 +8516,7 @@ class Character implements java.io.Serializable, Comparable<Character>, Constabl
|
|||
int size = 127 + 1;
|
||||
|
||||
// Load and use the archived cache if it exists
|
||||
VM.initializeFromArchive(CharacterCache.class);
|
||||
CDS.initializeFromArchive(CharacterCache.class);
|
||||
if (archivedCache == null || archivedCache.length != size) {
|
||||
Character[] c = new Character[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.util.Objects;
|
|||
import java.util.Optional;
|
||||
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.CDS;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
import static java.lang.String.COMPACT_STRINGS;
|
||||
|
@ -1023,7 +1024,7 @@ public final class Integer extends Number
|
|||
high = h;
|
||||
|
||||
// Load IntegerCache.archivedCache from archive, if possible
|
||||
VM.initializeFromArchive(IntegerCache.class);
|
||||
CDS.initializeFromArchive(IntegerCache.class);
|
||||
int size = (high - low) + 1;
|
||||
|
||||
// Use the archived cache if it exists and is large enough
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.Objects;
|
|||
import java.util.Optional;
|
||||
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.CDS;
|
||||
|
||||
import static java.lang.String.COMPACT_STRINGS;
|
||||
import static java.lang.String.LATIN1;
|
||||
|
@ -1169,7 +1169,7 @@ public final class Long extends Number
|
|||
int size = -(-128) + 127 + 1;
|
||||
|
||||
// Load and use the archived cache if it exists
|
||||
VM.initializeFromArchive(LongCache.class);
|
||||
CDS.initializeFromArchive(LongCache.class);
|
||||
if (archivedCache == null || archivedCache.length != size) {
|
||||
Long[] c = new Long[size];
|
||||
long value = -128;
|
||||
|
|
|
@ -55,6 +55,7 @@ import java.util.stream.Stream;
|
|||
import jdk.internal.loader.BuiltinClassLoader;
|
||||
import jdk.internal.loader.BootLoader;
|
||||
import jdk.internal.loader.ClassLoaders;
|
||||
import jdk.internal.misc.CDS;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.module.IllegalAccessLogger;
|
||||
import jdk.internal.module.ModuleLoaderMap;
|
||||
|
@ -277,7 +278,7 @@ public final class Module implements AnnotatedElement {
|
|||
}
|
||||
|
||||
static {
|
||||
VM.initializeFromArchive(ArchivedData.class);
|
||||
CDS.initializeFromArchive(ArchivedData.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package java.lang;
|
||||
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.CDS;
|
||||
|
||||
import java.lang.constant.Constable;
|
||||
import java.lang.constant.DynamicConstantDesc;
|
||||
|
@ -234,7 +234,7 @@ public final class Short extends Number implements Comparable<Short>, Constable
|
|||
int size = -(-128) + 127 + 1;
|
||||
|
||||
// Load and use the archived cache if it exists
|
||||
VM.initializeFromArchive(ShortCache.class);
|
||||
CDS.initializeFromArchive(ShortCache.class);
|
||||
if (archivedCache == null || archivedCache.length != size) {
|
||||
Short[] c = new Short[size];
|
||||
short value = -128;
|
||||
|
|
|
@ -26,15 +26,15 @@
|
|||
package java.lang.invoke;
|
||||
|
||||
import jdk.internal.loader.BuiltinClassLoader;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.CDS;
|
||||
|
||||
final class LambdaProxyClassArchive {
|
||||
private static final boolean dumpArchive;
|
||||
private static final boolean sharingEnabled;
|
||||
|
||||
static {
|
||||
dumpArchive = VM.isCDSDumpingEnabled();
|
||||
sharingEnabled = VM.isCDSSharingEnabled();
|
||||
dumpArchive = CDS.isDynamicDumpingEnabled();
|
||||
sharingEnabled = CDS.isSharingEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,7 +41,7 @@ import java.util.Set;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.CDS;
|
||||
import jdk.internal.module.ModuleReferenceImpl;
|
||||
import jdk.internal.module.ModuleTarget;
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
|
@ -110,7 +110,7 @@ public final class Configuration {
|
|||
|
||||
static {
|
||||
// Initialize EMPTY_CONFIGURATION from the archive.
|
||||
VM.initializeFromArchive(Configuration.class);
|
||||
CDS.initializeFromArchive(Configuration.class);
|
||||
// Create a new empty Configuration if there is no archived version.
|
||||
if (EMPTY_CONFIGURATION == null) {
|
||||
EMPTY_CONFIGURATION = new Configuration();
|
||||
|
|
|
@ -37,7 +37,7 @@ import java.util.function.Function;
|
|||
import java.util.function.Predicate;
|
||||
import java.util.function.UnaryOperator;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.CDS;
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
|
||||
/**
|
||||
|
@ -76,7 +76,7 @@ class ImmutableCollections {
|
|||
// derived from the JVM build/version, so can we generate the exact same
|
||||
// CDS archive for the same JDK build. This makes it possible to verify the
|
||||
// consistency of the JDK build.
|
||||
long seed = VM.getRandomSeedForCDSDump();
|
||||
long seed = CDS.getRandomSeedForDumping();
|
||||
if (seed == 0) {
|
||||
seed = System.nanoTime();
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class ImmutableCollections {
|
|||
static final MapN<?,?> EMPTY_MAP;
|
||||
|
||||
static {
|
||||
VM.initializeFromArchive(ImmutableCollections.class);
|
||||
CDS.initializeFromArchive(ImmutableCollections.class);
|
||||
if (archivedObjects == null) {
|
||||
EMPTY = new Object();
|
||||
EMPTY_LIST = new ListN<>();
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.Map;
|
|||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.CDS;
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
|
||||
import sun.nio.cs.UTF_8;
|
||||
|
@ -672,7 +672,7 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
|
||||
static {
|
||||
|
||||
VM.initializeFromArchive(Attributes.Name.class);
|
||||
CDS.initializeFromArchive(Attributes.Name.class);
|
||||
|
||||
if (KNOWN_NAMES == null) {
|
||||
MANIFEST_VERSION = new Name("Manifest-Version");
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
package jdk.internal.loader;
|
||||
|
||||
import java.util.Map;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.CDS;
|
||||
import jdk.internal.module.ServicesCatalog;
|
||||
|
||||
/**
|
||||
|
@ -91,6 +91,6 @@ class ArchivedClassLoaders {
|
|||
}
|
||||
|
||||
static {
|
||||
VM.initializeFromArchive(ArchivedClassLoaders.class);
|
||||
CDS.initializeFromArchive(ArchivedClassLoaders.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
package jdk.internal.math;
|
||||
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.CDS;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
|
@ -84,7 +84,7 @@ public /*@ spec_bigint_math @*/ class FDBigInteger {
|
|||
|
||||
// Initialize FDBigInteger cache of powers of 5.
|
||||
static {
|
||||
VM.initializeFromArchive(FDBigInteger.class);
|
||||
CDS.initializeFromArchive(FDBigInteger.class);
|
||||
Object[] caches = archivedCaches;
|
||||
if (caches == null) {
|
||||
long[] long5pow = {
|
||||
|
|
|
@ -457,31 +457,6 @@ public class VM {
|
|||
}
|
||||
private static native void initialize();
|
||||
|
||||
/**
|
||||
* Initialize archived static fields in the given Class using archived
|
||||
* values from CDS dump time. Also initialize the classes of objects in
|
||||
* the archived graph referenced by those fields.
|
||||
*
|
||||
* Those static fields remain as uninitialized if there is no mapped CDS
|
||||
* java heap data or there is any error during initialization of the
|
||||
* object class in the archived graph.
|
||||
*/
|
||||
public static native void initializeFromArchive(Class<?> c);
|
||||
|
||||
public static native void defineArchivedModules(ClassLoader platformLoader, ClassLoader systemLoader);
|
||||
|
||||
public static native long getRandomSeedForCDSDump();
|
||||
|
||||
/**
|
||||
* Check if CDS dynamic dumping is enabled via the DynamicDumpSharedSpaces flag.
|
||||
*/
|
||||
public static native boolean isCDSDumpingEnabled();
|
||||
|
||||
/**
|
||||
* Check if CDS sharing is enabled by via the UseSharedSpaces flag.
|
||||
*/
|
||||
public static native boolean isCDSSharingEnabled();
|
||||
|
||||
/**
|
||||
* Provides access to information on buffer usage.
|
||||
*/
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
package jdk.internal.module;
|
||||
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.CDS;
|
||||
|
||||
/**
|
||||
* Used by ModuleBootstrap for archiving the boot layer and the builder needed to
|
||||
|
@ -59,6 +59,6 @@ class ArchivedBootLayer {
|
|||
}
|
||||
|
||||
static {
|
||||
VM.initializeFromArchive(ArchivedBootLayer.class);
|
||||
CDS.initializeFromArchive(ArchivedBootLayer.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Set;
|
|||
import java.util.function.Function;
|
||||
import java.lang.module.Configuration;
|
||||
import java.lang.module.ModuleFinder;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.CDS;
|
||||
|
||||
/**
|
||||
* Used by ModuleBootstrap for archiving the configuration for the boot layer,
|
||||
|
@ -123,6 +123,6 @@ class ArchivedModuleGraph {
|
|||
}
|
||||
|
||||
static {
|
||||
VM.initializeFromArchive(ArchivedModuleGraph.class);
|
||||
CDS.initializeFromArchive(ArchivedModuleGraph.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ import jdk.internal.access.SharedSecrets;
|
|||
import jdk.internal.loader.BootLoader;
|
||||
import jdk.internal.loader.BuiltinClassLoader;
|
||||
import jdk.internal.loader.ClassLoaders;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.CDS;
|
||||
import jdk.internal.perf.PerfCounter;
|
||||
|
||||
/**
|
||||
|
@ -167,7 +167,7 @@ public final class ModuleBootstrap {
|
|||
assert canUseArchivedBootLayer();
|
||||
bootLayer = archivedBootLayer.bootLayer();
|
||||
BootLoader.getUnnamedModule(); // trigger <clinit> of BootLoader.
|
||||
VM.defineArchivedModules(ClassLoaders.platformClassLoader(), ClassLoaders.appClassLoader());
|
||||
CDS.defineArchivedModules(ClassLoaders.platformClassLoader(), ClassLoaders.appClassLoader());
|
||||
|
||||
// assume boot layer has at least one module providing a service
|
||||
// that is mapped to the application class loader.
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
package sun.util.locale;
|
||||
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.misc.CDS;
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
|
@ -62,7 +62,7 @@ public final class BaseLocale {
|
|||
ROOT = 18,
|
||||
NUM_CONSTANTS = 19;
|
||||
static {
|
||||
VM.initializeFromArchive(BaseLocale.class);
|
||||
CDS.initializeFromArchive(BaseLocale.class);
|
||||
BaseLocale[] baseLocales = constantBaseLocales;
|
||||
if (baseLocales == null) {
|
||||
baseLocales = new BaseLocale[NUM_CONSTANTS];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue