Skip to content

Commit

Permalink
Merge latest openjdk
Browse files Browse the repository at this point in the history
  • Loading branch information
j9build committed Nov 26, 2022
2 parents 26bb243 + 0a0d718 commit dbe6b0d
Show file tree
Hide file tree
Showing 18 changed files with 707 additions and 233 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public Document parse(InputStream is, String systemId)
* Parse the content of the given URI as an XML document
* and return a new DOM {@link Document} object.
* An <code>IllegalArgumentException</code> is thrown if the
* URI is <code>null</code> null.
* URI is <code>null</code>.
*
* @param uri The location of the content to be parsed.
*
Expand All @@ -182,7 +182,7 @@ public Document parse(String uri)
* Parse the content of the given file as an XML document
* and return a new DOM {@link Document} object.
* An <code>IllegalArgumentException</code> is thrown if the
* <code>File</code> is <code>null</code> null.
* <code>File</code> is <code>null</code>.
*
* @param f The file containing the XML to parse.
*
Expand Down Expand Up @@ -210,7 +210,7 @@ public Document parse(File f) throws SAXException, IOException {
* Parse the content of the given input source as an XML document
* and return a new DOM {@link Document} object.
* An <code>IllegalArgumentException</code> is thrown if the
* <code>InputSource</code> is <code>null</code> null.
* <code>InputSource</code> is <code>null</code>.
*
* @param is InputSource containing the content to be parsed.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4183,6 +4183,7 @@ public void visitRecordPattern(JCRecordPattern tree) {
expectedRecordTypes = Stream.generate(() -> Type.noType)
.limit(tree.nested.size())
.collect(List.collector());
tree.record = syms.errSymbol;
}
ListBuffer<BindingSymbol> outBindings = new ListBuffer<>();
List<Type> recordTypes = expectedRecordTypes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2022, 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
Expand Down Expand Up @@ -136,9 +136,6 @@ protected void buildMonitorMap(Map<String, Monitor> map) throws MonitorException
// synchronize with the target jvm
synchWithTarget(map);

// work around 1.4.2 counter inititization bugs
kludge(map);

insertedMonitors = new ArrayList<Monitor>(map.values());
}

Expand Down Expand Up @@ -301,151 +298,6 @@ protected Monitor pollFor(Map<String, Monitor> map, String name, long timeLimit)
return monitor;
}

/**
* method to make adjustments for known counter problems. This
* method depends on the availability of certain counters, which
* is generally guaranteed by the synchWithTarget() method.
*/
protected void kludge(Map<String, Monitor> map) {
if (Boolean.getBoolean("sun.jvmstat.perfdata.disableKludge")) {
// bypass all kludges
return;
}

String name = "java.vm.version";
StringMonitor jvm_version = (StringMonitor)map.get(name);
if (jvm_version == null) {
jvm_version = (StringMonitor)findByAlias(name);
}

name = "java.vm.name";
StringMonitor jvm_name = (StringMonitor)map.get(name);
if (jvm_name == null) {
jvm_name = (StringMonitor)findByAlias(name);
}

name = "hotspot.vm.args";
StringMonitor args = (StringMonitor)map.get(name);
if (args == null) {
args = (StringMonitor)findByAlias(name);
}

assert ((jvm_name != null) && (jvm_version != null) && (args != null));

if (jvm_name.stringValue().indexOf("HotSpot") >= 0) {
if (jvm_version.stringValue().startsWith("1.4.2")) {
kludgeMantis(map, args);
}
}
}

