Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperIRL committed Jan 7, 2021
2 parents b996ccc + 677802d commit 56a354e
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 51 deletions.
4 changes: 2 additions & 2 deletions make/Docs.gmk
@@ -1,4 +1,4 @@
# Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 2021, 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 @@ -474,7 +474,7 @@ $(eval $(call SetupApiDocsGeneration, REFERENCE_API, \
SHORT_NAME := $(JAVASE_SHORT_NAME), \
LONG_NAME := $(JAVASE_LONG_NAME), \
TARGET_DIR := $(DOCS_REFERENCE_IMAGE_DIR)/api, \
JAVADOC_CMD := $(JAVADOC), \
JAVADOC_CMD := $(DOCS_REFERENCE_JAVADOC), \
OPTIONS := $(REFERENCE_OPTIONS), \
TAGS := $(REFERENCE_TAGS), \
))
Expand Down
27 changes: 26 additions & 1 deletion make/autoconf/boot-jdk.m4
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2021, 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 @@ -606,3 +606,28 @@ AC_DEFUN([BOOTJDK_SETUP_BUILD_JDK],
AC_SUBST(BUILD_JDK)
AC_SUBST(EXTERNAL_BUILDJDK)
])

# The docs-reference JDK is used to run javadoc for the docs-reference targets.
# If not set, the reference docs will be built using the interim javadoc.
AC_DEFUN([BOOTJDK_SETUP_DOCS_REFERENCE_JDK],
[
AC_ARG_WITH(docs-reference-jdk, [AS_HELP_STRING([--with-docs-reference-jdk],
[path to JDK to use for building the reference documentation])])
AC_MSG_CHECKING([for docs-reference JDK])
if test "x$with_docs_reference_jdk" != "x"; then
DOCS_REFERENCE_JDK="$with_docs_reference_jdk"
AC_MSG_RESULT([$DOCS_REFERENCE_JDK])
DOCS_REFERENCE_JAVADOC="$DOCS_REFERENCE_JDK/bin/javadoc"
if test ! -x "$DOCS_REFERENCE_JAVADOC"; then
AC_MSG_ERROR([docs-reference JDK found at $DOCS_REFERENCE_JDK did not contain bin/javadoc])
fi
UTIL_FIXUP_EXECUTABLE(DOCS_REFERENCE_JAVADOC)
else
AC_MSG_RESULT([no, using interim javadoc for the docs-reference targets])
# By leaving this empty, Docs.gmk will revert to the default interim javadoc
DOCS_REFERENCE_JAVADOC=
fi
AC_SUBST(DOCS_REFERENCE_JAVADOC)
])
3 changes: 2 additions & 1 deletion make/autoconf/configure.ac
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2021, 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 @@ -144,6 +144,7 @@ JDKVER_SETUP_JDK_VERSION_NUMBERS

BOOTJDK_SETUP_BOOT_JDK
BOOTJDK_SETUP_BUILD_JDK
BOOTJDK_SETUP_DOCS_REFERENCE_JDK

###############################################################################
#
Expand Down
4 changes: 3 additions & 1 deletion make/autoconf/spec.gmk.in
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2021, 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 @@ -648,6 +648,8 @@ BUILD_JAVA=@FIXPATH@ $(BUILD_JDK)/bin/java $(BUILD_JAVA_FLAGS)
BUILD_JAVAC=@FIXPATH@ $(BUILD_JDK)/bin/javac
BUILD_JAR=@FIXPATH@ $(BUILD_JDK)/bin/jar

DOCS_REFERENCE_JAVADOC := @DOCS_REFERENCE_JAVADOC@

