From 5a7ecbdf94e0156b0c2aeb0f61d42449704707f9 Mon Sep 17 00:00:00 2001 From: Gerard Ziemski Date: Wed, 30 Mar 2016 11:28:51 -0500 Subject: [PATCH] 8143958: CDS Shared flags need constraint function Implement range constraints for CDS flags. Reviewed-by: iklam, jiangli --- .../commandLineFlagConstraintsRuntime.cpp | 35 ++++++++++++++++++- .../commandLineFlagConstraintsRuntime.hpp | 7 +++- hotspot/src/share/vm/runtime/globals.hpp | 4 +++ .../TestOptionsWithRanges.java | 9 ----- 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsRuntime.cpp b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsRuntime.cpp index a34896c49aa..abcf73ca3a7 100644 --- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsRuntime.cpp +++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsRuntime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016 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 @@ -130,3 +130,36 @@ Flag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose) { return Flag::SUCCESS; } } + +static inline Flag::Error sharedConstraintFunc(const char *name, size_t value, size_t taken, bool verbose) { + size_t available = (MAX_SHARED_DELTA-(taken+SHARED_PAGE)); + if (value > available) { + CommandLineError::print(verbose, + "%s (" SIZE_FORMAT ") must be " + "smaller than or equal to (" SIZE_FORMAT ")\n", + name, value, available); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error SharedReadWriteSizeConstraintFunc(size_t value, bool verbose) { + size_t taken = (SharedReadOnlySize+SharedMiscDataSize+SharedMiscCodeSize); + return sharedConstraintFunc("SharedReadWriteSize", value, taken, verbose); +} + +Flag::Error SharedReadOnlySizeConstraintFunc(size_t value, bool verbose) { + size_t taken = (SharedReadWriteSize+SharedMiscDataSize+SharedMiscCodeSize); + return sharedConstraintFunc("SharedReadOnlySize", value, taken, verbose); +} + +Flag::Error SharedMiscDataSizeConstraintFunc(size_t value, bool verbose) { + size_t taken = (SharedReadWriteSize+SharedReadOnlySize+SharedMiscCodeSize); + return sharedConstraintFunc("SharedMiscDataSize", value, taken, verbose); +} + +Flag::Error SharedMiscCodeSizeConstraintFunc(size_t value, bool verbose) { + size_t taken = (SharedReadWriteSize+SharedReadOnlySize+SharedMiscDataSize); + return sharedConstraintFunc("SharedMiscCodeSize", value, taken, verbose); +} diff --git a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsRuntime.hpp b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsRuntime.hpp index 788b3b0dc75..3bfb2825b74 100644 --- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsRuntime.hpp +++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsRuntime.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016 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 @@ -45,4 +45,9 @@ Flag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose); Flag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose); +Flag::Error SharedReadWriteSizeConstraintFunc(size_t value, bool verbose); +Flag::Error SharedReadOnlySizeConstraintFunc(size_t value, bool verbose); +Flag::Error SharedMiscDataSizeConstraintFunc(size_t value, bool verbose); +Flag::Error SharedMiscCodeSizeConstraintFunc(size_t value, bool verbose); + #endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSRUNTIME_HPP */ diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 6a42138d74c..afea39bd81d 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -3961,18 +3961,22 @@ public: product(size_t, SharedReadWriteSize, DEFAULT_SHARED_READ_WRITE_SIZE, \ "Size of read-write space for metadata (in bytes)") \ range(MIN_SHARED_READ_WRITE_SIZE, MAX_SHARED_READ_WRITE_SIZE) \ + constraint(SharedReadWriteSizeConstraintFunc,AfterErgo) \ \ product(size_t, SharedReadOnlySize, DEFAULT_SHARED_READ_ONLY_SIZE, \ "Size of read-only space for metadata (in bytes)") \ range(MIN_SHARED_READ_ONLY_SIZE, MAX_SHARED_READ_ONLY_SIZE) \ + constraint(SharedReadOnlySizeConstraintFunc,AfterErgo) \ \ product(size_t, SharedMiscDataSize, DEFAULT_SHARED_MISC_DATA_SIZE, \ "Size of the shared miscellaneous data area (in bytes)") \ range(MIN_SHARED_MISC_DATA_SIZE, MAX_SHARED_MISC_DATA_SIZE) \ + constraint(SharedMiscDataSizeConstraintFunc,AfterErgo) \ \ product(size_t, SharedMiscCodeSize, DEFAULT_SHARED_MISC_CODE_SIZE, \ "Size of the shared miscellaneous code area (in bytes)") \ range(MIN_SHARED_MISC_CODE_SIZE, MAX_SHARED_MISC_CODE_SIZE) \ + constraint(SharedMiscCodeSizeConstraintFunc,AfterErgo) \ \ product(size_t, SharedBaseAddress, LP64_ONLY(32*G) \ NOT_LP64(LINUX_ONLY(2*G) NOT_LINUX(0)), \ diff --git a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java index f9dbbda1698..3a04f892c9b 100644 --- a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java +++ b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java @@ -96,15 +96,6 @@ public class TestOptionsWithRanges { */ excludeTestRange("ThreadStackSize"); - /* - * JDK-8143958 - * Temporarily exclude testing of max range for Shared* flags - */ - excludeTestMaxRange("SharedReadWriteSize"); - excludeTestMaxRange("SharedReadOnlySize"); - excludeTestMaxRange("SharedMiscDataSize"); - excludeTestMaxRange("SharedMiscCodeSize"); - /* * Remove the flag controlling the size of the stack because the * flag has direct influence on the physical memory usage of