Merge
This commit is contained in:
commit
16548883ec
@ -63,27 +63,25 @@ void ZBarrierSetAssembler::load_at(MacroAssembler* masm,
|
||||
return;
|
||||
}
|
||||
|
||||
// rscratch1 can be passed as src or dst, so don't use it.
|
||||
RegSet savedRegs = RegSet::of(rscratch2, rheapbase);
|
||||
assert_different_registers(rscratch1, rscratch2, src.base());
|
||||
assert_different_registers(rscratch1, rscratch2, dst);
|
||||
|
||||
RegSet savedRegs = RegSet::range(r0,r28) - RegSet::of(dst, rscratch1, rscratch2);
|
||||
|
||||
Label done;
|
||||
assert_different_registers(rheapbase, rscratch2, dst);
|
||||
assert_different_registers(rheapbase, rscratch2, src.base());
|
||||
|
||||
__ push(savedRegs, sp);
|
||||
|
||||
// Load bad mask into scratch register.
|
||||
__ ldr(rheapbase, address_bad_mask_from_thread(rthread));
|
||||
__ ldr(rscratch1, address_bad_mask_from_thread(rthread));
|
||||
__ lea(rscratch2, src);
|
||||
__ ldr(dst, src);
|
||||
|
||||
// Test reference against bad mask. If mask bad, then we need to fix it up.
|
||||
__ tst(dst, rheapbase);
|
||||
__ tst(dst, rscratch1);
|
||||
__ br(Assembler::EQ, done);
|
||||
|
||||
__ enter();
|
||||
|
||||
__ push(RegSet::range(r0,r28) - RegSet::of(dst), sp);
|
||||
__ push(savedRegs, sp);
|
||||
|
||||
if (c_rarg0 != dst) {
|
||||
__ mov(c_rarg0, dst);
|
||||
@ -91,13 +89,15 @@ void ZBarrierSetAssembler::load_at(MacroAssembler* masm,
|
||||
__ mov(c_rarg1, rscratch2);
|
||||
|
||||
int step = 4 * wordSize;
|
||||
__ mov(rscratch1, -step);
|
||||
__ mov(rscratch2, -step);
|
||||
__ sub(sp, sp, step);
|
||||
|
||||
for (int i = 28; i >= 4; i -= 4) {
|
||||
__ st1(as_FloatRegister(i), as_FloatRegister(i+1), as_FloatRegister(i+2),
|
||||
as_FloatRegister(i+3), __ T1D, Address(__ post(sp, rscratch1)));
|
||||
as_FloatRegister(i+3), __ T1D, Address(__ post(sp, rscratch2)));
|
||||
}
|
||||
__ st1(as_FloatRegister(0), as_FloatRegister(1), as_FloatRegister(2),
|
||||
as_FloatRegister(3), __ T1D, Address(sp));
|
||||
|
||||
__ call_VM_leaf(ZBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr(decorators), 2);
|
||||
|
||||
@ -111,13 +111,10 @@ void ZBarrierSetAssembler::load_at(MacroAssembler* masm,
|
||||
__ mov(dst, r0);
|
||||
}
|
||||
|
||||
__ pop(RegSet::range(r0,r28) - RegSet::of(dst), sp);
|
||||
__ pop(savedRegs, sp);
|
||||
__ leave();
|
||||
|
||||
__ bind(done);
|
||||
|
||||
// Restore tmps
|
||||
__ pop(savedRegs, sp);
|
||||
}
|
||||
|
||||
#ifdef ASSERT
|
||||
|
@ -886,8 +886,8 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) {
|
||||
}
|
||||
|
||||
// Get mirror and store it in the frame as GC root for this Method*
|
||||
__ load_mirror(rscratch1, rmethod);
|
||||
__ stp(rscratch1, zr, Address(sp, 4 * wordSize));
|
||||
__ load_mirror(r10, rmethod);
|
||||
__ stp(r10, zr, Address(sp, 4 * wordSize));
|
||||
|
||||
__ ldr(rcpool, Address(rmethod, Method::const_offset()));
|
||||
__ ldr(rcpool, Address(rcpool, ConstMethod::constants_offset()));
|
||||
|
@ -1815,6 +1815,10 @@ void Arguments::set_heap_size() {
|
||||
// was not specified.
|
||||
if (reasonable_max > max_coop_heap) {
|
||||
if (FLAG_IS_ERGO(UseCompressedOops) && override_coop_limit) {
|
||||
log_info(cds)("UseCompressedOops and UseCompressedClassPointers have been disabled due to"
|
||||
" max heap " SIZE_FORMAT " > compressed oop heap " SIZE_FORMAT ". "
|
||||
"Please check the setting of MaxRAMPercentage %5.2f."
|
||||
,(size_t)reasonable_max, (size_t)max_coop_heap, MaxRAMPercentage);
|
||||
FLAG_SET_ERGO(UseCompressedOops, false);
|
||||
FLAG_SET_ERGO(UseCompressedClassPointers, false);
|
||||
} else {
|
||||
|
@ -131,8 +131,14 @@ final class MethodTypeDescImpl implements MethodTypeDesc {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodType resolveConstantDesc(MethodHandles.Lookup lookup) {
|
||||
return MethodType.fromMethodDescriptorString(descriptorString(), lookup.lookupClass().getClassLoader());
|
||||
public MethodType resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException {
|
||||
MethodType mtype = MethodType.fromMethodDescriptorString(descriptorString(), lookup.lookupClass().getClassLoader());
|
||||
// let's check that the lookup has access to all the types in the method type
|
||||
lookup.accessClass(mtype.returnType());
|
||||
for (Class<?> paramType: mtype.parameterArray()) {
|
||||
lookup.accessClass(paramType);
|
||||
}
|
||||
return mtype;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -268,7 +268,7 @@ public abstract class DatagramSocketImpl implements SocketOptions {
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation of this method first checks that the given
|
||||
* socket option {code name} is not null, then throws {@code
|
||||
* socket option {@code name} is not null, then throws {@code
|
||||
* UnsupportedOperationException}. Subclasses should override this method
|
||||
* with an appropriate implementation.
|
||||
*
|
||||
@ -296,7 +296,7 @@ public abstract class DatagramSocketImpl implements SocketOptions {
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation of this method first checks that the given
|
||||
* socket option {code name} is not null, then throws {@code
|
||||
* socket option {@code name} is not null, then throws {@code
|
||||
* UnsupportedOperationException}. Subclasses should override this method
|
||||
* with an appropriate implementation.
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2019, 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
|
||||
@ -81,7 +81,7 @@ public abstract class URLStreamHandler {
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation of this method first checks that the given
|
||||
* {code URL} and {code Proxy} are not null, then throws {@code
|
||||
* {@code URL} and {@code Proxy} are not null, then throws {@code
|
||||
* UnsupportedOperationException}. Subclasses should override this method
|
||||
* with an appropriate implementation.
|
||||
*
|
||||
|
132
test/hotspot/jtreg/gc/arguments/TestMaxRAMFlags.java
Normal file
132
test/hotspot/jtreg/gc/arguments/TestMaxRAMFlags.java
Normal file
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
package gc.arguments;
|
||||
|
||||
/*
|
||||
* @test TestMaxRAMFlags
|
||||
* @key gc
|
||||
* @bug 8222252
|
||||
* @summary Verify correct MaxHeapSize and UseCompressedOops when MaxRAM and MaxRAMPercentage
|
||||
* are specified.
|
||||
* @library /test/lib
|
||||
* @library /
|
||||
* @requires vm.bits == "64"
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
* @build sun.hotspot.WhiteBox
|
||||
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* sun.hotspot.WhiteBox$WhiteBoxPermission
|
||||
* @run main gc.arguments.TestMaxRAMFlags
|
||||
* @author bob.vandette@oracle.com
|
||||
*/
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
public class TestMaxRAMFlags {
|
||||
|
||||
private static void checkMaxRAMSize(long maxram, int maxrampercent, boolean forcecoop, long expectheap, boolean expectcoop) throws Exception {
|
||||
|
||||
ArrayList<String> args = new ArrayList<String>();
|
||||
args.add("-XX:MaxRAM=" + maxram);
|
||||
args.add("-XX:MaxRAMPercentage=" + maxrampercent);
|
||||
if (forcecoop) {
|
||||
args.add("-XX:+UseCompressedOops");
|
||||
}
|
||||
|
||||
args.add("-XX:+PrintFlagsFinal");
|
||||
args.add("-version");
|
||||
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(new String[0]));
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
String stdout = output.getStdout();
|
||||
|
||||
long actualheap = new Long(getFlagValue("MaxHeapSize", stdout)).longValue();
|
||||
if (actualheap != expectheap) {
|
||||
throw new RuntimeException("MaxHeapSize value set to " + actualheap +
|
||||
", expected " + expectheap + " when running with the following flags: " + Arrays.asList(args).toString());
|
||||
}
|
||||
|
||||
boolean actualcoop = getFlagBoolValue("UseCompressedOops", stdout);
|
||||
if (actualcoop != expectcoop) {
|
||||
throw new RuntimeException("UseCompressedOops set to " + actualcoop +
|
||||
", expected " + expectcoop + " when running with the following flags: " + Arrays.asList(args).toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static long getHeapBaseMinAddress() throws Exception {
|
||||
ArrayList<String> args = new ArrayList<String>();
|
||||
args.add("-XX:+PrintFlagsFinal");
|
||||
args.add("-version");
|
||||
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(new String[0]));
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
String stdout = output.getStdout();
|
||||
return (new Long(getFlagValue("HeapBaseMinAddress", stdout)).longValue());
|
||||
}
|
||||
|
||||
private static String getFlagValue(String flag, String where) {
|
||||
Matcher m = Pattern.compile(flag + "\\s+:?=\\s+\\d+").matcher(where);
|
||||
if (!m.find()) {
|
||||
throw new RuntimeException("Could not find value for flag " + flag + " in output string");
|
||||
}
|
||||
String match = m.group();
|
||||
return match.substring(match.lastIndexOf(" ") + 1, match.length());
|
||||
}
|
||||
|
||||
private static boolean getFlagBoolValue(String flag, String where) {
|
||||
Matcher m = Pattern.compile(flag + "\\s+:?= (true|false)").matcher(where);
|
||||
if (!m.find()) {
|
||||
throw new RuntimeException("Could not find value for flag " + flag + " in output string");
|
||||
}
|
||||
return m.group(1).equals("true");
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
// Tests
|
||||
// 1. Verify that MaxRAMPercentage overrides UseCompressedOops Ergo
|
||||
// 2. Verify that UseCompressedOops forces compressed oops limit even
|
||||
// when other flags are specified.
|
||||
|
||||
long oneG = 1L * 1024L * 1024L * 1024L;
|
||||
|
||||
// Hotspot startup logic reduces MaxHeapForCompressedOops by HeapBaseMinAddress
|
||||
// in order to get zero based compressed oops offsets.
|
||||
long heapbaseminaddr = getHeapBaseMinAddress();
|
||||
long maxcoopheap = TestUseCompressedOopsErgoTools.getMaxHeapForCompressedOops(new String [0]) - heapbaseminaddr;
|
||||
|
||||
// Args: MaxRAM , MaxRAMPercentage, forcecoop, expect heap, expect coop
|
||||
checkMaxRAMSize(maxcoopheap - oneG, 100, false, maxcoopheap - oneG, true);
|
||||
checkMaxRAMSize(maxcoopheap + oneG, 100, false, maxcoopheap + oneG, false);
|
||||
checkMaxRAMSize(maxcoopheap + oneG, 100, true, maxcoopheap, true);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, 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
|
||||
@ -53,7 +53,22 @@ public class SysDictCrash {
|
||||
"-Xshare:dump",
|
||||
"-showversion", "-Xlog:cds,cds+hashtables"));
|
||||
|
||||
TestCommon.checkDump(TestCommon.executeAndLog(dumpPb, "dump"));
|
||||
boolean continueTest = true;
|
||||
OutputAnalyzer output = TestCommon.executeAndLog(dumpPb, "dump");
|
||||
try {
|
||||
TestCommon.checkDump(output);
|
||||
} catch (java.lang.RuntimeException re) {
|
||||
if (!output.getStdout().contains("UseCompressedOops and UseCompressedClassPointers have been disabled due to")) {
|
||||
throw re;
|
||||
} else {
|
||||
System.out.println("Shared archive was not created due to UseCompressedOops and UseCompressedClassPointers have been disabled.");
|
||||
continueTest = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!continueTest) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessBuilder runPb = ProcessTools.createJavaProcessBuilder(true,
|
||||
TestCommon.concat(vmOptionsPrefix,
|
||||
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8226709
|
||||
* @summary MethodTypeDesc::resolveConstantDesc needs access check per the specification
|
||||
* @compile ../pkg2/PublicClass.java ../pkg2/NonPublicClass.java
|
||||
* @run main pkg1.MethodTypeDescriptorAccessTest
|
||||
*/
|
||||
|
||||
package pkg1;
|
||||
|
||||
import java.lang.invoke.*;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.constant.*;
|
||||
|
||||
import static java.lang.invoke.MethodHandles.*;
|
||||
import static java.lang.invoke.MethodHandles.Lookup.*;
|
||||
import static java.lang.invoke.MethodType.*;
|
||||
|
||||
public class MethodTypeDescriptorAccessTest {
|
||||
public static void main(String... args) throws Throwable {
|
||||
new MethodTypeDescriptorAccessTest().test();
|
||||
}
|
||||
|
||||
void test() {
|
||||
Lookup selfLookup = MethodHandles.lookup();
|
||||
//first test PublicClass
|
||||
String descriptorpub = "(Lpkg2/PublicClass;)Lpkg2/PublicClass;";
|
||||
MethodTypeDesc mtdpub = MethodTypeDesc.ofDescriptor(descriptorpub);
|
||||
checkValidAccess(mtdpub, selfLookup);
|
||||
|
||||
// test NonPublicClass in the return type
|
||||
String descriptornp = "()Lpkg2/NonPublicClass;";
|
||||
MethodTypeDesc mtdnp = MethodTypeDesc.ofDescriptor(descriptornp);
|
||||
checkInvalidAccess(mtdnp, selfLookup);
|
||||
|
||||
// test NonPublicClass in the parameters
|
||||
descriptornp = "(Lpkg2/NonPublicClass;)I";
|
||||
mtdnp = MethodTypeDesc.ofDescriptor(descriptornp);
|
||||
checkInvalidAccess(mtdnp, selfLookup);
|
||||
|
||||
MethodType mt = MethodType.fromMethodDescriptorString("(Lpkg2/NonPublicClass;)I", selfLookup.lookupClass().getClassLoader());
|
||||
}
|
||||
|
||||
private void checkValidAccess(MethodTypeDesc mtd, Lookup lookup) {
|
||||
try {
|
||||
MethodType mt = (MethodType)mtd.resolveConstantDesc(lookup);
|
||||
} catch (ReflectiveOperationException unexpected) {
|
||||
throw new Error("resolveConstantDesc() threw ReflectiveOperationException unexpectedly with cause " +
|
||||
unexpected.getCause() + " for " + mtd);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkInvalidAccess(MethodTypeDesc mtd, Lookup lookup) {
|
||||
try {
|
||||
MethodType mt = (MethodType)mtd.resolveConstantDesc(lookup);
|
||||
throw new Error("resolveConstantDesc() succeeded unexpectedly " + mtd);
|
||||
} catch (ReflectiveOperationException expected) {
|
||||
if (expected.getClass() != IllegalAccessException.class) {
|
||||
throw new Error("resolveConstantDesc() threw unexpected ReflectiveOperationException with cause " +
|
||||
expected.getCause() + " for " + mtd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
package pkg2;
|
||||
|
||||
class NonPublicClass {}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
package pkg2;
|
||||
|
||||
public class PublicClass {}
|
Loading…
x
Reference in New Issue
Block a user