Skip to content

Commit

Permalink
Merge branch 'master' into 8332689
Browse files Browse the repository at this point in the history
  • Loading branch information
robehn committed Jun 17, 2024
2 parents f1dd3e1 + 31e8deb commit b3a4f8f
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 67 deletions.
8 changes: 8 additions & 0 deletions src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,14 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
OuterStripMinedLoopNode* outer = head->as_OuterStripMinedLoop();
hide_strip_mined_loop(outer, outer->unique_ctrl_out()->as_CountedLoop(), phase);
}
if (head->is_BaseCountedLoop() && ctrl->is_IfProj() && ctrl->in(0)->is_BaseCountedLoopEnd() &&
head->as_BaseCountedLoop()->loopexit() == ctrl->in(0)) {
Node* entry = head->in(LoopNode::EntryControl);
Node* backedge = head->in(LoopNode::LoopBackControl);
Node* new_head = new LoopNode(entry, backedge);
phase->register_control(new_head, phase->get_loop(entry), entry);
phase->lazy_replace(head, new_head);
}
}

// Expand load-reference-barriers
Expand Down
90 changes: 59 additions & 31 deletions src/java.base/share/native/libjli/java.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,73 +387,92 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */
} \
} while (JNI_FALSE)

#define CHECK_EXCEPTION_NULL_FAIL(obj) \
do { \
if ((*env)->ExceptionOccurred(env)) { \
return 0; \
} else if (obj == NULL) { \
return 0; \
} \
} while (JNI_FALSE)

/*
* Invoke a static main with arguments. Returns 1 (true) if successful otherwise
* processes the pending exception from GetStaticMethodID and returns 0 (false).
* Invokes static main(String[]) method if found.
* Returns 0 with a pending exception if not found. Returns 1 if invoked, maybe
* a pending exception if the method threw.
*/
int
invokeStaticMainWithArgs(JNIEnv *env, jclass mainClass, jobjectArray mainArgs) {
jmethodID mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
"([Ljava/lang/String;)V");
CHECK_EXCEPTION_NULL_FAIL(mainID);
if (mainID == NULL) {
// static main(String[]) not found
return 0;
}
(*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
return 1;
return 1; // method was invoked
}

/*
* Invoke an instance main with arguments. Returns 1 (true) if successful otherwise
* processes the pending exception from GetMethodID and returns 0 (false).
* Invokes instance main(String[]) method if found.
* Returns 0 with a pending exception if not found. Returns 1 if invoked, maybe
* a pending exception if the method threw.
*/
int
invokeInstanceMainWithArgs(JNIEnv *env, jclass mainClass, jobjectArray mainArgs) {
jmethodID constructor = (*env)->GetMethodID(env, mainClass, "<init>", "()V");
CHECK_EXCEPTION_NULL_FAIL(constructor);
if (constructor == NULL) {
// main class' no-arg constructor not found
return 0;
}
jobject mainObject = (*env)->NewObject(env, mainClass, constructor);
CHECK_EXCEPTION_NULL_FAIL(mainObject);
if (mainObject == NULL) {
// main class instance couldn't be constructed
return 0;
}
jmethodID mainID =
(*env)->GetMethodID(env, mainClass, "main", "([Ljava/lang/String;)V");
CHECK_EXCEPTION_NULL_FAIL(mainID);
if (mainID == NULL) {
// instance method main(String[]) method not found
return 0;
}
(*env)->CallVoidMethod(env, mainObject, mainID, mainArgs);
return 1;
return 1; // method was invoked
}

/*
* Invoke a static main without arguments. Returns 1 (true) if successful otherwise
* processes the pending exception from GetStaticMethodID and returns 0 (false).
* Invokes no-arg static main() method if found.
* Returns 0 with a pending exception if not found. Returns 1 if invoked, maybe
* a pending exception if the method threw.
*/
int
invokeStaticMainWithoutArgs(JNIEnv *env, jclass mainClass) {
jmethodID mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
"()V");
CHECK_EXCEPTION_NULL_FAIL(mainID);
if (mainID == NULL) {
// static main() method couldn't be located
return 0;
}
(*env)->CallStaticVoidMethod(env, mainClass, mainID);
return 1;
return 1; // method was invoked
}