/**
* method to repair the 1.4.2 parallel scavenge counters that are
* incorrectly initialized by the JVM when UseAdaptiveSizePolicy
* is set. This bug couldn't be fixed for 1.4.2 FCS due to putback
* restrictions.
*/
private void kludgeMantis(Map<String, Monitor> map, StringMonitor args) {
/*
* the HotSpot 1.4.2 JVM with the +UseParallelGC option along
* with its default +UseAdaptiveSizePolicy option has a bug with
* the initialization of the sizes of the eden and survivor spaces.
* See bugid 4890736.
*
* note - use explicit 1.4.2 counter names here - don't update
* to latest counter names or attempt to find aliases.
*/

String cname = "hotspot.gc.collector.0.name";
StringMonitor collector = (StringMonitor)map.get(cname);

if (collector.stringValue().equals("PSScavenge")) {
boolean adaptiveSizePolicy = true;

/*
* HotSpot processes the -XX:Flags/.hotspotrc arguments prior to
* processing the command line arguments. This allows the command
* line arguments to override any defaults set in .hotspotrc
*/
cname = "hotspot.vm.flags";
StringMonitor flags = (StringMonitor)map.get(cname);
String allArgs = flags.stringValue() + " " + args.stringValue();

/*
* ignore the -XX: prefix as it only applies to the arguments
* passed from the command line (i.e. the invocation api).
* arguments passed through .hotspotrc omit the -XX: prefix.
*/
int ahi = allArgs.lastIndexOf("+AggressiveHeap");
int aspi = allArgs.lastIndexOf("-UseAdaptiveSizePolicy");

if (ahi != -1) {
/*
* +AggressiveHeap was set, check if -UseAdaptiveSizePolicy
* is set after +AggressiveHeap.
*/
//
if ((aspi != -1) && (aspi > ahi)) {
adaptiveSizePolicy = false;
}
} else {
/*
* +AggressiveHeap not set, must be +UseParallelGC. The
* relative position of -UseAdaptiveSizePolicy is not
* important in this case, as it will override the
* UseParallelGC default (+UseAdaptiveSizePolicy) if it
* appears anywhere in the JVM arguments.
*/
if (aspi != -1) {
adaptiveSizePolicy = false;
}
}

if (adaptiveSizePolicy) {
// adjust the buggy AdaptiveSizePolicy size counters.

// first remove the real counters.
String eden_size = "hotspot.gc.generation.0.space.0.size";
String s0_size = "hotspot.gc.generation.0.space.1.size";
String s1_size = "hotspot.gc.generation.0.space.2.size";
map.remove(eden_size);
map.remove(s0_size);
map.remove(s1_size);

// get the maximum new generation size
String new_max_name = "hotspot.gc.generation.0.capacity.max";
LongMonitor new_max = (LongMonitor)map.get(new_max_name);

/*
* replace the real counters with pseudo counters that are
* initialized to the correct values. The maximum size of
* the eden and survivor spaces are supposed to be:
* max_eden_size = new_size - (2*alignment).
* max_survivor_size = new_size - (2*alignment).
* since we don't know the alignment value used, and because
* of other parallel scavenge bugs that result in oversized
* spaces, we just set the maximum size of each space to the
* full new gen size.
*/
Monitor monitor = null;

LongBuffer lb = LongBuffer.allocate(1);
lb.put(new_max.longValue());
monitor = new PerfLongMonitor(eden_size, Units.BYTES,
Variability.CONSTANT, false, lb);
map.put(eden_size, monitor);

monitor = new PerfLongMonitor(s0_size, Units.BYTES,
Variability.CONSTANT, false, lb);
map.put(s0_size, monitor);

monitor = new PerfLongMonitor(s1_size, Units.BYTES,
Variability.CONSTANT, false, lb);
map.put(s1_size, monitor);
}
}
}