# Interim langtools modules and arguments
INTERIM_LANGTOOLS_BASE_MODULES := java.compiler jdk.compiler jdk.javadoc
INTERIM_LANGTOOLS_MODULES := $(addsuffix .interim, $(INTERIM_LANGTOOLS_BASE_MODULES))
Expand Down
9 changes: 6 additions & 3 deletions make/conf/jib-profiles.js
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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 @@ -723,8 +723,11 @@ var getJibProfilesProfiles = function (input, common, data) {
configure_args: concat(
"--enable-full-docs",
versionArgs(input, common),
"--with-build-jdk=" + input.get(buildJdkDep, "home_path")
+ (input.build_os == "macosx" ? "/Contents/Home" : "")
"--with-build-jdk=" + input.get(buildJdkDep, "home_path"),
// Provide an explicit JDK for the docs-reference target to
// mimic the running conditions of when it's run for real as
// closely as possible.
"--with-docs-reference-jdk=" + input.get(buildJdkDep, "home_path")
),
default_make_targets: ["all-docs-bundles"],
artifacts: {
Expand Down
10 changes: 6 additions & 4 deletions src/hotspot/share/opto/ifnode.cpp
Expand Up @@ -1477,14 +1477,16 @@ Node* IfNode::dominated_by(Node* prev_dom, PhaseIterGVN *igvn) {
// Loop ends when projection has no more uses.
for (DUIterator_Last jmin, j = ifp->last_outs(jmin); j >= jmin; --j) {
Node* s = ifp->last_out(j); // Get child of IfTrue/IfFalse
if( !s->depends_only_on_test() ) {
if (s->depends_only_on_test() && igvn->no_dependent_zero_check(s)) {
// For control producers.
// Do not rewire Div and Mod nodes which could have a zero divisor to avoid skipping their zero check.
igvn->replace_input_of(s, 0, data_target); // Move child to data-target
} else {
// Find the control input matching this def-use edge.
// For Regions it may not be in slot 0.
uint l;
for( l = 0; s->in(l) != ifp; l++ ) { }
for (l = 0; s->in(l) != ifp; l++) { }
igvn->replace_input_of(s, l, ctrl_target);
} else { // Else, for control producers,
igvn->replace_input_of(s, 0, data_target); // Move child to data-target
}
} // End for each child of a projection

Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/opto/loopnode.hpp
Expand Up @@ -1451,7 +1451,6 @@ class PhaseIdealLoop : public PhaseTransform {
// Mark an IfNode as being dominated by a prior test,
// without actually altering the CFG (and hence IDOM info).
void dominated_by( Node *prevdom, Node *iff, bool flip = false, bool exclude_loop_predicate = false );
bool no_dependent_zero_check(Node* n) const;

// Split Node 'n' through merge point
Node *split_thru_region( Node *n, Node *region );
Expand Down
21 changes: 1 addition & 20 deletions src/hotspot/share/opto/loopopts.cpp
Expand Up @@ -283,7 +283,7 @@ void PhaseIdealLoop::dominated_by( Node *prevdom, Node *iff, bool flip, bool exc
for (DUIterator_Fast imax, i = dp->fast_outs(imax); i < imax; i++) {
Node* cd = dp->fast_out(i); // Control-dependent node
// Do not rewire Div and Mod nodes which could have a zero divisor to avoid skipping their zero check.
if (cd->depends_only_on_test() && no_dependent_zero_check(cd)) {
if (cd->depends_only_on_test() && _igvn.no_dependent_zero_check(cd)) {
assert(cd->in(0) == dp, "");
_igvn.replace_input_of(cd, 0, prevdom);
set_early_ctrl(cd, false);
Expand All @@ -302,25 +302,6 @@ void PhaseIdealLoop::dominated_by( Node *prevdom, Node *iff, bool flip, bool exc
}
}

// Check if the type of a divisor of a Div or Mod node includes zero.
bool PhaseIdealLoop::no_dependent_zero_check(Node* n) const {
switch (n->Opcode()) {
case Op_DivI:
case Op_ModI: {
// Type of divisor includes 0?
const TypeInt* type_divisor = _igvn.type(n->in(2))->is_int();
return (type_divisor->_hi < 0 || type_divisor->_lo > 0);
}
case Op_DivL:
case Op_ModL: {
// Type of divisor includes 0?
const TypeLong* type_divisor = _igvn.type(n->in(2))->is_long();
return (type_divisor->_hi < 0 || type_divisor->_lo > 0);
}
}
return true;
}

//------------------------------has_local_phi_input----------------------------
// Return TRUE if 'n' has Phi inputs from its local block and no other
// block-local inputs (all non-local-phi inputs come from earlier blocks)
Expand Down
19 changes: 19 additions & 0 deletions src/hotspot/share/opto/phaseX.cpp
Expand Up @@ -1659,6 +1659,25 @@ void PhaseIterGVN::remove_speculative_types() {
_table.check_no_speculative_types();
}

// Check if the type of a divisor of a Div or Mod node includes zero.
bool PhaseIterGVN::no_dependent_zero_check(Node* n) const {
switch (n->Opcode()) {
case Op_DivI:
case Op_ModI: {
// Type of divisor includes 0?
const TypeInt* type_divisor = type(n->in(2))->is_int();
return (type_divisor->_hi < 0 || type_divisor->_lo > 0);
}
case Op_DivL:
case Op_ModL: {
// Type of divisor includes 0?
const TypeLong* type_divisor = type(n->in(2))->is_long();
return (type_divisor->_hi < 0 || type_divisor->_lo > 0);
}
}
return true;
}

//=============================================================================
#ifndef PRODUCT
uint PhaseCCP::_total_invokes = 0;
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/opto/phaseX.hpp
Expand Up @@ -546,6 +546,7 @@ class PhaseIterGVN : public PhaseGVN {
}

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

#ifndef PRODUCT
protected:
Expand Down
Expand Up @@ -1667,11 +1667,11 @@ public boolean isCastable(Type t, Type s, Warner warn) {
}
// where
private boolean areDisjoint(ClassSymbol ts, ClassSymbol ss) {
if (isSubtype(ts.type, ss.type)) {
if (isSubtype(erasure(ts.type), erasure(ss.type))) {
return false;
}
// if both are classes or both are interfaces, shortcut
if (ts.isInterface() == ss.isInterface() && isSubtype(ss.type, ts.type)) {
if (ts.isInterface() == ss.isInterface() && isSubtype(erasure(ss.type), erasure(ts.type))) {
return false;
}
if (ts.isInterface() && !ss.isInterface()) {
Expand Down
78 changes: 78 additions & 0 deletions test/hotspot/jtreg/compiler/loopopts/TestDivZeroDominatedBy.java
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2021, 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
* @key stress randomness
* @bug 8259227
* @summary Verify that zero check is executed before division/modulo operation.
* @requires vm.compiler2.enabled
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler/loopopts/TestDivZeroDominatedBy::test
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM -XX:StressSeed=917280111 compiler.loopopts.TestDivZeroDominatedBy
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler/loopopts/TestDivZeroDominatedBy::test
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM compiler.loopopts.TestDivZeroDominatedBy
*/

package compiler.loopopts;

public class TestDivZeroDominatedBy {

public static int iFld = 1;
public static int iFld1 = 2;
public static int iFld2 = 3;
public static int iArrFld[] = new int[10];
public static double dFld = 1.0;

public static void test() {
int x = 1;
int y = 2;
int z = 3;

iFld = y;
iArrFld[5] += iFld1;
int i = 1;
do {
for (int j = 0; j < 10; j++) {
iFld2 += iFld2;
iFld1 = iFld2;
int k = 1;
do {
iArrFld[k] = y;
z = iFld2;
dFld = x;
try {
y = iArrFld[k];
iArrFld[8] = 5;
iFld = (100 / z);
} catch (ArithmeticException a_e) {}
} while (++k < 2);
}
} while (++i < 10);
}

public static void main(String[] strArr) {
test();
}
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 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 All @@ -24,11 +24,14 @@

/*
* @test
* @key stress randomness
* @bug 8257822
* @summary Verify that zero check is executed before division/modulo operation.
* @requires vm.compiler2.enabled
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler/loopopts/TestDivZeroWithSplitIf::test
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM -XX:StressSeed=873732072 compiler.loopopts.TestDivZeroWithSplitIf
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler/loopopts/TestDivZeroWithSplitIf::test
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM compiler.loopopts.TestDivZeroWithSplitIf
*/

package compiler.loopopts;
Expand Down
21 changes: 6 additions & 15 deletions test/jdk/jdk/jfr/javaagent/EventEmitterAgent.java
Expand Up @@ -35,12 +35,10 @@
import jdk.test.lib.Asserts;
import jdk.test.lib.jfr.EventNames;

// Java agent that emits in multiple threads
// Java agent that emits events
public class EventEmitterAgent {

private static final int THREADS = 5;
private static final int EVENTS_PER_THREAD = 150_000;
private static final int EXPECTED_COUNT = THREADS * EVENTS_PER_THREAD;
private static final long EVENTS = 150_000;
private static final Path DUMP_PATH = Paths.get("dump.jfr").toAbsolutePath();

// Called when agent is loaded from command line
Expand All @@ -58,20 +56,13 @@ private static void agentWork() throws Exception {
r.enable(EventNames.JavaExceptionThrow);
r.setDestination(DUMP_PATH);
r.start();
Thread[] threads = new Thread[THREADS];
for (int i = 0; i < THREADS; i++) {
threads[i] = new Thread(EventEmitterAgent::emitEvents);
threads[i].start();
}
for (int i = 0; i < THREADS; i++) {
threads[i].join();
}
emitEvents();
r.stop();
}
}

public static void emitEvents() {
for (int i = 0; i < EVENTS_PER_THREAD; i++) {
for (int i = 0; i < EVENTS; i++) {
TestEvent e = new TestEvent();
e.msg = "Long message that puts pressure on the string pool " + i % 100;
e.count = i;
Expand All @@ -80,7 +71,7 @@ public static void emitEvents() {
e.commit();
if (i % 10000 == 0) {
try {
Thread.sleep(1);
Thread.sleep(10);
} catch (InterruptedException ie) {
// ignore
}
Expand All @@ -101,6 +92,6 @@ public static void validateRecording() throws Exception {
.stream()
.filter(e -> e.getEventType().getName().equals("Test"))
.count();
Asserts.assertTrue(testEventCount == EXPECTED_COUNT, "Mismatch in TestEvent count");
Asserts.assertEquals(testEventCount, EVENTS, "Mismatch in TestEvent count");
}
}
11 changes: 11 additions & 0 deletions test/langtools/tools/javac/sealed/SealedCompilationTests.java
Expand Up @@ -1247,6 +1247,17 @@ void m(A a, C c) {
a = (A)c;
}
}
""",
"""
sealed interface A<T> {
final class B implements A<Object> { }
}
class Test {
void f(A.B a, A<Object> b) {
a = (A.B)b;
}
}
"""
)) {
assertOK(s);
Expand Down

0 comments on commit 56a354e

Please sign in to comment.