Skip to content

Commit

Permalink
Merge upstream-jdk
Browse files Browse the repository at this point in the history
  • Loading branch information
corretto-github-robot committed Oct 26, 2024
2 parents f32435f + 309ef3f commit 7af18b8
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 12 deletions.
22 changes: 19 additions & 3 deletions src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,20 @@ void LIR_Assembler::osr_entry() {
// copied into place by code emitted in the IR.

Register OSR_buf = osrBufferPointer()->as_register();
{ assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below");
int monitor_offset = BytesPerWord * method()->max_locals() +
(2 * BytesPerWord) * (number_of_locks - 1);
{
assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below");

const int locals_space = BytesPerWord * method()->max_locals();
int monitor_offset = locals_space + (2 * BytesPerWord) * (number_of_locks - 1);
bool use_OSR_bias = false;

if (!Assembler::is_simm16(monitor_offset + BytesPerWord) && number_of_locks > 0) {
// Offsets too large for ld instructions. Use bias.
__ add_const_optimized(OSR_buf, OSR_buf, locals_space);
monitor_offset -= locals_space;
use_OSR_bias = true;
}

// SharedRuntime::OSR_migration_begin() packs BasicObjectLocks in
// the OSR buffer using 2 word entries: first the lock and then
// the oop.
Expand All @@ -161,6 +172,11 @@ void LIR_Assembler::osr_entry() {
__ ld(R0, slot_offset + 1*BytesPerWord, OSR_buf);
__ std(R0, mo.disp(), mo.base());
}

if (use_OSR_bias) {
// Restore.
__ sub_const_optimized(OSR_buf, OSR_buf, locals_space);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ void ShenandoahBarrierC2Support::fix_ctrl(Node* barrier, Node* region, const Mem
Node* u = ctrl->fast_out(i);
if (u->_idx < last &&
u != barrier &&
!u->depends_only_on_test() && // preserve dependency on test
!uses_to_ignore.member(u) &&
(u->in(0) != ctrl || (!u->is_Region() && !u->is_Phi())) &&
(ctrl->Opcode() != Op_CatchProj || u->Opcode() != Op_CreateEx)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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 @@ -2174,7 +2174,7 @@ public void visitCompoundAnnotationProxy(CompoundAnnotationProxy proxy) {

Type resolvePossibleProxyType(Type t) {
if (t instanceof ProxyType proxyType) {
Assert.check(requestingOwner.owner.kind == MDL);
Assert.check(requestingOwner.owner instanceof ModuleSymbol);
ModuleSymbol prevCurrentModule = currentModule;
currentModule = (ModuleSymbol) requestingOwner.owner;
try {
Expand Down
2 changes: 2 additions & 0 deletions test/hotspot/jtreg/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ compiler/codecache/CheckLargePages.java 8332654 linux-x64

compiler/vectorapi/reshape/TestVectorReinterpret.java 8320897 aix-ppc64,linux-ppc64le
compiler/vectorapi/VectorLogicalOpIdentityTest.java 8302459 linux-x64,windows-x64
compiler/vectorapi/VectorRebracket128Test.java#ZSinglegen 8330538 generic-all
compiler/vectorapi/VectorRebracket128Test.java#ZGenerational 8330538 generic-all

compiler/jvmci/TestUncaughtErrorInCompileMethod.java 8309073 generic-all
compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java 8331704 linux-riscv64
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* 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 8342496
* @summary C2/Shenandoah: SEGV in compiled code when running jcstress
* @requires vm.flavor == "server"
* @requires vm.gc.Shenandoah
*
* @run main/othervm -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:+StressGCM
* -XX:+StressLCM -XX:+UseShenandoahGC -XX:LoopMaxUnroll=0 -XX:StressSeed=270847015 TestLoadBypassesNullCheck
* @run main/othervm -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:+StressGCM
* -XX:+StressLCM -XX:+UseShenandoahGC -XX:LoopMaxUnroll=0 TestLoadBypassesNullCheck
*
*/

public class TestLoadBypassesNullCheck {
private static A fieldA = new A();
private static Object fieldO = new Object();
private static volatile int volatileField;

public static void main(String[] args) {
for (int i = 0; i < 20_000; i++) {
test1();
}
fieldA = null;
try {
test1();
} catch (NullPointerException npe) {
}
}

private static boolean test1() {
for (int i = 0; i < 1000; i++) {
volatileField = 42;
A a = fieldA;
Object o = a.fieldO;
if (o == fieldO) {
return true;
}
}
return false;
}

private static class A {
public Object fieldO;
}
}
21 changes: 16 additions & 5 deletions test/jdk/java/time/tck/java/time/TCKInstant.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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 @@ -187,10 +187,21 @@ public void constant_MAX() {
//-----------------------------------------------------------------------
@Test
public void now() {
Instant expected = Instant.now(Clock.systemUTC());
Instant test = Instant.now();
long diff = Math.abs(test.toEpochMilli() - expected.toEpochMilli());
assertTrue(diff < 100); // less than 0.1 secs
long beforeMillis, instantMillis, afterMillis, diff;
int retryRemaining = 5; // MAX_RETRY_COUNT
do {
beforeMillis = Instant.now(Clock.systemUTC()).toEpochMilli();
instantMillis = Instant.now().toEpochMilli();
afterMillis = Instant.now(Clock.systemUTC()).toEpochMilli();
diff = instantMillis - beforeMillis;
if (instantMillis < beforeMillis || instantMillis > afterMillis) {
throw new RuntimeException(": Invalid instant: (~" + instantMillis + "ms)"
+ " when systemUTC in millis is in ["
+ beforeMillis + ", "
+ afterMillis + "]");
}
} while (diff > 100 && --retryRemaining > 0); // retry if diff more than 0.1 sec
assertTrue(retryRemaining > 0);
}

//-----------------------------------------------------------------------
Expand Down
94 changes: 92 additions & 2 deletions test/langtools/tools/javac/modules/AnnotationsOnModules.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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 All @@ -23,7 +23,7 @@

/*
* @test
* @bug 8159602 8170549 8171255 8171322 8254023
* @bug 8159602 8170549 8171255 8171322 8254023 8341966
* @summary Test annotations on module declaration.
* @library /tools/lib
* @enablePreview
Expand All @@ -35,8 +35,10 @@
*/

import java.io.File;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
Expand All @@ -55,6 +57,7 @@
import java.lang.classfile.*;
import java.lang.classfile.ClassFile;
import java.lang.classfile.attribute.*;
import java.lang.reflect.AccessFlag;
import toolbox.JavacTask;
import toolbox.Task;
import toolbox.Task.OutputKind;
Expand Down Expand Up @@ -726,6 +729,93 @@ public TestCase(String extraDecl, String decl, String use, String expectedAnnota
}
}

@Test
public void testBrokenModuleInfoClassWithAnnotation(Path base) throws Exception {
Path lib = base.resolve("lib");
tb.writeJavaFiles(lib,
"""
@Deprecated
module m{}
""");

Path libClasses = base.resolve("lib-classes");
Files.createDirectories(libClasses);

new JavacTask(tb)
.options("--release", "21")
.outdir(libClasses)
.files(findJavaFiles(lib))
.run()
.writeAll();

Path modifiedModuleInfo = libClasses.resolve("module-info.class");
ClassModel cm1 = ClassFile.of().parse(modifiedModuleInfo);
byte[] newBytes = ClassFile.of().transform(cm1, (builder, element) -> {
if (element instanceof ModuleAttribute attr) {
List<ModuleRequireInfo> requires = new ArrayList<>();

for (ModuleRequireInfo mri : attr.requires()) {
if (mri.requires().name().equalsString("java.base")) {
requires.add(ModuleRequireInfo.of(mri.requires(),
List.of(AccessFlag.TRANSITIVE),
mri.requiresVersion()
.orElse(null)));
} else {
requires.add(mri);
}
}

builder.accept(ModuleAttribute.of(attr.moduleName(),
attr.moduleFlagsMask(),
attr.moduleVersion()
.orElseGet(() -> null),
requires,
attr.exports(),
attr.opens(),
attr.uses(),
attr.provides()));
} else {
builder.accept(element);
}
});

try (OutputStream out = Files.newOutputStream(modifiedModuleInfo)) {
out.write(newBytes);
}

Path src = base.resolve("src");
Path classes = base.resolve("classes");

tb.writeJavaFiles(src,
"""
public class C {}
""");

Files.createDirectories(classes);

List<String> actualErrors =
new JavacTask(tb)
.options("--module-path", libClasses.toString(),
"--add-modules", "m",
"-XDshould-stop.at=FLOW",
"-XDdev",
"-XDrawDiagnostics")
.outdir(classes)
.files(findJavaFiles(src))
.run(Task.Expect.FAIL)
.writeAll()
.getOutputLines(OutputKind.DIRECT);
List<String> expectedErrors = List.of(
"- compiler.err.cant.access: m.module-info, (compiler.misc.bad.class.file.header: module-info.class, (compiler.misc.bad.requires.flag: ACC_TRANSITIVE (0x0020))",
"1 error"
);

if (!expectedErrors.equals(actualErrors)) {
throw new AssertionError("Unexpected errors, expected: " + expectedErrors +
", but got: " + actualErrors);
}
}

private static final String OPT_EXPECTED_ANNOTATIONS = "expectedAnnotations";

@SupportedAnnotationTypes("*")
Expand Down

0 comments on commit 7af18b8

Please sign in to comment.