/**
* method to extract the next monitor entry from the instrumentation memory.
* assumes that nextEntry is the offset into the byte array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void main(String[] args) {
"test14", "test15", "test16",
"test17", "test18", "test19",
"test20", "test21", "test22",
"test23"})
"test23", "test24", "test25"})
public void runMethod() {
int a = RunInfo.getRandom().nextInt();
int b = RunInfo.getRandom().nextInt();
Expand All @@ -63,31 +63,33 @@ public void runMethod() {

@DontCompile
public void assertResult(int a, int b, int c, int d) {
Asserts.assertEQ(((a+a) + (a+a)) , additions(a));
Asserts.assertEQ(0 , xMinusX(a));
Asserts.assertEQ(a + 1 + 2 , test1(a));
Asserts.assertEQ((a + 2021) + b , test2(a, b));
Asserts.assertEQ(a + (b + 2021) , test3(a, b));
Asserts.assertEQ((1 - a) + 2 , test4(a));
Asserts.assertEQ((a - b) + (c - d), test5(a, b, c, d));
Asserts.assertEQ((a - b) + (b + c), test6(a, b, c));
Asserts.assertEQ((a - b) + (c + b), test7(a, b, c));
Asserts.assertEQ((a - b) + (b - c), test8(a, b, c));
Asserts.assertEQ((a - b) + (c - a), test9(a, b, c));
Asserts.assertEQ(a + (0 - b) , test10(a, b));
Asserts.assertEQ((0 - b) + a , test11(a, b));
Asserts.assertEQ((a - b) + b , test12(a, b));
Asserts.assertEQ(b + (a - b) , test13(a, b));
Asserts.assertEQ(a + 0 , test14(a));
Asserts.assertEQ(0 + a , test15(a));
Asserts.assertEQ(a*b + a*c , test16(a, b, c));
Asserts.assertEQ(a*b + b*c , test17(a, b, c));
Asserts.assertEQ(a*c + b*c , test18(a, b, c));
Asserts.assertEQ(a*b + c*a , test19(a, b, c));
Asserts.assertEQ((a - b) + 210 , test20(a, b));
Asserts.assertEQ((a - b) + 190 , test21(a, b));
Asserts.assertEQ((a - b) + 210 , test22(a, b));
Asserts.assertEQ((a - b) + 190 , test23(a, b));
Asserts.assertEQ(((a+a) + (a+a)) , additions(a));
Asserts.assertEQ(0 , xMinusX(a));
Asserts.assertEQ(a + 1 + 2 , test1(a));
Asserts.assertEQ((a + 2021) + b , test2(a, b));
Asserts.assertEQ(a + (b + 2021) , test3(a, b));
Asserts.assertEQ((1 - a) + 2 , test4(a));
Asserts.assertEQ((a - b) + (c - d) , test5(a, b, c, d));
Asserts.assertEQ((a - b) + (b + c) , test6(a, b, c));
Asserts.assertEQ((a - b) + (c + b) , test7(a, b, c));
Asserts.assertEQ((a - b) + (b - c) , test8(a, b, c));
Asserts.assertEQ((a - b) + (c - a) , test9(a, b, c));
Asserts.assertEQ(a + (0 - b) , test10(a, b));
Asserts.assertEQ((0 - b) + a , test11(a, b));
Asserts.assertEQ((a - b) + b , test12(a, b));
Asserts.assertEQ(b + (a - b) , test13(a, b));
Asserts.assertEQ(a + 0 , test14(a));
Asserts.assertEQ(0 + a , test15(a));
Asserts.assertEQ(a*b + a*c , test16(a, b, c));
Asserts.assertEQ(a*b + b*c , test17(a, b, c));
Asserts.assertEQ(a*c + b*c , test18(a, b, c));
Asserts.assertEQ(a*b + c*a , test19(a, b, c));
Asserts.assertEQ((a - b) + 210 , test20(a, b));
Asserts.assertEQ((a - b) + 190 , test21(a, b));
Asserts.assertEQ((a - b) + 210 , test22(a, b));
Asserts.assertEQ((a - b) + 190 , test23(a, b));
Asserts.assertEQ(Math.max(a, b) + Math.min(a, b), test24(a, b));
Asserts.assertEQ(Math.min(a, b) + Math.max(a, b), test25(a, b));
}

@Test
Expand Down Expand Up @@ -293,4 +295,20 @@ public int test22(int x, int y) {
public int test23(int x, int y) {
return x + (-10 - y) + 200; // transformed to (x - y) + 190;
}

@Test
@IR(failOn = { IRNode.MAX, IRNode.MIN })
@IR(counts = { IRNode.ADD, "1" })
// Checks Math.max(a, b) + Math.min(a, b) => a + b
public int test24(int a, int b) {
return Math.max(a, b) + Math.min(a, b);
}

@Test
@IR(failOn = { IRNode.MAX, IRNode.MIN })
@IR(counts = { IRNode.ADD, "1" })
// Checks Math.min(a, b) + Math.max(a, b) => a + b
public int test25(int a, int b) {
return Math.min(a, b) + Math.max(a, b);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public static void main(String[] args) {
"test11", "test12", "test13",
"test14", "test15", "test16",
"test17", "test18", "test19",
"test20", "test21", "test22"})
"test20", "test21", "test22",
"test23", "test24"})
public void runMethod() {
long a = RunInfo.getRandom().nextLong();
long b = RunInfo.getRandom().nextLong();
Expand All @@ -62,30 +63,32 @@ public void runMethod() {

@DontCompile
public void assertResult(long a, long b, long c, long d) {
Asserts.assertEQ(((a+a) + (a+a)) , additions(a));
Asserts.assertEQ(0L , xMinusX(a));
Asserts.assertEQ(a + 1 + 2 , test1(a));
Asserts.assertEQ((a + 2021) + b , test2(a, b));
Asserts.assertEQ(a + (b + 2021) , test3(a, b));
Asserts.assertEQ((1 - a) + 2 , test4(a));
Asserts.assertEQ((a - b) + (c - d) , test5(a, b, c, d));
Asserts.assertEQ((a - b) + (b + c) , test6(a, b, c));
Asserts.assertEQ((a - b) + (c + b) , test7(a, b, c));
Asserts.assertEQ((a - b) + (c - a) , test8(a, b, c));
Asserts.assertEQ(a + (0 - b) , test9(a, b));
Asserts.assertEQ((0 - b) + a , test10(a, b));
Asserts.assertEQ((a - b) + b , test11(a, b));
Asserts.assertEQ(b + (a - b) , test12(a, b));
Asserts.assertEQ(a + 0 , test13(a));
Asserts.assertEQ(0 + a , test14(a));
Asserts.assertEQ(a*b + a*c , test15(a, b, c));
Asserts.assertEQ(a*b + b*c , test16(a, b, c));
Asserts.assertEQ(a*c + b*c , test17(a, b, c));
Asserts.assertEQ(a*b + c*a , test18(a, b, c));
Asserts.assertEQ((a - b) + 123_456_789_123L , test19(a, b));
Asserts.assertEQ((a - b) + -123_456_788_877L , test20(a, b));
Asserts.assertEQ((a - b) + 123_456_789_123L , test21(a, b));
Asserts.assertEQ((a - b) + -123_456_788_877L , test22(a, b));
Asserts.assertEQ(((a+a) + (a+a)) , additions(a));
Asserts.assertEQ(0L , xMinusX(a));
Asserts.assertEQ(a + 1 + 2 , test1(a));
Asserts.assertEQ((a + 2021) + b , test2(a, b));
Asserts.assertEQ(a + (b + 2021) , test3(a, b));
Asserts.assertEQ((1 - a) + 2 , test4(a));
Asserts.assertEQ((a - b) + (c - d) , test5(a, b, c, d));
Asserts.assertEQ((a - b) + (b + c) , test6(a, b, c));
Asserts.assertEQ((a - b) + (c + b) , test7(a, b, c));
Asserts.assertEQ((a - b) + (c - a) , test8(a, b, c));
Asserts.assertEQ(a + (0 - b) , test9(a, b));
Asserts.assertEQ((0 - b) + a , test10(a, b));
Asserts.assertEQ((a - b) + b , test11(a, b));
Asserts.assertEQ(b + (a - b) , test12(a, b));
Asserts.assertEQ(a + 0 , test13(a));
Asserts.assertEQ(0 + a , test14(a));
Asserts.assertEQ(a*b + a*c , test15(a, b, c));
Asserts.assertEQ(a*b + b*c , test16(a, b, c));
Asserts.assertEQ(a*c + b*c , test17(a, b, c));
Asserts.assertEQ(a*b + c*a , test18(a, b, c));
Asserts.assertEQ((a - b) + 123_456_789_123L , test19(a, b));
Asserts.assertEQ((a - b) + -123_456_788_877L , test20(a, b));
Asserts.assertEQ((a - b) + 123_456_789_123L , test21(a, b));
Asserts.assertEQ((a - b) + -123_456_788_877L , test22(a, b));
Asserts.assertEQ(Math.max(a, b) + Math.min(a, b), test23(a, b));
Asserts.assertEQ(Math.min(a, b) + Math.max(a, b), test24(a, b));
}

@Test
Expand Down Expand Up @@ -287,4 +290,20 @@ public long test22(long x, long y) {
return x + (-123_456_789_000L - y) + 123;
// transformed to (x - y) + -123_456_788_877L;
}

@Test
@IR(failOn = { IRNode.MAX, IRNode.MIN })
@IR(counts = { IRNode.ADD, "1" })
// Checks Math.max(a, b) + Math.min(a, b) => a + b
public long test23(long a, long b) {
return Math.max(a, b) + Math.min(a, b);
}

@Test
@IR(failOn = { IRNode.MAX, IRNode.MIN })
@IR(counts = { IRNode.ADD, "1" })
// Checks Math.min(a, b) + Math.max(a, b) => a + b
public long test24(long a, long b) {
return Math.min(a, b) + Math.max(a, b);
}
}
Loading

0 comments on commit dbe6b0d

Please sign in to comment.