Skip to content

Commit

Permalink
8253500: [REDO] JDK-8253208 Move CDS related code to a separate class
Browse files Browse the repository at this point in the history
Reviewed-by: mchung, iklam
  • Loading branch information
yminqi committed Sep 24, 2020
1 parent bf442c5 commit 89c5e49
Show file tree
Hide file tree
Showing 22 changed files with 103 additions and 99 deletions.
6 changes: 3 additions & 3 deletions make/hotspot/symbols/symbols-unix
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ JVM_GetPermittedSubclasses
JVM_GetPrimitiveArrayElement
JVM_GetProperties
JVM_GetProtectionDomain
JVM_GetRandomSeedForCDSDump
JVM_GetRandomSeedForDumping
JVM_GetRecordComponents
JVM_GetSimpleBinaryName
JVM_GetStackAccessControlContext
Expand All @@ -143,8 +143,8 @@ JVM_InternString
JVM_Interrupt
JVM_InvokeMethod
JVM_IsArrayClass
JVM_IsCDSDumpingEnabled
JVM_IsCDSSharingEnabled
JVM_IsDynamicDumpingEnabled
JVM_IsSharingEnabled
JVM_IsConstructorIx
JVM_IsHiddenClass
JVM_IsInterface
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/include/jvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,13 @@ JVM_LookupLambdaProxyClassFromArchive(JNIEnv* env, jclass caller,
jboolean initialize);

JNIEXPORT jboolean JNICALL
JVM_IsCDSDumpingEnabled(JNIEnv* env);
JVM_IsDynamicDumpingEnabled(JNIEnv* env);

JNIEXPORT jboolean JNICALL
JVM_IsCDSSharingEnabled(JNIEnv* env);
JVM_IsSharingEnabled(JNIEnv* env);

JNIEXPORT jlong JNICALL
JVM_GetRandomSeedForCDSDump();
JVM_GetRandomSeedForDumping();

/*
* java.lang.Throwable
Expand Down
14 changes: 7 additions & 7 deletions src/hotspot/share/prims/jvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3833,18 +3833,18 @@ JVM_ENTRY(jclass, JVM_LookupLambdaProxyClassFromArchive(JNIEnv* env,
#endif // INCLUDE_CDS
JVM_END

JVM_ENTRY(jboolean, JVM_IsCDSDumpingEnabled(JNIEnv* env))
JVMWrapper("JVM_IsCDSDumpingEnable");
JVM_ENTRY(jboolean, JVM_IsDynamicDumpingEnabled(JNIEnv* env))
JVMWrapper("JVM_IsDynamicDumpingEnable");
return DynamicDumpSharedSpaces;
JVM_END

JVM_ENTRY(jboolean, JVM_IsCDSSharingEnabled(JNIEnv* env))
JVMWrapper("JVM_IsCDSSharingEnable");
JVM_ENTRY(jboolean, JVM_IsSharingEnabled(JNIEnv* env))
JVMWrapper("JVM_IsSharingEnable");
return UseSharedSpaces;
JVM_END

JVM_ENTRY_NO_ENV(jlong, JVM_GetRandomSeedForCDSDump())
JVMWrapper("JVM_GetRandomSeedForCDSDump");
JVM_ENTRY_NO_ENV(jlong, JVM_GetRandomSeedForDumping())
JVMWrapper("JVM_GetRandomSeedForDumping");
if (DumpSharedSpaces) {
const char* release = Abstract_VM_Version::vm_release();
const char* dbg_level = Abstract_VM_Version::jdk_debug_level();
Expand All @@ -3859,7 +3859,7 @@ JVM_ENTRY_NO_ENV(jlong, JVM_GetRandomSeedForCDSDump())
if (seed == 0) { // don't let this ever be zero.
seed = 0x87654321;
}
log_debug(cds)("JVM_GetRandomSeedForCDSDump() = " JLONG_FORMAT, seed);
log_debug(cds)("JVM_GetRandomSeedForDumping() = " JLONG_FORMAT, seed);
return seed;
} else {
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/Byte.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -108,7 +108,7 @@ private ByteCache() {}
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;
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/Character.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -8516,7 +8516,7 @@ private CharacterCache(){}
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++) {
Expand Down
3 changes: 2 additions & 1 deletion src/java.base/share/classes/java/lang/Integer.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
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;
Expand Down Expand Up @@ -1023,7 +1024,7 @@ private static class IntegerCache {
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
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/Long.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
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;
Expand Down Expand Up @@ -1169,7 +1169,7 @@ private LongCache() {}
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;
Expand Down
3 changes: 2 additions & 1 deletion src/java.base/share/classes/java/lang/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
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;
Expand Down Expand Up @@ -277,7 +278,7 @@ static ArchivedData get() {
}

static {
VM.initializeFromArchive(ArchivedData.class);
CDS.initializeFromArchive(ArchivedData.class);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/Short.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -234,7 +234,7 @@ private ShortCache() {}
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
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;

/**
Expand Down Expand Up @@ -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();
}
Expand All @@ -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<>();
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/util/jar/Attributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
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;
Expand Down Expand Up @@ -672,7 +672,7 @@ private static void addName(Map<String, Name> names, Name name) {

static {

VM.initializeFromArchive(Attributes.Name.class);
CDS.initializeFromArchive(Attributes.Name.class);

if (KNOWN_NAMES == null) {
MANIFEST_VERSION = new Name("Manifest-Version");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -91,6 +91,6 @@ static ArchivedClassLoaders get() {
}

static {
VM.initializeFromArchive(ArchivedClassLoaders.class);
CDS.initializeFromArchive(ArchivedClassLoaders.class);
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -84,7 +84,7 @@

// Initialize FDBigInteger cache of powers of 5.
static {
VM.initializeFromArchive(FDBigInteger.class);
CDS.initializeFromArchive(FDBigInteger.class);
Object[] caches = archivedCaches;
if (caches == null) {
long[] long5pow = {
Expand Down
25 changes: 0 additions & 25 deletions src/java.base/share/classes/jdk/internal/misc/VM.java
Original file line number Diff line number Diff line change
Expand Up @@ -457,31 +457,6 @@ public static boolean isSetUID() {
}
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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,6 +59,6 @@ static void archive(ModuleLayer layer, IllegalAccessLogger.Builder builder) {
}

static {
VM.initializeFromArchive(ArchivedBootLayer.class);
CDS.initializeFromArchive(ArchivedBootLayer.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
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,
Expand Down Expand Up @@ -123,6 +123,6 @@ static void archive(boolean hasSplitPackages,
}

static {
VM.initializeFromArchive(ArchivedModuleGraph.class);
CDS.initializeFromArchive(ArchivedModuleGraph.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
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;

/**
Expand Down Expand Up @@ -167,7 +167,7 @@ public static ModuleLayer boot() {
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.
Expand Down
Loading

1 comment on commit 89c5e49

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 89c5e49 Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.