/*
* Invoke an instance main without arguments. Returns 1 (true) if successful otherwise
* processes the pending exception from GetMethodID and returns 0 (false).
* Invokes no-arg instance main() method if found.
* Returns 0 with a pending exception if not found. Returns 1 if invoked, maybe
* a pending exception if the method threw.
*/
int
invokeInstanceMainWithoutArgs(JNIEnv *env, jclass mainClass) {
jmethodID constructor = (*env)->GetMethodID(env, mainClass, "<init>", "()V");
CHECK_EXCEPTION_NULL_FAIL(constructor);
if (constructor == NULL) {
// main class' no-arg constructor not found
return 0;
}
jobject mainObject = (*env)->NewObject(env, mainClass, constructor);
CHECK_EXCEPTION_NULL_FAIL(mainObject);
if (mainObject == NULL) {
// couldn't create instance of main class
return 0;
}
jmethodID mainID = (*env)->GetMethodID(env, mainClass, "main",
"()V");
CHECK_EXCEPTION_NULL_FAIL(mainID);
if (mainID == NULL) {
// instance method main() not found
return 0;
}
(*env)->CallVoidMethod(env, mainObject, mainID);
return 1;
return 1; // method was invoked
}

int
Expand Down Expand Up @@ -639,15 +658,24 @@ JavaMain(void* _args)
}
}
if (!ret) {
// An appropriate main method couldn't be located, check and report
// any exception and LEAVE()
CHECK_EXCEPTION_LEAVE(1);
}

/*
* The launcher's exit code (in the absence of calls to
* System.exit) will be non-zero if main threw an exception.
*/
ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;

