diff --git a/.hgtags b/.hgtags index 7b4f8681742d85ec9bfc78fe29a8bd0342841cb7..851ae3e54e0de61df5e93f42d54da33c8309ceff 100644 --- a/.hgtags +++ b/.hgtags @@ -1035,6 +1035,11 @@ cdfe7ec6f29293d7c2f64239518e8947733ad85c jdk8u152-b12 0a9d8db98fc5f0302da6520ba329f41baa092ae0 jdk8u152-b14 c1bf165d3b27e864a9f8eec5bb0c1e746a972ad5 jdk8u152-b15 98b4b0661837817cc39047000e1a7efa6015af7c jdk8u152-b16 +91894ffc746c1681172aaa37e2cf5bff69560f20 jdk8u152-b31 +d278f122e65dfb5d239ed420a534df75f527a504 jdk8u152-b32 +c066fe30d0a141b14ab7788cbbd35eba11196e72 jdk8u152-b33 +12a0cebfae93a638dc69a34f8276e1ef43b11b7a jdk8u152-b34 +f6719c3d02787da6e232703f61efc931ead7683b jdk8u152-b35 2d5100bddeb80cf767485b787fc3051311e3d7b9 jdk8u151-b00 596b584c68b73ec635347807571463580deb955f jdk8u151-b01 1f6f436360d5cd375b806aec1c78abb8fcb4e5f6 jdk8u151-b02 @@ -1105,10 +1110,24 @@ a17bab9405474602b18cd62e060a09b17d6413ac jdk8u161-b02 4cf0fd9f1fe53e3140413623d72f6a00e587830d jdk8u161-b03 4022d56fc6b83eab7213c92e1277e7ce9753a21f jdk8u161-b04 37e8b74faccc8e795be1a171033487e2270dc605 jdk8u161-b05 +a769f683df5daa694fd5124c4825a9c6ad9d72d2 jdk8u161-b06 +3eb5127534005ac1f6f50db95adcff7b19a7e636 jdk8u161-b07 +796d399766f27aa0724a7951ee319c5e490a32cb jdk8u161-b08 +6e5cabb7995ef8357c5c61c16af659bf7cc1d2ff jdk8u161-b09 +b9a9aa038ad84a3fe6c91e27e359b95da8eb8629 jdk8u161-b10 +b1606443958a9a64020b596327ff586ca5c8ae1d jdk8u161-b11 +210f7ef62595c608d69fc8bf442a4f5b0bceddb5 jdk8u161-b12 7b96cfeed22242bb68a387d1680e602e37e48050 jdk8u162-b00 92693f9dd704467ddd5fbae5a5908c1713a08ee0 jdk8u162-b01 741b7a6743c0e02eae7e4a864f378fa1df0da112 jdk8u162-b02 e0c000e8eb7588501637873c6dcd255306c9c5cc jdk8u162-b03 18366fa39fe0839291b672ce4f8f12605d88b0d0 jdk8u162-b04 e34428c12886692f9d562263a10bc72c8d222613 jdk8u162-b05 +cd7f8ee4553d0f884ddc150ceefcb5b48b12ca21 jdk8u162-b06 +7be95092ed8b37b7b55ae341c8d62d377d7310df jdk8u162-b07 +080cfab193208aeb198f5b98841782fbf51ab851 jdk8u162-b08 +02f9409295f9ea7350cc2d25eeabf3c2b13b1df6 jdk8u162-b09 +c3618e1cdefdda6c262f082791bfd988e0e9d9c9 jdk8u162-b10 +39e2895b795aded8b584626fb019d35f12e9d1e7 jdk8u162-b11 +69aec2ca5d905dde1d0f29a89076d02a531808a3 jdk8u162-b12 a17bab9405474602b18cd62e060a09b17d6413ac jdk8u171-b00 diff --git a/src/share/vm/memory/metaspace.cpp b/src/share/vm/memory/metaspace.cpp index be680218a34b9a1585d69e3cc30cbc3fb4cf6a23..f80d7b3a6b1d0ae1e9722cf29bc8daa5ff2718cd 100644 --- a/src/share/vm/memory/metaspace.cpp +++ b/src/share/vm/memory/metaspace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, 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 @@ -3135,6 +3135,24 @@ void Metaspace::ergo_initialize() { CompressedClassSpaceSize = align_size_down_bounded(CompressedClassSpaceSize, _reserve_alignment); set_compressed_class_space_size(CompressedClassSpaceSize); + + // Initial virtual space size will be calculated at global_initialize() + uintx min_metaspace_sz = + VIRTUALSPACEMULTIPLIER * InitialBootClassLoaderMetaspaceSize; + if (UseCompressedClassPointers) { + if ((min_metaspace_sz + CompressedClassSpaceSize) > MaxMetaspaceSize) { + if (min_metaspace_sz >= MaxMetaspaceSize) { + vm_exit_during_initialization("MaxMetaspaceSize is too small."); + } else { + FLAG_SET_ERGO(uintx, CompressedClassSpaceSize, + MaxMetaspaceSize - min_metaspace_sz); + } + } + } else if (min_metaspace_sz >= MaxMetaspaceSize) { + FLAG_SET_ERGO(uintx, InitialBootClassLoaderMetaspaceSize, + min_metaspace_sz); + } + } void Metaspace::global_initialize() { diff --git a/test/runtime/Metaspace/MaxMetaspaceSizeTest.java b/test/runtime/Metaspace/MaxMetaspaceSizeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a10b54d483385338c207d31525ffdc572684d6d6 --- /dev/null +++ b/test/runtime/Metaspace/MaxMetaspaceSizeTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.ProcessTools; +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test MaxMetaspaceSizeTest + * @requires vm.bits == "64" + * @bug 8087291 + * @library /testlibrary + * @run main/othervm MaxMetaspaceSizeTest + */ + +public class MaxMetaspaceSizeTest { + public static void main(String... args) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-Xmx1g", + "-XX:InitialBootClassLoaderMetaspaceSize=4195328", + "-XX:MaxMetaspaceSize=4195328", + "-XX:+UseCompressedClassPointers", + "-XX:CompressedClassSpaceSize=1g", + "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("MaxMetaspaceSize is too small."); + } +}