Skip to content

Commit 56a354e

Browse files
committed
Merge
2 parents b996ccc + 677802d commit 56a354e

File tree

15 files changed

+167
-51
lines changed

15 files changed

+167
-51
lines changed

make/Docs.gmk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# This code is free software; you can redistribute it and/or modify it
@@ -474,7 +474,7 @@ $(eval $(call SetupApiDocsGeneration, REFERENCE_API, \
474474
SHORT_NAME := $(JAVASE_SHORT_NAME), \
475475
LONG_NAME := $(JAVASE_LONG_NAME), \
476476
TARGET_DIR := $(DOCS_REFERENCE_IMAGE_DIR)/api, \
477-
JAVADOC_CMD := $(JAVADOC), \
477+
JAVADOC_CMD := $(DOCS_REFERENCE_JAVADOC), \
478478
OPTIONS := $(REFERENCE_OPTIONS), \
479479
TAGS := $(REFERENCE_TAGS), \
480480
))

make/autoconf/boot-jdk.m4

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -606,3 +606,28 @@ AC_DEFUN([BOOTJDK_SETUP_BUILD_JDK],
606606
AC_SUBST(BUILD_JDK)
607607
AC_SUBST(EXTERNAL_BUILDJDK)
608608
])
609+
610+
# The docs-reference JDK is used to run javadoc for the docs-reference targets.
611+
# If not set, the reference docs will be built using the interim javadoc.
612+
AC_DEFUN([BOOTJDK_SETUP_DOCS_REFERENCE_JDK],
613+
[
614+
AC_ARG_WITH(docs-reference-jdk, [AS_HELP_STRING([--with-docs-reference-jdk],
615+
[path to JDK to use for building the reference documentation])])
616+
617+
AC_MSG_CHECKING([for docs-reference JDK])
618+
if test "x$with_docs_reference_jdk" != "x"; then
619+
DOCS_REFERENCE_JDK="$with_docs_reference_jdk"
620+
AC_MSG_RESULT([$DOCS_REFERENCE_JDK])
621+
DOCS_REFERENCE_JAVADOC="$DOCS_REFERENCE_JDK/bin/javadoc"
622+
if test ! -x "$DOCS_REFERENCE_JAVADOC"; then
623+
AC_MSG_ERROR([docs-reference JDK found at $DOCS_REFERENCE_JDK did not contain bin/javadoc])
624+
fi
625+
UTIL_FIXUP_EXECUTABLE(DOCS_REFERENCE_JAVADOC)
626+
else
627+
AC_MSG_RESULT([no, using interim javadoc for the docs-reference targets])
628+
# By leaving this empty, Docs.gmk will revert to the default interim javadoc
629+
DOCS_REFERENCE_JAVADOC=
630+
fi
631+
632+
AC_SUBST(DOCS_REFERENCE_JAVADOC)
633+
])

make/autoconf/configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -144,6 +144,7 @@ JDKVER_SETUP_JDK_VERSION_NUMBERS
144144

145145
BOOTJDK_SETUP_BOOT_JDK
146146
BOOTJDK_SETUP_BUILD_JDK
147+
BOOTJDK_SETUP_DOCS_REFERENCE_JDK
147148

148149
###############################################################################
149150
#

make/autoconf/spec.gmk.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -648,6 +648,8 @@ BUILD_JAVA=@FIXPATH@ $(BUILD_JDK)/bin/java $(BUILD_JAVA_FLAGS)
648648
BUILD_JAVAC=@FIXPATH@ $(BUILD_JDK)/bin/javac
649649
BUILD_JAR=@FIXPATH@ $(BUILD_JDK)/bin/jar
650650

651+
DOCS_REFERENCE_JAVADOC := @DOCS_REFERENCE_JAVADOC@
652+
651653
# Interim langtools modules and arguments
652654
INTERIM_LANGTOOLS_BASE_MODULES := java.compiler jdk.compiler jdk.javadoc
653655
INTERIM_LANGTOOLS_MODULES := $(addsuffix .interim, $(INTERIM_LANGTOOLS_BASE_MODULES))