if (ret && (*env)->ExceptionOccurred(env) == NULL) {
// main method was invoked and no exception was thrown from it,
// return success.
ret = 0;
} else {
// Either the main method couldn't be located or an exception occurred
// in the invoked main method, return failure.
ret = 1;
}
LEAVE();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024, 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 @@ -1239,7 +1239,7 @@ class LambdaAnalyzerPreprocessor extends TreeTranslator {
private int lambdaCount = 0;

/**
* List of types undergoing construction via explicit constructor chaining.
* List of types undergoing construction, i.e., in an early construction context.
*/
private List<ClassSymbol> typesUnderConstruction;

Expand Down Expand Up @@ -1280,15 +1280,10 @@ private JCClassDecl analyzeAndPreprocessClass(JCClassDecl tree) {

@Override
public void visitApply(JCMethodInvocation tree) {
List<ClassSymbol> previousNascentTypes = typesUnderConstruction;
try {
Name methName = TreeInfo.name(tree.meth);
if (methName == names._this || methName == names._super) {
typesUnderConstruction = typesUnderConstruction.prepend(currentClass());
}
super.visitApply(tree);
} finally {
typesUnderConstruction = previousNascentTypes;
super.visitApply(tree);
if (TreeInfo.isConstructorCall(tree)) {
Assert.check(typesUnderConstruction.head == currentClass());
typesUnderConstruction = typesUnderConstruction.tail; // end of early construction context
}
}
// where
Expand Down Expand Up @@ -1439,13 +1434,16 @@ private LambdaTranslationContext analyzeLambda(JCLambda tree, String statKey) {

@Override
public void visitMethodDef(JCMethodDecl tree) {
List<ClassSymbol> prevTypesUnderConstruction = typesUnderConstruction;
List<Frame> prevStack = frameStack;
try {
if (TreeInfo.isConstructor(tree)) // start early construction context (Object() notwithstanding)
typesUnderConstruction = typesUnderConstruction.prepend(currentClass());
frameStack = frameStack.prepend(new Frame(tree));
super.visitMethodDef(tree);
}
finally {
} finally {
frameStack = prevStack;
typesUnderConstruction = prevTypesUnderConstruction;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2024, 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 @@ -104,8 +104,11 @@ private List<PatternAction> getPatternActions(PrintWriter log,

private String[] getTools(PrintWriter writer, Properties p, String key) {
String value = p.getProperty(key);
if (value == null || value.isEmpty()) {
writer.printf("ERROR: '%s' property is empty%n", key);
if (value == null) {
writer.printf("ERROR: '%s' property is not set%n", key);
return new String[]{};
}
if (value.isEmpty()) {
return new String[]{};
}
return value.split(" ");
Expand Down
4 changes: 3 additions & 1 deletion test/failure_handler/src/share/conf/windows.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2015, 2024, 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 @@ -59,6 +59,8 @@ native.stack.params.repeat=6
native.core.app=cdb
native.core.args=-c ".dump /mA core.%p;qd" -p %p
native.core.params.timeout=600000

cores=
################################################################################
# environment info to gather
################################################################################
Expand Down
2 changes: 0 additions & 2 deletions test/hotspot/jtreg/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ gc/epsilon/TestMemoryMXBeans.java 8206434 generic-all
gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java 8156755 generic-all
gc/g1/logging/TestG1LoggingFailure.java 8169634 generic-all
gc/g1/humongousObjects/TestHeapCounters.java 8178918 generic-all
gc/parallel/TestAlwaysPreTouchBehavior.java 8325218 linux-all
gc/TestAllocHumongousFragment.java#adaptive 8298781 generic-all
gc/TestAllocHumongousFragment.java#aggressive 8298781 generic-all
gc/TestAllocHumongousFragment.java#iu-aggressive 8298781 generic-all
Expand All @@ -102,7 +101,6 @@ runtime/StackGuardPages/TestStackGuardPagesNative.java 8303612 linux-all
runtime/ErrorHandling/TestDwarf.java#checkDecoder 8305489 linux-all
runtime/ErrorHandling/MachCodeFramesInErrorFile.java 8313315 linux-ppc64le
runtime/cds/appcds/customLoader/HelloCustom_JFR.java 8241075 linux-all,windows-x64
runtime/Thread/TestAlwaysPreTouchStacks.java 8324781 linux-all

applications/jcstress/copy.java 8229852 linux-all

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @requires os.family == "linux"
* @requires os.maxMemory > 2G
* @library /test/lib
* @run main/othervm -Xmx1g -Xms1g -XX:+UseParallelGC -XX:+AlwaysPreTouch gc.parallel.TestAlwaysPreTouchBehavior
* @run main/othervm -Xmx1g -Xms1g -XX:+UseParallelGC -XX:+AlwaysPreTouch -XX:+UnlockDiagnosticVMOptions -XX:-UseMadvPopulateWrite gc.parallel.TestAlwaysPreTouchBehavior
*/
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
Expand Down Expand Up @@ -77,4 +77,3 @@ public static void main(String [] args) {
Asserts.assertGreaterThanOrEqual(rss, committedMemory, "RSS of this process(" + rss + "kb) should be bigger than or equal to committed heap mem(" + committedMemory + "kb)");
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright (c) 2024, Red Hat, Inc. 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 8328107
* @summary Barrier expanded on backedge break loop verification code
* @requires vm.gc.Shenandoah
*
* @run main/othervm -XX:+UseShenandoahGC -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestBarrierOnLoopBackedge::notInlined
* -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyLoopOptimizations TestBarrierOnLoopBackedge
* @run main/othervm -XX:+UseShenandoahGC -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestBarrierOnLoopBackedge::notInlined
* -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyLoopOptimizations -XX:-UseCountedLoopSafepoints TestBarrierOnLoopBackedge
*/

public class TestBarrierOnLoopBackedge {
private static A field = new A();
private static final A finalField = new A();
private static float floatField;

public static void main(String[] args) {
A[] array = new A[1];
array[0] = finalField;
for (int i = 0; i < 20_000; i++) {
test1();
test2();
}
}

private static void test1() {
floatField = field.f;
for (int i = 0; i < 1000; i++) {
notInlined(field); // load barrier split thru phi and ends up on back edge
if (i % 2 == 0) {
field = finalField;
}
}
}

private static void test2() {
A[] array = new A[1];
notInlined(array);
int i = 0;
A a = array[0];
for (;;) {
synchronized (new Object()) {
}
notInlined(a);
i++;
if (i >= 1000) {
break;
}
a = array[0]; // load barrier pinned on backedge
}
}

private static void notInlined(Object a) {

}

private static class A {
float f;
}
}
Loading

0 comments on commit b3a4f8f

Please sign in to comment.