# HG changeset patch # User redestad # Date 1563962007 -7200 # Wed Jul 24 11:53:27 2019 +0200 # Node ID 778c3bbc3476466ccbceb58111acd057b9d30686 # Parent 650335128b9d3483243b67e998cb958816465033 8228507: Archive FDBigInteger Reviewed-by: TBD diff --git a/make/jdk/src/classes/build/tools/classlist/HelloClasslist.java b/make/jdk/src/classes/build/tools/classlist/HelloClasslist.java --- a/make/jdk/src/classes/build/tools/classlist/HelloClasslist.java +++ b/make/jdk/src/classes/build/tools/classlist/HelloClasslist.java @@ -84,6 +84,7 @@ String CICI = "string" + args.length + "string" + args.length; String CJ = "string" + System.currentTimeMillis(); String JC = System.currentTimeMillis() + "string"; + String CD = "string" + (args.length/2.0); String CJC = "string" + System.currentTimeMillis() + "string"; String CJCJ = "string" + System.currentTimeMillis() + "string" + System.currentTimeMillis(); String CJCJC = "string" + System.currentTimeMillis() + "string" + System.currentTimeMillis() + "string"; diff --git a/src/hotspot/share/memory/heapShared.cpp b/src/hotspot/share/memory/heapShared.cpp --- a/src/hotspot/share/memory/heapShared.cpp +++ b/src/hotspot/share/memory/heapShared.cpp @@ -79,6 +79,7 @@ {"java/util/ImmutableCollections$MapN", "EMPTY_MAP"}, {"java/util/ImmutableCollections$SetN", "EMPTY_SET"}, {"java/lang/module/Configuration", "EMPTY_CONFIGURATION"}, + {"jdk/internal/math/FDBigInteger", "archivedCaches"}, }; const static int num_closed_archive_subgraph_entry_fields = diff --git a/src/java.base/share/classes/jdk/internal/math/FDBigInteger.java b/src/java.base/share/classes/jdk/internal/math/FDBigInteger.java --- a/src/java.base/share/classes/jdk/internal/math/FDBigInteger.java +++ b/src/java.base/share/classes/jdk/internal/math/FDBigInteger.java @@ -24,6 +24,8 @@ */ package jdk.internal.math; +import jdk.internal.misc.VM; + import java.math.BigInteger; import java.util.Arrays; //@ model import org.jmlspecs.models.JMLMath; @@ -64,52 +66,9 @@ @ } @*/ - static final int[] SMALL_5_POW = { - 1, - 5, - 5 * 5, - 5 * 5 * 5, - 5 * 5 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 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, - 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, - 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, - 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, - 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, - 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, - 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, - 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, - 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, - }; + static final long[] LONG_5_POW; // Maximum size of cache of powers of 5 as FDBigIntegers. private static final int MAX_FIVE_POW = 340; @@ -117,31 +76,84 @@ // Cache of big powers of 5 as FDBigIntegers. private static final FDBigInteger POW_5_CACHE[]; + // Archive proxy + private static Object[] archivedCaches; + // Initialize FDBigInteger cache of powers of 5. static { - POW_5_CACHE = new FDBigInteger[MAX_FIVE_POW]; - int i = 0; - while (i < SMALL_5_POW.length) { - FDBigInteger pow5 = new FDBigInteger(new int[]{SMALL_5_POW[i]}, 0); - pow5.makeImmutable(); - POW_5_CACHE[i] = pow5; - i++; + VM.initializeFromArchive(FDBigInteger.class); + if (archivedCaches == null) { + long[] long5pow = { + 1L, + 5L, + 5L * 5, + 5L * 5 * 5, + 5L * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5L * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + }; + int[] small5pow = { + 1, + 5, + 5 * 5, + 5 * 5 * 5, + 5 * 5 * 5 * 5, + 5 * 5 * 5 * 5 * 5, + 5 * 5 * 5 * 5 * 5 * 5, + 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5, + 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 + }; + FDBigInteger[] pow5cache = new FDBigInteger[MAX_FIVE_POW]; + int i = 0; + while (i < small5pow.length) { + FDBigInteger pow5 = new FDBigInteger(new int[] { small5pow[i] }, 0); + pow5.makeImmutable(); + pow5cache[i] = pow5; + i++; + } + FDBigInteger prev = pow5cache[i - 1]; + while (i < MAX_FIVE_POW) { + pow5cache[i] = prev = prev.mult(5); + prev.makeImmutable(); + i++; + } + FDBigInteger zero = new FDBigInteger(new int[0], 0); + zero.makeImmutable(); + archivedCaches = new Object[] {small5pow, long5pow, pow5cache, zero}; } - FDBigInteger prev = POW_5_CACHE[i - 1]; - while (i < MAX_FIVE_POW) { - POW_5_CACHE[i] = prev = prev.mult(5); - prev.makeImmutable(); - i++; - } + SMALL_5_POW = (int[])archivedCaches[0]; + LONG_5_POW = (long[])archivedCaches[1]; + POW_5_CACHE = (FDBigInteger[])archivedCaches[2]; + ZERO = (FDBigInteger)archivedCaches[3]; } // Zero as an FDBigInteger. - public static final FDBigInteger ZERO = new FDBigInteger(new int[0], 0); - - // Ensure ZERO is immutable. - static { - ZERO.makeImmutable(); - } + public static final FDBigInteger ZERO; // Constant for casting an int to a long via bitwise AND. private static final long LONG_MASK = 0xffffffffL; diff --git a/src/java.base/share/classes/jdk/internal/math/FloatingDecimal.java b/src/java.base/share/classes/jdk/internal/math/FloatingDecimal.java --- a/src/java.base/share/classes/jdk/internal/math/FloatingDecimal.java +++ b/src/java.base/share/classes/jdk/internal/math/FloatingDecimal.java @@ -131,32 +131,32 @@ * Converts a floating point value into an ASCII String. * @return The value converted to a String. */ - public String toJavaFormatString(); + String toJavaFormatString(); /** * Appends a floating point value to an Appendable. * @param buf The Appendable to receive the value. */ - public void appendTo(Appendable buf); + void appendTo(Appendable buf); /** * Retrieves the decimal exponent most closely corresponding to this value. * @return The decimal exponent. */ - public int getDecimalExponent(); + int getDecimalExponent(); /** * Retrieves the value as an array of digits. * @param digits The digit array. * @return The number of valid digits copied into the array. */ - public int getDigits(char[] digits); + int getDigits(char[] digits); /** * Indicates the sign of the value. * @return {@code value < 0.0}. */ - public boolean isNegative(); + boolean isNegative(); /** * Indicates whether the value is either infinite or not a number. @@ -164,7 +164,7 @@ * @return true if and only if the value is NaN * or infinite. */ - public boolean isExceptional(); + boolean isExceptional(); /** * Indicates whether the value was rounded up during the binary to ASCII @@ -172,14 +172,14 @@ * * @return true if and only if the value was rounded up. */ - public boolean digitsRoundedUp(); + boolean digitsRoundedUp(); /** * Indicates whether the binary to ASCII conversion was exact. * * @return true if any only if the conversion was exact. */ - public boolean decimalDigitsExact(); + boolean decimalDigitsExact(); } /** @@ -321,7 +321,7 @@ @Override public int getDigits(char[] digits) { - System.arraycopy(this.digits,firstDigitIndex,digits,0,this.nDigits); + System.arraycopy(this.digits, firstDigitIndex, digits, 0, this.nDigits); return this.nDigits; } @@ -849,7 +849,7 @@ * */ private static int insignificantDigitsForPow2(int p2) { - if(p2>1 && p2 < insignificantDigitsNumber.length) { + if (p2 > 1 && p2 < insignificantDigitsNumber.length) { return insignificantDigitsNumber[p2]; } return 0; @@ -862,7 +862,7 @@ * for ( i = 0; insignificant >= 10L; i++ ) * insignificant /= 10L; */ - private static int[] insignificantDigitsNumber = { + private static final int[] insignificantDigitsNumber = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, 11, @@ -1873,11 +1873,11 @@ } // look for and process decimal floating-point string char[] digits = new char[ len ]; - int nDigits= 0; boolean decSeen = false; + int nDigits = 0; int decPt = 0; int nLeadZero = 0; - int nTrailZero= 0; + int nTrailZero = 0; skipLeadingZerosLoop: while (i < len) { @@ -2137,9 +2137,9 @@ // signed zero. // - String significandString = null; - int signifLength = 0; - int exponentAdjust = 0; + String significandString; + int signifLength; + int exponentAdjust; { int leftDigits = 0; // number of meaningful digits to // left of "decimal" point @@ -2246,7 +2246,7 @@ boolean round = false; boolean sticky = false; - int nextShift = 0; + int nextShift; long significand = 0L; // First iteration is different, since we only copy // from the leading significand bit; one more exponent @@ -2525,7 +2525,6 @@ * Returns s with any leading zeros removed. */ static String stripLeadingZeros(String s) { -// return s.replaceFirst("^0+", ""); if(!s.isEmpty() && s.charAt(0)=='0') { for(int i=1; i