make/conf/jib-profiles.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -723,8 +723,11 @@ var getJibProfilesProfiles = function (input, common, data) {
723723
configure_args: concat(
724724
"--enable-full-docs",
725725
versionArgs(input, common),
726-
"--with-build-jdk=" + input.get(buildJdkDep, "home_path")
727-
+ (input.build_os == "macosx" ? "/Contents/Home" : "")
726+
"--with-build-jdk=" + input.get(buildJdkDep, "home_path"),
727+
// Provide an explicit JDK for the docs-reference target to
728+
// mimic the running conditions of when it's run for real as
729+
// closely as possible.
730+
"--with-docs-reference-jdk=" + input.get(buildJdkDep, "home_path")
728731
),
729732
default_make_targets: ["all-docs-bundles"],
730733
artifacts: {

src/hotspot/share/opto/ifnode.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,14 +1477,16 @@ Node* IfNode::dominated_by(Node* prev_dom, PhaseIterGVN *igvn) {
14771477
// Loop ends when projection has no more uses.
14781478
for (DUIterator_Last jmin, j = ifp->last_outs(jmin); j >= jmin; --j) {
14791479
Node* s = ifp->last_out(j); // Get child of IfTrue/IfFalse
1480-
if( !s->depends_only_on_test() ) {
1480+
if (s->depends_only_on_test() && igvn->no_dependent_zero_check(s)) {
1481+
// For control producers.
1482+
// Do not rewire Div and Mod nodes which could have a zero divisor to avoid skipping their zero check.
1483+
igvn->replace_input_of(s, 0, data_target); // Move child to data-target
1484+
} else {
14811485
// Find the control input matching this def-use edge.
14821486
// For Regions it may not be in slot 0.
14831487
uint l;
1484-
for( l = 0; s->in(l) != ifp; l++ ) { }
1488+
for (l = 0; s->in(l) != ifp; l++) { }
14851489
igvn->replace_input_of(s, l, ctrl_target);
1486-
} else { // Else, for control producers,
1487-
igvn->replace_input_of(s, 0, data_target); // Move child to data-target
14881490
}
14891491
} // End for each child of a projection
14901492

src/hotspot/share/opto/loopnode.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,6 @@ class PhaseIdealLoop : public PhaseTransform {
14511451
// Mark an IfNode as being dominated by a prior test,
14521452
// without actually altering the CFG (and hence IDOM info).
14531453
void dominated_by( Node *prevdom, Node *iff, bool flip = false, bool exclude_loop_predicate = false );
1454-
bool no_dependent_zero_check(Node* n) const;
14551454

14561455
// Split Node 'n' through merge point
14571456
Node *split_thru_region( Node *n, Node *region );

src/hotspot/share/opto/loopopts.cpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ void PhaseIdealLoop::dominated_by( Node *prevdom, Node *iff, bool flip, bool exc
283283
for (DUIterator_Fast imax, i = dp->fast_outs(imax); i < imax; i++) {
284284
Node* cd = dp->fast_out(i); // Control-dependent node
285285
// Do not rewire Div and Mod nodes which could have a zero divisor to avoid skipping their zero check.
286-
if (cd->depends_only_on_test() && no_dependent_zero_check(cd)) {
286+
if (cd->depends_only_on_test() && _igvn.no_dependent_zero_check(cd)) {
287287
assert(cd->in(0) == dp, "");
288288
_igvn.replace_input_of(cd, 0, prevdom);
289289
set_early_ctrl(cd, false);
@@ -302,25 +302,6 @@ void PhaseIdealLoop::dominated_by( Node *prevdom, Node *iff, bool flip, bool exc
302302
}
303303
}
304304

305-
// Check if the type of a divisor of a Div or Mod node includes zero.
306-
bool PhaseIdealLoop::no_dependent_zero_check(Node* n) const {
307-
switch (n->Opcode()) {
308-
case Op_DivI:
309-
case Op_ModI: {
310-
// Type of divisor includes 0?
311-
const TypeInt* type_divisor = _igvn.type(n->in(2))->is_int();
312-
return (type_divisor->_hi < 0 || type_divisor->_lo > 0);
313-
}
314-
case Op_DivL:
315-
case Op_ModL: {
316-
// Type of divisor includes 0?
317-
const TypeLong* type_divisor = _igvn.type(n->in(2))->is_long();
318-
return (type_divisor->_hi < 0 || type_divisor->_lo > 0);
319-
}
320-
}
321-
return true;
322-
}
323-
324305
//------------------------------has_local_phi_input----------------------------
325306
// Return TRUE if 'n' has Phi inputs from its local block and no other
326307
// block-local inputs (all non-local-phi inputs come from earlier blocks)

src/hotspot/share/opto/phaseX.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,25 @@ void PhaseIterGVN::remove_speculative_types() {
16591659
_table.check_no_speculative_types();
16601660
}
16611661

1662+
// Check if the type of a divisor of a Div or Mod node includes zero.
1663+
bool PhaseIterGVN::no_dependent_zero_check(Node* n) const {
1664+
switch (n->Opcode()) {
1665+
case Op_DivI:
1666+
case Op_ModI: {
1667+
// Type of divisor includes 0?
1668+
const TypeInt* type_divisor = type(n->in(2))->is_int();
1669+
return (type_divisor->_hi < 0 || type_divisor->_lo > 0);
1670+
}
1671+
case Op_DivL:
1672+
case Op_ModL: {
1673+
// Type of divisor includes 0?
1674+
const TypeLong* type_divisor = type(n->in(2))->is_long();
1675+
return (type_divisor->_hi < 0 || type_divisor->_lo > 0);
1676+
}
1677+
}
1678+
return true;
1679+
}
1680+
16621681
//=============================================================================
16631682
#ifndef PRODUCT
16641683
uint PhaseCCP::_total_invokes = 0;

src/hotspot/share/opto/phaseX.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ class PhaseIterGVN : public PhaseGVN {
546546
}
547547

548548
bool is_dominator(Node *d, Node *n) { return is_dominator_helper(d, n, false); }
549+
bool no_dependent_zero_check(Node* n) const;
549550

550551
#ifndef PRODUCT
551552
protected:

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,11 +1667,11 @@ public boolean isCastable(Type t, Type s, Warner warn) {
16671667
}
16681668
// where
16691669
private boolean areDisjoint(ClassSymbol ts, ClassSymbol ss) {
1670-
if (isSubtype(ts.type, ss.type)) {
1670+
if (isSubtype(erasure(ts.type), erasure(ss.type))) {
16711671
return false;
16721672
}
16731673
// if both are classes or both are interfaces, shortcut
1674-
if (ts.isInterface() == ss.isInterface() && isSubtype(ss.type, ts.type)) {
1674+
if (ts.isInterface() == ss.isInterface() && isSubtype(erasure(ss.type), erasure(ts.type))) {
16751675
return false;
16761676
}
16771677
if (ts.isInterface() && !ss.isInterface()) {
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*
23+
*/
24+
25+
/*
26+
* @test
27+
* @key stress randomness
28+
* @bug 8259227
29+
* @summary Verify that zero check is executed before division/modulo operation.
30+
* @requires vm.compiler2.enabled
31+
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler/loopopts/TestDivZeroDominatedBy::test
32+
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM -XX:StressSeed=917280111 compiler.loopopts.TestDivZeroDominatedBy
33+
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler/loopopts/TestDivZeroDominatedBy::test
34+
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM compiler.loopopts.TestDivZeroDominatedBy
35+
*/
36+
37+
package compiler.loopopts;
38+
39+
public class TestDivZeroDominatedBy {
40+
41+
public static int iFld = 1;
42+
public static int iFld1 = 2;
43+
public static int iFld2 = 3;
44+
public static int iArrFld[] = new int[10];
45+
public static double dFld = 1.0;
46+
47+
public static void test() {
48+
int x = 1;
49+
int y = 2;
50+
int z = 3;
51+
52+
iFld = y;
53+
iArrFld[5] += iFld1;
54+
int i = 1;
55+
do {
56+
for (int j = 0; j < 10; j++) {
57+
iFld2 += iFld2;
58+
iFld1 = iFld2;
59+
int k = 1;
60+
do {
61+
iArrFld[k] = y;
62+
z = iFld2;
63+
dFld = x;
64+
try {
65+
y = iArrFld[k];
66+
iArrFld[8] = 5;
67+
iFld = (100 / z);
68+
} catch (ArithmeticException a_e) {}
69+
} while (++k < 2);
70+
}
71+
} while (++i < 10);
72+
}
73+
74+
public static void main(String[] strArr) {
75+
test();
76+
}
77+
}
78+

test/hotspot/jtreg/compiler/loopopts/TestDivZeroWithSplitIf.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,11 +24,14 @@
2424

2525
/*
2626
* @test
27+
* @key stress randomness
2728
* @bug 8257822
2829
* @summary Verify that zero check is executed before division/modulo operation.
2930
* @requires vm.compiler2.enabled
3031
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler/loopopts/TestDivZeroWithSplitIf::test
3132
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM -XX:StressSeed=873732072 compiler.loopopts.TestDivZeroWithSplitIf
33+
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler/loopopts/TestDivZeroWithSplitIf::test
34+
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM compiler.loopopts.TestDivZeroWithSplitIf
3235
*/
3336

3437
package compiler.loopopts;

test/jdk/jdk/jfr/javaagent/EventEmitterAgent.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@
3535
import jdk.test.lib.Asserts;
3636
import jdk.test.lib.jfr.EventNames;
3737

38-
// Java agent that emits in multiple threads
38+
// Java agent that emits events
3939
public class EventEmitterAgent {
4040

41-
private static final int THREADS = 5;
42-
private static final int EVENTS_PER_THREAD = 150_000;
43-
private static final int EXPECTED_COUNT = THREADS * EVENTS_PER_THREAD;
41+
private static final long EVENTS = 150_000;
4442
private static final Path DUMP_PATH = Paths.get("dump.jfr").toAbsolutePath();
4543

4644
// Called when agent is loaded from command line
@@ -58,20 +56,13 @@ private static void agentWork() throws Exception {
5856
r.enable(EventNames.JavaExceptionThrow);
5957
r.setDestination(DUMP_PATH);
6058
r.start();
61-
Thread[] threads = new Thread[THREADS];
62-
for (int i = 0; i < THREADS; i++) {
63-
threads[i] = new Thread(EventEmitterAgent::emitEvents);
64-
threads[i].start();
65-
}
66-
for (int i = 0; i < THREADS; i++) {
67-
threads[i].join();
68-
}
59+
emitEvents();
6960
r.stop();
7061
}
7162
}
7263

7364
public static void emitEvents() {
74-
for (int i = 0; i < EVENTS_PER_THREAD; i++) {
65+
for (int i = 0; i < EVENTS; i++) {
7566
TestEvent e = new TestEvent();
7667
e.msg = "Long message that puts pressure on the string pool " + i % 100;
7768
e.count = i;
@@ -80,7 +71,7 @@ public static void emitEvents() {
8071
e.commit();
8172
if (i % 10000 == 0) {
8273
try {
83-
Thread.sleep(1);
74+
Thread.sleep(10);
8475
} catch (InterruptedException ie) {
8576
// ignore
8677
}
@@ -101,6 +92,6 @@ public static void validateRecording() throws Exception {
10192
.stream()
10293
.filter(e -> e.getEventType().getName().equals("Test"))
10394
.count();
104-
Asserts.assertTrue(testEventCount == EXPECTED_COUNT, "Mismatch in TestEvent count");
95+
Asserts.assertEquals(testEventCount, EVENTS, "Mismatch in TestEvent count");
10596
}
10697
}

test/langtools/tools/javac/sealed/SealedCompilationTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,17 @@ void m(A a, C c) {
12471247
a = (A)c;
12481248
}
12491249
}
1250+
""",
1251+
"""
1252+
sealed interface A<T> {
1253+
final class B implements A<Object> { }
1254+
}
1255+
1256+
class Test {
1257+
void f(A.B a, A<Object> b) {
1258+
a = (A.B)b;
1259+
}
1260+
}
12501261
"""
12511262
)) {
12521263
assertOK(s);

0 commit comments

Comments
 (0)