mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8241071: Generation of classes.jsa with -Xshare:dump is not deterministic
Reviewed-by: dholmes, stuefe
This commit is contained in:
parent
957eb270f0
commit
eadcb08c3c
20 changed files with 369 additions and 92 deletions
|
@ -64,14 +64,22 @@ class ImmutableCollections {
|
|||
private static final boolean REVERSE;
|
||||
static {
|
||||
// to generate a reasonably random and well-mixed SALT, use an arbitrary
|
||||
// value (a slice of pi), multiply with the System.nanoTime, then pick
|
||||
// value (a slice of pi), multiply with a random seed, then pick
|
||||
// the mid 32-bits from the product. By picking a SALT value in the
|
||||
// [0 ... 0xFFFF_FFFFL == 2^32-1] range, we ensure that for any positive
|
||||
// int N, (SALT32L * N) >> 32 is a number in the [0 ... N-1] range. This
|
||||
// property will be used to avoid more expensive modulo-based
|
||||
// calculations.
|
||||
long color = 0x243F_6A88_85A3_08D3L; // slice of pi
|
||||
long seed = System.nanoTime();
|
||||
|
||||
// When running with -Xshare:dump, the VM will supply a "random" seed that's
|
||||
// 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();
|
||||
if (seed == 0) {
|
||||
seed = System.nanoTime();
|
||||
}
|
||||
SALT32L = (int)((color * seed) >> 16) & 0xFFFF_FFFFL;
|
||||
// use the lowest bit to determine if we should reverse iteration
|
||||
REVERSE = (SALT32L & 1) == 0;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 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
|
||||
|
@ -421,6 +421,8 @@ public class VM {
|
|||
*/
|
||||
public static native void initializeFromArchive(Class<?> c);
|
||||
|
||||
public static native long getRandomSeedForCDSDump();
|
||||
|
||||
/**
|
||||
* Provides access to information on buffer usage.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue