diff --git a/common.json b/common.json index 3f88e17674a6..341f06ff71ca 100644 --- a/common.json +++ b/common.json @@ -8,7 +8,7 @@ "COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet", "jdks": { - "galahad-jdk": {"name": "jpg-jdk", "version": "26", "build_id": "jdk-26+11-1117", "platformspecific": true, "extrabundles": ["static-libs"]}, + "galahad-jdk": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-25+26-3319", "platformspecific": true, "extrabundles": ["static-libs"]}, "oraclejdk17": {"name": "jpg-jdk", "version": "17.0.7", "build_id": "jdk-17.0.7+8", "platformspecific": true, "extrabundles": ["static-libs"]}, "labsjdk-ce-17": {"name": "labsjdk", "version": "ce-17.0.7+4-jvmci-23.1-b02", "platformspecific": true }, @@ -54,13 +54,13 @@ "labsjdk-ee-25-llvm": {"name": "labsjdk", "version": "ee-25+30-jvmci-b01-sulong", "platformspecific": true }, "graalvm-ee-25-ea": {"name": "graalvm-jdk", "version": "25.0.0", "ea": "36", "platformspecific": true }, - "oraclejdk-latest": {"name": "jpg-jdk", "version": "26", "build_id": "jdk-26+13", "platformspecific": true, "extrabundles": ["static-libs"]}, - "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-26+13-jvmci-b01", "platformspecific": true }, - "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-26+13-jvmci-b01-debug", "platformspecific": true }, - "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-26+13-jvmci-b01-sulong", "platformspecific": true }, - "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-26+13-jvmci-b01", "platformspecific": true }, - "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-26+13-jvmci-b01-debug", "platformspecific": true }, - "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-26+13-jvmci-b01-sulong", "platformspecific": true } + "oraclejdk-latest": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-25+37", "platformspecific": true, "extrabundles": ["static-libs"]}, + "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-25+37-jvmci-b02", "platformspecific": true }, + "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-25+37-jvmci-b02-debug", "platformspecific": true }, + "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-25+37-jvmci-b02-sulong", "platformspecific": true }, + "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-25+37-jvmci-b02", "platformspecific": true }, + "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-25+37-jvmci-b02-debug", "platformspecific": true }, + "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-25+37-jvmci-b02-sulong", "platformspecific": true } }, "eclipse": { diff --git a/compiler/ci/ci_common/gate.jsonnet b/compiler/ci/ci_common/gate.jsonnet index 5e6d6b03561c..63ada50c1f9a 100644 --- a/compiler/ci/ci_common/gate.jsonnet +++ b/compiler/ci/ci_common/gate.jsonnet @@ -550,7 +550,8 @@ local style_builds = [self.make_build(self.jdk_latest, "linux-amd64", "style").build + { environment+: { # Run the strict JVMCI version check, i.e., that JVMCIVersionCheck.JVMCI_MIN_VERSION matches the versions in common.json. - JVMCI_VERSION_CHECK: "strict", + # temporarily disable until labsjdk-ce|ee-25 is gone from common.json + # JVMCI_VERSION_CHECK: "strict", }, }], diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/CountedLoopOverflowTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/CountedLoopOverflowTest.java index d08937cf9995..bc782de60aab 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/CountedLoopOverflowTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/CountedLoopOverflowTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, 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 diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/lir/test/BenchmarkCounterOverflowTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/lir/test/BenchmarkCounterOverflowTest.java index f760b1200473..fac768ca56af 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/lir/test/BenchmarkCounterOverflowTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/lir/test/BenchmarkCounterOverflowTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/HotSpotCompressedKlassPointerTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/HotSpotCompressedKlassPointerTest.java index e12281fb22a8..99984d3c4c8a 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/HotSpotCompressedKlassPointerTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/HotSpotCompressedKlassPointerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 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 @@ -40,7 +40,7 @@ public class HotSpotCompressedKlassPointerTest extends HotSpotGraalCompilerTest @Before public void setUp() { GraalHotSpotVMConfig config = runtime().getVMConfig(); - assumeTrue("compressed class pointers specific tests", config.useCompressedClassPointers && !config.useClassMetaspaceForAllClasses); + assumeTrue("compressed class pointers specific tests", config.useCompressedClassPointers); } // Non-abstract class diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/MonitorPEATest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/MonitorPEATest.java index 767b155605dd..1be953c283b4 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/MonitorPEATest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/MonitorPEATest.java @@ -28,15 +28,23 @@ import static jdk.graal.compiler.api.directives.GraalDirectives.deoptimize; import static jdk.graal.compiler.api.directives.GraalDirectives.injectBranchProbability; +import org.junit.Assume; +import org.junit.Before; import org.junit.Test; import jdk.graal.compiler.api.directives.GraalDirectives; +import jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil; /** * Tests that PEA preserves the monitorenter order. This is essential for lightweight locking. */ public final class MonitorPEATest extends HotSpotGraalCompilerTest { + @Before + public void checkUseLightweightLocking() { + Assume.assumeTrue(HotSpotReplacementsUtil.useLightweightLocking(runtime().getVMConfig())); + } + static int staticInt = 0; static Object staticObj; static Object staticObj1; diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/RangeCheckPredicatesTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/RangeCheckPredicatesTest.java index 9d0466461be0..2cdf8a706b4b 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/RangeCheckPredicatesTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/RangeCheckPredicatesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/except/BC_getfield1.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/except/BC_getfield1.java index 86b966d16509..f0072dcccf86 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/except/BC_getfield1.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/except/BC_getfield1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -26,9 +26,10 @@ */ package jdk.graal.compiler.jtt.except; +import org.junit.Test; + import jdk.graal.compiler.jtt.JTTTest; import jdk.graal.compiler.phases.OptimisticOptimizations; -import org.junit.Test; public class BC_getfield1 extends JTTTest { diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/jdk/Unsafe_compareAndSwapNullCheck.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/jdk/Unsafe_compareAndSwapNullCheck.java index e81dc3a45a95..b66057236065 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/jdk/Unsafe_compareAndSwapNullCheck.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/jdk/Unsafe_compareAndSwapNullCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/lang/Math_pow.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/lang/Math_pow.java index 2c65f078588e..14cc31ff171e 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/lang/Math_pow.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/lang/Math_pow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2023, 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 @@ -24,10 +24,10 @@ */ package jdk.graal.compiler.jtt.lang; -import jdk.graal.compiler.jtt.JTTTest; -import jdk.graal.compiler.options.OptionValues; import org.junit.Test; +import jdk.graal.compiler.jtt.JTTTest; +import jdk.graal.compiler.options.OptionValues; import jdk.vm.ci.meta.ResolvedJavaMethod; /* diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/lang/UnaryMath.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/lang/UnaryMath.java index f249091ddb5f..bd2ca8b0a19a 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/lang/UnaryMath.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/lang/UnaryMath.java @@ -26,7 +26,6 @@ import jdk.graal.compiler.jtt.JTTTest; import jdk.graal.compiler.options.OptionValues; - import jdk.vm.ci.meta.ResolvedJavaMethod; public abstract class UnaryMath extends JTTTest { diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/CountPositivesTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/CountPositivesTest.java index 44f2529ef412..590ec168c4ef 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/CountPositivesTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/CountPositivesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/EncodeArrayTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/EncodeArrayTest.java index adb88f18167a..2369450f5be4 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/EncodeArrayTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/EncodeArrayTest.java @@ -67,7 +67,7 @@ private static Result executeCompiledMethod(InstalledCode compiledMethod, Object @Test public void testStringCodingISO() throws ClassNotFoundException { Class klass = Class.forName("java.lang.StringCoding"); - ResolvedJavaMethod method = getResolvedJavaMethod(klass, "encodeISOArray0"); + ResolvedJavaMethod method = getResolvedJavaMethod(klass, "implEncodeISOArray"); StructuredGraph graph = getIntrinsicGraph(method, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext(), StructuredGraph.AllowAssumptions.YES, null); InstalledCode compiledMethod = getCode(method, graph); @@ -100,7 +100,7 @@ public void testStringCodingISO() throws ClassNotFoundException { @Test public void testStringCodingAscii() throws ClassNotFoundException { Class klass = Class.forName("java.lang.StringCoding"); - ResolvedJavaMethod method = getResolvedJavaMethod(klass, "encodeAsciiArray0"); + ResolvedJavaMethod method = getResolvedJavaMethod(klass, "implEncodeAsciiArray"); StructuredGraph graph = getIntrinsicGraph(method, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext(), StructuredGraph.AllowAssumptions.YES, null); InstalledCode compiledMethod = getCode(method, graph); @@ -133,7 +133,7 @@ public void testStringCodingAscii() throws ClassNotFoundException { @Test public void testISOEncoding() throws ClassNotFoundException { Class klass = Class.forName("sun.nio.cs.ISO_8859_1$Encoder"); - ResolvedJavaMethod method = getResolvedJavaMethod(klass, "encodeISOArray0"); + ResolvedJavaMethod method = getResolvedJavaMethod(klass, "implEncodeISOArray"); StructuredGraph graph = getIntrinsicGraph(method, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext(), StructuredGraph.AllowAssumptions.YES, null); InstalledCode compiledMethod = getCode(method, graph); diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/MathSinhTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/MathSinhTest.java deleted file mode 100644 index 9c35be8ec6f3..000000000000 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/MathSinhTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2025, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ -package jdk.graal.compiler.replacements.test; - -import org.junit.Test; - -import jdk.graal.compiler.jtt.JTTTest; - -public class MathSinhTest extends JTTTest { - - public double sinh(double d) { - return Math.sinh(d); - } - - @Test - public void testSinh() { - for (double d = -3.0d; d <= 3.0D; d += 0.01D) { - test("sinh", d); - } - - double[] inputs = {Math.PI / 2, Math.PI, -1.0D, Double.MAX_VALUE, Double.MIN_VALUE, Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, - Double.longBitsToDouble(0x7fffffffffffffffL), Double.longBitsToDouble(0xffffffffffffffffL)}; - for (double d : inputs) { - test("sinh", d); - } - } -} diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/StandardMethodSubstitutionsTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/StandardMethodSubstitutionsTest.java index 991b646ad29f..97e5697fac42 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/StandardMethodSubstitutionsTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/StandardMethodSubstitutionsTest.java @@ -60,9 +60,6 @@ public void testMathSubstitutions() { testGraph("mathSqrt"); testGraph("mathTan"); testGraph("mathAll"); - if (getReplacements().hasSubstitution(getResolvedJavaMethod(Math.class, "sinh"), getInitialOptions())) { - testGraph("mathSinh"); - } if (getReplacements().hasSubstitution(getResolvedJavaMethod(Math.class, "tanh"), getInitialOptions())) { testGraph("mathTanh"); } @@ -75,7 +72,6 @@ public void testMathSubstitutions() { test("mathLog", value); test("mathLog10", value); test("mathSin", value); - test("mathSinh", value); test("mathSqrt", value); test("mathTan", value); test("mathTanh", value); @@ -137,10 +133,6 @@ public static double mathSin(double value) { return Math.sin(value); } - public static double mathSinh(double value) { - return Math.sinh(value); - } - public static double mathCos(double value) { return Math.cos(value); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/aarch64/AArch64Assembler.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/aarch64/AArch64Assembler.java index 4a68164320e5..4cd9a4d89097 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/aarch64/AArch64Assembler.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/aarch64/AArch64Assembler.java @@ -138,7 +138,6 @@ import static jdk.graal.compiler.asm.aarch64.AArch64Assembler.Instruction.REVW; import static jdk.graal.compiler.asm.aarch64.AArch64Assembler.Instruction.REVX; import static jdk.graal.compiler.asm.aarch64.AArch64Assembler.Instruction.RORV; -import static jdk.graal.compiler.asm.aarch64.AArch64Assembler.Instruction.SB; import static jdk.graal.compiler.asm.aarch64.AArch64Assembler.Instruction.SBC; import static jdk.graal.compiler.asm.aarch64.AArch64Assembler.Instruction.SBCS; import static jdk.graal.compiler.asm.aarch64.AArch64Assembler.Instruction.SBFM; @@ -1058,7 +1057,6 @@ public enum Instruction { MSR(0xD5100000), DC(0xD5087000), ISB(0x000000C0), - SB(0x000000E0), PACIA(0b00001 << 16 | 0b000000 << 10), AUTIA(0b00001 << 16 | 0b000100 << 10), @@ -4036,15 +4034,6 @@ public enum BarrierKind { } } - /** - * C6.2.75 Data Cache operation. - */ - public void dc(DataCacheOperationType type, Register src) { - assert verifyRegistersR(src); - - emitInt(DC.encoding | type.encoding() | rt(src)); - } - /** * C6.2.80 Data Memory Barrier. * @@ -4093,12 +4082,12 @@ public void msr(SystemRegister systemRegister, Register src) { } /** - * C6.2.230 Speculation barrier. + * C6.2.75 Data Cache operation. */ - public void sb() { - if (supports(CPUFeature.SB)) { - emitInt(SB.encoding | BarrierOp); - } + public void dc(DataCacheOperationType type, Register src) { + assert verifyRegistersR(src); + + emitInt(DC.encoding | type.encoding() | rt(src)); } public void annotatePatchingImmediate(int pos, Instruction instruction, int operandSizeBits, int offsetBits, int shift) { diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/amd64/AMD64Assembler.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/amd64/AMD64Assembler.java index b8c005ff315e..01d8941166ce 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/amd64/AMD64Assembler.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/amd64/AMD64Assembler.java @@ -950,24 +950,22 @@ public final void emit(AMD64Assembler asm, OperandSize size, Register dst, int i public static class SSERMIOp extends AMD64RMIOp { // @formatter:off - public static final SSERMIOp ROUNDSS = new SSERMIOp("ROUNDSS", true, P_0F3A, 0x0A, PreferredNDS.SRC, OpAssertion.PackedDoubleAssertion, CPUFeature.SSE4_1); - public static final SSERMIOp ROUNDSD = new SSERMIOp("ROUNDSD", true, P_0F3A, 0x0B, PreferredNDS.SRC, OpAssertion.PackedDoubleAssertion, CPUFeature.SSE4_1); + public static final SSERMIOp ROUNDSS = new SSERMIOp("ROUNDSS", true, P_0F3A, 0x0A, PreferredNDS.SRC, OpAssertion.PackedDoubleAssertion, CPUFeature.SSE4_1); + public static final SSERMIOp ROUNDSD = new SSERMIOp("ROUNDSD", true, P_0F3A, 0x0B, PreferredNDS.SRC, OpAssertion.PackedDoubleAssertion, CPUFeature.SSE4_1); - public static final SSERMIOp PCMPESTRI = new SSERMIOp("PCMPESTRI", true, P_0F3A, 0x61, PreferredNDS.NONE, OpAssertion.PackedDoubleAssertion, CPUFeature.SSE4_2); - public static final SSERMIOp PCLMULQDQ = new SSERMIOp("PCLMULQDQ", true, P_0F3A, 0x44, PreferredNDS.DST, OpAssertion.PackedDoubleAssertion, CPUFeature.CLMUL); - public static final SSERMIOp GF2P8AFFINEQB = new SSERMIOp("GF2P8AFFINEQB", true, P_0F3A, true, 0xCE, PreferredNDS.DST, OpAssertion.PackedDoubleAssertion, CPUFeature.GFNI); + public static final SSERMIOp PCMPESTRI = new SSERMIOp("PCMPESTRI", true, P_0F3A, 0x61, PreferredNDS.NONE, OpAssertion.PackedDoubleAssertion, CPUFeature.SSE4_2); + public static final SSERMIOp PCLMULQDQ = new SSERMIOp("PCLMULQDQ", true, P_0F3A, 0x44, PreferredNDS.DST, OpAssertion.PackedDoubleAssertion, CPUFeature.CLMUL); + public static final SSERMIOp GF2P8AFFINEQB = new SSERMIOp("GF2P8AFFINEQB", true, P_0F3A, true, 0xCE, PreferredNDS.DST, OpAssertion.PackedDoubleAssertion, CPUFeature.GFNI); public static final SSERMIOp PINSRB = new SSERMIOp("PINSRB", true, P_0F3A, 0x20, PreferredNDS.DST, OpAssertion.PackedDoubleIntToFloatAssertion, CPUFeature.SSE4_1); public static final SSERMIOp PINSRW = new SSERMIOp("PINSRW", true, P_0F, 0xC4, PreferredNDS.DST, OpAssertion.PackedDoubleIntToFloatAssertion, CPUFeature.SSE2); public static final SSERMIOp PINSRD = new SSERMIOp("PINSRD", true, P_0F3A, 0x22, PreferredNDS.DST, OpAssertion.PackedDoubleIntToFloatAssertion, CPUFeature.SSE4_1); public static final SSERMIOp PINSRQ = new SSERMIOp("PINSRQ", true, P_0F3A, true, 0x22, PreferredNDS.DST, OpAssertion.PackedDoubleIntToFloatAssertion, CPUFeature.SSE4_1); - public static final SSERMIOp PALIGNR = new SSERMIOp("PALIGNR", true, P_0F3A, 0x0F, PreferredNDS.DST, OpAssertion.PackedDoubleAssertion, CPUFeature.SSSE3); - public static final SSERMIOp PBLENDW = new SSERMIOp("PBLENDW", true, P_0F3A, 0x0E, PreferredNDS.DST, OpAssertion.PackedDoubleAssertion, CPUFeature.SSE4_1); - public static final SSERMIOp PSHUFD = new SSERMIOp("PSHUFD", true, P_0F, 0x70, PreferredNDS.NONE, OpAssertion.PackedDoubleAssertion, CPUFeature.SSE2); - public static final SSERMIOp PSHUFLW = new SSERMIOp("PSHUFLW", true, P_0F, 0x70, PreferredNDS.NONE, OpAssertion.DoubleAssertion, CPUFeature.SSE2); - - public static final SSERMIOp SHUFPD = new SSERMIOp("SHUFPD", true, P_0F, 0xC6, PreferredNDS.DST, OpAssertion.PackedDoubleAssertion, CPUFeature.SSE2); + public static final SSERMIOp PALIGNR = new SSERMIOp("PALIGNR", true, P_0F3A, 0x0F, PreferredNDS.DST, OpAssertion.PackedDoubleAssertion, CPUFeature.SSSE3); + public static final SSERMIOp PBLENDW = new SSERMIOp("PBLENDW", true, P_0F3A, 0x0E, PreferredNDS.DST, OpAssertion.PackedDoubleAssertion, CPUFeature.SSE4_1); + public static final SSERMIOp PSHUFD = new SSERMIOp("PSHUFD", true, P_0F, 0x70, PreferredNDS.NONE, OpAssertion.PackedDoubleAssertion, CPUFeature.SSE2); + public static final SSERMIOp PSHUFLW = new SSERMIOp("PSHUFLW", true, P_0F, 0x70, PreferredNDS.NONE, OpAssertion.DoubleAssertion, CPUFeature.SSE2); // @formatter:on private final PreferredNDS preferredNDS; @@ -5691,10 +5689,6 @@ public final void psubusw(Register dst, AMD64Address src) { SSEOp.PSUBUSW.emit(this, OperandSize.PD, dst, src); } - public final void psubw(Register dst, Register src) { - SSEOp.PSUBW.emit(this, OperandSize.PD, dst, src); - } - public final void ptest(Register dst, Register src) { SSEOp.PTEST.emit(this, OperandSize.PD, dst, src); } @@ -5865,10 +5859,6 @@ public final void shrq(Register dst) { AMD64MOp.SHR.emit(this, OperandSize.QWORD, dst); } - public final void shufpd(Register dst, Register src, int imm8) { - SSERMIOp.SHUFPD.emit(this, OperandSize.PD, dst, src, imm8); - } - public final void sqrtsd(Register dst, Register src) { SSEOp.SQRT.emit(this, OperandSize.SD, dst, src); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/amd64/AMD64ArithmeticLIRGenerator.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/amd64/AMD64ArithmeticLIRGenerator.java index 1bec2f482e48..2d080d422c5e 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/amd64/AMD64ArithmeticLIRGenerator.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/amd64/AMD64ArithmeticLIRGenerator.java @@ -144,7 +144,6 @@ import jdk.graal.compiler.lir.amd64.AMD64MathPowOp; import jdk.graal.compiler.lir.amd64.AMD64MathSignumOp; import jdk.graal.compiler.lir.amd64.AMD64MathSinOp; -import jdk.graal.compiler.lir.amd64.AMD64MathSinhOp; import jdk.graal.compiler.lir.amd64.AMD64MathTanOp; import jdk.graal.compiler.lir.amd64.AMD64MathTanhOp; import jdk.graal.compiler.lir.amd64.AMD64Move; @@ -1308,11 +1307,6 @@ public Value emitMathSin(Value input) { return new AMD64MathSinOp().emitLIRWrapper(getLIRGen(), input); } - @Override - public Value emitMathSinh(Value input) { - return new AMD64MathSinhOp().emitLIRWrapper(getLIRGen(), input); - } - @Override public Value emitMathTan(Value input) { return new AMD64MathTanOp().emitLIRWrapper(getLIRGen(), input); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/GraalHotSpotVMConfig.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/GraalHotSpotVMConfig.java index b1542e93cff0..9be0df530ead 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/GraalHotSpotVMConfig.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/GraalHotSpotVMConfig.java @@ -135,6 +135,16 @@ private HotSpotGraalRuntime.HotSpotGC getSelectedGC() throws GraalError { public final boolean printInlining = getFlag("PrintInlining", Boolean.class); public final boolean inline = getFlag("Inline", Boolean.class); + // There are 3 available locking modes: + // LM_MONITOR uses only heavy monitors for locking; + // LM_LEGACY uses stack-locking, with monitors as 2nd tier; + // LM_LIGHTWEIGHT uses thread-local space for storing locked objects. This avoids the overload + // of the mark word. + public final int lockingMode = getFlag("LockingMode", Integer.class); + + public final int lockingModeStack = getConstant("LockingMode::LM_LEGACY", Integer.class); + public final int lockingModeLightweight = getConstant("LockingMode::LM_LIGHTWEIGHT", Integer.class); + public final boolean foldStableValues = getFlag("FoldStableValues", Boolean.class); public final int maxVectorSize = getFlag("MaxVectorSize", Integer.class); @@ -195,9 +205,6 @@ public long gcTotalCollectionsAddress() { // Compressed Oops related values. public final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); public final boolean useCompressedClassPointers = getFlag("UseCompressedClassPointers", Boolean.class); - - public final boolean useClassMetaspaceForAllClasses = getFlag("UseClassMetaspaceForAllClasses", Boolean.class); - // JDK-8305895 allows storing the compressed class pointer in the upper 22 bits of the mark // word. This runtime optimization is guarded by the flag UseCompactObjectHeaders. It depends // on compressed class pointers, meaning that if useCompactObjectHeaders is true, @@ -464,7 +471,7 @@ public int threadTlabTopOffset() { public final long deoptBlobUncommonTrap = getFieldValue("CompilerToVM::Data::SharedRuntime_deopt_blob_uncommon_trap", Long.class, "address"); public final long updateBytesCRC32Stub = getFieldValue("StubRoutines::_updateBytesCRC32", Long.class, "address"); - public final long crcTableAddress = getFieldValue("CompilerToVM::Data::crc_table_addr", Long.class, "address"); + public final long crcTableAddress = getFieldValue("StubRoutines::_crc_table_adr", Long.class, "address"); public final long md5ImplCompressMultiBlock = getFieldValue("StubRoutines::_md5_implCompressMB", Long.class, "address"); public final long sha1ImplCompressMultiBlock = getFieldValue("StubRoutines::_sha1_implCompressMB", Long.class, "address"); @@ -703,7 +710,6 @@ private long getZGCAddressField(String name) { public final long javaTimeMillisAddress = getAddress("os::javaTimeMillis"); public final long javaTimeNanosAddress = getAddress("os::javaTimeNanos"); public final long arithmeticSinAddress = getFieldValue("CompilerToVM::Data::dsin", Long.class, "address"); - public final long arithmeticSinhAddress = getFieldValue("CompilerToVM::Data::dsinh", Long.class, "address"); public final long arithmeticCosAddress = getFieldValue("CompilerToVM::Data::dcos", Long.class, "address"); public final long arithmeticTanAddress = getFieldValue("CompilerToVM::Data::dtan", Long.class, "address"); public final long arithmeticTanhAddress = getFieldValue("CompilerToVM::Data::dtanh", Long.class, "address"); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java index 08555caffa09..b23b591a3273 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java @@ -56,16 +56,16 @@ public final class JVMCIVersionCheck { */ // Checkstyle: stop stable iteration order check private static final Map> JVMCI_MIN_VERSIONS = Map.of( - "26", Map.of( - "Oracle Corporation", createLabsJDKVersion("26+13", 1), - DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("26+13", 1))); + "25", Map.of( + "Oracle Corporation", createLabsJDKVersion("25+37", 1), + DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("25+37", 1))); // Checkstyle: resume stable iteration order check private static final int NA = 0; /** * Minimum Java release supported by Graal. */ - private static final int JAVA_MIN_RELEASE = 26; + private static final int JAVA_MIN_RELEASE = 25; /** * Convenience factory for the current version scheme that only uses the JDK version and the diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotLIRGenerator.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotLIRGenerator.java index 515d2683e5a1..6317a8cb22b1 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotLIRGenerator.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotLIRGenerator.java @@ -40,7 +40,6 @@ import jdk.graal.compiler.asm.Label; import jdk.graal.compiler.asm.aarch64.AArch64Address; -import jdk.graal.compiler.asm.aarch64.AArch64Assembler; import jdk.graal.compiler.asm.aarch64.AArch64Assembler.ConditionFlag; import jdk.graal.compiler.asm.aarch64.AArch64Assembler.PrefetchMode; import jdk.graal.compiler.asm.aarch64.AArch64MacroAssembler; @@ -486,7 +485,6 @@ private Consumer onSpinWaitInst() { case "nop" -> AArch64MacroAssembler::nop; case "isb" -> AArch64MacroAssembler::isb; case "yield" -> AArch64MacroAssembler::pause; - case "sb" -> AArch64Assembler::sb; default -> throw GraalError.shouldNotReachHere("Unknown OnSpinWaitInst " + config.onSpinWaitInst); }; } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java index 5d03e8d2774f..03ea6b157f54 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java @@ -39,7 +39,6 @@ import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.LOG; import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.LOG10; import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.SIN; -import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.SINH; import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.TAN; import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.TANH; import static jdk.vm.ci.amd64.AMD64.rax; @@ -105,7 +104,6 @@ public Value[] getNativeABICallerSaveRegisters() { protected void registerMathStubs(GraalHotSpotVMConfig hotSpotVMConfig, HotSpotProviders providers, OptionValues options) { if (GraalArithmeticStubs.getValue(options)) { link(new AMD64MathStub(SIN, options, providers, registerStubCall(SIN.foreignCallSignature, LEAF, NO_SIDE_EFFECT, COMPUTES_REGISTERS_KILLED, NO_LOCATIONS))); - link(new AMD64MathStub(SINH, options, providers, registerStubCall(SINH.foreignCallSignature, LEAF, NO_SIDE_EFFECT, COMPUTES_REGISTERS_KILLED, NO_LOCATIONS))); link(new AMD64MathStub(COS, options, providers, registerStubCall(COS.foreignCallSignature, LEAF, NO_SIDE_EFFECT, COMPUTES_REGISTERS_KILLED, NO_LOCATIONS))); link(new AMD64MathStub(TAN, options, providers, registerStubCall(TAN.foreignCallSignature, LEAF, NO_SIDE_EFFECT, COMPUTES_REGISTERS_KILLED, NO_LOCATIONS))); link(new AMD64MathStub(TANH, options, providers, registerStubCall(TANH.foreignCallSignature, LEAF, NO_SIDE_EFFECT, COMPUTES_REGISTERS_KILLED, NO_LOCATIONS))); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64MathStub.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64MathStub.java index 921c564a47d9..4c70633a354b 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64MathStub.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64MathStub.java @@ -51,7 +51,6 @@ public AMD64MathStub(BinaryOperation operation, OptionValues options, HotSpotPro private static String snippetName(UnaryOperation operation) { return switch (operation) { case SIN -> "sin"; - case SINH -> "sinh"; case COS -> "cos"; case TAN -> "tan"; case TANH -> "tanh"; @@ -84,11 +83,6 @@ private static double sin(double value) { return UnaryMathIntrinsicNode.compute(value, UnaryOperation.SIN); } - @Snippet - private static double sinh(double value) { - return UnaryMathIntrinsicNode.compute(value, UnaryOperation.SINH); - } - @Snippet private static double cos(double value) { return UnaryMathIntrinsicNode.compute(value, UnaryOperation.COS); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/DefaultHotSpotLoweringProvider.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/DefaultHotSpotLoweringProvider.java index 333d033d45fc..9abe6ef6fed9 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/DefaultHotSpotLoweringProvider.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/DefaultHotSpotLoweringProvider.java @@ -35,6 +35,7 @@ import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.HUB_LOCATION; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.HUB_WRITE_LOCATION; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.MARK_WORD_LOCATION; +import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.useLightweightLocking; import static org.graalvm.word.LocationIdentity.any; import java.util.Arrays; @@ -329,7 +330,7 @@ public void initialize(OptionValues options, Iterable assert target == providers.getCodeCache().getTarget() : Assertions.errorMessage(target, providers.getCodeCache().getTarget()); instanceofSnippets = new InstanceOfSnippets.Templates(options, runtime, providers); allocationSnippets = allocationSnippetTemplates; - monitorSnippets = new MonitorSnippets.Templates(options, runtime, providers); + monitorSnippets = new MonitorSnippets.Templates(options, runtime, providers, config); g1WriteBarrierSnippets = new HotSpotG1WriteBarrierSnippets.Templates(options, runtime, providers, config); serialWriteBarrierSnippets = new HotSpotSerialWriteBarrierSnippets.Templates(options, runtime, providers); exceptionObjectSnippets = new LoadExceptionObjectSnippets.Templates(options, providers); @@ -396,11 +397,14 @@ public MonitorSnippets.Templates getMonitorSnippets() { @Override protected FixedWithNextNode maybeEmitLockingCheck(List locks, FixedWithNextNode insertionPoint, FrameState stateBefore) { if (!locks.isEmpty()) { - StructuredGraph graph = insertionPoint.graph(); - CheckFastPathMonitorEnterNode check = graph.add(new CheckFastPathMonitorEnterNode(locks)); - graph.addAfterFixed(insertionPoint, check); - check.setStateBefore(stateBefore.duplicate()); - return check; + if (useLightweightLocking(getVMConfig())) { + StructuredGraph graph = insertionPoint.graph(); + CheckFastPathMonitorEnterNode check = graph.add(new CheckFastPathMonitorEnterNode(locks)); + graph.addAfterFixed(insertionPoint, check); + check.setStateBefore(stateBefore.duplicate()); + return check; + } + // The stack lock and heavyweight monitors cases don't need any checks. } return insertionPoint; } @@ -526,7 +530,7 @@ private boolean lowerWithoutDelegation(Node n, LoweringTool tool) { } } else if (n instanceof CheckFastPathMonitorEnterNode) { if (graph.getGuardsStage().areFrameStatesAtDeopts()) { - monitorSnippets.lower((CheckFastPathMonitorEnterNode) n, registers, tool); + monitorSnippets.lower((CheckFastPathMonitorEnterNode) n, registers, runtime.getVMConfig(), tool); } } else if (n instanceof MonitorExitNode) { if (graph.getGuardsStage().areFrameStatesAtDeopts()) { diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotGraphBuilderPlugins.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotGraphBuilderPlugins.java index 49371c80f064..edf17c13eb2f 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotGraphBuilderPlugins.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotGraphBuilderPlugins.java @@ -289,7 +289,7 @@ public void run() { registerMathPlugins(invocationPlugins, target.arch); registerContinuationPlugins(invocationPlugins, config); registerCallSitePlugins(invocationPlugins); - registerReflectionPlugins(invocationPlugins); + registerReflectionPlugins(invocationPlugins, config); registerAESPlugins(invocationPlugins, config); registerAdler32Plugins(invocationPlugins, config); registerCRC32Plugins(invocationPlugins, config); @@ -508,7 +508,7 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec plugins.register(VolatileCallSite.class, plugin); } - private static void registerReflectionPlugins(InvocationPlugins plugins) { + private static void registerReflectionPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config) { Registration r = new Registration(plugins, "jdk.internal.reflect.Reflection"); r.register(new InlineOnlyInvocationPlugin("getCallerClass") { @Override @@ -517,6 +517,20 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec return true; } }); + r.register(new InvocationPlugin("getClassAccessFlags", Class.class) { + @Override + public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) { + try (HotSpotInvocationPluginHelper helper = new HotSpotInvocationPluginHelper(b, targetMethod, config)) { + ValueNode klass = helper.readKlassFromClass(b.nullCheckedValue(arg)); + // Primitive Class case + ValueNode klassNonNull = helper.emitNullReturnGuard(klass, ConstantNode.forInt(Modifier.ABSTRACT | Modifier.FINAL | Modifier.PUBLIC), GraalDirectives.UNLIKELY_PROBABILITY); + // Return (Klass::_access_flags & jvmAccWrittenFlags) + ValueNode accessFlags = helper.readKlassAccessFlags(klassNonNull); + helper.emitFinalReturn(JavaKind.Int, accessFlags); + } + return true; + } + }); } private static final SpeculationReasonGroup JVMTI_NOTIFY_ALLOCATE_INSTANCE = new SpeculationReasonGroup("JvmtiNotifyAllocateInstance"); @@ -1791,18 +1805,6 @@ protected boolean useExplicitReachabilityFence(GraphBuilderContext b) { return Options.ForceExplicitReachabilityFence.getValue(b.getOptions()); } }); - r.register(new InlineOnlyInvocationPlugin("get0", Receiver.class) { - @Override - public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { - ValueNode offset = b.add(ConstantNode.forLong(HotSpotReplacementsUtil.referentOffset(b.getMetaAccess()))); - AddressNode address = b.add(new OffsetAddressNode(receiver.get(true), offset)); - FieldLocationIdentity locationIdentity = new FieldLocationIdentity(HotSpotReplacementsUtil.referentField(b.getMetaAccess())); - JavaReadNode read = b.add(new JavaReadNode(StampFactory.object(), JavaKind.Object, address, locationIdentity, BarrierType.REFERENCE_GET, MemoryOrderMode.PLAIN, true)); - b.add(new MembarNode(MembarNode.FenceKind.NONE, locationIdentity)); - b.addPush(JavaKind.Object, read); - return true; - } - }); r.register(new InlineOnlyInvocationPlugin("refersTo0", Receiver.class, Object.class) { @Override public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode o) { @@ -1810,7 +1812,6 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec AddressNode address = b.add(new OffsetAddressNode(receiver.get(true), offset)); FieldLocationIdentity locationIdentity = new FieldLocationIdentity(HotSpotReplacementsUtil.referentField(b.getMetaAccess())); JavaReadNode read = b.add(new JavaReadNode(StampFactory.object(), JavaKind.Object, address, locationIdentity, BarrierType.WEAK_REFERS_TO, MemoryOrderMode.PLAIN, true)); - b.add(new MembarNode(MembarNode.FenceKind.NONE, locationIdentity)); LogicNode objectEquals = b.add(ObjectEqualsNode.create(b.getConstantReflection(), b.getMetaAccess(), b.getOptions(), read, o, NodeView.DEFAULT)); b.addPush(JavaKind.Boolean, ConditionalNode.create(objectEquals, b.add(forBoolean(true)), b.add(forBoolean(false)), NodeView.DEFAULT)); return true; diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotHostForeignCallsProvider.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotHostForeignCallsProvider.java index ffe1f317f04f..483a94a160ad 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotHostForeignCallsProvider.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotHostForeignCallsProvider.java @@ -111,7 +111,6 @@ import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.LOG; import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.LOG10; import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.SIN; -import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.SINH; import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.TAN; import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.TANH; import static jdk.vm.ci.hotspot.HotSpotCallingConventionType.NativeCall; @@ -741,9 +740,6 @@ protected void registerMathStubs(GraalHotSpotVMConfig hotSpotVMConfig, HotSpotPr registerForeignCall(createDescriptor(LOG.foreignCallSignature, LEAF, NO_SIDE_EFFECT, NO_LOCATIONS), hotSpotVMConfig.arithmeticLogAddress, NativeCall); registerForeignCall(createDescriptor(LOG10.foreignCallSignature, LEAF, NO_SIDE_EFFECT, NO_LOCATIONS), hotSpotVMConfig.arithmeticLog10Address, NativeCall); registerForeignCall(createDescriptor(POW.foreignCallSignature, LEAF, NO_SIDE_EFFECT, NO_LOCATIONS), hotSpotVMConfig.arithmeticPowAddress, NativeCall); - if (hotSpotVMConfig.arithmeticSinhAddress != 0L) { - registerForeignCall(createDescriptor(SINH.foreignCallSignature, LEAF, NO_SIDE_EFFECT, NO_LOCATIONS), hotSpotVMConfig.arithmeticSinhAddress, NativeCall); - } if (hotSpotVMConfig.arithmeticTanhAddress != 0L) { registerForeignCall(createDescriptor(TANH.foreignCallSignature, LEAF, NO_SIDE_EFFECT, NO_LOCATIONS), hotSpotVMConfig.arithmeticTanhAddress, NativeCall); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotPlatformConfigurationProvider.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotPlatformConfigurationProvider.java index 8c33ff12857d..f5ac6a18aca2 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotPlatformConfigurationProvider.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotPlatformConfigurationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, 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 @@ -25,6 +25,7 @@ package jdk.graal.compiler.hotspot.meta; import jdk.graal.compiler.hotspot.GraalHotSpotVMConfig; +import jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil; import jdk.graal.compiler.nodes.gc.BarrierSet; import jdk.graal.compiler.nodes.spi.PlatformConfigurationProvider; @@ -33,9 +34,12 @@ public class HotSpotPlatformConfigurationProvider implements PlatformConfigurati private final boolean canVirtualizeLargeByteArrayAccess; + private final boolean useLightweightLocking; + public HotSpotPlatformConfigurationProvider(GraalHotSpotVMConfig config, BarrierSet barrierSet) { this.barrierSet = barrierSet; this.canVirtualizeLargeByteArrayAccess = config.deoptimizationSupportLargeAccessByteArrayVirtualization; + this.useLightweightLocking = HotSpotReplacementsUtil.useLightweightLocking(config); } @Override @@ -45,7 +49,7 @@ public boolean canVirtualizeLargeByteArrayAccess() { @Override public boolean requiresStrictLockOrder() { - return true; + return useLightweightLocking; } @Override diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/UnimplementedGraalIntrinsics.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/UnimplementedGraalIntrinsics.java index 49da510e9a1e..9eb14fa71905 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/UnimplementedGraalIntrinsics.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/UnimplementedGraalIntrinsics.java @@ -87,6 +87,8 @@ private static void add(Collection c, String... elements) { public UnimplementedGraalIntrinsics(Architecture arch) { add(toBeInvestigated, // @formatter:off + // JDK-8360559: Optimize Math.sinh for x86 64 bit platforms + "java/lang/Math.sinh(D)D", // JDK-8342103: C2 compiler support for Float16 type and associated // scalar operations "jdk/internal/vm/vector/Float16Math.fma(Ljava/lang/Class;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljdk/internal/vm/vector/Float16Math$TernaryOperator;)Ljava/lang/Object;", @@ -95,11 +97,11 @@ public UnimplementedGraalIntrinsics(Architecture arch) { // JDK-8353786: Migrate Vector API math library support to FFM API "jdk/internal/vm/vector/VectorSupport.libraryBinaryOp(JLjava/lang/Class;Ljava/lang/Class;ILjava/lang/String;Ljdk/internal/vm/vector/VectorSupport$VectorPayload;Ljdk/internal/vm/vector/VectorSupport$VectorPayload;Ljdk/internal/vm/vector/VectorSupport$BinaryOperation;)Ljdk/internal/vm/vector/VectorSupport$VectorPayload;", "jdk/internal/vm/vector/VectorSupport.libraryUnaryOp(JLjava/lang/Class;Ljava/lang/Class;ILjava/lang/String;Ljdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$UnaryOperation;)Ljdk/internal/vm/vector/VectorSupport$Vector;", - "jdk/internal/vm/vector/VectorSupport.loadWithMap(Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;ILjava/lang/Class;ILjava/lang/Object;JLjdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$VectorMask;Ljava/lang/Object;I[IILjdk/internal/vm/vector/VectorSupport$VectorSpecies;Ljdk/internal/vm/vector/VectorSupport$LoadVectorOperationWithMap;)Ljdk/internal/vm/vector/VectorSupport$Vector;", + "jdk/internal/vm/vector/VectorSupport.loadWithMap(Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;ILjava/lang/Class;Ljava/lang/Object;JLjdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$VectorMask;Ljava/lang/Object;I[IILjdk/internal/vm/vector/VectorSupport$VectorSpecies;Ljdk/internal/vm/vector/VectorSupport$LoadVectorOperationWithMap;)Ljdk/internal/vm/vector/VectorSupport$Vector;", "jdk/internal/vm/vector/VectorSupport.maybeRebox(Ljdk/internal/vm/vector/VectorSupport$VectorPayload;)Ljdk/internal/vm/vector/VectorSupport$VectorPayload;", "jdk/internal/vm/vector/VectorSupport.selectFromOp(Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;ILjdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$VectorMask;Ljdk/internal/vm/vector/VectorSupport$VectorSelectFromOp;)Ljdk/internal/vm/vector/VectorSupport$Vector;", "jdk/internal/vm/vector/VectorSupport.selectFromTwoVectorOp(Ljava/lang/Class;Ljava/lang/Class;ILjdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$SelectFromTwoVector;)Ljdk/internal/vm/vector/VectorSupport$Vector;", - "jdk/internal/vm/vector/VectorSupport.storeWithMap(Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;ILjava/lang/Class;ILjava/lang/Object;JLjdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$VectorMask;Ljava/lang/Object;I[IILjdk/internal/vm/vector/VectorSupport$StoreVectorOperationWithMap;)V" + "jdk/internal/vm/vector/VectorSupport.storeWithMap(Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;ILjava/lang/Class;Ljava/lang/Object;JLjdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$VectorMask;Ljava/lang/Object;I[IILjdk/internal/vm/vector/VectorSupport$StoreVectorOperationWithMap;)V" // @formatter:on ); @@ -128,6 +130,8 @@ public UnimplementedGraalIntrinsics(Architecture arch) { // handled by an intrinsic for StringUTF16.indexOfLatin1Unsafe "java/lang/StringUTF16.indexOfLatin1([BI[BII)I", "java/lang/StringUTF16.indexOfLatin1([B[B)I", + // implemented through lowering + "java/lang/ref/Reference.get()Ljava/lang/Object;", // Relevant for Java flight recorder // [GR-10106] These JFR intrinsics are used for firing socket/file events // via Java instrumentation and are of low priority. @@ -153,8 +157,6 @@ public UnimplementedGraalIntrinsics(Architecture arch) { add(ignore, // JDK-8355644 "java/lang/Math.cbrt(D)D", - // JDK-8360559 - "java/lang/Math.sinh(D)D", // JDK-8338694 "java/lang/Math.tanh(D)D", // JDK-8309130 diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/nodes/HotSpotCompressionNode.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/nodes/HotSpotCompressionNode.java index 790cc1d7ec20..72ec01582775 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/nodes/HotSpotCompressionNode.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/nodes/HotSpotCompressionNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -44,6 +44,7 @@ import jdk.vm.ci.meta.Constant; import jdk.vm.ci.meta.ConstantReflectionProvider; import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.ResolvedJavaType; @NodeInfo(nameTemplate = "{p#op/s}", cycles = CYCLES_2, size = SIZE_2) public final class HotSpotCompressionNode extends CompressionNode { @@ -81,7 +82,9 @@ private static CompressionNode uncompress(ValueNode input, CompressEncoding enco @Override public boolean isCompressible(Constant constant) { if (constant instanceof HotSpotMetaspaceConstant mc) { - return mc.isCompressible(); + ResolvedJavaType type = mc.asResolvedJavaType(); + // As of JDK-8338526, interface and abstract types are not compressible. + return type.isArray() || (!type.isAbstract() && !type.isInterface()); } return true; } @@ -108,10 +111,14 @@ protected Constant uncompress(Constant c) { @Override public ValueNode reverse(ValueNode input) { - return switch (op) { - case Compress -> uncompress(input, encoding); - case Uncompress -> compress(input, encoding); - }; + switch (op) { + case Compress: + return uncompress(input, encoding); + case Uncompress: + return compress(input, encoding); + default: + throw GraalError.shouldNotReachHereUnexpectedValue(op); // ExcludeFromJacocoGeneratedReport + } } @Override diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotHashCodeSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotHashCodeSnippets.java index 41f25813ff4f..cd78efdfa901 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotHashCodeSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotHashCodeSnippets.java @@ -34,6 +34,8 @@ import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.markWordLockMaskInPlace; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.monitorValue; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.uninitializedIdentityHashCodeValue; +import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.unlockedValue; +import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.useLightweightLocking; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.useObjectMonitorTable; import static jdk.graal.compiler.nodes.extended.BranchProbabilityNode.FAST_PATH_PROBABILITY; import static jdk.graal.compiler.nodes.extended.BranchProbabilityNode.probability; @@ -73,7 +75,9 @@ protected int computeIdentityHashCode(final Object x) { // // See src/hotspot/share/oops/markWord.hpp for more details. final Word lockBits = mark.and(Word.unsigned(markWordLockMaskInPlace(INJECTED_VMCONFIG))); - if (useObjectMonitorTable(INJECTED_VMCONFIG) || probability(FAST_PATH_PROBABILITY, lockBits.notEqual(Word.unsigned(monitorValue(INJECTED_VMCONFIG))))) { + if (useObjectMonitorTable(INJECTED_VMCONFIG) || probability(FAST_PATH_PROBABILITY, + useLightweightLocking(INJECTED_VMCONFIG) ? lockBits.notEqual(Word.unsigned(monitorValue(INJECTED_VMCONFIG))) + : lockBits.equal(Word.unsigned(unlockedValue(INJECTED_VMCONFIG))))) { // `& markWord::hash_mask' is essential with -XX:+UseCompactObjectHeaders, because bit // 42 might be set. int hash = (int) mark.unsignedShiftRight(markWordHashCodeShift(INJECTED_VMCONFIG)).and((int) markWordHashMark(INJECTED_VMCONFIG)).rawValue(); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotReplacementsUtil.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotReplacementsUtil.java index 99b63e917cec..d6ff8f1acbe9 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotReplacementsUtil.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/HotSpotReplacementsUtil.java @@ -363,6 +363,11 @@ public static int wordSize() { return runtime().getHostJVMCIBackend().getCodeCache().getTarget().wordSize; } + @Fold + public static int pageSize(@InjectedParameter GraalHotSpotVMConfig config) { + return config.vmPageSize; + } + public static final LocationIdentity PROTOTYPE_MARK_WORD_LOCATION = NamedLocationIdentity.mutable("PrototypeMarkWord"); public static final LocationIdentity KLASS_ACCESS_FLAGS_LOCATION = NamedLocationIdentity.immutable("Klass::_access_flags"); @@ -530,6 +535,16 @@ public static void initializeObjectHeader(Word memory, Word markWord, KlassPoint } } + @Fold + public static boolean useStackLocking(@InjectedParameter GraalHotSpotVMConfig config) { + return config.lockingMode == config.lockingModeStack; + } + + @Fold + public static boolean useLightweightLocking(@InjectedParameter GraalHotSpotVMConfig config) { + return config.lockingMode == config.lockingModeLightweight; + } + @Fold public static boolean useObjectMonitorTable(@InjectedParameter GraalHotSpotVMConfig config) { return config.useObjectMonitorTable; @@ -545,6 +560,11 @@ public static int monitorValue(@InjectedParameter GraalHotSpotVMConfig config) { return config.monitorValue; } + @Fold + public static int unusedMark(@InjectedParameter GraalHotSpotVMConfig config) { + return config.unusedMark; + } + @Fold public static int objectMonitorOwnerOffset(@InjectedParameter GraalHotSpotVMConfig config) { return config.objectMonitorOwner; @@ -775,6 +795,11 @@ public static int lockMetadataOffset(@InjectedParameter GraalHotSpotVMConfig con return config.basicLockMetadataOffset; } + @Fold + static int heldMonitorCountOffset(@InjectedParameter GraalHotSpotVMConfig config) { + return config.threadHeldMonitorCountOffset; + } + @Fold static int javaThreadMonitorOwnerIDOffset(@InjectedParameter GraalHotSpotVMConfig config) { return config.javaThreadMonitorOwnerIDOffset; diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/MonitorSnippets.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/MonitorSnippets.java index 8f17ebeab8b5..dbc2c93a1c50 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/MonitorSnippets.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replacements/MonitorSnippets.java @@ -48,6 +48,7 @@ import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.OBJECT_MONITOR_STACK_LOCKER_LOCATION; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.OBJECT_MONITOR_SUCC_LOCATION; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.diagnoseSyncOnValueBasedClasses; +import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.heldMonitorCountOffset; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.isCAssertEnabled; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.javaThreadLockStackEndOffset; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.javaThreadLockStackTopOffset; @@ -67,9 +68,13 @@ import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.objectMonitorSuccOffset; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.omCacheOopToMonitorDifference; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.omCacheOopToOopDifference; +import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.pageSize; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.unlockedValue; +import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.unusedMark; +import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.useLightweightLocking; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.useObjectMonitorTable; +import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.useStackLocking; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.verifyOop; import static jdk.graal.compiler.hotspot.replacements.HotSpotReplacementsUtil.wordSize; import static jdk.graal.compiler.hotspot.replacements.HotspotSnippetsOptions.ProfileMonitors; @@ -79,11 +84,13 @@ import static jdk.graal.compiler.nodes.extended.BranchProbabilityNode.NOT_FREQUENT_PROBABILITY; import static jdk.graal.compiler.nodes.extended.BranchProbabilityNode.NOT_LIKELY_PROBABILITY; import static jdk.graal.compiler.nodes.extended.BranchProbabilityNode.SLOW_PATH_PROBABILITY; +import static jdk.graal.compiler.nodes.extended.BranchProbabilityNode.VERY_FAST_PATH_PROBABILITY; import static jdk.graal.compiler.nodes.extended.BranchProbabilityNode.probability; import static jdk.graal.compiler.nodes.extended.MembarNode.memoryBarrier; import static jdk.graal.compiler.replacements.SnippetTemplate.DEFAULT_REPLACER; import static jdk.graal.compiler.replacements.nodes.CStringConstant.cstring; import static jdk.graal.compiler.word.Word.nullPointer; +import static jdk.graal.compiler.word.Word.unsigned; import static jdk.graal.compiler.word.Word.zero; import static org.graalvm.word.LocationIdentity.any; @@ -107,6 +114,7 @@ import jdk.graal.compiler.graph.Node.ConstantNodeParameter; import jdk.graal.compiler.graph.Node.NodeIntrinsic; import jdk.graal.compiler.graph.iterators.NodeIterable; +import jdk.graal.compiler.hotspot.GraalHotSpotVMConfig; import jdk.graal.compiler.hotspot.meta.HotSpotForeignCallDescriptor; import jdk.graal.compiler.hotspot.meta.HotSpotProviders; import jdk.graal.compiler.hotspot.meta.HotSpotRegistersProvider; @@ -199,6 +207,12 @@ // @formatter:off @SyncPort(from = "https://github.com/openjdk/jdk/blob/c2d76f9844aadf77a0b213a9169a7c5c8c8f1ffb/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L149-L578", sha1 = "ee04c86e8b12a9f8331c5e79f95a17b27615c845") +@SyncPort(from = "https://github.com/openjdk/jdk/blob/9eeb86d972ac4cc38d923b2b868b426bbd27a4e8/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L465-L625", + sha1 = "2d66e0ccf8dbf69f575be2633d5a17f77a20131d") +@SyncPort(from = "https://github.com/openjdk/jdk/blob/250eb743c112fbcc45bf2b3ded1c644b19893577/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L627-L788", + sha1 = "e88d7b8c4bb85358c6a810ee1d7d92fde5db42e6") +@SyncPort(from = "https://github.com/openjdk/jdk/blob/c2d76f9844aadf77a0b213a9169a7c5c8c8f1ffb/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L149-L455", + sha1 = "223a88b7bdd10862cd3b112181e1d17682b0fbe2") // @formatter:on public class MonitorSnippets implements Snippets { @@ -252,8 +266,10 @@ public static void monitorenter(Object object, KlassPointer hub, @ConstantParame } } - if (!tryLightweightLocking(object, lock, mark, thread, trace, counters, stackPointerRegister)) { - if (synthetic) { + if (tryFastPathLocking(object, stackPointerRegister, trace, counters, mark, lock, thread)) { + maybeUpdateHeldMonitorCount(thread, 1); + } else { + if (synthetic && (useLightweightLocking(INJECTED_VMCONFIG) || useStackLocking(INJECTED_VMCONFIG))) { // The fast locking cases are never permitted to use the slow path. throw UnreachableNode.unreachable(); } else { @@ -263,6 +279,20 @@ public static void monitorenter(Object object, KlassPointer hub, @ConstantParame } } + /** + * Dispatch to the appropriate locking strategy based on the {@code LockingMode} flag value. + */ + private static boolean tryFastPathLocking(Object object, Register stackPointerRegister, boolean trace, Counters counters, Word mark, Word lock, Word thread) { + if (useLightweightLocking(INJECTED_VMCONFIG)) { + return tryLightweightLocking(object, lock, mark, thread, trace, counters, stackPointerRegister); + } else if (useStackLocking(INJECTED_VMCONFIG)) { + return tryStackLocking(object, lock, mark, thread, trace, counters, stackPointerRegister); + } else { + // LM_MONITOR case + return false; + } + } + // Cache the monitor for unlock private static void writeMonitorCache(Word lock, Word monitor) { if (useObjectMonitorTable(INJECTED_VMCONFIG)) { @@ -344,6 +374,69 @@ private static boolean tryEnterInflated(Object object, Word lock, Word mark, Wor return false; } + private static boolean tryStackLocking(Object object, Word lock, Word mark, Word thread, boolean trace, Counters counters, Register stackPointerRegister) { + if (probability(SLOW_PATH_PROBABILITY, mark.and(monitorValue(INJECTED_VMCONFIG)).notEqual(0))) { + // Inflated case + // Set the lock slot's displaced mark to unused. Any non-0 value suffices. + lock.writeWord(lockMetadataOffset(INJECTED_VMCONFIG), Word.unsigned(unusedMark(INJECTED_VMCONFIG)), BASICLOCK_METADATA_LOCATION); + return tryEnterInflated(object, lock, mark, thread, trace, counters); + } + + Pointer objectPointer = Word.objectToTrackedPointer(object); + + // Create the unlocked mark word pattern + Word unlockedMark = mark.or(unlockedValue(INJECTED_VMCONFIG)); + trace(trace, " unlockedMark: 0x%016lx\n", unlockedMark); + + // Copy this unlocked mark word into the lock slot on the stack + lock.writeWord(lockMetadataOffset(INJECTED_VMCONFIG), unlockedMark, BASICLOCK_METADATA_LOCATION); + + // Test if the object's mark word is unlocked, and if so, store the (address of) the + // lock slot into the object's mark word. + // + // Since pointer cas operations are volatile accesses, previous stores cannot float + // below it. + Word currentMark = objectPointer.compareAndSwapWord(markOffset(INJECTED_VMCONFIG), unlockedMark, lock, MARK_WORD_LOCATION); + if (probability(FAST_PATH_PROBABILITY, currentMark.equal(unlockedMark))) { + traceObject(trace, "+lock{stack:cas}", object, true); + counters.lockFastCas.inc(); + return true; + } else { + trace(trace, " currentMark: 0x%016lx\n", currentMark); + // The mark word in the object header was not the same. + // Either the object is locked by another thread or is already locked + // by the current thread. The latter is true if the mark word + // is a stack pointer into the current thread's stack, i.e.: + // + // 1) (currentMark & aligned_mask) == 0 + // 2) rsp <= currentMark + // 3) currentMark <= rsp + page_size + // + // These 3 tests can be done by evaluating the following expression: + // + // (currentMark - rsp) & (aligned_mask - page_size) + // + // assuming both the stack pointer and page_size have their least + // significant 2 bits cleared and page_size is a power of 2 + final Word alignedMask = unsigned(wordSize() - 1); + final Word stackPointer = registerAsWord(stackPointerRegister); + if (probability(FAST_PATH_PROBABILITY, currentMark.subtract(stackPointer).and(alignedMask.subtract(pageSize(INJECTED_VMCONFIG))).equal(0))) { + // Recursively locked => write 0 to the lock slot + lock.writeWord(lockMetadataOffset(INJECTED_VMCONFIG), zero(), BASICLOCK_METADATA_LOCATION); + traceObject(trace, "+lock{stack:recursive}", object, true); + counters.lockFastRecursive.inc(); + return true; + } + traceObject(trace, "+lock{stack:failed-cas}", object, true); + counters.lockFastFailedCas.inc(); + } + return false; + } + + // @formatter:off + @SyncPort(from = "https://github.com/openjdk/jdk/blob/c2d76f9844aadf77a0b213a9169a7c5c8c8f1ffb/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L457-L617", + sha1 = "2d66e0ccf8dbf69f575be2633d5a17f77a20131d") + // @formatter:on @SuppressWarnings("unused") private static boolean tryLightweightLocking(Object object, Word lock, Word mark, Word thread, boolean trace, Counters counters, Register stackPointerRegister) { writeMonitorCache(lock, Word.nullPointer()); @@ -416,13 +509,62 @@ public static void monitorexit(Object object, @ConstantParameter int lockDepth, trace(trace, " object: 0x%016lx\n", Word.objectToTrackedPointer(object)); trace(trace, " lock: 0x%016lx\n", lock); - if (!tryLightweightUnlocking(object, thread, lock, trace, counters)) { + if (tryFastPathUnlocking(object, trace, counters, thread, lock)) { + maybeUpdateHeldMonitorCount(thread, -1); + } else { monitorexitStubC(MONITOREXIT, object, lock); } endLockScope(); decCounter(); } + /** + * Dispatch to the appropriate unlocking strategy based on the {@code LockingMode} flag value. + */ + private static boolean tryFastPathUnlocking(Object object, boolean trace, Counters counters, Word thread, Word lock) { + if (useLightweightLocking(INJECTED_VMCONFIG)) { + return tryLightweightUnlocking(object, thread, lock, trace, counters); + } else if (useStackLocking(INJECTED_VMCONFIG)) { + return tryStackUnlocking(object, thread, lock, trace, counters); + } else { + // LM_MONITOR case, i.e., use heavy monitor directly + return false; + } + } + + private static boolean tryStackUnlocking(Object object, Word thread, Word lock, boolean trace, Counters counters) { + final Word displacedMark = lock.readWord(lockMetadataOffset(INJECTED_VMCONFIG), BASICLOCK_METADATA_LOCATION); + + if (probability(NOT_LIKELY_PROBABILITY, displacedMark.equal(0))) { + // Recursive locking => done + traceObject(trace, "-lock{stack:recursive}", object, false); + counters.unlockFastRecursive.inc(); + return true; + } + + Word mark = loadWordFromObject(object, markOffset(INJECTED_VMCONFIG)); + + if (probability(SLOW_PATH_PROBABILITY, mark.and(monitorValue(INJECTED_VMCONFIG)).notEqual(0))) { + return tryExitInflated(object, mark, thread, lock, trace, counters); + } + + if (probability(VERY_FAST_PATH_PROBABILITY, Word.objectToTrackedPointer(object).logicCompareAndSwapWord(markOffset(INJECTED_VMCONFIG), + lock, displacedMark, MARK_WORD_LOCATION))) { + traceObject(trace, "-lock{stack:cas}", object, false); + counters.unlockFastCas.inc(); + return true; + } + + // The object's mark word was not pointing to the displaced header + traceObject(trace, "-lock{stack:failed-cas}", object, false); + counters.unlockFastFailedCas.inc(); + return false; + } + + // @formatter:off + @SyncPort(from = "https://github.com/openjdk/jdk/blob/c2d76f9844aadf77a0b213a9169a7c5c8c8f1ffb/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp#L619-L780", + sha1 = "e88d7b8c4bb85358c6a810ee1d7d92fde5db42e6") + // @formatter:on private static boolean tryLightweightUnlocking(Object object, Word thread, Word lock, boolean trace, Counters counters) { // Load top Word lockStackTop = Word.unsigned(thread.readInt(javaThreadLockStackTopOffset(INJECTED_VMCONFIG), JAVA_THREAD_LOCK_STACK_TOP_LOCATION)); @@ -536,6 +678,13 @@ private static boolean tryExitInflated(Object object, Word mark, Word thread, Wo return false; } + private static void maybeUpdateHeldMonitorCount(Word thread, int increment) { + if (useStackLocking(INJECTED_VMCONFIG)) { + Word heldMonitorCount = thread.readWord(heldMonitorCountOffset(INJECTED_VMCONFIG), JAVA_THREAD_HOLD_MONITOR_COUNT_LOCATION); + thread.writeWord(heldMonitorCountOffset(INJECTED_VMCONFIG), heldMonitorCount.add(increment), JAVA_THREAD_HOLD_MONITOR_COUNT_LOCATION); + } + } + @Fold static boolean doProfile(@Fold.InjectedParameter OptionValues options) { return ProfileMonitors.getValue(options); @@ -650,28 +799,49 @@ public static class Templates extends AbstractTemplates { public final Counters counters; + private final boolean requiresStrictLockOrder; + @SuppressWarnings("this-escape") - public Templates(OptionValues options, SnippetCounter.Group.Factory factory, HotSpotProviders providers) { + public Templates(OptionValues options, SnippetCounter.Group.Factory factory, HotSpotProviders providers, GraalHotSpotVMConfig config) { super(options, providers); - LocationIdentity[] enterLocations = new LocationIdentity[]{ - JAVA_THREAD_LOCK_STACK_LOCATION, - JAVA_THREAD_LOCK_STACK_TOP_LOCATION, - JAVA_THREAD_OM_CACHE_LOCATION, - JAVA_THREAD_HOLD_MONITOR_COUNT_LOCATION, - JAVA_THREAD_MONITOR_OWNER_ID_LOCATION}; - LocationIdentity[] exitLocations = new LocationIdentity[]{ - JAVA_THREAD_LOCK_STACK_LOCATION, - JAVA_THREAD_LOCK_STACK_TOP_LOCATION, - BASICLOCK_METADATA_LOCATION, - OBJECT_MONITOR_OWNER_LOCATION, - OBJECT_MONITOR_CXQ_LOCATION, - OBJECT_MONITOR_ENTRY_LIST_LOCATION, - OBJECT_MONITOR_RECURSION_LOCATION, - OBJECT_MONITOR_SUCC_LOCATION, - OBJECT_MONITOR_STACK_LOCKER_LOCATION, - MARK_WORD_LOCATION, - JAVA_THREAD_HOLD_MONITOR_COUNT_LOCATION}; + LocationIdentity[] enterLocations; + LocationIdentity[] exitLocations; + + if (useLightweightLocking(config)) { + enterLocations = new LocationIdentity[]{ + JAVA_THREAD_LOCK_STACK_LOCATION, + JAVA_THREAD_LOCK_STACK_TOP_LOCATION, + JAVA_THREAD_OM_CACHE_LOCATION, + JAVA_THREAD_HOLD_MONITOR_COUNT_LOCATION, + JAVA_THREAD_MONITOR_OWNER_ID_LOCATION}; + exitLocations = new LocationIdentity[]{ + JAVA_THREAD_LOCK_STACK_LOCATION, + JAVA_THREAD_LOCK_STACK_TOP_LOCATION, + BASICLOCK_METADATA_LOCATION, + OBJECT_MONITOR_OWNER_LOCATION, + OBJECT_MONITOR_CXQ_LOCATION, + OBJECT_MONITOR_ENTRY_LIST_LOCATION, + OBJECT_MONITOR_RECURSION_LOCATION, + OBJECT_MONITOR_SUCC_LOCATION, + OBJECT_MONITOR_STACK_LOCKER_LOCATION, + MARK_WORD_LOCATION, + JAVA_THREAD_HOLD_MONITOR_COUNT_LOCATION}; + } else { + enterLocations = new LocationIdentity[]{ + JAVA_THREAD_HOLD_MONITOR_COUNT_LOCATION, + JAVA_THREAD_MONITOR_OWNER_ID_LOCATION}; + exitLocations = new LocationIdentity[]{ + BASICLOCK_METADATA_LOCATION, + OBJECT_MONITOR_OWNER_LOCATION, + OBJECT_MONITOR_CXQ_LOCATION, + OBJECT_MONITOR_ENTRY_LIST_LOCATION, + OBJECT_MONITOR_RECURSION_LOCATION, + OBJECT_MONITOR_SUCC_LOCATION, + OBJECT_MONITOR_STACK_LOCKER_LOCATION, + MARK_WORD_LOCATION, + JAVA_THREAD_HOLD_MONITOR_COUNT_LOCATION}; + } this.checkMonitorenter = snippet(providers, MonitorSnippets.class, "checkMonitorenter", enterLocations); this.monitorenter = snippet(providers, MonitorSnippets.class, "monitorenter", enterLocations); @@ -680,9 +850,12 @@ public Templates(OptionValues options, SnippetCounter.Group.Factory factory, Hot this.checkCounter = snippet(providers, MonitorSnippets.class, "checkCounter"); this.counters = new Counters(factory); + this.requiresStrictLockOrder = providers.getPlatformConfigurationProvider().requiresStrictLockOrder(); } - public void lower(CheckFastPathMonitorEnterNode checkFastPathMonitorEnterNode, HotSpotRegistersProvider registers, LoweringTool tool) { + public void lower(CheckFastPathMonitorEnterNode checkFastPathMonitorEnterNode, HotSpotRegistersProvider registers, GraalHotSpotVMConfig config, LoweringTool tool) { + GraalError.guarantee(HotSpotReplacementsUtil.useLightweightLocking(config), "should only be used with lightweight locking"); + StructuredGraph graph = checkFastPathMonitorEnterNode.graph(); Arguments args = new Arguments(checkMonitorenter, graph, tool.getLoweringStage()); // Speculation.equals is too weak so it can incorrectly cache snippet graphs so just @@ -718,17 +891,19 @@ private static boolean isVirtualLock(FrameState frameState, int lockIdx) { return false; } - private static boolean verifyLockOrder(MonitorEnterNode monitorenterNode) { - FrameState state = monitorenterNode.stateAfter(); - boolean subsequentLocksMustBeEliminated = false; - for (int lockIdx = 0; lockIdx < state.locksSize(); lockIdx++) { - if (subsequentLocksMustBeEliminated) { - if (!isVirtualLock(state, lockIdx)) { - return false; + private boolean verifyLockOrder(MonitorEnterNode monitorenterNode) { + if (requiresStrictLockOrder) { + FrameState state = monitorenterNode.stateAfter(); + boolean subsequentLocksMustBeEliminated = false; + for (int lockIdx = 0; lockIdx < state.locksSize(); lockIdx++) { + if (subsequentLocksMustBeEliminated) { + if (!isVirtualLock(state, lockIdx)) { + return false; + } + } + if (state.monitorIdAt(lockIdx) == monitorenterNode.getMonitorId()) { + subsequentLocksMustBeEliminated = true; } - } - if (state.monitorIdAt(lockIdx) == monitorenterNode.getMonitorId()) { - subsequentLocksMustBeEliminated = true; } } return true; @@ -774,7 +949,7 @@ public static boolean isTracingEnabledForType(ValueNode object) { if (filter == null) { return false; } else { - if (filter.isEmpty()) { + if (filter.length() == 0) { return true; } if (type == null) { @@ -789,7 +964,7 @@ public static boolean isTracingEnabledForMethod(StructuredGraph graph) { if (filter == null) { return false; } else { - if (filter.isEmpty()) { + if (filter.length() == 0) { return true; } if (graph.method() == null) { diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64SpinWaitOp.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64SpinWaitOp.java index 14b3f7bcc505..2b4df6705d2e 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64SpinWaitOp.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64SpinWaitOp.java @@ -28,10 +28,10 @@ import jdk.graal.compiler.asm.aarch64.AArch64MacroAssembler; import jdk.graal.compiler.debug.GraalError; -import jdk.graal.compiler.lir.asm.CompilationResultBuilder; import jdk.graal.compiler.lir.LIRInstructionClass; import jdk.graal.compiler.lir.Opcode; import jdk.graal.compiler.lir.SyncPort; +import jdk.graal.compiler.lir.asm.CompilationResultBuilder; /** * Emits spin wait instruction(s). @@ -41,6 +41,10 @@ sha1 = "874fea5e6191c9c19947b4dc818a434a24b33358") @SyncPort(from = "https://github.com/openjdk/jdk/blob/23985c29b44b489472dcd3aad2cb98d9ce003a7b/src/hotspot/cpu/aarch64/spin_wait_aarch64.cpp#L38-L52", sha1 = "9a1f313aa92ab513f5e8cd20fd3b037469455b77") +@SyncPort(from = "https://github.com/openjdk/jdk/blob/ecd2d83096a1fea7d5086736306770bcffa4fdb6/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp#L53-L74", + sha1 = "6bd5ba27c0b3a8416ee5d8d495a55d86cfe1fad1") +@SyncPort(from = "https://github.com/openjdk/jdk/blob/98a93e115137a305aed6b7dbf1d4a7d5906fe77c/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp#L53-L69", + sha1 = "92f81ed500658553a2ef2e7c48633094d95ba974") // @formatter:on @Opcode("SPIN_WAIT") public final class AArch64SpinWaitOp extends AArch64LIRInstruction { diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/amd64/AMD64MathSinhOp.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/amd64/AMD64MathSinhOp.java deleted file mode 100644 index 70f386ad4227..000000000000 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/amd64/AMD64MathSinhOp.java +++ /dev/null @@ -1,593 +0,0 @@ -/* - * Copyright (c) 2025, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ -package jdk.graal.compiler.lir.amd64; - -import static jdk.graal.compiler.lir.amd64.AMD64LIRHelper.pointerConstant; -import static jdk.graal.compiler.lir.amd64.AMD64LIRHelper.recordExternalAddress; -import static jdk.vm.ci.amd64.AMD64.r10; -import static jdk.vm.ci.amd64.AMD64.r11; -import static jdk.vm.ci.amd64.AMD64.r8; -import static jdk.vm.ci.amd64.AMD64.r9; -import static jdk.vm.ci.amd64.AMD64.rax; -import static jdk.vm.ci.amd64.AMD64.rcx; -import static jdk.vm.ci.amd64.AMD64.rdx; -import static jdk.vm.ci.amd64.AMD64.xmm0; -import static jdk.vm.ci.amd64.AMD64.xmm1; -import static jdk.vm.ci.amd64.AMD64.xmm2; -import static jdk.vm.ci.amd64.AMD64.xmm3; -import static jdk.vm.ci.amd64.AMD64.xmm4; -import static jdk.vm.ci.amd64.AMD64.xmm5; -import static jdk.vm.ci.amd64.AMD64.xmm6; -import static jdk.vm.ci.amd64.AMD64.xmm7; - -import jdk.graal.compiler.asm.Label; -import jdk.graal.compiler.asm.amd64.AMD64Address; -import jdk.graal.compiler.asm.amd64.AMD64Assembler.ConditionFlag; -import jdk.graal.compiler.asm.amd64.AMD64MacroAssembler; -import jdk.graal.compiler.core.common.Stride; -import jdk.graal.compiler.lir.LIRInstructionClass; -import jdk.graal.compiler.lir.SyncPort; -import jdk.graal.compiler.lir.asm.ArrayDataPointerConstant; -import jdk.graal.compiler.lir.asm.CompilationResultBuilder; - -/** - *
- *                     ALGORITHM DESCRIPTION
- *                     ---------------------
- *
- * sinh(x)=(exp(x)-exp(-x))/2
- *
- * Let |x|=xH+xL (upper 26 bits, lower 27 bits)
- * log2(e) rounded to 26 bits (high part) plus a double precision low part is
- *         L2EH+L2EL (upper 26, lower 53 bits)
- *
- * Let xH*L2EH=k+f+r`, where (k+f)*2^7=int(xH*L2EH*2^7),
- *                             f=0.b1 b2 ... b7, k integer
- * 2^f is approximated as Tp[f]+Dp[f], and 2^{-f} as Tn[f]+Dn[f]
- * Tp stores the high 53 bits, Dp stores (2^f-Tp[f]) rounded to double precision
- *
- * e^|x|=2^{k+f}*2^r, r=r`+xL*L2EH+|x|*L2EL, |r|<2^{-8}+2^{-14},
- *                      for |x| in [23/64,3*2^7)
- * e^{-|x|}=2^{-k-f}*2^{-r}
- *
- * e^|x| is approximated as 2^k*Tp+2^k*Tp*c1*r(1+c2*r+..+c5*r^4)+2^k*Dp=
- *                          =2^k*Tp+2^k*Tp*P15+2^k*Dp
- * e^{-|x|} approximated as 2^{-k}*Tn-2^{-k}*Tn*c1*r(1-c2*r+..+c5*r^4)+2^{-k}*Dn
- *
- * For |x| in [1/8, 3*2^7), sinh(x) is formed as
- *     RN(2^k*Tp-2^{-k}*Tn)+2^k*Tp*P15-2^{-k}*Tn*P`15-2^{-k}*TnL-2^{-k}*Dn+2^k*Dp
- *
- * For x in (3*2^7, 3*2^8), sign(x)*(e^|x|)/2 is returned, and
- * the result is checked for overflow.
- *
- * For |x|<23/64, a Taylor polynomial expansion is used (degree 13)
- * To reduce rounding errors, the p3*x^3 term is computed as
- *    (p3*xh^3)_high+[(p3*xl*(3*x*xh+xl^2))+(p3*xh^3)_low],
- * where x=xh+xl, (xh are the leading 17 bits of x), and
- *    (p3*xh^3)_high=RN(x+p3*xh^3)-x
- *
- * Error bound:
- *  0.51 ulp
- *
- * Special cases:
- *  sinh(NaN) = quiet NaN, and raise invalid exception
- *  sinh(+/-INF) = +/-INF
- *  sinh(+/-0) = +/-0
- * 
- */ -// @formatter:off -@SyncPort(from = "https://github.com/openjdk/jdk/blob/001aaa1e49f2692061cad44d68c9e81a27ea3b98/src/hotspot/cpu/x86/stubGenerator_x86_64_sinh.cpp#L30-L523", - sha1 = "ec41339ad6dcdce94d6e288a56c0502fa59bf5ec") -// @formatter:on -public final class AMD64MathSinhOp extends AMD64MathIntrinsicUnaryOp { - - public static final LIRInstructionClass TYPE = LIRInstructionClass.create(AMD64MathSinhOp.class); - - public AMD64MathSinhOp() { - super(TYPE, /* GPR */ rax, rcx, rdx, r8, r9, r10, r11, - /* XMM */ xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7); - } - - private static ArrayDataPointerConstant halfMask = pointerConstant(16, new int[]{ - // @formatter:off - 0xF8000000, 0x7FFFFFFF - // @formatter:on - }); - - private static ArrayDataPointerConstant mask3 = pointerConstant(16, new int[]{ - // @formatter:off - 0x00000000, 0xFFFFFFF0, 0x00000000, 0xFFFFFFF0 - // @formatter:on - }); - - private static ArrayDataPointerConstant l2E = pointerConstant(16, new int[]{ - // @formatter:off - 0x60000000, 0x40671547 - // @formatter:on - }); - - private static ArrayDataPointerConstant l2E8 = pointerConstant(16, new int[]{ - // @formatter:off - 0xF85DDF44, 0x3EC4AE0B - // @formatter:on - }); - - private static ArrayDataPointerConstant shifter = pointerConstant(16, new int[]{ - // @formatter:off - 0x00000000, 0x43380000, 0x00000000, 0xC3380000 - // @formatter:on - }); - - private static ArrayDataPointerConstant cv = pointerConstant(16, new int[]{ - // @formatter:off - 0xD704A0C0, 0x3E3C6B08, 0xD704A0C0, 0xBE3C6B08, - // @formatter:on - }); - - private static ArrayDataPointerConstant cv16 = pointerConstant(16, new int[]{ - // @formatter:off - 0xFEFA39EF, 0x3F662E42, 0xFEFA39EF, 0xBF662E42, - // @formatter:on - }); - - private static ArrayDataPointerConstant cv32 = pointerConstant(16, new int[]{ - // @formatter:off - 0x7F907D8B, 0x3D9F8445, 0x7F907D8B, 0x3D9F8445, - // @formatter:on - }); - - private static ArrayDataPointerConstant cv48 = pointerConstant(16, new int[]{ - // @formatter:off - 0xFFAC83B4, 0x3ED47FD3, 0xFFAC83B4, 0x3ED47FD3, - // @formatter:on - }); - - private static ArrayDataPointerConstant cv64 = pointerConstant(16, new int[]{ - // @formatter:off - 0xFEFA39EF, 0x3F762E42, 0xFEFA39EF, 0x3F762E42 - // @formatter:on - }); - - private static ArrayDataPointerConstant pv = pointerConstant(16, new int[]{ - // @formatter:off - 0x13A86D08, 0x3DE61246, 0xA556C732, 0x3EC71DE3, - // @formatter:on - }); - - private static ArrayDataPointerConstant pv16 = pointerConstant(16, new int[]{ - // @formatter:off - 0x11111111, 0x3F811111, 0x55555555, 0x3FC55555, - // @formatter:on - }); - - private static ArrayDataPointerConstant pv32 = pointerConstant(16, new int[]{ - // @formatter:off - 0x67F544E1, 0x3E5AE645, 0x1A01A019, 0x3F2A01A0 - // @formatter:on - }); - - private static ArrayDataPointerConstant t2F = pointerConstant(16, new int[]{ - // @formatter:off - 0x00000000, 0x3FF00000, 0x00000000, 0x00000000, 0xA9FB3335, 0x3FF0163D, - 0x9AB8CDB7, 0x3C9B6129, 0x3E778061, 0x3FF02C9A, 0x535B085D, 0xBC719083, - 0xE86E7F85, 0x3FF04315, 0x1977C96E, 0xBC90A31C, 0xD3158574, 0x3FF059B0, - 0xA475B465, 0x3C8D73E2, 0x29DDF6DE, 0x3FF0706B, 0xE2B13C27, 0xBC8C91DF, - 0x18759BC8, 0x3FF08745, 0x4BB284FF, 0x3C6186BE, 0xCAC6F383, 0x3FF09E3E, - 0x18316136, 0x3C914878, 0x6CF9890F, 0x3FF0B558, 0x4ADC610B, 0x3C98A62E, - 0x2B7247F7, 0x3FF0CC92, 0x16E24F71, 0x3C901EDC, 0x32D3D1A2, 0x3FF0E3EC, - 0x27C57B52, 0x3C403A17, 0xAFFED31B, 0x3FF0FB66, 0xC44EBD7B, 0xBC6B9BED, - 0xD0125B51, 0x3FF11301, 0x39449B3A, 0xBC96C510, 0xC06C31CC, 0x3FF12ABD, - 0xB36CA5C7, 0xBC51B514, 0xAEA92DE0, 0x3FF1429A, 0x9AF1369E, 0xBC932FBF, - 0xC8A58E51, 0x3FF15A98, 0xB9EEAB0A, 0x3C82406A, 0x3C7D517B, 0x3FF172B8, - 0xB9D78A76, 0xBC819041, 0x388C8DEA, 0x3FF18AF9, 0xD1970F6C, 0xBC911023, - 0xEB6FCB75, 0x3FF1A35B, 0x7B4968E4, 0x3C8E5B4C, 0x84045CD4, 0x3FF1BBE0, - 0x352EF607, 0xBC995386, 0x3168B9AA, 0x3FF1D487, 0x00A2643C, 0x3C9E016E, - 0x22FCD91D, 0x3FF1ED50, 0x027BB78C, 0xBC91DF98, 0x88628CD6, 0x3FF2063B, - 0x814A8495, 0x3C8DC775, 0x917DDC96, 0x3FF21F49, 0x9494A5EE, 0x3C82A97E, - 0x6E756238, 0x3FF2387A, 0xB6C70573, 0x3C99B07E, 0x4FB2A63F, 0x3FF251CE, - 0xBEF4F4A4, 0x3C8AC155, 0x65E27CDD, 0x3FF26B45, 0x9940E9D9, 0x3C82BD33, - 0xE1F56381, 0x3FF284DF, 0x8C3F0D7E, 0xBC9A4C3A, 0xF51FDEE1, 0x3FF29E9D, - 0xAFAD1255, 0x3C8612E8, 0xD0DAD990, 0x3FF2B87F, 0xD6381AA4, 0xBC410ADC, - 0xA6E4030B, 0x3FF2D285, 0x54DB41D5, 0x3C900247, 0xA93E2F56, 0x3FF2ECAF, - 0x45D52383, 0x3C71CA0F, 0x0A31B715, 0x3FF306FE, 0xD23182E4, 0x3C86F46A, - 0xFC4CD831, 0x3FF32170, 0x8E18047C, 0x3C8A9CE7, 0xB26416FF, 0x3FF33C08, - 0x843659A6, 0x3C932721, 0x5F929FF1, 0x3FF356C5, 0x5C4E4628, 0xBC8B5CEE, - 0x373AA9CB, 0x3FF371A7, 0xBF42EAE2, 0xBC963AEA, 0x6D05D866, 0x3FF38CAE, - 0x3C9904BD, 0xBC9E958D, 0x34E59FF7, 0x3FF3A7DB, 0xD661F5E3, 0xBC75E436, - 0xC313A8E5, 0x3FF3C32D, 0x375D29C3, 0xBC9EFFF8, 0x4C123422, 0x3FF3DEA6, - 0x11F09EBC, 0x3C8ADA09, 0x04AC801C, 0x3FF3FA45, 0xF956F9F3, 0xBC97D023, - 0x21F72E2A, 0x3FF4160A, 0x1C309278, 0xBC5EF369, 0xD950A897, 0x3FF431F5, - 0xE35F7999, 0xBC81C7DD, 0x6061892D, 0x3FF44E08, 0x04EF80D0, 0x3C489B7A, - 0xED1D0057, 0x3FF46A41, 0xD1648A76, 0x3C9C944B, 0xB5C13CD0, 0x3FF486A2, - 0xB69062F0, 0x3C73C1A3, 0xF0D7D3DE, 0x3FF4A32A, 0xF3D1BE56, 0x3C99CB62, - 0xD5362A27, 0x3FF4BFDA, 0xAFEC42E2, 0x3C7D4397, 0x99FDDD0D, 0x3FF4DCB2, - 0xBC6A7833, 0x3C98ECDB, 0x769D2CA7, 0x3FF4F9B2, 0xD25957E3, 0xBC94B309, - 0xA2CF6642, 0x3FF516DA, 0x69BD93EF, 0xBC8F7685, 0x569D4F82, 0x3FF5342B, - 0x1DB13CAD, 0xBC807ABE, 0xCA5D920F, 0x3FF551A4, 0xEFEDE59B, 0xBC8D689C, - 0x36B527DA, 0x3FF56F47, 0x011D93AD, 0x3C99BB2C, 0xD497C7FD, 0x3FF58D12, - 0x5B9A1DE8, 0x3C8295E1, 0xDD485429, 0x3FF5AB07, 0x054647AD, 0x3C96324C, - 0x8A5946B7, 0x3FF5C926, 0x816986A2, 0x3C3C4B1B, 0x15AD2148, 0x3FF5E76F, - 0x3080E65E, 0x3C9BA6F9, 0xB976DC09, 0x3FF605E1, 0x9B56DE47, 0xBC93E242, - 0xB03A5585, 0x3FF6247E, 0x7E40B497, 0xBC9383C1, 0x34CCC320, 0x3FF64346, - 0x759D8933, 0xBC8C483C, 0x82552225, 0x3FF66238, 0x87591C34, 0xBC9BB609, - 0xD44CA973, 0x3FF68155, 0x44F73E65, 0x3C6038AE, 0x667F3BCD, 0x3FF6A09E, - 0x13B26456, 0xBC9BDD34, 0x750BDABF, 0x3FF6C012, 0x67FF0B0D, 0xBC728956, - 0x3C651A2F, 0x3FF6DFB2, 0x683C88AB, 0xBC6BBE3A, 0xF9519484, 0x3FF6FF7D, - 0x25860EF6, 0xBC883C0F, 0xE8EC5F74, 0x3FF71F75, 0x86887A99, 0xBC816E47, - 0x48A58174, 0x3FF73F9A, 0x6C65D53C, 0xBC90A8D9, 0x564267C9, 0x3FF75FEB, - 0x57316DD3, 0xBC902459, 0x4FDE5D3F, 0x3FF78069, 0x0A02162D, 0x3C9866B8, - 0x73EB0187, 0x3FF7A114, 0xEE04992F, 0xBC841577, 0x0130C132, 0x3FF7C1ED, - 0xD1164DD6, 0x3C9F124C, 0x36CF4E62, 0x3FF7E2F3, 0xBA15797E, 0x3C705D02, - 0x543E1A12, 0x3FF80427, 0x626D972B, 0xBC927C86, 0x994CCE13, 0x3FF82589, - 0xD41532D8, 0xBC9D4C1D, 0x4623C7AD, 0x3FF8471A, 0xA341CDFB, 0xBC88D684, - 0x9B4492ED, 0x3FF868D9, 0x9BD4F6BA, 0xBC9FC6F8, 0xD98A6699, 0x3FF88AC7, - 0xF37CB53A, 0x3C9994C2, 0x422AA0DB, 0x3FF8ACE5, 0x56864B27, 0x3C96E9F1, - 0x16B5448C, 0x3FF8CF32, 0x32E9E3AA, 0xBC70D55E, 0x99157736, 0x3FF8F1AE, - 0xA2E3976C, 0x3C85CC13, 0x0B91FFC6, 0x3FF9145B, 0x2E582524, 0xBC9DD679, - 0xB0CDC5E5, 0x3FF93737, 0x81B57EBC, 0xBC675FC7, 0xCBC8520F, 0x3FF95A44, - 0x96A5F039, 0xBC764B7C, 0x9FDE4E50, 0x3FF97D82, 0x7C1B85D1, 0xBC9D185B, - 0x70CA07BA, 0x3FF9A0F1, 0x91CEE632, 0xBC9173BD, 0x82A3F090, 0x3FF9C491, - 0xB071F2BE, 0x3C7C7C46, 0x19E32323, 0x3FF9E863, 0x78E64C6E, 0x3C7824CA, - 0x7B5DE565, 0x3FFA0C66, 0x5D1CD533, 0xBC935949, 0xEC4A2D33, 0x3FFA309B, - 0x7DDC36AB, 0x3C96305C, 0xB23E255D, 0x3FFA5503, 0xDB8D41E1, 0xBC9D2F6E, - 0x1330B358, 0x3FFA799E, 0xCAC563C7, 0x3C9BCB7E, 0x5579FDBF, 0x3FFA9E6B, - 0x0EF7FD31, 0x3C90FAC9, 0xBFD3F37A, 0x3FFAC36B, 0xCAE76CD0, 0xBC8F9234, - 0x995AD3AD, 0x3FFAE89F, 0x345DCC81, 0x3C97A1CD, 0x298DB666, 0x3FFB0E07, - 0x4C80E425, 0xBC9BDEF5, 0xB84F15FB, 0x3FFB33A2, 0x3084D708, 0xBC62805E, - 0x8DE5593A, 0x3FFB5972, 0xBBBA6DE3, 0xBC9C71DF, 0xF2FB5E47, 0x3FFB7F76, - 0x7E54AC3B, 0xBC75584F, 0x30A1064A, 0x3FFBA5B0, 0x0E54292E, 0xBC9EFCD3, - 0x904BC1D2, 0x3FFBCC1E, 0x7A2D9E84, 0x3C823DD0, 0x5BD71E09, 0x3FFBF2C2, - 0x3F6B9C73, 0xBC9EFDCA, 0xDD85529C, 0x3FFC199B, 0x895048DD, 0x3C811065, - 0x5FFFD07A, 0x3FFC40AB, 0xE083C60A, 0x3C9B4537, 0x2E57D14B, 0x3FFC67F1, - 0xFF483CAD, 0x3C92884D, 0x9406E7B5, 0x3FFC8F6D, 0x48805C44, 0x3C71ACBC, - 0xDCEF9069, 0x3FFCB720, 0xD1E949DC, 0x3C7503CB, 0x555DC3FA, 0x3FFCDF0B, - 0x53829D72, 0xBC8DD83B, 0x4A07897C, 0x3FFD072D, 0x43797A9C, 0xBC9CBC37, - 0x080D89F2, 0x3FFD2F87, 0x719D8578, 0xBC9D487B, 0xDCFBA487, 0x3FFD5818, - 0xD75B3707, 0x3C82ED02, 0x16C98398, 0x3FFD80E3, 0x8BEDDFE8, 0xBC911EC1, - 0x03DB3285, 0x3FFDA9E6, 0x696DB532, 0x3C9C2300, 0xF301B460, 0x3FFDD321, - 0x78F018C3, 0x3C92DA57, 0x337B9B5F, 0x3FFDFC97, 0x4F184B5C, 0xBC91A5CD, - 0x14F5A129, 0x3FFE2646, 0x817A1496, 0xBC97B627, 0xE78B3FF6, 0x3FFE502E, - 0x80A9CC8F, 0x3C839E89, 0xFBC74C83, 0x3FFE7A51, 0xCA0C8DE2, 0x3C92D522, - 0xA2A490DA, 0x3FFEA4AF, 0x179C2893, 0xBC9E9C23, 0x2D8E67F1, 0x3FFECF48, - 0xB411AD8C, 0xBC9C93F3, 0xEE615A27, 0x3FFEFA1B, 0x86A4B6B0, 0x3C9DC7F4, - 0x376BBA97, 0x3FFF252B, 0xBF0D8E43, 0x3C93A1A5, 0x5B6E4540, 0x3FFF5076, - 0x2DD8A18B, 0x3C99D3E1, 0xAD9CBE14, 0x3FFF7BFD, 0xD006350A, 0xBC9DBB12, - 0x819E90D8, 0x3FFFA7C1, 0xF3A5931E, 0x3C874853, 0x2B8F71F1, 0x3FFFD3C2, - 0x966579E7, 0x3C62EB74 - // @formatter:on - }); - - private static ArrayDataPointerConstant t2NegF = pointerConstant(16, new int[]{ - // @formatter:off - 0x00000000, 0x3FF00000, 0x00000000, 0x00000000, 0x2B8F71F1, 0x3FEFD3C2, - 0x966579E7, 0x3C52EB74, 0x819E90D8, 0x3FEFA7C1, 0xF3A5931E, 0x3C774853, - 0xAD9CBE14, 0x3FEF7BFD, 0xD006350A, 0xBC8DBB12, 0x5B6E4540, 0x3FEF5076, - 0x2DD8A18B, 0x3C89D3E1, 0x376BBA97, 0x3FEF252B, 0xBF0D8E43, 0x3C83A1A5, - 0xEE615A27, 0x3FEEFA1B, 0x86A4B6B0, 0x3C8DC7F4, 0x2D8E67F1, 0x3FEECF48, - 0xB411AD8C, 0xBC8C93F3, 0xA2A490DA, 0x3FEEA4AF, 0x179C2893, 0xBC8E9C23, - 0xFBC74C83, 0x3FEE7A51, 0xCA0C8DE2, 0x3C82D522, 0xE78B3FF6, 0x3FEE502E, - 0x80A9CC8F, 0x3C739E89, 0x14F5A129, 0x3FEE2646, 0x817A1496, 0xBC87B627, - 0x337B9B5F, 0x3FEDFC97, 0x4F184B5C, 0xBC81A5CD, 0xF301B460, 0x3FEDD321, - 0x78F018C3, 0x3C82DA57, 0x03DB3285, 0x3FEDA9E6, 0x696DB532, 0x3C8C2300, - 0x16C98398, 0x3FED80E3, 0x8BEDDFE8, 0xBC811EC1, 0xDCFBA487, 0x3FED5818, - 0xD75B3707, 0x3C72ED02, 0x080D89F2, 0x3FED2F87, 0x719D8578, 0xBC8D487B, - 0x4A07897C, 0x3FED072D, 0x43797A9C, 0xBC8CBC37, 0x555DC3FA, 0x3FECDF0B, - 0x53829D72, 0xBC7DD83B, 0xDCEF9069, 0x3FECB720, 0xD1E949DC, 0x3C6503CB, - 0x9406E7B5, 0x3FEC8F6D, 0x48805C44, 0x3C61ACBC, 0x2E57D14B, 0x3FEC67F1, - 0xFF483CAD, 0x3C82884D, 0x5FFFD07A, 0x3FEC40AB, 0xE083C60A, 0x3C8B4537, - 0xDD85529C, 0x3FEC199B, 0x895048DD, 0x3C711065, 0x5BD71E09, 0x3FEBF2C2, - 0x3F6B9C73, 0xBC8EFDCA, 0x904BC1D2, 0x3FEBCC1E, 0x7A2D9E84, 0x3C723DD0, - 0x30A1064A, 0x3FEBA5B0, 0x0E54292E, 0xBC8EFCD3, 0xF2FB5E47, 0x3FEB7F76, - 0x7E54AC3B, 0xBC65584F, 0x8DE5593A, 0x3FEB5972, 0xBBBA6DE3, 0xBC8C71DF, - 0xB84F15FB, 0x3FEB33A2, 0x3084D708, 0xBC52805E, 0x298DB666, 0x3FEB0E07, - 0x4C80E425, 0xBC8BDEF5, 0x995AD3AD, 0x3FEAE89F, 0x345DCC81, 0x3C87A1CD, - 0xBFD3F37A, 0x3FEAC36B, 0xCAE76CD0, 0xBC7F9234, 0x5579FDBF, 0x3FEA9E6B, - 0x0EF7FD31, 0x3C80FAC9, 0x1330B358, 0x3FEA799E, 0xCAC563C7, 0x3C8BCB7E, - 0xB23E255D, 0x3FEA5503, 0xDB8D41E1, 0xBC8D2F6E, 0xEC4A2D33, 0x3FEA309B, - 0x7DDC36AB, 0x3C86305C, 0x7B5DE565, 0x3FEA0C66, 0x5D1CD533, 0xBC835949, - 0x19E32323, 0x3FE9E863, 0x78E64C6E, 0x3C6824CA, 0x82A3F090, 0x3FE9C491, - 0xB071F2BE, 0x3C6C7C46, 0x70CA07BA, 0x3FE9A0F1, 0x91CEE632, 0xBC8173BD, - 0x9FDE4E50, 0x3FE97D82, 0x7C1B85D1, 0xBC8D185B, 0xCBC8520F, 0x3FE95A44, - 0x96A5F039, 0xBC664B7C, 0xB0CDC5E5, 0x3FE93737, 0x81B57EBC, 0xBC575FC7, - 0x0B91FFC6, 0x3FE9145B, 0x2E582524, 0xBC8DD679, 0x99157736, 0x3FE8F1AE, - 0xA2E3976C, 0x3C75CC13, 0x16B5448C, 0x3FE8CF32, 0x32E9E3AA, 0xBC60D55E, - 0x422AA0DB, 0x3FE8ACE5, 0x56864B27, 0x3C86E9F1, 0xD98A6699, 0x3FE88AC7, - 0xF37CB53A, 0x3C8994C2, 0x9B4492ED, 0x3FE868D9, 0x9BD4F6BA, 0xBC8FC6F8, - 0x4623C7AD, 0x3FE8471A, 0xA341CDFB, 0xBC78D684, 0x994CCE13, 0x3FE82589, - 0xD41532D8, 0xBC8D4C1D, 0x543E1A12, 0x3FE80427, 0x626D972B, 0xBC827C86, - 0x36CF4E62, 0x3FE7E2F3, 0xBA15797E, 0x3C605D02, 0x0130C132, 0x3FE7C1ED, - 0xD1164DD6, 0x3C8F124C, 0x73EB0187, 0x3FE7A114, 0xEE04992F, 0xBC741577, - 0x4FDE5D3F, 0x3FE78069, 0x0A02162D, 0x3C8866B8, 0x564267C9, 0x3FE75FEB, - 0x57316DD3, 0xBC802459, 0x48A58174, 0x3FE73F9A, 0x6C65D53C, 0xBC80A8D9, - 0xE8EC5F74, 0x3FE71F75, 0x86887A99, 0xBC716E47, 0xF9519484, 0x3FE6FF7D, - 0x25860EF6, 0xBC783C0F, 0x3C651A2F, 0x3FE6DFB2, 0x683C88AB, 0xBC5BBE3A, - 0x750BDABF, 0x3FE6C012, 0x67FF0B0D, 0xBC628956, 0x667F3BCD, 0x3FE6A09E, - 0x13B26456, 0xBC8BDD34, 0xD44CA973, 0x3FE68155, 0x44F73E65, 0x3C5038AE, - 0x82552225, 0x3FE66238, 0x87591C34, 0xBC8BB609, 0x34CCC320, 0x3FE64346, - 0x759D8933, 0xBC7C483C, 0xB03A5585, 0x3FE6247E, 0x7E40B497, 0xBC8383C1, - 0xB976DC09, 0x3FE605E1, 0x9B56DE47, 0xBC83E242, 0x15AD2148, 0x3FE5E76F, - 0x3080E65E, 0x3C8BA6F9, 0x8A5946B7, 0x3FE5C926, 0x816986A2, 0x3C2C4B1B, - 0xDD485429, 0x3FE5AB07, 0x054647AD, 0x3C86324C, 0xD497C7FD, 0x3FE58D12, - 0x5B9A1DE8, 0x3C7295E1, 0x36B527DA, 0x3FE56F47, 0x011D93AD, 0x3C89BB2C, - 0xCA5D920F, 0x3FE551A4, 0xEFEDE59B, 0xBC7D689C, 0x569D4F82, 0x3FE5342B, - 0x1DB13CAD, 0xBC707ABE, 0xA2CF6642, 0x3FE516DA, 0x69BD93EF, 0xBC7F7685, - 0x769D2CA7, 0x3FE4F9B2, 0xD25957E3, 0xBC84B309, 0x99FDDD0D, 0x3FE4DCB2, - 0xBC6A7833, 0x3C88ECDB, 0xD5362A27, 0x3FE4BFDA, 0xAFEC42E2, 0x3C6D4397, - 0xF0D7D3DE, 0x3FE4A32A, 0xF3D1BE56, 0x3C89CB62, 0xB5C13CD0, 0x3FE486A2, - 0xB69062F0, 0x3C63C1A3, 0xED1D0057, 0x3FE46A41, 0xD1648A76, 0x3C8C944B, - 0x6061892D, 0x3FE44E08, 0x04EF80D0, 0x3C389B7A, 0xD950A897, 0x3FE431F5, - 0xE35F7999, 0xBC71C7DD, 0x21F72E2A, 0x3FE4160A, 0x1C309278, 0xBC4EF369, - 0x04AC801C, 0x3FE3FA45, 0xF956F9F3, 0xBC87D023, 0x4C123422, 0x3FE3DEA6, - 0x11F09EBC, 0x3C7ADA09, 0xC313A8E5, 0x3FE3C32D, 0x375D29C3, 0xBC8EFFF8, - 0x34E59FF7, 0x3FE3A7DB, 0xD661F5E3, 0xBC65E436, 0x6D05D866, 0x3FE38CAE, - 0x3C9904BD, 0xBC8E958D, 0x373AA9CB, 0x3FE371A7, 0xBF42EAE2, 0xBC863AEA, - 0x5F929FF1, 0x3FE356C5, 0x5C4E4628, 0xBC7B5CEE, 0xB26416FF, 0x3FE33C08, - 0x843659A6, 0x3C832721, 0xFC4CD831, 0x3FE32170, 0x8E18047C, 0x3C7A9CE7, - 0x0A31B715, 0x3FE306FE, 0xD23182E4, 0x3C76F46A, 0xA93E2F56, 0x3FE2ECAF, - 0x45D52383, 0x3C61CA0F, 0xA6E4030B, 0x3FE2D285, 0x54DB41D5, 0x3C800247, - 0xD0DAD990, 0x3FE2B87F, 0xD6381AA4, 0xBC310ADC, 0xF51FDEE1, 0x3FE29E9D, - 0xAFAD1255, 0x3C7612E8, 0xE1F56381, 0x3FE284DF, 0x8C3F0D7E, 0xBC8A4C3A, - 0x65E27CDD, 0x3FE26B45, 0x9940E9D9, 0x3C72BD33, 0x4FB2A63F, 0x3FE251CE, - 0xBEF4F4A4, 0x3C7AC155, 0x6E756238, 0x3FE2387A, 0xB6C70573, 0x3C89B07E, - 0x917DDC96, 0x3FE21F49, 0x9494A5EE, 0x3C72A97E, 0x88628CD6, 0x3FE2063B, - 0x814A8495, 0x3C7DC775, 0x22FCD91D, 0x3FE1ED50, 0x027BB78C, 0xBC81DF98, - 0x3168B9AA, 0x3FE1D487, 0x00A2643C, 0x3C8E016E, 0x84045CD4, 0x3FE1BBE0, - 0x352EF607, 0xBC895386, 0xEB6FCB75, 0x3FE1A35B, 0x7B4968E4, 0x3C7E5B4C, - 0x388C8DEA, 0x3FE18AF9, 0xD1970F6C, 0xBC811023, 0x3C7D517B, 0x3FE172B8, - 0xB9D78A76, 0xBC719041, 0xC8A58E51, 0x3FE15A98, 0xB9EEAB0A, 0x3C72406A, - 0xAEA92DE0, 0x3FE1429A, 0x9AF1369E, 0xBC832FBF, 0xC06C31CC, 0x3FE12ABD, - 0xB36CA5C7, 0xBC41B514, 0xD0125B51, 0x3FE11301, 0x39449B3A, 0xBC86C510, - 0xAFFED31B, 0x3FE0FB66, 0xC44EBD7B, 0xBC5B9BED, 0x32D3D1A2, 0x3FE0E3EC, - 0x27C57B52, 0x3C303A17, 0x2B7247F7, 0x3FE0CC92, 0x16E24F71, 0x3C801EDC, - 0x6CF9890F, 0x3FE0B558, 0x4ADC610B, 0x3C88A62E, 0xCAC6F383, 0x3FE09E3E, - 0x18316136, 0x3C814878, 0x18759BC8, 0x3FE08745, 0x4BB284FF, 0x3C5186BE, - 0x29DDF6DE, 0x3FE0706B, 0xE2B13C27, 0xBC7C91DF, 0xD3158574, 0x3FE059B0, - 0xA475B465, 0x3C7D73E2, 0xE86E7F85, 0x3FE04315, 0x1977C96E, 0xBC80A31C, - 0x3E778061, 0x3FE02C9A, 0x535B085D, 0xBC619083, 0xA9FB3335, 0x3FE0163D, - 0x9AB8CDB7, 0x3C8B6129 - // @formatter:on - }); - - @Override - public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { - Label l2TAGPACKET002 = new Label(); - Label l2TAGPACKET102 = new Label(); - Label l2TAGPACKET302 = new Label(); - Label l2TAGPACKET402 = new Label(); - Label l2TAGPACKET502 = new Label(); - Label l2TAGPACKET602 = new Label(); - Label b12 = new Label(); - Label b15 = new Label(); - - masm.bind(b12); - masm.xorpd(xmm4, xmm4); - masm.movsd(xmm1, recordExternalAddress(crb, l2E)); - masm.movl(rax, 32768); - masm.pinsrw(xmm4, rax, 3); - masm.pextrw(rcx, xmm0, 3); - masm.andnpd(xmm4, xmm0); - masm.pshufd(xmm5, xmm4, 68); - masm.movl(rdx, 32768); - masm.andl(rdx, rcx); - masm.andl(rcx, 32767); - masm.subl(rcx, 16343); - // Branch only if |x| is not in [23/64, 3*2^8) - masm.cmplAndJcc(rcx, 177, ConditionFlag.AboveEqual, l2TAGPACKET002, false); - masm.movsd(xmm3, recordExternalAddress(crb, halfMask)); - masm.movsd(xmm2, recordExternalAddress(crb, l2E8)); - masm.movsd(xmm6, recordExternalAddress(crb, shifter)); - masm.andpd(xmm3, xmm0); - masm.subsd(xmm4, xmm3); - masm.mulsd(xmm3, xmm1); - masm.mulsd(xmm2, xmm5); - masm.cvtsd2siq(rax, xmm3); - masm.shll(rdx, 3); - masm.orl(rax, rdx); - masm.movq(xmm7, xmm3); - masm.addsd(xmm3, xmm6); - masm.mulsd(xmm1, xmm4); - masm.xorpd(xmm5, xmm5); - masm.subsd(xmm3, xmm6); - masm.movapd(xmm4, recordExternalAddress(crb, cv)); - masm.addsd(xmm2, xmm1); - masm.movapd(xmm6, recordExternalAddress(crb, cv16)); - masm.subsd(xmm7, xmm3); - masm.movl(rdx, 32704); - masm.pinsrw(xmm5, rdx, 3); - masm.movapd(xmm1, recordExternalAddress(crb, cv32)); - masm.addsd(xmm2, xmm7); - masm.movl(rdx, 127); - masm.andl(rdx, rax); - masm.addl(rdx, rdx); - masm.shrl(rax, 3); - masm.andl(rax, 65520); - masm.addl(rax, 16352); - masm.xorpd(xmm0, xmm0); - // Branch only if |x| is not in [23/64, 3*2^7) - masm.cmplAndJcc(rcx, 161, ConditionFlag.AboveEqual, l2TAGPACKET102, false); - masm.pshufd(xmm5, xmm5, 68); - masm.pinsrw(xmm0, rax, 3); - masm.pshufd(xmm0, xmm0, 68); - masm.psubw(xmm5, xmm0); - masm.leaq(r8, recordExternalAddress(crb, t2F)); - masm.mulpd(xmm0, new AMD64Address(r8, rdx, Stride.S8)); - masm.leaq(r8, recordExternalAddress(crb, t2NegF)); - masm.mulpd(xmm5, new AMD64Address(r8, rdx, Stride.S8)); - masm.pshufd(xmm3, xmm2, 68); - masm.movapd(xmm7, recordExternalAddress(crb, cv48)); - masm.pshufd(xmm2, xmm2, 68); - masm.mulpd(xmm3, xmm3); - masm.mulpd(xmm4, xmm2); - masm.mulpd(xmm6, xmm2); - masm.mulpd(xmm2, recordExternalAddress(crb, cv64)); - masm.mulpd(xmm1, xmm3); - masm.mulpd(xmm7, xmm3); - masm.mulpd(xmm4, xmm3); - masm.mulpd(xmm1, xmm3); - masm.addpd(xmm6, xmm7); - masm.movq(xmm7, xmm0); - masm.addpd(xmm4, xmm1); - masm.shufpd(xmm7, xmm5, 0); - masm.subpd(xmm0, xmm5); - masm.mulpd(xmm2, xmm7); - masm.addpd(xmm4, xmm6); - masm.subsd(xmm7, xmm0); - masm.mulpd(xmm4, xmm2); - masm.pshufd(xmm6, xmm0, 238); - masm.subsd(xmm7, xmm5); - masm.addpd(xmm4, xmm2); - masm.addsd(xmm7, xmm6); - masm.pshufd(xmm2, xmm4, 238); - masm.addsd(xmm2, xmm7); - masm.addsd(xmm2, xmm4); - masm.addsd(xmm0, xmm2); - masm.jmp(b15); - - masm.bind(l2TAGPACKET102); - masm.subl(rax, 16352); - masm.movl(rcx, rax); - masm.andl(rax, 32752); - masm.shrl(rax, 1); - masm.andl(rax, 65520); - masm.subl(rcx, rax); - masm.addl(rax, 16352); - masm.pinsrw(xmm0, rax, 3); - masm.pshufd(xmm0, xmm0, 68); - masm.leaq(r8, recordExternalAddress(crb, t2F)); - masm.mulpd(xmm0, new AMD64Address(r8, rdx, Stride.S8)); - masm.pshufd(xmm3, xmm2, 68); - masm.movsd(xmm7, recordExternalAddress(crb, cv48)); - masm.mulsd(xmm3, xmm3); - masm.mulsd(xmm4, xmm2); - masm.mulsd(xmm6, xmm2); - masm.mulsd(xmm2, recordExternalAddress(crb, cv64)); - masm.mulsd(xmm1, xmm3); - masm.mulsd(xmm7, xmm3); - masm.mulsd(xmm4, xmm3); - masm.addl(rcx, 16368); - masm.pinsrw(xmm5, rcx, 3); - masm.mulsd(xmm1, xmm3); - masm.addsd(xmm6, xmm7); - masm.addsd(xmm4, xmm1); - masm.mulsd(xmm2, xmm0); - masm.addsd(xmm4, xmm6); - masm.mulsd(xmm4, xmm2); - masm.pshufd(xmm6, xmm0, 238); - masm.addsd(xmm4, xmm6); - masm.addsd(xmm2, xmm4); - masm.addsd(xmm0, xmm2); - masm.mulsd(xmm0, xmm5); - masm.jmp(b15); - - masm.bind(l2TAGPACKET002); - masm.addl(rcx, 16343); - // Branch only if |x| > 23/64 - masm.cmplAndJcc(rcx, 16343, ConditionFlag.Above, l2TAGPACKET302, false); - // Branch only if |x| < 2^-32 - masm.cmplAndJcc(rcx, 15856, ConditionFlag.Below, l2TAGPACKET402, false); - masm.movapd(xmm1, recordExternalAddress(crb, pv)); - masm.pshufd(xmm6, xmm0, 68); - masm.mulpd(xmm5, xmm5); - masm.movapd(xmm2, recordExternalAddress(crb, pv16)); - masm.pshufd(xmm7, xmm0, 68); - masm.movapd(xmm3, recordExternalAddress(crb, pv32)); - masm.pshufd(xmm4, xmm0, 68); - masm.andpd(xmm6, recordExternalAddress(crb, mask3)); - masm.mulpd(xmm1, xmm5); - masm.mulsd(xmm2, xmm5); - masm.subpd(xmm4, xmm6); - masm.mulpd(xmm7, xmm5); - masm.addpd(xmm1, xmm3); - masm.pshufd(xmm3, xmm6, 68); - masm.mulpd(xmm5, xmm5); - masm.mulsd(xmm2, xmm7); - masm.mulpd(xmm1, xmm7); - masm.pshufd(xmm7, xmm0, 68); - masm.mulsd(xmm6, xmm6); - masm.addsd(xmm7, xmm7); - masm.mulsd(xmm4, xmm4); - masm.mulpd(xmm1, xmm5); - masm.addsd(xmm7, xmm0); - masm.mulsd(xmm6, xmm3); - masm.mulsd(xmm7, xmm3); - masm.pshufd(xmm3, xmm1, 238); - masm.mulsd(xmm1, xmm5); - masm.pshufd(xmm5, xmm4, 238); - masm.addsd(xmm3, xmm2); - masm.pshufd(xmm2, xmm2, 238); - masm.addsd(xmm7, xmm4); - masm.movq(xmm4, xmm0); - masm.mulsd(xmm6, xmm2); - masm.mulsd(xmm7, xmm5); - masm.addsd(xmm0, xmm6); - masm.mulsd(xmm7, xmm2); - masm.subsd(xmm4, xmm0); - masm.addsd(xmm1, xmm7); - masm.addsd(xmm6, xmm4); - masm.addsd(xmm1, xmm3); - masm.addsd(xmm1, xmm6); - masm.addsd(xmm0, xmm1); - masm.jmp(b15); - - masm.bind(l2TAGPACKET402); - // Branch only if |x| is not denormalized - masm.cmplAndJcc(rcx, 16, ConditionFlag.AboveEqual, l2TAGPACKET502, false); - masm.movq(xmm1, xmm0); - masm.mulsd(xmm1, xmm1); - masm.jmp(b15); - - masm.bind(l2TAGPACKET502); - masm.xorpd(xmm2, xmm2); - masm.movl(rcx, 17392); - masm.pinsrw(xmm2, rcx, 3); - masm.xorpd(xmm3, xmm3); - masm.movl(rdx, 15344); - masm.pinsrw(xmm3, rdx, 3); - masm.mulsd(xmm2, xmm0); - masm.addsd(xmm0, xmm2); - masm.mulsd(xmm0, xmm3); - masm.jmp(b15); - - masm.bind(l2TAGPACKET302); - // Branch only if |x| is INF or NaN - masm.cmplAndJcc(rcx, 32752, ConditionFlag.AboveEqual, l2TAGPACKET602, false); - masm.xorpd(xmm0, xmm0); - masm.movl(rax, 32736); - masm.pinsrw(xmm0, rax, 3); - masm.orl(rax, rdx); - masm.pinsrw(xmm1, rax, 3); - masm.mulsd(xmm0, xmm1); - masm.jmp(b15); - - masm.bind(l2TAGPACKET602); - masm.xorpd(xmm1, xmm1); - masm.movl(rax, 32768); - masm.pinsrw(xmm1, rax, 3); - masm.andnpd(xmm1, xmm0); - masm.mulsd(xmm0, xmm1); - - masm.bind(b15); - } -} diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/gen/ArithmeticLIRGeneratorTool.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/gen/ArithmeticLIRGeneratorTool.java index 97966dd072e5..dd21e5d7d1af 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/gen/ArithmeticLIRGeneratorTool.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/gen/ArithmeticLIRGeneratorTool.java @@ -159,11 +159,6 @@ default Value emitMathSin(Value input) { throw GraalError.unimplemented("No specialized implementation available"); // ExcludeFromJacocoGeneratedReport } - @SuppressWarnings("unused") - default Value emitMathSinh(Value input) { - throw GraalError.unimplemented("No specialized implementation available"); // ExcludeFromJacocoGeneratedReport - } - @SuppressWarnings("unused") default Value emitMathTan(Value input) { throw GraalError.unimplemented("No specialized implementation available"); // ExcludeFromJacocoGeneratedReport diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/CompressionNode.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/CompressionNode.java index d08b3be2e22e..ed108c4c9686 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/CompressionNode.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/CompressionNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -30,6 +30,7 @@ import jdk.graal.compiler.core.common.CompressEncoding; import jdk.graal.compiler.core.common.type.AbstractObjectStamp; import jdk.graal.compiler.core.common.type.Stamp; +import jdk.graal.compiler.debug.GraalError; import jdk.graal.compiler.graph.NodeClass; import jdk.graal.compiler.lir.gen.LIRGeneratorTool; import jdk.graal.compiler.nodeinfo.NodeInfo; @@ -82,18 +83,26 @@ public JavaConstant nullConstant() { @Override public Constant convert(Constant c, ConstantReflectionProvider constantReflection) { - return switch (op) { - case Compress -> compress(c); - case Uncompress -> uncompress(c); - }; + switch (op) { + case Compress: + return compress(c); + case Uncompress: + return uncompress(c); + default: + throw GraalError.shouldNotReachHereUnexpectedValue(op); // ExcludeFromJacocoGeneratedReport + } } @Override public Constant reverse(Constant c, ConstantReflectionProvider constantReflection) { - return switch (op) { - case Compress -> uncompress(c); - case Uncompress -> compress(c); - }; + switch (op) { + case Compress: + return uncompress(c); + case Uncompress: + return compress(c); + default: + throw GraalError.shouldNotReachHereUnexpectedValue(op); // ExcludeFromJacocoGeneratedReport + } } /** @@ -129,12 +138,14 @@ public boolean isCompressible(Constant constant) { @Override public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) { - if (forValue instanceof ConstantNode constant) { + if (forValue.isConstant()) { + ConstantNode constant = (ConstantNode) forValue; if (isCompressible(constant.getValue())) { return ConstantNode.forConstant(stamp(NodeView.DEFAULT), convert(constant.getValue(), tool.getConstantReflection()), constant.getStableDimension(), constant.isDefaultStable(), tool.getMetaAccess()); } - } else if (forValue instanceof CompressionNode other) { + } else if (forValue instanceof CompressionNode) { + CompressionNode other = (CompressionNode) forValue; if (op != other.op && encoding.equals(other.encoding)) { return other.getValue(); } @@ -153,10 +164,17 @@ public void generate(NodeLIRBuilderTool gen) { } LIRGeneratorTool tool = gen.getLIRGeneratorTool(); - Value result = switch (op) { - case Compress -> tool.emitCompress(gen.operand(value), encoding, nonNull); - case Uncompress -> tool.emitUncompress(gen.operand(value), encoding, nonNull); - }; + Value result; + switch (op) { + case Compress: + result = tool.emitCompress(gen.operand(value), encoding, nonNull); + break; + case Uncompress: + result = tool.emitUncompress(gen.operand(value), encoding, nonNull); + break; + default: + throw GraalError.shouldNotReachHereUnexpectedValue(op); // ExcludeFromJacocoGeneratedReport + } gen.setResult(this, result); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/StandardGraphBuilderPlugins.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/StandardGraphBuilderPlugins.java index 7c509daa6c64..ec6c03dc0365 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/StandardGraphBuilderPlugins.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/StandardGraphBuilderPlugins.java @@ -2622,7 +2622,7 @@ public boolean isApplicable(Architecture arch) { private static void registerStringCodingPlugins(InvocationPlugins plugins) { Registration r = new Registration(plugins, "java.lang.StringCoding"); - r.register(new InvocationPlugin("encodeISOArray0", byte[].class, int.class, byte[].class, int.class, int.class) { + r.register(new InvocationPlugin("implEncodeISOArray", byte[].class, int.class, byte[].class, int.class, int.class) { @Override public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode sa, ValueNode sp, ValueNode da, ValueNode dp, ValueNode len) { @@ -2635,7 +2635,7 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec } } }); - r.register(new InvocationPlugin("encodeAsciiArray0", char[].class, int.class, byte[].class, int.class, int.class) { + r.register(new InvocationPlugin("implEncodeAsciiArray", char[].class, int.class, byte[].class, int.class, int.class) { @Override public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode sa, ValueNode sp, ValueNode da, ValueNode dp, ValueNode len) { @@ -2647,10 +2647,17 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec } } }); - r.register(new InvocationPlugin("countPositives0", byte[].class, int.class, int.class) { + r.register(new InvocationPlugin("countPositives", byte[].class, int.class, int.class) { @Override public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode ba, ValueNode off, ValueNode len) { try (InvocationPluginHelper helper = new InvocationPluginHelper(b, targetMethod)) { + helper.intrinsicRangeCheck(off, Condition.LT, ConstantNode.forInt(0)); + helper.intrinsicRangeCheck(len, Condition.LT, ConstantNode.forInt(0)); + + ValueNode arrayLength = b.add(new ArrayLengthNode(ba)); + ValueNode limit = b.add(AddNode.create(off, len, NodeView.DEFAULT)); + helper.intrinsicRangeCheck(arrayLength, Condition.LT, limit); + ValueNode array = helper.arrayElementPointer(ba, JavaKind.Byte, off); b.addPush(JavaKind.Int, new CountPositivesNode(array, len)); return true; @@ -2659,7 +2666,7 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec }); r = new Registration(plugins, "sun.nio.cs.ISO_8859_1$Encoder"); - r.register(new InvocationPlugin("encodeISOArray0", char[].class, int.class, byte[].class, int.class, int.class) { + r.register(new InvocationPlugin("implEncodeISOArray", char[].class, int.class, byte[].class, int.class, int.class) { @Override public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode sa, ValueNode sp, ValueNode da, ValueNode dp, ValueNode len) { diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/amd64/AMD64GraphBuilderPlugins.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/amd64/AMD64GraphBuilderPlugins.java index 5fd3948e44cf..f0f66c87ac94 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/amd64/AMD64GraphBuilderPlugins.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/amd64/AMD64GraphBuilderPlugins.java @@ -31,7 +31,6 @@ import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.LOG; import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.LOG10; import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.SIN; -import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.SINH; import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.TAN; import static jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.TANH; @@ -200,7 +199,6 @@ private static void registerMathPlugins(InvocationPlugins plugins) { registerUnaryMath(r, "exp", EXP); registerBinaryMath(r, "pow", BinaryMathIntrinsicNode.BinaryOperation.POW); registerUnaryMath(r, "sin", SIN); - registerUnaryMath(r, "sinh", SINH); registerUnaryMath(r, "cos", COS); registerUnaryMath(r, "tan", TAN); registerUnaryMath(r, "tanh", TANH); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/nodes/UnaryMathIntrinsicNode.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/nodes/UnaryMathIntrinsicNode.java index 2d1a320e7522..385464b54ea6 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/nodes/UnaryMathIntrinsicNode.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/nodes/UnaryMathIntrinsicNode.java @@ -57,7 +57,6 @@ public enum UnaryOperation { LOG(new ForeignCallSignature("arithmeticLog", double.class, double.class)), LOG10(new ForeignCallSignature("arithmeticLog10", double.class, double.class)), SIN(new ForeignCallSignature("arithmeticSin", double.class, double.class)), - SINH(new ForeignCallSignature("arithmeticSinh", double.class, double.class)), COS(new ForeignCallSignature("arithmeticCos", double.class, double.class)), TAN(new ForeignCallSignature("arithmeticTan", double.class, double.class)), TANH(new ForeignCallSignature("arithmeticTanh", double.class, double.class)), @@ -76,7 +75,6 @@ public static double compute(UnaryOperation op, double value) { case LOG10 -> Math.log10(value); case EXP -> Math.exp(value); case SIN -> Math.sin(value); - case SINH -> Math.sinh(value); case COS -> Math.cos(value); case TAN -> Math.tan(value); case TANH -> Math.tanh(value); @@ -96,7 +94,6 @@ public static Stamp computeStamp(UnaryOperation op, Stamp valueStamp) { boolean nonNaN = floatStamp.lowerBound() != Double.NEGATIVE_INFINITY && floatStamp.upperBound() != Double.POSITIVE_INFINITY && floatStamp.isNonNaN(); return StampFactory.forFloat(JavaKind.Double, -1.0, 1.0, nonNaN); } - case SINH: case TAN: { boolean nonNaN = floatStamp.lowerBound() != Double.NEGATIVE_INFINITY && floatStamp.upperBound() != Double.POSITIVE_INFINITY && floatStamp.isNonNaN(); return StampFactory.forFloat(JavaKind.Double, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, nonNaN); @@ -166,7 +163,6 @@ public void generate(NodeLIRBuilderTool nodeValueMap, ArithmeticLIRGeneratorTool case LOG10 -> gen.emitMathLog(input, true); case EXP -> gen.emitMathExp(input); case SIN -> gen.emitMathSin(input); - case SINH -> gen.emitMathSinh(input); case COS -> gen.emitMathCos(input); case TAN -> gen.emitMathTan(input); case TANH -> gen.emitMathTanh(input); diff --git a/espresso-shared/src/com.oracle.truffle.espresso.classfile/src/com/oracle/truffle/espresso/classfile/JavaVersion.java b/espresso-shared/src/com.oracle.truffle.espresso.classfile/src/com/oracle/truffle/espresso/classfile/JavaVersion.java index 9dca107df3be..4adfd598b04f 100644 --- a/espresso-shared/src/com.oracle.truffle.espresso.classfile/src/com/oracle/truffle/espresso/classfile/JavaVersion.java +++ b/espresso-shared/src/com.oracle.truffle.espresso.classfile/src/com/oracle/truffle/espresso/classfile/JavaVersion.java @@ -43,7 +43,6 @@ public static final class VersionRange { public static final VersionRange VERSION_22_OR_HIGHER = higher(22); public static final VersionRange VERSION_24_OR_LOWER = lower(24); public static final VersionRange VERSION_25_OR_HIGHER = higher(25); - public static final VersionRange VERSION_26_OR_HIGHER = higher(26); public static final VersionRange ALL = between(0, LATEST_SUPPORTED); public static final VersionRange VERSION_9_TO_21 = between(9, 21); @@ -220,14 +219,6 @@ public boolean java25OrLater() { return version >= 25; } - public boolean java25OrEarlier() { - return version <= 25; - } - - public boolean java26OrLater() { - return version >= 26; - } - public boolean inRange(int low, int high) { return version >= low && version <= high; } diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/descriptors/EspressoSymbols.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/descriptors/EspressoSymbols.java index 84db6a2943ff..a1688059a305 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/descriptors/EspressoSymbols.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/descriptors/EspressoSymbols.java @@ -327,6 +327,7 @@ public static void ensureInitialized() { public static final Symbol java_lang_ref_Reference$Lock = SYMBOLS.putType("Ljava/lang/ref/Reference$Lock;"); public static final Symbol sun_misc_Cleaner = SYMBOLS.putType("Lsun/misc/Cleaner;"); + public static final Symbol jdk_internal_ref_Cleaner = SYMBOLS.putType("Ljdk/internal/ref/Cleaner;"); public static final Symbol java_lang_StackTraceElement = SYMBOLS.putType("Ljava/lang/StackTraceElement;"); public static final Symbol java_lang_StackTraceElement_array = SYMBOLS.putType("[Ljava/lang/StackTraceElement;"); @@ -616,7 +617,6 @@ public static class Names { public static final Symbol componentType = SYMBOLS.putName("componentType"); public static final Symbol protectionDomain = SYMBOLS.putName("protectionDomain"); public static final Symbol modifiers = SYMBOLS.putName("modifiers"); - public static final Symbol classFileAccessFlags = SYMBOLS.putName("classFileAccessFlags"); public static final Symbol primitive = SYMBOLS.putName("primitive"); public static final Symbol signers = SYMBOLS.putName("signers"); // j.l.ClassLoader diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/Method.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/Method.java index f75cc86b23af..d48f20790087 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/Method.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/Method.java @@ -1961,7 +1961,7 @@ private EspressoException unsatisfiedLinkError() { private void checkPoisonPill(Meta meta) { if (poisonPill) { // Conflicting Maximally-specific non-abstract interface methods. - if (getJavaVersion().inRange(9, 25) && getSpecComplianceMode() == EspressoOptions.SpecComplianceMode.HOTSPOT) { + if (getJavaVersion().inRange(9, 24) && getSpecComplianceMode() == EspressoOptions.SpecComplianceMode.HOTSPOT) { /* * Supposed to be IncompatibleClassChangeError (see jvms-6.5.invokeinterface), * but HotSpot throws AbstractMethodError. See JDK-8356942. diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/libs/libjava/impl/Target_java_lang_Class.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/libs/libjava/impl/Target_java_lang_Class.java index 5e0fa170f882..377471485761 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/libs/libjava/impl/Target_java_lang_Class.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/libs/libjava/impl/Target_java_lang_Class.java @@ -186,7 +186,6 @@ public static boolean isRecord0(@JavaType(Class.class) StaticObject self, @Injec } @Substitution(hasReceiver = true) - // Method no longer exists in 26. public static int getClassAccessFlagsRaw0(@JavaType(Class.class) StaticObject self, @Inject EspressoContext ctx) { return ctx.getVM().JVM_GetClassAccessFlags(self); } diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/libs/libjava/impl/Target_jdk_internal_reflect_ConstantPool.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/libs/libjava/impl/Target_jdk_internal_reflect_ConstantPool.java new file mode 100644 index 000000000000..676de96822f0 --- /dev/null +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/libs/libjava/impl/Target_jdk_internal_reflect_ConstantPool.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2023, 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. + */ +package com.oracle.truffle.espresso.libs.libjava.impl; + +import java.lang.reflect.Field; +import java.lang.reflect.Member; + +import com.oracle.truffle.espresso.libs.libjava.LibJava; +import com.oracle.truffle.espresso.meta.Meta; +import com.oracle.truffle.espresso.runtime.staticobject.StaticObject; +import com.oracle.truffle.espresso.substitutions.EspressoSubstitutions; +import com.oracle.truffle.espresso.substitutions.Inject; +import com.oracle.truffle.espresso.substitutions.JavaSubstitution; +import com.oracle.truffle.espresso.substitutions.JavaType; +import com.oracle.truffle.espresso.substitutions.Substitution; +import com.oracle.truffle.espresso.substitutions.SubstitutionProfiler; +import com.oracle.truffle.espresso.vm.VM; + +@EspressoSubstitutions(type = "Ljdk/internal/reflect/ConstantPool;", group = LibJava.class) +public final class Target_jdk_internal_reflect_ConstantPool { + @Substitution(hasReceiver = true) + public static int getSize0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, @Inject VM vm) { + return vm.JVM_ConstantPoolGetSize(unused, jcpool); + } + + @Substitution(hasReceiver = true) + public static @JavaType(Class.class) StaticObject getClassAt0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, + @Inject VM vm, + @Inject Meta meta, + @Inject SubstitutionProfiler profiler) { + return vm.JVM_ConstantPoolGetClassAt(unused, jcpool, index, meta, profiler); + } + + @Substitution(hasReceiver = true) + @SuppressWarnings("unused") + public static @JavaType(Class.class) StaticObject getClassAtIfLoaded0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { + throw JavaSubstitution.unimplemented(); + + } + + @Substitution(hasReceiver = true) + @SuppressWarnings("unused") + public static int getClassRefIndexAt0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { + throw JavaSubstitution.unimplemented(); + + } + + @Substitution(hasReceiver = true) + @SuppressWarnings("unused") + public static @JavaType(Member.class) StaticObject getMethodAt0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { + throw JavaSubstitution.unimplemented(); + + } + + @Substitution(hasReceiver = true) + @SuppressWarnings("unused") + public static @JavaType(Member.class) StaticObject getMethodAtIfLoaded0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { + throw JavaSubstitution.unimplemented(); + + } + + @Substitution(hasReceiver = true) + @SuppressWarnings("unused") + public static @JavaType(Field.class) StaticObject getFieldAt0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { + throw JavaSubstitution.unimplemented(); + + } + + @Substitution(hasReceiver = true) + @SuppressWarnings("unused") + public static @JavaType(Field.class) StaticObject getFieldAtIfLoaded0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { + throw JavaSubstitution.unimplemented(); + + } + + @Substitution(hasReceiver = true) + @SuppressWarnings("unused") + public static @JavaType(String[].class) StaticObject getMemberRefInfoAt0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { + throw JavaSubstitution.unimplemented(); + + } + + @Substitution(hasReceiver = true) + @SuppressWarnings("unused") + public static int getNameAndTypeRefIndexAt0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { + throw JavaSubstitution.unimplemented(); + + } + + @Substitution(hasReceiver = true) + @SuppressWarnings("unused") + public static @JavaType(String[].class) StaticObject getNameAndTypeRefInfoAt0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { + throw JavaSubstitution.unimplemented(); + + } + + @Substitution(hasReceiver = true) + public static int getIntAt0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, + @Inject VM vm, + @Inject Meta meta, + @Inject SubstitutionProfiler profiler) { + return vm.JVM_ConstantPoolGetIntAt(unused, jcpool, index, meta, profiler); + } + + @Substitution(hasReceiver = true) + public static long getLongAt0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, + @Inject VM vm, + @Inject Meta meta, + @Inject SubstitutionProfiler profiler) { + return vm.JVM_ConstantPoolGetLongAt(unused, jcpool, index, meta, profiler); + } + + @Substitution(hasReceiver = true) + public static float getFloatAt0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, + @Inject VM vm, + @Inject Meta meta, + @Inject SubstitutionProfiler profiler) { + return vm.JVM_ConstantPoolGetFloatAt(unused, jcpool, index, meta, profiler); + } + + @Substitution(hasReceiver = true) + public static double getDoubleAt0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, + @Inject VM vm, + @Inject Meta meta, + @Inject SubstitutionProfiler profiler) { + return vm.JVM_ConstantPoolGetDoubleAt(unused, jcpool, index, meta, profiler); + } + + @Substitution(hasReceiver = true) + public static @JavaType(String.class) StaticObject getStringAt0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, + @Inject VM vm, + @Inject Meta meta, + @Inject SubstitutionProfiler profiler) { + return vm.JVM_ConstantPoolGetStringAt(unused, jcpool, index, meta, profiler); + } + + @Substitution(hasReceiver = true) + public static @JavaType(String.class) StaticObject getUTF8At0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, + @Inject VM vm, + @Inject Meta meta, + @Inject SubstitutionProfiler profiler) { + return vm.JVM_ConstantPoolGetUTF8At(unused, jcpool, index, meta, profiler); + } + + @Substitution(hasReceiver = true) + @SuppressWarnings("unused") + public static byte getTagAt0(@JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { + throw JavaSubstitution.unimplemented(); + + } +} diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/libs/libjava/impl/Target_jdk_internal_reflect_Reflection.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/libs/libjava/impl/Target_jdk_internal_reflect_Reflection.java index b734f1e9e574..0f531d78d591 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/libs/libjava/impl/Target_jdk_internal_reflect_Reflection.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/libs/libjava/impl/Target_jdk_internal_reflect_Reflection.java @@ -29,12 +29,11 @@ import com.oracle.truffle.espresso.substitutions.Inject; import com.oracle.truffle.espresso.substitutions.JavaType; import com.oracle.truffle.espresso.substitutions.Substitution; -import com.oracle.truffle.espresso.substitutions.VersionFilter; import com.oracle.truffle.espresso.vm.VM; @EspressoSubstitutions(type = "Ljdk/internal/reflect/Reflection;", group = LibJava.class) public final class Target_jdk_internal_reflect_Reflection { - @Substitution(languageFilter = VersionFilter.Java25OrEarlier.class) + @Substitution public static int getClassAccessFlags(@JavaType(Class.class) StaticObject cls, @Inject EspressoContext ctx) { return ctx.getVM().JVM_GetClassAccessFlags(cls); } diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/meta/Meta.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/meta/Meta.java index ef03e6032a65..ea83ec0eb689 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/meta/Meta.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/meta/Meta.java @@ -33,7 +33,6 @@ import static com.oracle.truffle.espresso.classfile.JavaVersion.VersionRange.VERSION_22_TO_23; import static com.oracle.truffle.espresso.classfile.JavaVersion.VersionRange.VERSION_24_OR_LOWER; import static com.oracle.truffle.espresso.classfile.JavaVersion.VersionRange.VERSION_25_OR_HIGHER; -import static com.oracle.truffle.espresso.classfile.JavaVersion.VersionRange.VERSION_26_OR_HIGHER; import static com.oracle.truffle.espresso.classfile.JavaVersion.VersionRange.VERSION_8_OR_LOWER; import static com.oracle.truffle.espresso.classfile.JavaVersion.VersionRange.VERSION_9_OR_HIGHER; import static com.oracle.truffle.espresso.classfile.JavaVersion.VersionRange.VERSION_9_TO_21; @@ -118,9 +117,6 @@ public Meta(EspressoContext context) { java_lang_Class_modifiers = diff() // .field(VERSION_25_OR_HIGHER, Names.modifiers, Types._char) // .notRequiredField(java_lang_Class); - java_lang_Class_classFileAccessFlags = diff() // - .field(VERSION_26_OR_HIGHER, Names.classFileAccessFlags, Types._char) // - .notRequiredField(java_lang_Class); java_lang_Class_primitive = diff() // .field(VERSION_25_OR_HIGHER, Names.primitive, Types._boolean) // .notRequiredField(java_lang_Class); @@ -951,12 +947,15 @@ public Meta(EspressoContext context) { .klass(); sun_reflect_ConstantPool_constantPoolOop = sun_reflect_ConstantPool.requireDeclaredField(Names.constantPoolOop, Types.java_lang_Object); + sun_misc_Cleaner = diff() // + .klass(VERSION_8_OR_LOWER, Types.sun_misc_Cleaner) // + .klass(VERSION_9_OR_HIGHER, Types.jdk_internal_ref_Cleaner) // + .klass(); + if (getJavaVersion().java8OrEarlier()) { java_lang_ref_Reference_pending = java_lang_ref_Reference.requireDeclaredField(Names.pending, Types.java_lang_ref_Reference); - sun_misc_Cleaner = knownKlass(Types.sun_misc_Cleaner); } else { java_lang_ref_Reference_pending = null; - sun_misc_Cleaner = null; } java_lang_ref_Reference_lock = diff() // .field(VERSION_8_OR_LOWER, Names.lock, Types.java_lang_ref_Reference$Lock) // @@ -1365,7 +1364,6 @@ private DiffVersionLoadHelper diff() { public final Field java_lang_Class_module; public final Field java_lang_Class_classLoader; public final Field java_lang_Class_modifiers; - public final Field java_lang_Class_classFileAccessFlags; public final Field java_lang_Class_primitive; public final Field sun_reflect_ConstantPool_constantPoolOop; public final ArrayKlass java_lang_Class_array; diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/EspressoReferenceDrainer.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/EspressoReferenceDrainer.java index a0226bb4eb9a..c1c9f9c35c80 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/EspressoReferenceDrainer.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/EspressoReferenceDrainer.java @@ -196,16 +196,12 @@ private void doWaitForReferencePendingList() { private void casNextIfNullAndMaybeClear(EspressoReference wrapper) { StaticObject ref = wrapper.getGuestReference(); - Meta meta = getMeta(); - assert meta.sun_misc_Cleaner != null || getJavaVersion().java9OrLater(); - if (meta.sun_misc_Cleaner != null && InterpreterToVM.instanceOf(ref, meta.sun_misc_Cleaner)) { - /* - * Cleaner references extends PhantomReference but are cleared. See HotSpot's - * ReferenceProcessor::process_discovered_references in referenceProcessor.cpp - */ + // Cleaner references extends PhantomReference but are cleared. + // See HotSpot's ReferenceProcessor::process_discovered_references in referenceProcessor.cpp + if (InterpreterToVM.instanceOf(ref, getMeta().sun_misc_Cleaner)) { wrapper.clear(); } - meta.java_lang_ref_Reference_next.compareAndSwapObject(ref, StaticObject.NULL, ref); + getMeta().java_lang_ref_Reference_next.compareAndSwapObject(ref, StaticObject.NULL, ref); } private static final class ExitTLA extends ThreadLocalAction { diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/GuestAllocator.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/GuestAllocator.java index 204e3d37a9f5..18cb1d3fbab7 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/GuestAllocator.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/GuestAllocator.java @@ -178,10 +178,6 @@ public StaticObject createClass(Klass klass) { meta.java_lang_Class_modifiers.setChar(newObj, (char) klass.getClassModifiers()); meta.java_lang_Class_primitive.setBoolean(newObj, klass.isPrimitive()); } - if (lang.getJavaVersion().java26OrLater()) { - assert meta.java_lang_Class_classFileAccessFlags != null; - meta.java_lang_Class_classFileAccessFlags.setChar(newObj, (char) VM.getClassAccessFlags(klass)); - } return trackAllocation(klass, newObj); } diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/VersionFilter.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/VersionFilter.java index e5058028c170..c2e6588d6834 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/VersionFilter.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/VersionFilter.java @@ -225,28 +225,4 @@ public boolean isValidFor(JavaVersion version) { return version.java25OrLater(); } } - - final class Java25OrEarlier implements VersionFilter { - public static final Java25OrEarlier INSTANCE = new Java25OrEarlier(); - - private Java25OrEarlier() { - } - - @Override - public boolean isValidFor(JavaVersion version) { - return version.java25OrEarlier(); - } - } - - final class Java26OrLater implements VersionFilter { - public static final Java26OrLater INSTANCE = new Java26OrLater(); - - private Java26OrLater() { - } - - @Override - public boolean isValidFor(JavaVersion version) { - return version.java26OrLater(); - } - } } diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/standard/Target_jdk_internal_reflect_ConstantPool.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/standard/Target_jdk_internal_reflect_ConstantPool.java deleted file mode 100644 index cc4b6bb8429b..000000000000 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/standard/Target_jdk_internal_reflect_ConstantPool.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (c) 2025, 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. - */ -package com.oracle.truffle.espresso.substitutions.standard; - -import java.lang.reflect.Field; -import java.lang.reflect.Member; - -import com.oracle.truffle.espresso.meta.Meta; -import com.oracle.truffle.espresso.runtime.staticobject.StaticObject; -import com.oracle.truffle.espresso.substitutions.EspressoSubstitutions; -import com.oracle.truffle.espresso.substitutions.Inject; -import com.oracle.truffle.espresso.substitutions.JavaSubstitution; -import com.oracle.truffle.espresso.substitutions.JavaType; -import com.oracle.truffle.espresso.substitutions.Substitution; -import com.oracle.truffle.espresso.substitutions.SubstitutionProfiler; -import com.oracle.truffle.espresso.substitutions.VersionFilter; -import com.oracle.truffle.espresso.vm.VM; - -@EspressoSubstitutions -public final class Target_jdk_internal_reflect_ConstantPool { - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - public static int getSize0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, @Inject VM vm) { - return vm.JVM_ConstantPoolGetSize(unused, jcpool); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - public static int getSize0(StaticObject self, @Inject VM vm, @Inject Meta meta) { - return vm.JVM_ConstantPoolGetSize(null, meta.sun_reflect_ConstantPool_constantPoolOop.getObject(self)); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - public static @JavaType(Class.class) StaticObject getClassAt0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, - @Inject VM vm, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - return vm.JVM_ConstantPoolGetClassAt(unused, jcpool, index, meta, profiler); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - public static @JavaType(Class.class) StaticObject getClassAt0(StaticObject self, int index, - @Inject VM vm, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - return vm.JVM_ConstantPoolGetClassAt(null, meta.sun_reflect_ConstantPool_constantPoolOop.getObject(self), index, meta, profiler); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - @SuppressWarnings("unused") - public static @JavaType(Class.class) StaticObject getClassAtIfLoaded0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - @SuppressWarnings("unused") - public static @JavaType(Class.class) StaticObject getClassAtIfLoaded0(StaticObject self, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - @SuppressWarnings("unused") - public static int getClassRefIndexAt0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - @SuppressWarnings("unused") - public static int getClassRefIndexAt0(StaticObject self, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - @SuppressWarnings("unused") - public static @JavaType(Member.class) StaticObject getMethodAt0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - @SuppressWarnings("unused") - public static @JavaType(Member.class) StaticObject getMethodAt0(StaticObject self, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - @SuppressWarnings("unused") - public static @JavaType(Member.class) StaticObject getMethodAtIfLoaded0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - @SuppressWarnings("unused") - public static @JavaType(Member.class) StaticObject getMethodAtIfLoaded0(StaticObject self, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - @SuppressWarnings("unused") - public static @JavaType(Field.class) StaticObject getFieldAt0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - @SuppressWarnings("unused") - public static @JavaType(Field.class) StaticObject getFieldAt0(StaticObject self, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - @SuppressWarnings("unused") - public static @JavaType(Field.class) StaticObject getFieldAtIfLoaded0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - @SuppressWarnings("unused") - public static @JavaType(Field.class) StaticObject getFieldAtIfLoaded0(StaticObject self, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - @SuppressWarnings("unused") - public static @JavaType(String[].class) StaticObject getMemberRefInfoAt0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - @SuppressWarnings("unused") - public static @JavaType(String[].class) StaticObject getMemberRefInfoAt0(StaticObject self, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - @SuppressWarnings("unused") - public static int getNameAndTypeRefIndexAt0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - @SuppressWarnings("unused") - public static int getNameAndTypeRefIndexAt0(StaticObject self, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - @SuppressWarnings("unused") - public static @JavaType(String[].class) StaticObject getNameAndTypeRefInfoAt0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - @SuppressWarnings("unused") - public static @JavaType(String[].class) StaticObject getNameAndTypeRefInfoAt0(StaticObject self, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - public static int getIntAt0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, - @Inject VM vm, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - return vm.JVM_ConstantPoolGetIntAt(unused, jcpool, index, meta, profiler); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - public static int getIntAt0(StaticObject self, int index, - @Inject VM vm, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - return vm.JVM_ConstantPoolGetIntAt(null, meta.sun_reflect_ConstantPool_constantPoolOop.getObject(self), index, meta, profiler); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - public static long getLongAt0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, - @Inject VM vm, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - return vm.JVM_ConstantPoolGetLongAt(unused, jcpool, index, meta, profiler); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - public static long getLongAt0(StaticObject self, int index, - @Inject VM vm, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - return vm.JVM_ConstantPoolGetLongAt(null, meta.sun_reflect_ConstantPool_constantPoolOop.getObject(self), index, meta, profiler); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - public static float getFloatAt0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, - @Inject VM vm, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - return vm.JVM_ConstantPoolGetFloatAt(unused, jcpool, index, meta, profiler); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - public static float getFloatAt0(StaticObject self, int index, - @Inject VM vm, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - return vm.JVM_ConstantPoolGetFloatAt(null, meta.sun_reflect_ConstantPool_constantPoolOop.getObject(self), index, meta, profiler); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - public static double getDoubleAt0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, - @Inject VM vm, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - return vm.JVM_ConstantPoolGetDoubleAt(unused, jcpool, index, meta, profiler); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - public static double getDoubleAt0(StaticObject self, int index, - @Inject VM vm, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - return vm.JVM_ConstantPoolGetDoubleAt(null, meta.sun_reflect_ConstantPool_constantPoolOop.getObject(self), index, meta, profiler); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - public static @JavaType(String.class) StaticObject getStringAt0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, - @Inject VM vm, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - return vm.JVM_ConstantPoolGetStringAt(unused, jcpool, index, meta, profiler); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - public static @JavaType(String.class) StaticObject getStringAt0(StaticObject self, int index, - @Inject VM vm, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - return vm.JVM_ConstantPoolGetStringAt(null, meta.sun_reflect_ConstantPool_constantPoolOop.getObject(self), index, meta, profiler); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - public static @JavaType(String.class) StaticObject getUTF8At0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, - @Inject VM vm, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - return vm.JVM_ConstantPoolGetUTF8At(unused, jcpool, index, meta, profiler); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - public static @JavaType(String.class) StaticObject getUTF8At0(StaticObject self, int index, - @Inject VM vm, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - return vm.JVM_ConstantPoolGetUTF8At(null, meta.sun_reflect_ConstantPool_constantPoolOop.getObject(self), index, meta, profiler); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java25OrEarlier.class) - @SuppressWarnings("unused") - public static byte getTagAt0(StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index) { - throw JavaSubstitution.unimplemented(); - } - - @Substitution(hasReceiver = true, languageFilter = VersionFilter.Java26OrLater.class) - @SuppressWarnings("unused") - public static byte getTagAt0(StaticObject self, int index) { - throw JavaSubstitution.unimplemented(); - } -} diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/standard/Target_sun_misc_Unsafe.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/standard/Target_sun_misc_Unsafe.java index 3b851cfd4989..d65e0de44e1b 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/standard/Target_sun_misc_Unsafe.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/standard/Target_sun_misc_Unsafe.java @@ -913,32 +913,6 @@ public static long objectFieldOffset1(@JavaType(Unsafe.class) StaticObject self, throw meta.throwException(meta.java_lang_InternalError); } - @Substitution(hasReceiver = true, nameProvider = Unsafe11.class) - static long knownObjectFieldOffset0(@SuppressWarnings("unused") StaticObject self, @JavaType(Class.class) StaticObject c, @JavaType(String.class) StaticObject guestName, - @Inject Meta meta, @Inject EspressoLanguage language) { - // Error code -1 is not found, -2 is static field - Klass k = c.getMirrorKlass(meta); - if (!(k instanceof ObjectKlass kl)) { - return -1; - } - String hostName = meta.toHostString(guestName); - Symbol name = meta.getNames().lookup(hostName); - if (name == null) { - return -1; - } - for (Field f : kl.getFieldTable()) { - if (!f.isRemoved() && f.getName() == name) { - return getGuestFieldOffset(f, language); - } - } - for (Field f : kl.getStaticFieldTable()) { - if (!f.isRemoved() && f.getName() == name) { - return -2; - } - } - return -1; - } - // region UnsafeAccessors @GenerateInline diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/vm/VM.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/vm/VM.java index 3480e81765bc..f5164240d521 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/vm/VM.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/vm/VM.java @@ -1378,10 +1378,6 @@ public boolean JVM_IsRecord(@JavaType(Class.class) StaticObject self) { @VmImpl(isJni = true) public int JVM_GetClassAccessFlags(@JavaType(Class.class) StaticObject clazz) { Klass klass = clazz.getMirrorKlass(getMeta()); - return getClassAccessFlags(klass); - } - - public static int getClassAccessFlags(Klass klass) { if (klass.isPrimitive()) { final int primitiveFlags = ACC_ABSTRACT | ACC_FINAL | ACC_PUBLIC; assert klass.getModifiers() == primitiveFlags; @@ -1896,59 +1892,52 @@ public int JVM_ConstantPoolGetSize(@SuppressWarnings("unused") @JavaType(Object. public @JavaType(Class.class) StaticObject JVM_ConstantPoolGetClassAt(@SuppressWarnings("unused") @JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - RuntimeConstantPool constantPool = jcpool.getMirrorKlass(getMeta()).getConstantPool(); - checkTag(constantPool, index, ConstantPool.Tag.CLASS, meta, profiler); - return constantPool.resolvedKlassAt(null, index).mirror(); + checkTag(jcpool.getMirrorKlass(getMeta()).getConstantPool(), index, ConstantPool.Tag.CLASS, meta, profiler); + return jcpool.getMirrorKlass(getMeta()).getConstantPool().resolvedKlassAt(null, index).mirror(); } @VmImpl(isJni = true) public double JVM_ConstantPoolGetDoubleAt(@SuppressWarnings("unused") @JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - RuntimeConstantPool constantPool = jcpool.getMirrorKlass(getMeta()).getConstantPool(); - checkTag(constantPool, index, ConstantPool.Tag.DOUBLE, meta, profiler); - return constantPool.doubleAt(index); + checkTag(jcpool.getMirrorKlass(getMeta()).getConstantPool(), index, ConstantPool.Tag.DOUBLE, meta, profiler); + return jcpool.getMirrorKlass(getMeta()).getConstantPool().doubleAt(index); } @VmImpl(isJni = true) public float JVM_ConstantPoolGetFloatAt(@SuppressWarnings("unused") @JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - RuntimeConstantPool constantPool = jcpool.getMirrorKlass(getMeta()).getConstantPool(); - checkTag(constantPool, index, ConstantPool.Tag.FLOAT, meta, profiler); - return constantPool.floatAt(index); + checkTag(jcpool.getMirrorKlass(getMeta()).getConstantPool(), index, ConstantPool.Tag.FLOAT, meta, profiler); + return jcpool.getMirrorKlass(getMeta()).getConstantPool().floatAt(index); } @VmImpl(isJni = true) public @JavaType(String.class) StaticObject JVM_ConstantPoolGetStringAt(@SuppressWarnings("unused") @JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - RuntimeConstantPool constantPool = jcpool.getMirrorKlass(getMeta()).getConstantPool(); - checkTag(constantPool, index, ConstantPool.Tag.STRING, meta, profiler); - return constantPool.resolvedStringAt(index); + checkTag(jcpool.getMirrorKlass(getMeta()).getConstantPool(), index, ConstantPool.Tag.STRING, meta, profiler); + return jcpool.getMirrorKlass(getMeta()).getConstantPool().resolvedStringAt(index); } @VmImpl(isJni = true) public @JavaType(String.class) StaticObject JVM_ConstantPoolGetUTF8At(@SuppressWarnings("unused") @JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - RuntimeConstantPool constantPool = jcpool.getMirrorKlass(getMeta()).getConstantPool(); - checkTag(constantPool, index, ConstantPool.Tag.UTF8, meta, profiler); - return getMeta().toGuestString(constantPool.utf8At(index).toString()); + checkTag(jcpool.getMirrorKlass(getMeta()).getConstantPool(), index, ConstantPool.Tag.UTF8, meta, profiler); + return getMeta().toGuestString(jcpool.getMirrorKlass(getMeta()).getConstantPool().utf8At(index).toString()); } @VmImpl(isJni = true) public int JVM_ConstantPoolGetIntAt(@SuppressWarnings("unused") @JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - RuntimeConstantPool constantPool = jcpool.getMirrorKlass(getMeta()).getConstantPool(); - checkTag(constantPool, index, ConstantPool.Tag.INTEGER, meta, profiler); - return constantPool.intAt(index); + checkTag(jcpool.getMirrorKlass(getMeta()).getConstantPool(), index, ConstantPool.Tag.INTEGER, meta, profiler); + return jcpool.getMirrorKlass(getMeta()).getConstantPool().intAt(index); } @VmImpl(isJni = true) public long JVM_ConstantPoolGetLongAt(@SuppressWarnings("unused") @JavaType(Object.class) StaticObject unused, @JavaType(Object.class) StaticObject jcpool, int index, @Inject Meta meta, @Inject SubstitutionProfiler profiler) { - RuntimeConstantPool constantPool = jcpool.getMirrorKlass(getMeta()).getConstantPool(); - checkTag(constantPool, index, ConstantPool.Tag.LONG, meta, profiler); - return constantPool.longAt(index); + checkTag(jcpool.getMirrorKlass(getMeta()).getConstantPool(), index, ConstantPool.Tag.LONG, meta, profiler); + return jcpool.getMirrorKlass(getMeta()).getConstantPool().longAt(index); } // endregion ConstantPool diff --git a/sdk/mx.sdk/mx_sdk_benchmark.py b/sdk/mx.sdk/mx_sdk_benchmark.py index 94791d69042e..0ffa9e3b4c6c 100644 --- a/sdk/mx.sdk/mx_sdk_benchmark.py +++ b/sdk/mx.sdk/mx_sdk_benchmark.py @@ -3430,13 +3430,6 @@ def renaissanceIterations(self): del benchmarks["gauss-mix"] del benchmarks["page-rank"] del benchmarks["movie-lens"] - if mx.get_jdk().javaCompliance >= '26': - # JDK-8361426 removes jdk.internal.ref.Cleaner and causes the following to fail - del benchmarks["als"] - del benchmarks["db-shootout"] - del benchmarks["dec-tree"] - del benchmarks["log-regression"] - del benchmarks["naive-bayes"] return benchmarks diff --git a/substratevm/ci/ci.jsonnet b/substratevm/ci/ci.jsonnet index 857bb7a082a2..f66891cb9873 100644 --- a/substratevm/ci/ci.jsonnet +++ b/substratevm/ci/ci.jsonnet @@ -140,9 +140,6 @@ "linux:amd64:jdk-latest": tier2 + partial(2) + gdb("14.2") + t("40:00"), }, }), - "oraclejdk-helloworld": mxgate("build,helloworld,hellomodule") + maven + jsonschema + platform_spec(no_jobs) + platform_spec({ - "linux:amd64:jdk-latest": tier1 + use_oraclejdk_latest + t("30:00"), - }), }, // END MAIN BUILD DEFINITION processed_builds::run_spec.process(task_dict), diff --git a/substratevm/mx.substratevm/suite.py b/substratevm/mx.substratevm/suite.py index 9bafaf3d14fd..9507701d2b8c 100644 --- a/substratevm/mx.substratevm/suite.py +++ b/substratevm/mx.substratevm/suite.py @@ -1240,7 +1240,7 @@ "requiresConcealed" : { "java.base" : [ "jdk.internal.misc", - "sun.nio", + "jdk.internal.ref", "sun.nio.ch", ], "jdk.internal.vm.ci" : [ diff --git a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_misc_ScopedMemoryAccess.java b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_misc_ScopedMemoryAccess.java index fd1a248a1bf8..1a4c72f5eb60 100644 --- a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_misc_ScopedMemoryAccess.java +++ b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_misc_ScopedMemoryAccess.java @@ -248,7 +248,7 @@ public static , E, M extends VectorSupport.Vec * {@link SyncCloseScopeOperation}) is essentially an empty operation but kills the field * location of {@link Target_jdk_internal_foreign_MemorySessionImpl#state}. */ - @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+5/src/hotspot/share/prims/scopedMemoryAccess.cpp#L215-L218") + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/prims/scopedMemoryAccess.cpp#L215-L218") @SuppressWarnings("static-method") @Substitute @TargetElement(onlyWith = SharedArenasEnabled.class) diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AbstractCollectionPolicy.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AbstractCollectionPolicy.java index a4417d2c44c8..fd8670301112 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AbstractCollectionPolicy.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AbstractCollectionPolicy.java @@ -75,8 +75,7 @@ static int getMaxSurvivorSpaces(Integer userValue) { protected static final int INITIAL_SURVIVOR_RATIO = 8; @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/gc/shared/gc_globals.hpp#L409-L411") // protected static final int MIN_SURVIVOR_RATIO = 3; - // GR-68417: adopt "JDK-8338977: Parallel: Improve heap resizing heuristics" - // @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/gc/shared/gc_globals.hpp#L340-L342") + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/gc/shared/gc_globals.hpp#L340-L342") // protected static final int ADAPTIVE_TIME_WEIGHT = 25; /* Constants to compute defaults for values which can be set through existing options. */ @@ -339,7 +338,7 @@ public final UnsignedWord getMinimumHeapSize() { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) protected abstract long gcCount(); - @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+2/src/hotspot/share/gc/shared/genArguments.cpp#L190-L305") + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+21/src/hotspot/share/gc/shared/genArguments.cpp#L195-L310") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+21/src/hotspot/share/gc/parallel/psYoungGen.cpp#L146-L168") protected SizeParameters computeSizeParameters(SizeParameters existing) { UnsignedWord minYoungSpaces = minSpaceSize(); // eden diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java index 7bd1411674a2..9d83e35ef955 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AdaptiveCollectionPolicy.java @@ -30,6 +30,7 @@ import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.heap.GCCause; +import com.oracle.svm.core.util.BasedOnJDKFile; import com.oracle.svm.core.util.TimeUtils; import com.oracle.svm.core.util.Timer; import com.oracle.svm.core.util.UnsignedUtils; @@ -44,14 +45,13 @@ * its base class {@code AdaptiveSizePolicy}. Method and variable names have been kept mostly the * same for comparability. */ -// GR-68417: adopt "JDK-8338977: Parallel: Improve heap resizing heuristics" -// @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+2/src/hotspot/share/gc/shared/adaptiveSizePolicy.hpp") -// @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+7/src/hotspot/share/gc/shared/adaptiveSizePolicy.cpp") -// @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+1/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.hpp") -// @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp") -// @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+8/src/hotspot/share/gc/parallel/psParallelCompact.cpp#L954-L1167") -// @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+5/src/hotspot/share/gc/parallel/psScavenge.cpp#L319-L634") -// @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+26/src/hotspot/share/gc/shared/gc_globals.hpp#L303-L407") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+2/src/hotspot/share/gc/shared/adaptiveSizePolicy.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+7/src/hotspot/share/gc/shared/adaptiveSizePolicy.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+1/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+25/src/hotspot/share/gc/parallel/psParallelCompact.cpp#L964-L1181") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+25/src/hotspot/share/gc/parallel/psScavenge.cpp#L319-L635") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+26/src/hotspot/share/gc/shared/gc_globals.hpp#L303-L407") class AdaptiveCollectionPolicy extends AbstractCollectionPolicy { /* diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxThreadCpuTimeSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxThreadCpuTimeSupport.java index 61ae2862e5f4..57f89137b123 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxThreadCpuTimeSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxThreadCpuTimeSupport.java @@ -66,7 +66,7 @@ public long getThreadCpuTime(IsolateThread isolateThread, boolean includeSystemT return fastCpuTime(pthread); } - @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+2/src/hotspot/os/linux/os_linux.cpp#L4939-L4951") + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+10/src/hotspot/os/linux/os_linux.cpp#L5113-L5125") @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static long fastCpuTime(pthread_t pthread) { CIntPointer threadsClockId = StackValue.get(Integer.BYTES); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java index f9aa6d29e1f7..80dca1fbd70f 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java @@ -354,7 +354,7 @@ protected void park(boolean isAbsolute, long time) { } } - @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+2/src/hotspot/os/posix/os_posix.cpp#L1830-L1906") + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+10/src/hotspot/os/posix/os_posix.cpp#L1662-L1738") private void park0(boolean isAbsolute, long time) { int status = Pthread.pthread_mutex_trylock_no_transition(mutex); if (status == Errno.EBUSY()) { @@ -393,7 +393,7 @@ private void park0(boolean isAbsolute, long time) { } @Override - @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+2/src/hotspot/os/posix/os_posix.cpp#L1908-L1931") + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+10/src/hotspot/os/posix/os_posix.cpp#L1740-L1763") protected void unpark() { StackOverflowCheck.singleton().makeYellowZoneAvailable(); try { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/aarch64/AArch64LibCHelper.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/aarch64/AArch64LibCHelper.java index 14e0f6dfd261..86c549c9dfff 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/aarch64/AArch64LibCHelper.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/aarch64/AArch64LibCHelper.java @@ -139,10 +139,6 @@ public interface CPUFeatures extends PointerBase { @AllowNarrowingCast @CField boolean fASIMDHP(); - - @AllowNarrowingCast - @CField - boolean fSB(); } // Checkstyle: resume } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/amd64/AMD64LibCHelper.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/amd64/AMD64LibCHelper.java index 151cc44fca00..53e493159002 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/amd64/AMD64LibCHelper.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/amd64/AMD64LibCHelper.java @@ -43,7 +43,7 @@ * - substratevm/src/com.oracle.svm.native.libchelper/include/amd64hotspotcpuinfo.h * - substratevm/src/com.oracle.svm.native.libchelper/src/cpuid.c */ -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+13/src/hotspot/cpu/x86/vm_version_x86.hpp#L43-L351") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+23/src/hotspot/cpu/x86/vm_version_x86.hpp#L41-L348") @CLibrary(value = "libchelper", requireStatic = true) public class AMD64LibCHelper { @Platforms(Platform.AMD64.class) @@ -322,10 +322,6 @@ public interface CPUFeatures extends PointerBase { @AllowNarrowingCast @CField boolean fAVX10_2(); - - @AllowNarrowingCast - @CField - boolean fHYBRID(); } // Checkstyle: resume } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/locale/LocaleCHelper.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/locale/LocaleCHelper.java index 380121402099..5832b2e9bc73 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/locale/LocaleCHelper.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/locale/LocaleCHelper.java @@ -59,7 +59,7 @@ class LocaleCHelper { * {@link #SVM_LOCALE_INITIALIZATION_OUT_OF_MEMORY}. */ @CFunction(value = "svm_initialize_locale", transition = NO_TRANSITION) - @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+7/src/java.base/unix/native/libjava/java_props_md.c#L71-L359") + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+17/src/java.base/unix/native/libjava/java_props_md.c#L71-L357") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+17/src/java.base/unix/native/libjava/java_props_md.c#L436-L460") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+21/src/java.base/windows/native/libjava/java_props_md.c#L263-L721") static native int initializeLocale(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/ContainerLibrary.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/ContainerLibrary.java index 0d699114aaf2..a05f1b4ebded 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/ContainerLibrary.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/ContainerLibrary.java @@ -48,47 +48,46 @@ @CContext(ContainerLibraryDirectives.class) @CLibrary(value = "svm_container", requireStatic = true, dependsOn = "m") // The following annotations are for files in `src/hotspot`, which are copied from the JDK -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/java.base/share/native/include/jni.h") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/java.base/unix/native/include/jni_md.h") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupSubsystem_linux.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupSubsystem_linux.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupUtil_linux.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupUtil_linux.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/osContainer_linux.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/osContainer_linux.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+11/src/hotspot/os/linux/os_linux.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/os_linux.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/linux/os_linux.inline.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/posix/include/jvm_md.h") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+10/src/hotspot/os/posix/os_posix.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/posix/os_posix.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/os/posix/os_posix.inline.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/memory/allocation.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/memory/allocation.inline.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/memory/allStatic.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+5/src/hotspot/share/nmt/memTag.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+12/src/hotspot/share/runtime/os.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+10/src/hotspot/share/runtime/os.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/runtime/os.inline.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/checkedCast.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/compilerWarnings_gcc.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/compilerWarnings.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/utilities/globalDefinitions_gcc.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+11/src/hotspot/share/utilities/globalDefinitions.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/macros.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/utilities/ostream.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+11/src/hotspot/share/utilities/ostream.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/permitForbiddenFunctions.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/java.base/share/native/include/jni.h") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/java.base/unix/native/include/jni_md.h") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+23/src/hotspot/os/linux/cgroupSubsystem_linux.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/cgroupSubsystem_linux.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/cgroupUtil_linux.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/cgroupUtil_linux.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/osContainer_linux.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/osContainer_linux.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+26/src/hotspot/os/linux/os_linux.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/os_linux.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/os_linux.inline.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/posix/include/jvm_md.h") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+25/src/hotspot/os/posix/os_posix.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+25/src/hotspot/os/posix/os_posix.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/posix/os_posix.inline.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+26/src/hotspot/share/memory/allocation.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+21/src/hotspot/share/memory/allocation.inline.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/memory/allStatic.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/nmt/memTag.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+22/src/hotspot/share/runtime/os.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+25/src/hotspot/share/runtime/os.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/runtime/os.inline.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/utilities/checkedCast.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+22/src/hotspot/share/utilities/compilerWarnings_gcc.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+22/src/hotspot/share/utilities/compilerWarnings.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/utilities/globalDefinitions_gcc.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+23/src/hotspot/share/utilities/globalDefinitions.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+21/src/hotspot/share/utilities/macros.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+23/src/hotspot/share/utilities/ostream.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+23/src/hotspot/share/utilities/ostream.hpp") // The following annotations are for files in `src/svm`, which are completely customized for SVM -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+13/src/hotspot/share/logging/log.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/memory/allocation.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+12/src/hotspot/share/runtime/globals.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/utilities/debug.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+4/src/hotspot/share/utilities/debug.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/logging/log.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+26/src/hotspot/share/memory/allocation.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+30/src/hotspot/share/runtime/globals.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+21/src/hotspot/share/utilities/debug.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/utilities/debug.hpp") public class ContainerLibrary { static final int VERSION = 240100; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceInternals.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceInternals.java index 5ac34fbd95a8..c576756a152c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceInternals.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceInternals.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, 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 @@ -217,7 +217,24 @@ public static void processPendingReferences() { Target_java_lang_ref_Reference ref = pendingList; pendingList = ref.discovered; ref.discovered = null; - ref.enqueueFromPending(); + + if (Target_jdk_internal_ref_Cleaner.class.isInstance(ref)) { + Target_jdk_internal_ref_Cleaner cleaner = Target_jdk_internal_ref_Cleaner.class.cast(ref); + // Cleaner catches all exceptions, cannot be overridden due to private c'tor + cleaner.clean(); + synchronized (processPendingLock) { + // Notify any waiters that progress has been made. This improves latency + // for nio.Bits waiters, which are the only important ones. + processPendingLock.notifyAll(); + } + } else { + @SuppressWarnings("unchecked") + Target_java_lang_ref_ReferenceQueue queue = SubstrateUtil.cast(ref.queue, Target_java_lang_ref_ReferenceQueue.class); + if (queue != Target_java_lang_ref_ReferenceQueue.NULL_QUEUE) { + // Enqueues, avoiding the potentially overridden Reference.enqueue(). + queue.enqueue(ref); + } + } } synchronized (processPendingLock) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Reference.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Reference.java index 2ed320704ecc..d155b37f2c66 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Reference.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Reference.java @@ -123,12 +123,6 @@ public final class Target_java_lang_ref_Reference { @KeepOriginal native T get(); - @Substitute - @SuppressWarnings("unchecked") - private T get0() { - return (T) ReferenceInternals.getReferent(SubstrateUtil.cast(this, Reference.class)); - } - @KeepOriginal native void clear(); @@ -154,9 +148,6 @@ boolean refersTo0(Object obj) { @KeepOriginal native boolean enqueue(); - @KeepOriginal - native void enqueueFromPending(); - @KeepOriginal native boolean isEnqueued(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_nio_BufferCleaner.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_nio_BufferCleaner.java deleted file mode 100644 index 802856ef2ba6..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_nio_BufferCleaner.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2025, 2025, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ -package com.oracle.svm.core.heap; - -import java.lang.ref.ReferenceQueue; - -import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.RecomputeFieldValue; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.thread.VMThreads; - -@TargetClass(className = "java.nio.BufferCleaner") -public final class Target_java_nio_BufferCleaner { - - @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "java.nio.BufferCleaner$CleanerList")// - static Target_java_nio_BufferCleaner_CleanerList cleanerList; - @Alias // - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.None, isFinal = true) // - static ReferenceQueue queue; - @Alias // - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) // - static Thread cleaningThread; -} - -@TargetClass(className = "java.nio.BufferCleaner", innerClass = "CleaningRunnable") -final class Target_java_nio_BufferCleaner_CleaningRunnable { - @SuppressWarnings("static-method") - @Substitute - public void run() { - while (true) { - try { - Target_sun_nio_Cleaner c = SubstrateUtil.cast(Target_java_nio_BufferCleaner.queue.remove(), Target_sun_nio_Cleaner.class); - c.clean(); - } catch (InterruptedException e) { - if (VMThreads.isTearingDown()) { - return; - } - // Ignore InterruptedException in cleaner thread. - } - } - } -} - -@TargetClass(className = "java.nio.BufferCleaner", innerClass = "CleanerList") -final class Target_java_nio_BufferCleaner_CleanerList { -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Cleaner.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_jdk_internal_ref_Cleaner.java similarity index 88% rename from substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Cleaner.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_jdk_internal_ref_Cleaner.java index 39ad8dcfebe4..9028f7bdcba8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Cleaner.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_jdk_internal_ref_Cleaner.java @@ -43,10 +43,29 @@ import jdk.internal.misc.InnocuousThread; +@TargetClass(className = "jdk.internal.ref.Cleaner") +public final class Target_jdk_internal_ref_Cleaner { + + @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// + static Target_jdk_internal_ref_Cleaner first; + + @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias)// + static ReferenceQueue dummyQueue = new ReferenceQueue<>(); + + @Alias + native void clean(); +} + +@TargetClass(className = "jdk.internal.ref.CleanerFactory") +final class Target_jdk_internal_ref_CleanerFactory { + @Alias + public static native Target_java_lang_ref_Cleaner cleaner(); +} + @TargetClass(className = "java.lang.ref.Cleaner") -public final class Target_java_lang_ref_Cleaner { +final class Target_java_lang_ref_Cleaner { @Alias// - Target_jdk_internal_ref_CleanerImpl impl; + public Target_jdk_internal_ref_CleanerImpl impl; } @TargetClass(className = "java.lang.ref.Cleaner$Cleanable") diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_sun_nio_Cleaner.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_sun_nio_Cleaner.java deleted file mode 100644 index 1f883d4ac5c9..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_sun_nio_Cleaner.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2025, 2025, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ -package com.oracle.svm.core.heap; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.TargetClass; - -@TargetClass(className = "sun.nio.Cleaner") -public final class Target_sun_nio_Cleaner { - @Alias - native void clean(); -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java index 46dafe7b2417..a829e31355f6 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java @@ -93,7 +93,6 @@ import com.oracle.svm.configure.ClassNameSupport; import com.oracle.svm.configure.config.SignatureUtil; - import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.BuildPhaseProvider.AfterHeapLayout; import com.oracle.svm.core.BuildPhaseProvider.AfterHostedUniverse; @@ -439,8 +438,8 @@ public final class DynamicHub implements AnnotatedElement, java.lang.reflect.Typ @Platforms(Platform.HOSTED_ONLY.class) public DynamicHub(Class hostedJavaClass, String name, byte hubType, ReferenceType referenceType, DynamicHub superType, - DynamicHub componentHub, String sourceFileName, int modifiers, int classFileAccessFlags, short flags, - ClassLoader classLoader, Class nestHost, String simpleBinaryName, Object declaringClass, String signature, int layerId) { + DynamicHub componentHub, String sourceFileName, int modifiers, short flags, ClassLoader classLoader, + Class nestHost, String simpleBinaryName, Object declaringClass, String signature, int layerId) { this.hostedJavaClass = hostedJavaClass; this.name = name; this.hubType = hubType; @@ -454,7 +453,7 @@ public DynamicHub(Class hostedJavaClass, String name, byte hubType, Reference Object loader = PredefinedClassesSupport.isPredefined(hostedJavaClass) ? NO_CLASS_LOADER : classLoader; this.companion = DynamicHubCompanion.createHosted(hostedJavaClass.getModule(), superType, sourceFileName, - modifiers, classFileAccessFlags, loader, nestHost, simpleBinaryName, declaringClass, signature); + modifiers, loader, nestHost, simpleBinaryName, declaringClass, signature); } /** @@ -474,7 +473,7 @@ public DynamicHub(Class hostedJavaClass, String name, byte hubType, Reference */ @NeverInline("Fields of DynamicHub are immutable. Immutable reads could float above ANY_LOCATION writes.") public static DynamicHub allocate(String name, DynamicHub superHub, Object interfacesEncoding, DynamicHub componentHub, String sourceFileName, - int modifiers, int classFileAccessFlags, short flags, ClassLoader classLoader, String simpleBinaryName, Module module, + int modifiers, short flags, ClassLoader classLoader, String simpleBinaryName, Module module, Object declaringClass, String signature, int typeID, int interfaceID, short numClassTypes, short typeIDDepth, @@ -502,7 +501,7 @@ public static DynamicHub allocate(String name, DynamicHub superHub, Object inter } } - DynamicHubCompanion companion = DynamicHubCompanion.createAtRuntime(module, superHub, sourceFileName, modifiers, classFileAccessFlags, classLoader, simpleBinaryName, declaringClass, + DynamicHubCompanion companion = DynamicHubCompanion.createAtRuntime(module, superHub, sourceFileName, modifiers, classLoader, simpleBinaryName, declaringClass, signature); /* Always allow unsafe allocation for classes that were loaded at run-time. */ @@ -1144,13 +1143,8 @@ public int getModifiers() { return companion.modifiers; } - @Substitute - int getClassFileAccessFlags() { + public int getClassAccessFlags() { if (ImageLayerBuildingSupport.buildingImageLayer()) { - /* - * Currently, layered images do not use the Class#classFileAccessFlags. This will be - * addressed by GR-68631. - */ int classAccessFlags = 0; for (var reflectionMetadataSingleton : LayeredReflectionMetadataSingleton.singletons()) { ImageReflectionMetadata reflectionMetadata = reflectionMetadataSingleton.getReflectionMetadata(this); @@ -1158,10 +1152,14 @@ int getClassFileAccessFlags() { } return classAccessFlags; } else { - return companion.classFileAccessFlags; + return getClassAccessFlags(reflectionMetadata()); } } + private int getClassAccessFlags(ReflectionMetadata reflectionMetadata) { + return reflectionMetadata != null ? (reflectionMetadata.getClassFlags() & CLASS_ACCESS_FLAGS_MASK) : companion.modifiers; + } + @Substitute private DynamicHub getComponentType() { return componentType; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHubCompanion.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHubCompanion.java index 341349df75b8..256eeaf2e11e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHubCompanion.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHubCompanion.java @@ -67,12 +67,6 @@ public final class DynamicHubCompanion { /** The {@link Modifier modifiers} of this class. */ final int modifiers; - /** - * The access flags of this class as they were in the class's bytecode, including the original - * setting of ACC_SUPER. - */ - final int classFileAccessFlags; - /** * The class that serves as the host for the nest. All nestmates have the same host. Always * encoded with null for Dynamic hubs allocated at runtime. @@ -155,25 +149,24 @@ public final class DynamicHubCompanion { @Stable boolean canUnsafeAllocate; @Platforms(Platform.HOSTED_ONLY.class) - static DynamicHubCompanion createHosted(Module module, DynamicHub superHub, String sourceFileName, int modifiers, int classFileAccessFlags, + static DynamicHubCompanion createHosted(Module module, DynamicHub superHub, String sourceFileName, int modifiers, Object classLoader, Class nestHost, String simpleBinaryName, Object declaringClass, String signature) { - return new DynamicHubCompanion(module, superHub, sourceFileName, modifiers, classFileAccessFlags, classLoader, nestHost, simpleBinaryName, declaringClass, signature); + return new DynamicHubCompanion(module, superHub, sourceFileName, modifiers, classLoader, nestHost, simpleBinaryName, declaringClass, signature); } - static DynamicHubCompanion createAtRuntime(Module module, DynamicHub superHub, String sourceFileName, int modifiers, int classFileAccessFlags, + static DynamicHubCompanion createAtRuntime(Module module, DynamicHub superHub, String sourceFileName, int modifiers, ClassLoader classLoader, String simpleBinaryName, Object declaringClass, String signature) { assert RuntimeClassLoading.isSupported(); - return new DynamicHubCompanion(module, superHub, sourceFileName, modifiers, classFileAccessFlags, classLoader, null, simpleBinaryName, declaringClass, signature); + return new DynamicHubCompanion(module, superHub, sourceFileName, modifiers, classLoader, null, simpleBinaryName, declaringClass, signature); } - private DynamicHubCompanion(Module module, DynamicHub superHub, String sourceFileName, int modifiers, int classFileAccessFlags, + private DynamicHubCompanion(Module module, DynamicHub superHub, String sourceFileName, int modifiers, Object classLoader, Class nestHost, String simpleBinaryName, Object declaringClass, String signature) { this.module = module; this.superHub = superHub; this.sourceFileName = sourceFileName; this.modifiers = modifiers; - this.classFileAccessFlags = classFileAccessFlags; this.nestHost = nestHost; this.simpleBinaryName = simpleBinaryName; this.declaringClass = declaringClass; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/registry/AbstractRuntimeClassRegistry.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/registry/AbstractRuntimeClassRegistry.java index 3fa34a7ffd22..2a5753013ffd 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/registry/AbstractRuntimeClassRegistry.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/registry/AbstractRuntimeClassRegistry.java @@ -43,11 +43,11 @@ import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.graal.meta.KnownOffsets; -import com.oracle.svm.core.hub.crema.CremaSupport; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.hub.DynamicHubTypeCheckUtil; import com.oracle.svm.core.hub.RuntimeClassLoading; import com.oracle.svm.core.hub.RuntimeClassLoading.ClassDefinitionInfo; +import com.oracle.svm.core.hub.crema.CremaSupport; import com.oracle.svm.core.hub.registry.SVMSymbols.SVMTypes; import com.oracle.svm.core.jdk.Target_java_lang_ClassLoader; import com.oracle.svm.core.util.VMError; @@ -289,7 +289,6 @@ private Class createClass(ParserKlass parsed, ClassDefinitionInfo info, Symbo String classSignature = getClassSignature(parsed); int modifiers = getClassModifiers(parsed); - int classFileAccessFlags = parsed.getFlags(); /* * The TypeCheckBuilder considers interface arrays as interfaces. Since we are dealing with @@ -413,7 +412,7 @@ private Class createClass(ParserKlass parsed, ClassDefinitionInfo info, Symbo checkNotHybrid(parsed); DynamicHub hub = DynamicHub.allocate(externalName, superHub, interfacesEncoding, null, - sourceFile, modifiers, classFileAccessFlags, flags, getClassLoader(), simpleBinaryName, module, enclosingClass, classSignature, + sourceFile, modifiers, flags, getClassLoader(), simpleBinaryName, module, enclosingClass, classSignature, typeID, interfaceID, numClassTypes, typeIDDepth, numIterableInterfaces, openTypeWorldTypeCheckSlots, openTypeWorldInterfaceHashTable, openTypeWorldInterfaceHashParam, dispatchTableLength, afterFieldsOffset, isValueBased); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/image/DisallowedImageHeapObjects.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/image/DisallowedImageHeapObjects.java index cd82c8a718bc..6d741986bc5b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/image/DisallowedImageHeapObjects.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/image/DisallowedImageHeapObjects.java @@ -59,7 +59,7 @@ public interface DisallowedObjectReporter { public static final Class CONTINUATION_CLASS = ReflectionUtil.lookupClass("jdk.internal.vm.Continuation"); private static final Method CONTINUATION_IS_STARTED_METHOD = ReflectionUtil.lookupMethod(CONTINUATION_CLASS, "isStarted"); private static final Class CLEANER_CLEANABLE_CLASS = ReflectionUtil.lookupClass("jdk.internal.ref.CleanerImpl$CleanerCleanable"); - public static final Class NIO_CLEANER_CLASS = ReflectionUtil.lookupClass("sun.nio.Cleaner"); + public static final Class LEGACY_CLEANER_CLASS = ReflectionUtil.lookupClass("jdk.internal.ref.Cleaner"); public static final Class MEMORY_SEGMENT_CLASS = ReflectionUtil.lookupClass("java.lang.foreign.MemorySegment"); public static final Class SCOPE_CLASS = ReflectionUtil.lookupClass("java.lang.foreign.MemorySegment$Scope"); @@ -86,7 +86,7 @@ public static void check(Object obj, DisallowedObjectReporter reporter) { onBufferReachable(buffer, reporter); } - if (obj instanceof Cleaner.Cleanable || NIO_CLEANER_CLASS.isInstance(obj)) { + if (obj instanceof Cleaner.Cleanable || LEGACY_CLEANER_CLASS.isInstance(obj)) { onCleanableReachable(obj, reporter); } @@ -182,10 +182,10 @@ public static void onBufferReachable(Buffer buffer, DisallowedObjectReporter rep } public static void onCleanableReachable(Object cleanable, DisallowedObjectReporter reporter) { - VMError.guarantee(cleanable instanceof Cleaner.Cleanable || NIO_CLEANER_CLASS.isInstance(cleanable)); + VMError.guarantee(cleanable instanceof Cleaner.Cleanable || LEGACY_CLEANER_CLASS.isInstance(cleanable)); /* - * Cleanable and sun.nio.Cleaner are used to release various resources such as native - * memory, file descriptors, or timers, which are not available at image runtime. By + * Cleanable and jdk.internal.ref.Cleaner are used to release various resources such as + * native memory, file descriptors, or timers, which are not available at image runtime. By * disallowing these objects, we detect when such resources are reachable. * * If a Cleanable is a nulled (Phantom)Reference, its problematic resource is already @@ -195,12 +195,12 @@ public static void onCleanableReachable(Object cleanable, DisallowedObjectReport * Thread) and does nothing, so we also tolerate it. We should encounter at least one such * object for jdk.internal.ref.CleanerFactory.commonCleaner. * - * Internal sun.nio.Cleaner objects (formerly in jdk.internal.ref, formerly in sun.misc) - * should be used only by DirectByteBuffer, which we already cover above, but other code - * could also use them. If they have been nulled, we tolerate them, too. + * Legacy jdk.internal.ref.Cleaner objects (formerly in sun.misc) should be used only by + * DirectByteBuffer, which we already cover above, but other code could also use them. If + * they have been nulled, we tolerate them, too. */ if (!(cleanable instanceof Reference && ((Reference) cleanable).refersTo(null)) && !CLEANER_CLEANABLE_CLASS.isInstance(cleanable)) { - throw reporter.raise("Detected an active instance of Cleanable or sun.io.Cleaner in the image heap. This usually means that a resource " + + throw reporter.raise("Detected an active instance of Cleanable or jdk.internal.ref.Cleaner in the image heap. This usually means that a resource " + "such as a Timer, native memory, a file descriptor or another resource is reachable which is not available at image runtime.", cleanable, "Prevent such objects being used during image generation, including by class initializers."); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java index 9a9358b81ca3..721b4867c78e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java @@ -104,9 +104,6 @@ final class Target_java_util_concurrent_atomic_AtomicReferenceFieldUpdater_Atomi if (!Modifier.isVolatile(modifiers)) throw new IllegalArgumentException("Must be volatile type"); - if (Modifier.isStatic(modifiers)) - throw new IllegalArgumentException("Must not be a static field"); - // access checks are disabled this.cclass = tclass; this.tclass = tclass; @@ -145,9 +142,6 @@ final class Target_java_util_concurrent_atomic_AtomicIntegerFieldUpdater_AtomicI if (!Modifier.isVolatile(modifiers)) throw new IllegalArgumentException("Must be volatile type"); - if (Modifier.isStatic(modifiers)) - throw new IllegalArgumentException("Must not be a static field"); - // access checks are disabled this.cclass = tclass; this.tclass = tclass; @@ -185,9 +179,6 @@ final class Target_java_util_concurrent_atomic_AtomicLongFieldUpdater_CASUpdater if (!Modifier.isVolatile(modifiers)) throw new IllegalArgumentException("Must be volatile type"); - if (Modifier.isStatic(modifiers)) - throw new IllegalArgumentException("Must not be a static field"); - // access checks are disabled this.cclass = tclass; this.tclass = tclass; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java index 683bd71d02fc..9a2a6d699a6e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java @@ -166,7 +166,7 @@ public Object getUncompressedObject(long address) { private native long objectFieldOffset0(Field f); @Delete - private native long knownObjectFieldOffset0(Class c, String name); + private native long objectFieldOffset1(Class c, String name); @Delete private native long staticFieldOffset0(Field f); @@ -198,6 +198,11 @@ private Class defineClass0(String name, byte[] b, int off, int len, ClassLoad @TargetClass(jdk.internal.access.SharedSecrets.class) final class Target_jdk_internal_access_SharedSecrets { + @Substitute + private static Target_jdk_internal_access_JavaAWTAccess getJavaAWTAccess() { + return null; + } + /** * The JavaIOAccess implementation installed by the class initializer of java.io.Console * captures state like "is a tty". The only way to remove such state is by resetting the field. @@ -210,6 +215,10 @@ final class Target_jdk_internal_access_SharedSecrets { final class Target_jdk_internal_access_JavaIOAccess { } +@TargetClass(jdk.internal.access.JavaAWTAccess.class) +final class Target_jdk_internal_access_JavaAWTAccess { +} + @TargetClass(className = "sun.reflect.misc.MethodUtil") final class Target_sun_reflect_misc_MethodUtil { @Substitute diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_nio_Bits.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_nio_Bits.java index db66f1e0d7ba..9cfc3b9fbb85 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_nio_Bits.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_nio_Bits.java @@ -52,8 +52,6 @@ final class Target_java_nio_Bits { @Alias @RecomputeFieldValue(kind = Kind.FromAlias) // private static AtomicLong COUNT = new AtomicLong(); - @Alias @RecomputeFieldValue(kind = Kind.Reset) // - private static int RESERVE_GC_EPOCH; // Checkstyle: resume } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_nio_DirectByteBuffer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_nio_DirectByteBuffer.java index 9852c3591e95..62efa2660aa9 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_nio_DirectByteBuffer.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_nio_DirectByteBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -29,12 +29,12 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.heap.Target_sun_nio_Cleaner; +import com.oracle.svm.core.heap.Target_jdk_internal_ref_Cleaner; import com.oracle.svm.core.util.BasedOnJDKFile; import com.oracle.svm.core.util.VMError; @TargetClass(className = "java.nio.DirectByteBuffer") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+6/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+26/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template") public final class Target_java_nio_DirectByteBuffer { /** @@ -49,7 +49,7 @@ public final class Target_java_nio_DirectByteBuffer { * registered for the buffer by resetting the field {@link #cleaner}. */ @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) // - Target_sun_nio_Cleaner cleaner; + Target_jdk_internal_ref_Cleaner cleaner; @Alias @SuppressWarnings("unused") diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_reflect_Reflection.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_reflect_Reflection.java index 3475bb62f960..76e39f35971d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_reflect_Reflection.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_reflect_Reflection.java @@ -44,6 +44,11 @@ private static Class getCallerClass() { return StackTraceUtils.getCallerClass(KnownIntrinsics.readCallerStackPointer(), true); } + @Substitute + private static int getClassAccessFlags(DynamicHub cls) { + return cls.getClassAccessFlags(); + } + @Substitute private static boolean areNestMates(Class currentClass, Class memberClass) { return DynamicHub.fromClass(currentClass).isNestmateOf(memberClass); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_util_StaticProperty.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_util_StaticProperty.java index 4b3db5f051e5..bb72eee8511c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_util_StaticProperty.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_util_StaticProperty.java @@ -96,18 +96,6 @@ final class Target_jdk_internal_util_StaticProperty { @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// private static String JAVA_PROPERTIES_DATE; - @Alias// - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// - private static String STDIN_ENCODING; - - @Alias// - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// - private static String STDERR_ENCODING; - - @Alias// - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// - private static String STDOUT_ENCODING; - @Alias// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// private static String SUN_JNU_ENCODING; @@ -205,10 +193,6 @@ final class Target_jdk_internal_util_StaticProperty { NATIVE_ENCODING = p.getInitialProperty("native.encoding"); FILE_ENCODING = p.getInitialProperty("file.encoding"); JAVA_PROPERTIES_DATE = p.getInitialProperty("java.properties.date"); - STDIN_ENCODING = p.getInitialProperty("stdin.encoding"); - STDERR_ENCODING = p.getInitialProperty("stderr.encoding"); - STDOUT_ENCODING = p.getInitialProperty("stdout.encoding"); - SUN_JNU_ENCODING = p.getInitialProperty("sun.jnu.encoding"); JAVA_LOCALE_USE_OLD_ISO_CODES = p.getInitialProperty("java.locale.useOldISOCodes", ""); @@ -313,24 +297,6 @@ public static String javaPropertiesDate() { return JAVA_PROPERTIES_DATE; } - @Substitute - public static String stdinEncoding() { - assert Objects.equals(STDIN_ENCODING, SystemPropertiesSupport.singleton().getInitialProperty("stdin.encoding")); - return STDIN_ENCODING; - } - - @Substitute - public static String stdoutEncoding() { - assert Objects.equals(STDOUT_ENCODING, SystemPropertiesSupport.singleton().getInitialProperty("stdout.encoding")); - return STDOUT_ENCODING; - } - - @Substitute - public static String stderrEncoding() { - assert Objects.equals(STDERR_ENCODING, SystemPropertiesSupport.singleton().getInitialProperty("stderr.encoding")); - return STDERR_ENCODING; - } - @Substitute public static String jnuEncoding() { assert Objects.equals(SUN_JNU_ENCODING, SystemPropertiesSupport.singleton().getInitialProperty("sun.jnu.encoding")); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_sun_nio_fs_UnixNativeDispatcher.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_sun_nio_fs_UnixNativeDispatcher.java deleted file mode 100644 index 88b2a910cf68..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_sun_nio_fs_UnixNativeDispatcher.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2025, 2025, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ -package com.oracle.svm.core.jdk; - -import static com.oracle.svm.core.jdk.Helper_sun_nio_fs_UnixNativeDispatcher.init1; - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -@TargetClass(className = "sun.nio.fs.UnixNativeDispatcher", onlyWith = NonWindowsOS.class) -final class Target_sun_nio_fs_UnixNativeDispatcher { - - /** - * Wraps the original native {@code init()} call with a pthread mutex. This is a workaround for - * GR-69415. The assumption is that there is a race condition when multiple isolates call the - * static initializer of {@code UnixNativeDispatcher} and thus the native {@code init} function - * concurrently. All those calls operate on the same global C variables so multiple isolates can - * interfere with each other. - */ - @Substitute - static int init() { - return init1(Target_sun_nio_fs_UnixNativeDispatcher.class); - } -} - -final class Helper_sun_nio_fs_UnixNativeDispatcher { - /** - * A C-level thread-safe wrapper for the original - * {@link Target_sun_nio_fs_UnixNativeDispatcher#init()}. Implementation is in - * {@code UnixNativeDispatcher.c}. - */ - static native int init1(Class targetSunNioFsUnixNativeDispatcherClass); -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/BundleContentSubstitutedLocalizationSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/BundleContentSubstitutedLocalizationSupport.java index 50771070fec5..42f2ed2c9dff 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/BundleContentSubstitutedLocalizationSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/BundleContentSubstitutedLocalizationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 @@ -53,6 +53,7 @@ import jdk.graal.compiler.debug.GraalError; import sun.util.resources.OpenListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; /** * This version of LocalizationSupport stores the content of resource bundles in a map to make the @@ -150,7 +151,7 @@ private static boolean isBundleSupported(ResourceBundle bundle) { @Platforms(Platform.HOSTED_ONLY.class) public static boolean isBundleSupported(Class bundleClass) { - return ListResourceBundle.class.isAssignableFrom(bundleClass) || OpenListResourceBundle.class.isAssignableFrom(bundleClass); + return ListResourceBundle.class.isAssignableFrom(bundleClass) || OpenListResourceBundle.class.isAssignableFrom(bundleClass) || ParallelListResourceBundle.class.isAssignableFrom(bundleClass); } @Platforms(Platform.HOSTED_ONLY.class) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/compression/utils/BundleSerializationUtils.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/compression/utils/BundleSerializationUtils.java index 1c2f90686167..17469fae477e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/compression/utils/BundleSerializationUtils.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/compression/utils/BundleSerializationUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 @@ -29,7 +29,6 @@ import java.util.List; import java.util.Map; import java.util.ResourceBundle; -import java.util.function.Supplier; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -60,11 +59,7 @@ public static Map extractContent(ResourceBundle bundle) { Class clazz = bundle.getClass().getSuperclass(); while (clazz != null && ResourceBundle.class.isAssignableFrom(clazz)) { try { - Object lookup = ReflectionUtil.lookupField(clazz, "lookup").get(bundle); - if (lookup instanceof Supplier) { - return ((Supplier>) lookup).get(); - } - return (Map) lookup; + return (Map) ReflectionUtil.lookupField(clazz, "lookup").get(bundle); } catch (ReflectionUtil.ReflectionUtilError | ReflectiveOperationException e) { clazz = clazz.getSuperclass(); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/substitutions/Target_sun_util_resources_OpenListResourceBundle_SubstituteLoadLookup.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/substitutions/Target_sun_util_resources_OpenListResourceBundle_SubstituteLoadLookup.java index f6e1fefc0e06..7ca2a208241b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/substitutions/Target_sun_util_resources_OpenListResourceBundle_SubstituteLoadLookup.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/substitutions/Target_sun_util_resources_OpenListResourceBundle_SubstituteLoadLookup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 @@ -38,13 +38,20 @@ @SuppressWarnings({"static-method"}) final class Target_sun_util_resources_OpenListResourceBundle_SubstituteLoadLookup { + @Alias private volatile Map lookup; + @Substitute - private Map lookup0() { - Map preloadedContent = ImageSingletons.lookup(LocalizationSupport.class).getBundleContentOf(this); - /* Use the type of map provided by the subclass. */ - Map map = createMap(preloadedContent.size()); - map.putAll(preloadedContent); - return map; + private void loadLookup() { + LocalizationSupport support = ImageSingletons.lookup(LocalizationSupport.class); + Map content = support.getBundleContentOf(this); + // use the supplied map implementation specified by the factory method + Map tmp = createMap(content.size()); + tmp.putAll(content); + synchronized (this) { + if (lookup == null) { + lookup = content; + } + } } @Alias diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/substitutions/Target_sun_util_resources_ParallelListResourceBundle_SubstituteLoadLookup.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/substitutions/Target_sun_util_resources_ParallelListResourceBundle_SubstituteLoadLookup.java new file mode 100644 index 000000000000..ea49b2811ab9 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/substitutions/Target_sun_util_resources_ParallelListResourceBundle_SubstituteLoadLookup.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2021, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ +package com.oracle.svm.core.jdk.localization.substitutions; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import org.graalvm.nativeimage.ImageSingletons; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import com.oracle.svm.core.jdk.localization.LocalizationSupport; +import com.oracle.svm.core.jdk.localization.substitutions.modes.SubstituteLoadLookup; +import com.oracle.svm.core.util.VMError; + +import sun.util.resources.OpenListResourceBundle; + +@TargetClass(value = sun.util.resources.ParallelListResourceBundle.class, onlyWith = SubstituteLoadLookup.class) +@SuppressWarnings({"unused", "static-method"}) +final class Target_sun_util_resources_ParallelListResourceBundle_SubstituteLoadLookup { + + @Alias private ConcurrentMap lookup; + + @Substitute + private void setParallelContents(OpenListResourceBundle rb) { + throw VMError.unsupportedFeature("Resource bundle lookup must be loaded during native image generation: " + getClass().getTypeName()); + } + + @Substitute + private boolean areParallelContentsComplete() { + return true; + } + + @Substitute + private void loadLookupTablesIfNecessary() { + LocalizationSupport support = ImageSingletons.lookup(LocalizationSupport.class); + synchronized (this) { + if (lookup == null) { + lookup = new ConcurrentHashMap<>(support.getBundleContentOf(this)); + } + } + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiDirectives.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiDirectives.java index 3ef48ecd7914..59b62437b21a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiDirectives.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiDirectives.java @@ -35,7 +35,7 @@ import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.util.BasedOnJDKFile; -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/prims/jvmti.xml") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+23/src/hotspot/share/prims/jvmti.xml") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+11/src/hotspot/share/prims/jvmtiH.xsl") class JvmtiDirectives implements CContext.Directives { private final Path jdkIncludeDir = Paths.get(System.getProperty("java.home")).resolve("include"); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/snippets/SnippetRuntime.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/snippets/SnippetRuntime.java index 5d114a2ae32d..0eca9dab356f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/snippets/SnippetRuntime.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/snippets/SnippetRuntime.java @@ -55,7 +55,6 @@ public class SnippetRuntime { * sequence. */ private static final SubstrateForeignCallDescriptor ARITHMETIC_SIN = findForeignJdkCall(UnaryOperation.SIN.foreignCallSignature.getName(), Math.class, "sin", NO_SIDE_EFFECT, true, true); - private static final SubstrateForeignCallDescriptor ARITHMETIC_SINH = findForeignJdkCall(UnaryOperation.SINH.foreignCallSignature.getName(), Math.class, "sinh", NO_SIDE_EFFECT, true, true); private static final SubstrateForeignCallDescriptor ARITHMETIC_COS = findForeignJdkCall(UnaryOperation.COS.foreignCallSignature.getName(), Math.class, "cos", NO_SIDE_EFFECT, true, true); private static final SubstrateForeignCallDescriptor ARITHMETIC_TAN = findForeignJdkCall(UnaryOperation.TAN.foreignCallSignature.getName(), Math.class, "tan", NO_SIDE_EFFECT, true, true); private static final SubstrateForeignCallDescriptor ARITHMETIC_TANH = findForeignJdkCall(UnaryOperation.TANH.foreignCallSignature.getName(), Math.class, "tanh", NO_SIDE_EFFECT, true, true); @@ -65,8 +64,8 @@ public class SnippetRuntime { private static final SubstrateForeignCallDescriptor ARITHMETIC_POW = findForeignJdkCall(BinaryOperation.POW.foreignCallSignature.getName(), Math.class, "pow", NO_SIDE_EFFECT, true, true); private static final SubstrateForeignCallDescriptor ARITHMETIC_CBRT = findForeignJdkCall(UnaryOperation.CBRT.foreignCallSignature.getName(), Math.class, "cbrt", NO_SIDE_EFFECT, true, true); - private static final SubstrateForeignCallDescriptor[] FOREIGN_CALLS = new SubstrateForeignCallDescriptor[]{UNSUPPORTED_FEATURE, REGISTER_FINALIZER, ARITHMETIC_SIN, ARITHMETIC_SINH, ARITHMETIC_COS, - ARITHMETIC_TAN, ARITHMETIC_TANH, ARITHMETIC_LOG, ARITHMETIC_LOG10, ARITHMETIC_EXP, ARITHMETIC_POW, ARITHMETIC_CBRT}; + private static final SubstrateForeignCallDescriptor[] FOREIGN_CALLS = new SubstrateForeignCallDescriptor[]{UNSUPPORTED_FEATURE, REGISTER_FINALIZER, ARITHMETIC_SIN, ARITHMETIC_COS, ARITHMETIC_TAN, + ARITHMETIC_TANH, ARITHMETIC_LOG, ARITHMETIC_LOG10, ARITHMETIC_EXP, ARITHMETIC_POW, ARITHMETIC_CBRT}; public static void registerForeignCalls(SubstrateForeignCallsProvider foreignCalls) { foreignCalls.register(FOREIGN_CALLS); diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java index 8989d33dbf88..f12c73108354 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java @@ -1969,7 +1969,7 @@ private Set getBuiltInModules() { Path jdkRoot = config.rootDir; try { var reader = ImageReader.open(jdkRoot.resolve("lib/modules")); - return new LinkedHashSet<>(reader.findNode("/modules").getChildNames().map(s -> s.substring("/modules/".length())).toList()); + return new LinkedHashSet<>(List.of(reader.getModuleNames())); } catch (IOException e) { throw showError("Unable to determine builtin modules of JDK in " + jdkRoot, e); } diff --git a/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/DowncallStub.java b/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/DowncallStub.java index 1a6fafecbf1d..84b5024c0da2 100644 --- a/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/DowncallStub.java +++ b/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/DowncallStub.java @@ -87,7 +87,7 @@ @SuppressWarnings("javadoc") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+7/src/hotspot/share/prims/nativeEntryPoint.cpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/cpu/x86/downcallLinker_x86_64.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+3/src/hotspot/cpu/aarch64/downcallLinker_aarch64.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+17/src/hotspot/cpu/aarch64/downcallLinker_aarch64.cpp") class DowncallStub extends NonBytecodeMethod { public static Signature createSignature(MetaAccessProvider metaAccess) { return ResolvedSignature.fromKinds(new JavaKind[]{JavaKind.Object}, JavaKind.Object, metaAccess); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java index 50edf6d8ff29..bdb44a1e5b68 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java @@ -164,7 +164,6 @@ import jdk.graal.compiler.phases.common.CanonicalizerPhase; import jdk.graal.compiler.virtual.phases.ea.PartialEscapePhase; import jdk.internal.loader.NativeLibraries; -import jdk.internal.reflect.Reflection; import jdk.internal.vm.annotation.DontInline; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.annotation.Stable; @@ -558,7 +557,6 @@ private DynamicHub createHub(AnalysisType type) { componentHub = dynamicHub(hybrid.componentType()); } int modifiers = javaClass.getModifiers(); - int classFileAccessFlags = Reflection.getClassAccessFlags(javaClass); /* * If the class is an application class then it was loaded by NativeImageClassLoader. The @@ -604,7 +602,7 @@ private DynamicHub createHub(AnalysisType type) { isLambdaFormHidden, isLinked, isProxyClass); return new DynamicHub(javaClass, className, computeHubType(type), ReferenceType.computeReferenceType(javaClass), - superHub, componentHub, sourceFileName, modifiers, classFileAccessFlags, flags, hubClassLoader, nestHost, + superHub, componentHub, sourceFileName, modifiers, flags, hubClassLoader, nestHost, simpleBinaryName, getDeclaringClass(javaClass), getSignature(javaClass), layerId); } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SecurityServicesFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SecurityServicesFeature.java index 4795070b4872..3ff424c9a901 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SecurityServicesFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SecurityServicesFeature.java @@ -301,14 +301,6 @@ public void duringSetup(DuringSetupAccess a) { rci.initializeAtRunTime(NativePRNG.Blocking.class, "for substitutions"); rci.initializeAtRunTime(NativePRNG.NonBlocking.class, "for substitutions"); - /* - * The following classes will pull a SecureRandom instance into the image heap, so we need - * to explicitly move them to a run time. - */ - rci.initializeAtRunTime(clazz(access, "com.sun.security.sasl.CramMD5Server"), "for substitutions"); - rci.initializeAtRunTime(clazz(access, "com.sun.security.sasl.digest.DigestMD5Base"), "for substitutions"); - rci.initializeAtRunTime(clazz(access, "com.sun.security.sasl.digest.DigestMD5Client"), "for substitutions"); - rci.initializeAtRunTime(clazz(access, "sun.security.provider.SeedGenerator"), "for substitutions"); rci.initializeAtRunTime(clazz(access, "sun.security.provider.SecureRandom$SeederHolder"), "for substitutions"); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/DisallowedImageHeapObjectFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/DisallowedImageHeapObjectFeature.java index 4ad79573f67d..b68cf684b209 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/DisallowedImageHeapObjectFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/DisallowedImageHeapObjectFeature.java @@ -25,8 +25,8 @@ package com.oracle.svm.hosted.image; import static com.oracle.svm.core.image.DisallowedImageHeapObjects.CANCELLABLE_CLASS; +import static com.oracle.svm.core.image.DisallowedImageHeapObjects.LEGACY_CLEANER_CLASS; import static com.oracle.svm.core.image.DisallowedImageHeapObjects.MEMORY_SEGMENT_CLASS; -import static com.oracle.svm.core.image.DisallowedImageHeapObjects.NIO_CLEANER_CLASS; import static com.oracle.svm.core.image.DisallowedImageHeapObjects.SCOPE_CLASS; import java.io.File; @@ -85,7 +85,7 @@ public void duringSetup(DuringSetupAccess a) { access.registerObjectReachableCallback(FileDescriptor.class, (a1, obj, reason) -> DisallowedImageHeapObjects.onFileDescriptorReachable(obj, this::error)); access.registerObjectReachableCallback(Buffer.class, (a1, obj, reason) -> DisallowedImageHeapObjects.onBufferReachable(obj, this::error)); access.registerObjectReachableCallback(Cleaner.Cleanable.class, (a1, obj, reason) -> DisallowedImageHeapObjects.onCleanableReachable(obj, this::error)); - access.registerObjectReachableCallback(NIO_CLEANER_CLASS, (a1, obj, reason) -> DisallowedImageHeapObjects.onCleanableReachable(obj, this::error)); + access.registerObjectReachableCallback(LEGACY_CLEANER_CLASS, (a1, obj, reason) -> DisallowedImageHeapObjects.onCleanableReachable(obj, this::error)); access.registerObjectReachableCallback(Cleaner.class, (a1, obj, reason) -> DisallowedImageHeapObjects.onCleanerReachable(obj, this::error)); access.registerObjectReachableCallback(ZipFile.class, (a1, obj, reason) -> DisallowedImageHeapObjects.onZipFileReachable(obj, this::error)); access.registerObjectReachableCallback(CANCELLABLE_CLASS, (a1, obj, reason) -> DisallowedImageHeapObjects.onCancellableReachable(obj, this::error)); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/localization/LocalizationFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/localization/LocalizationFeature.java index 504587e5a921..6f42f5ffac85 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/localization/LocalizationFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/localization/LocalizationFeature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, 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 @@ -103,6 +103,7 @@ import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.ResourceBundleBasedAdapter; import sun.util.resources.LocaleData; +import sun.util.resources.ParallelListResourceBundle; import sun.util.spi.CalendarProvider; /** @@ -163,6 +164,7 @@ public class LocalizationFeature implements InternalFeature { private Field baseLocaleCacheField; private Field localeCacheField; private Field candidatesCacheField; + private Field localeObjectCacheMapField; private Field langAliasesCacheField; private Field parentLocalesMapField; @Platforms(Platform.HOSTED_ONLY.class) private ImageClassLoader imageClassLoader; @@ -292,9 +294,10 @@ public void duringSetup(DuringSetupAccess a) { } langAliasesCacheField = access.findField(CLDRLocaleProviderAdapter.class, "langAliasesCache"); parentLocalesMapField = access.findField(CLDRLocaleProviderAdapter.class, "parentLocalesMap"); + baseLocaleCacheField = access.findField("sun.util.locale.BaseLocale$1InterningCache", "CACHE"); + localeCacheField = access.findField("java.util.Locale$LocaleCache", "LOCALE_CACHE"); + localeObjectCacheMapField = null; candidatesCacheField = access.findField("java.util.ResourceBundle$Control", "CANDIDATES_CACHE"); - baseLocaleCacheField = access.findField("sun.util.locale.BaseLocale", "CACHE"); - localeCacheField = access.findField("java.util.Locale", "LOCALE_CACHE"); String reason = "All ResourceBundleControlProvider that are registered as services end up as objects in the image heap, and are therefore registered to be initialized at image build time"; ServiceLoader.load(ResourceBundleControlProvider.class).stream() @@ -345,14 +348,27 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { @Override public void duringAnalysis(DuringAnalysisAccess a) { DuringAnalysisAccessImpl access = (DuringAnalysisAccessImpl) a; - - access.rescanRoot(baseLocaleCacheField); - access.rescanRoot(localeCacheField); - access.rescanRoot(candidatesCacheField); + scanLocaleCache(access, baseLocaleCacheField); + scanLocaleCache(access, localeCacheField); + scanLocaleCache(access, candidatesCacheField); access.rescanRoot(langAliasesCacheField); access.rescanRoot(parentLocalesMapField); } + private void scanLocaleCache(DuringAnalysisAccessImpl access, Field cacheFieldField) { + access.rescanRoot(cacheFieldField); + + Object localeCache; + try { + localeCache = cacheFieldField.get(null); + } catch (ReflectiveOperationException ex) { + throw VMError.shouldNotReachHere(ex); + } + if (localeCache != null && localeObjectCacheMapField != null) { + access.rescanField(localeCache, localeObjectCacheMapField); + } + } + @Platforms(Platform.HOSTED_ONLY.class) private static Set processLocalesOption() { Set locales = new HashSet<>(); @@ -494,6 +510,10 @@ protected void addResourceBundles() { prepareNegativeBundle(ConfigurationCondition.alwaysTrue(), baseName, locale, true); continue; /* No bundle for this `locale`. */ } + if (bundle instanceof ParallelListResourceBundle) { + /* Make sure the `bundle` content is complete. */ + localeData.setSupplementary((ParallelListResourceBundle) bundle); + } prepareJDKBundle(bundle, locale); } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/IdentityHashCodeUtil.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/IdentityHashCodeUtil.java index 759b73b6f283..8fa1b77b6bc7 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/IdentityHashCodeUtil.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/IdentityHashCodeUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 @@ -117,7 +117,13 @@ private static int readIdentityHashCode(long markWord) { * See HotSpotHashCodeSnippets for explanation. */ long lockBits = markWord & config.markWordLockMaskInPlace; - if (lockBits != config.monitorValue) { + boolean containsHashCode; + if (config.lockingMode == config.lockingModeLightweight) { + containsHashCode = lockBits != config.monitorValue; + } else { + containsHashCode = lockBits == config.unlockedValue; + } + if (containsHashCode) { int hashcode = (int) ((markWord & hashCodeMask) >>> config.markWordHashCodeShift); if (hashcode == config.uninitializedIdentityHashCodeValue) { return UNINITIALIZED; diff --git a/substratevm/src/com.oracle.svm.native.jvm.posix/src/UnixNativeDispatcherHelper.c b/substratevm/src/com.oracle.svm.native.jvm.posix/src/UnixNativeDispatcherHelper.c deleted file mode 100644 index df88b8ab73c7..000000000000 --- a/substratevm/src/com.oracle.svm.native.jvm.posix/src/UnixNativeDispatcherHelper.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2025, 2025, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -#include -#include - -// The original init function -jint JNICALL Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this); - -// cached capabilities -static jint capabilities = 0; - -// Global/static initialization flag and mutex -static jboolean initialized = JNI_FALSE; -static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER; - -JNIEXPORT jint JNICALL Java_com_oracle_svm_core_jdk_Helper_1sun_1nio_1fs_1UnixNativeDispatcher_init1(JNIEnv* env, jclass this, jclass unixNativeDispatcherClass) { - pthread_mutex_lock(&init_mutex); - if (initialized == JNI_FALSE) { - capabilities = Java_sun_nio_fs_UnixNativeDispatcher_init(env, unixNativeDispatcherClass); - // initialization done - initialized = JNI_TRUE; - } - pthread_mutex_unlock(&init_mutex); - return capabilities; -} diff --git a/substratevm/src/com.oracle.svm.native.libchelper/include/aarch64cpufeatures.h b/substratevm/src/com.oracle.svm.native.libchelper/include/aarch64cpufeatures.h index 4bbd44f63fdf..a6092e4a05a9 100644 --- a/substratevm/src/com.oracle.svm.native.libchelper/include/aarch64cpufeatures.h +++ b/substratevm/src/com.oracle.svm.native.libchelper/include/aarch64cpufeatures.h @@ -48,5 +48,4 @@ typedef struct { uint8_t fSVEBITPERM; uint8_t fFPHP; uint8_t fASIMDHP; - uint8_t fSB; } CPUFeatures; diff --git a/substratevm/src/com.oracle.svm.native.libchelper/include/amd64cpufeatures.h b/substratevm/src/com.oracle.svm.native.libchelper/include/amd64cpufeatures.h index dfbe6f46555f..e975876cb771 100644 --- a/substratevm/src/com.oracle.svm.native.libchelper/include/amd64cpufeatures.h +++ b/substratevm/src/com.oracle.svm.native.libchelper/include/amd64cpufeatures.h @@ -91,5 +91,4 @@ typedef struct { uint8_t fAVX512_FP16; uint8_t fAVX10_1; uint8_t fAVX10_2; - uint8_t fHYBRID; } CPUFeatures; diff --git a/substratevm/src/com.oracle.svm.native.libchelper/include/amd64hotspotcpuinfo.h b/substratevm/src/com.oracle.svm.native.libchelper/include/amd64hotspotcpuinfo.h index 687aa4e1bd8f..92f2b08be7ca 100644 --- a/substratevm/src/com.oracle.svm.native.libchelper/include/amd64hotspotcpuinfo.h +++ b/substratevm/src/com.oracle.svm.native.libchelper/include/amd64hotspotcpuinfo.h @@ -188,8 +188,8 @@ typedef union { typedef union { uint32_t value; struct { - uint32_t threads_per_cpu : 8, - : 24; + uint32_t cores_per_cpu : 8, + : 24; } bits; } ExtCpuid8Ecx; @@ -265,8 +265,7 @@ typedef union { fast_short_rep_mov : 1, : 9, serialize : 1, - hybrid : 1, - : 4, + : 5, cet_ibt : 1, : 2, avx512_fp16 : 1, diff --git a/substratevm/src/com.oracle.svm.native.libchelper/src/cpuid.c b/substratevm/src/com.oracle.svm.native.libchelper/src/cpuid.c index c2f8f09cd190..193fb145c62d 100644 --- a/substratevm/src/com.oracle.svm.native.libchelper/src/cpuid.c +++ b/substratevm/src/com.oracle.svm.native.libchelper/src/cpuid.c @@ -211,10 +211,7 @@ static uint32_t cores_per_cpu(CpuidInfo *_cpuid_info) { } else if (is_amd_family(_cpuid_info)) { - result = _cpuid_info->ext_cpuid8_ecx.bits.threads_per_cpu + 1; - if (cpu_family(_cpuid_info) >= 0x17) { // Zen or later - result /= _cpuid_info->ext_cpuid1E_ebx.bits.threads_per_core + 1; - } + result = (_cpuid_info->ext_cpuid8_ecx.bits.cores_per_cpu + 1); } else if (is_zx(_cpuid_info)) { @@ -580,8 +577,6 @@ NO_INLINE static void set_cpufeatures(CPUFeatures *features, CpuidInfo *_cpuid_i { if (_cpuid_info->sef_cpuid7_edx.bits.serialize != 0) features->fSERIALIZE = 1; - if (_cpuid_info->sef_cpuid7_edx.bits.hybrid != 0) - features->fHYBRID = 1; if (_cpuid_info->sef_cpuid7_edx.bits.avx512_fp16 != 0) features->fAVX512_FP16 = 1; } @@ -695,7 +690,6 @@ void determineCPUFeatures(CPUFeatures* features) { features->fLSE = !!(cpu_has("hw.optional.arm.FEAT_LSE")) | !!(cpu_has("hw.optional.armv8_1_atomics")); features->fSHA512 = !!(cpu_has("hw.optional.arm.FEAT_SHA512")) | !!(cpu_has("hw.optional.armv8_2_sha512")); features->fSHA3 = !!(cpu_has("hw.optional.arm.FEAT_SHA3")) | !!(cpu_has("hw.optional.armv8_2_sha3")); - features->fSB = !!(cpu_has("hw.optional.arm.FEAT_SB")); // Not (yet) checked in the Hotspot code. features->fDCPOP = 0; features->fSVE = 0; @@ -757,9 +751,6 @@ void determineCPUFeatures(CPUFeatures* features) { #ifndef HWCAP_SVE #define HWCAP_SVE (1L << 22) #endif -#ifndef HWCAP_SB -#define HWCAP_SB (1L << 29) -#endif #ifndef HWCAP_PACA #define HWCAP_PACA (1L << 30) #endif @@ -804,7 +795,6 @@ void determineCPUFeatures(CPUFeatures* features) { features->fSTXR_PREFETCH = 0; features->fA53MAC = 0; features->fDMB_ATOMICS = 0; - features->fSB = !!(auxv & HWCAP_SB); features->fPACA = !!(auxv & HWCAP_PACA); features->fSVEBITPERM = !!(auxv2 & HWCAP2_SVEBITPERM); features->fFPHP = !!(auxv & HWCAP_FPHP); diff --git a/substratevm/src/com.oracle.svm.native.libchelper/src/locale.c b/substratevm/src/com.oracle.svm.native.libchelper/src/locale.c index bda9b7185476..25889390f680 100644 --- a/substratevm/src/com.oracle.svm.native.libchelper/src/locale.c +++ b/substratevm/src/com.oracle.svm.native.libchelper/src/locale.c @@ -206,7 +206,6 @@ static int ParseLocale(int cat, char ** std_language, char ** std_script, if (language != NULL && mapLookup(language_names, language, std_language) == 0) { *std_language = malloc(strlen(language)+1); if (*std_language == NULL) { - free(temp); free(encoding_variant); return SVM_LOCALE_INITIALIZATION_OUT_OF_MEMORY; } @@ -219,7 +218,6 @@ static int ParseLocale(int cat, char ** std_language, char ** std_script, if (mapLookup(country_names, country, std_country) == 0) { *std_country = malloc(strlen(country)+1); if (*std_country == NULL) { - free(temp); free(encoding_variant); return SVM_LOCALE_INITIALIZATION_OUT_OF_MEMORY; } diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp index 3e74f42f618c..8c671388f573 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -66,7 +66,7 @@ CgroupSubsystem* CgroupSubsystemFactory::create() { CgroupV1MemoryController* memory = nullptr; CgroupV1Controller* cpuset = nullptr; CgroupV1CpuController* cpu = nullptr; - CgroupV1CpuacctController* cpuacct = nullptr; + CgroupV1Controller* cpuacct = nullptr; CgroupV1Controller* pids = nullptr; CgroupInfo cg_infos[CG_INFO_LENGTH]; u1 cg_type_flags = INVALID_CGROUPS_GENERIC; @@ -109,10 +109,9 @@ CgroupSubsystem* CgroupSubsystemFactory::create() { CgroupV2CpuController* cpu = new CgroupV2CpuController(CgroupV2Controller(cg_infos[CPU_IDX]._mount_path, cg_infos[CPU_IDX]._cgroup_path, cg_infos[CPU_IDX]._read_only)); - CgroupV2CpuacctController* cpuacct = new CgroupV2CpuacctController(cpu); log_debug(os, container)("Detected cgroups v2 unified hierarchy"); cleanup(cg_infos); - return new CgroupV2Subsystem(memory, cpu, cpuacct, mem_other); + return new CgroupV2Subsystem(memory, cpu, mem_other); } /* @@ -155,7 +154,7 @@ CgroupSubsystem* CgroupSubsystemFactory::create() { cpu = new CgroupV1CpuController(CgroupV1Controller(info._root_mount_path, info._mount_path, info._read_only)); cpu->set_subsystem_path(info._cgroup_path); } else if (strcmp(info._name, "cpuacct") == 0) { - cpuacct = new CgroupV1CpuacctController(CgroupV1Controller(info._root_mount_path, info._mount_path, info._read_only)); + cpuacct = new CgroupV1Controller(info._root_mount_path, info._mount_path, info._read_only); cpuacct->set_subsystem_path(info._cgroup_path); } else if (strcmp(info._name, "pids") == 0) { pids = new CgroupV1Controller(info._root_mount_path, info._mount_path, info._read_only); @@ -302,7 +301,6 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos, } else { log_debug(os, container)("Can't read %s, %s", controllers_file, os::strerror(errno)); *flags = INVALID_CGROUPS_V2; - fclose(controllers); return false; } for (int i = 0; i < CG_INFO_LENGTH; i++) { @@ -363,7 +361,7 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos, all_required_controllers_enabled = all_required_controllers_enabled && cg_infos[i]._enabled; } if (log_is_enabled(Debug, os, container) && !cg_infos[i]._enabled) { - log_debug(os, container)("controller %s is not enabled", cg_controller_name[i]); + log_debug(os, container)("controller %s is not enabled\n", cg_controller_name[i]); } } } @@ -861,10 +859,6 @@ jlong CgroupSubsystem::memory_soft_limit_in_bytes() { return memory_controller()->controller()->memory_soft_limit_in_bytes(phys_mem); } -jlong CgroupSubsystem::memory_throttle_limit_in_bytes() { - return memory_controller()->controller()->memory_throttle_limit_in_bytes(); -} - jlong CgroupSubsystem::memory_usage_in_bytes() { return memory_controller()->controller()->memory_usage_in_bytes(); } @@ -893,10 +887,6 @@ int CgroupSubsystem::cpu_shares() { return cpu_controller()->controller()->cpu_shares(); } -jlong CgroupSubsystem::cpu_usage_in_micros() { - return cpuacct_controller()->cpu_usage_in_micros(); -} - #ifndef NATIVE_IMAGE void CgroupSubsystem::print_version_specific_info(outputStream* st) { julong phys_mem = os::Linux::physical_memory(); diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp index 514d84c786bc..a2ea1476d09a 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupSubsystem_linux.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -227,18 +227,6 @@ class CgroupCpuController: public CHeapObj { virtual const char* cgroup_path() = 0; }; -// Pure virtual class representing version agnostic CPU accounting controllers -class CgroupCpuacctController: public CHeapObj { - public: - virtual jlong cpu_usage_in_micros() = 0; - virtual bool needs_hierarchy_adjustment() = 0; - virtual bool is_read_only() = 0; - virtual const char* subsystem_path() = 0; - virtual void set_subsystem_path(const char* cgroup_path) = 0; - virtual const char* mount_point() = 0; - virtual const char* cgroup_path() = 0; -}; - // Pure virtual class representing version agnostic memory controllers class CgroupMemoryController: public CHeapObj { public: @@ -247,7 +235,6 @@ class CgroupMemoryController: public CHeapObj { virtual jlong memory_and_swap_limit_in_bytes(julong host_mem, julong host_swap) = 0; virtual jlong memory_and_swap_usage_in_bytes(julong host_mem, julong host_swap) = 0; virtual jlong memory_soft_limit_in_bytes(julong upper_bound) = 0; - virtual jlong memory_throttle_limit_in_bytes() = 0; virtual jlong memory_max_usage_in_bytes() = 0; virtual jlong rss_usage_in_bytes() = 0; virtual jlong cache_usage_in_bytes() = 0; @@ -276,19 +263,15 @@ class CgroupSubsystem: public CHeapObj { virtual const char * container_type() = 0; virtual CachingCgroupController* memory_controller() = 0; virtual CachingCgroupController* cpu_controller() = 0; - virtual CgroupCpuacctController* cpuacct_controller() = 0; int cpu_quota(); int cpu_period(); int cpu_shares(); - jlong cpu_usage_in_micros(); - jlong memory_usage_in_bytes(); jlong memory_and_swap_limit_in_bytes(); jlong memory_and_swap_usage_in_bytes(); jlong memory_soft_limit_in_bytes(); - jlong memory_throttle_limit_in_bytes(); jlong memory_max_usage_in_bytes(); jlong rss_usage_in_bytes(); jlong cache_usage_in_bytes(); diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp index ee5c09bd51c2..a21f4ab8446d 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp @@ -252,16 +252,10 @@ jlong CgroupV1MemoryController::memory_soft_limit_in_bytes(julong phys_mem) { } } -jlong CgroupV1MemoryController::memory_throttle_limit_in_bytes() { - // Log this string at trace level so as to make tests happy. - log_trace(os, container)("Memory Throttle Limit is not supported."); - return OSCONTAINER_ERROR; // not supported -} - // Constructor CgroupV1Subsystem::CgroupV1Subsystem(CgroupV1Controller* cpuset, CgroupV1CpuController* cpu, - CgroupV1CpuacctController* cpuacct, + CgroupV1Controller* cpuacct, CgroupV1Controller* pids, CgroupV1MemoryController* memory) : _cpuset(cpuset), @@ -428,13 +422,6 @@ int CgroupV1CpuController::cpu_shares() { return shares_int; } -jlong CgroupV1CpuacctController::cpu_usage_in_micros() { - julong cpu_usage; - CONTAINER_READ_NUMBER_CHECKED(reader(), "/cpuacct.usage", "CPU Usage", cpu_usage); - // Output is in nanoseconds, convert to microseconds. - return (jlong)cpu_usage / 1000; -} - /* pids_max * * Return the maximum number of tasks available to the process diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp index 4019e46d52e5..28c9a8166e61 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -86,7 +86,6 @@ class CgroupV1MemoryController final : public CgroupMemoryController { jlong memory_and_swap_limit_in_bytes(julong host_mem, julong host_swap) override; jlong memory_and_swap_usage_in_bytes(julong host_mem, julong host_swap) override; jlong memory_soft_limit_in_bytes(julong upper_bound) override; - jlong memory_throttle_limit_in_bytes() override; jlong memory_max_usage_in_bytes() override; jlong rss_usage_in_bytes() override; jlong cache_usage_in_bytes() override; @@ -147,41 +146,12 @@ class CgroupV1CpuController final : public CgroupCpuController { } }; -class CgroupV1CpuacctController final : public CgroupCpuacctController { - - private: - CgroupV1Controller _reader; - CgroupV1Controller* reader() { return &_reader; } - public: - jlong cpu_usage_in_micros() override; - void set_subsystem_path(const char *cgroup_path) override { - reader()->set_subsystem_path(cgroup_path); - } - bool is_read_only() override { - return reader()->is_read_only(); - } - const char* subsystem_path() override { - return reader()->subsystem_path(); - } - const char* mount_point() override { - return reader()->mount_point(); - } - bool needs_hierarchy_adjustment() override { - return reader()->needs_hierarchy_adjustment(); - } - const char* cgroup_path() override { return reader()->cgroup_path(); } - - public: - CgroupV1CpuacctController(const CgroupV1Controller& reader) : _reader(reader) { - } -}; - class CgroupV1Subsystem: public CgroupSubsystem { public: CgroupV1Subsystem(CgroupV1Controller* cpuset, CgroupV1CpuController* cpu, - CgroupV1CpuacctController* cpuacct, + CgroupV1Controller* cpuacct, CgroupV1Controller* pids, CgroupV1MemoryController* memory); @@ -201,14 +171,13 @@ class CgroupV1Subsystem: public CgroupSubsystem { } CachingCgroupController* memory_controller() { return _memory; } CachingCgroupController* cpu_controller() { return _cpu; } - CgroupCpuacctController* cpuacct_controller() { return _cpuacct; } private: /* controllers */ CachingCgroupController* _memory = nullptr; CgroupV1Controller* _cpuset = nullptr; CachingCgroupController* _cpu = nullptr; - CgroupV1CpuacctController* _cpuacct = nullptr; + CgroupV1Controller* _cpuacct = nullptr; CgroupV1Controller* _pids = nullptr; }; diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp index 7015bc6c9206..519f3eef814d 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2025, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -119,14 +119,12 @@ int CgroupV2CpuController::cpu_quota() { // Constructor CgroupV2Subsystem::CgroupV2Subsystem(CgroupV2MemoryController * memory, CgroupV2CpuController* cpu, - CgroupV2CpuacctController* cpuacct, CgroupV2Controller unified) : _unified(unified) { CgroupUtil::adjust_controller(memory); CgroupUtil::adjust_controller(cpu); _memory = new CachingCgroupController(memory); _cpu = new CachingCgroupController(cpu); - _cpuacct = cpuacct; } bool CgroupV2Subsystem::is_containerized() { @@ -159,17 +157,6 @@ int CgroupV2CpuController::cpu_period() { return period; } -jlong CgroupV2CpuController::cpu_usage_in_micros() { - julong cpu_usage; - bool is_ok = reader()->read_numerical_key_value("/cpu.stat", "usage_usec", &cpu_usage); - if (!is_ok) { - log_trace(os, container)("CPU Usage failed: %d", OSCONTAINER_ERROR); - return OSCONTAINER_ERROR; - } - log_trace(os, container)("CPU Usage is: " JULONG_FORMAT, cpu_usage); - return (jlong)cpu_usage; -} - /* memory_usage_in_bytes * * Return the amount of used memory used by this cgroup and descendents @@ -191,16 +178,10 @@ jlong CgroupV2MemoryController::memory_soft_limit_in_bytes(julong phys_mem) { return mem_soft_limit; } -jlong CgroupV2MemoryController::memory_throttle_limit_in_bytes() { - jlong mem_throttle_limit; - CONTAINER_READ_NUMBER_CHECKED_MAX(reader(), "/memory.high", "Memory Throttle Limit", mem_throttle_limit); - return mem_throttle_limit; -} - jlong CgroupV2MemoryController::memory_max_usage_in_bytes() { - julong mem_max_usage; - CONTAINER_READ_NUMBER_CHECKED(reader(), "/memory.peak", "Maximum Memory Usage", mem_max_usage); - return mem_max_usage; + // Log this string at trace level so as to make tests happy. + log_trace(os, container)("Maximum Memory Usage is not supported."); + return OSCONTAINER_ERROR; // not supported } jlong CgroupV2MemoryController::rss_usage_in_bytes() { diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp index 1d754321265f..3dd6000d4202 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -66,34 +66,6 @@ class CgroupV2CpuController: public CgroupCpuController { int cpu_quota() override; int cpu_period() override; int cpu_shares() override; - jlong cpu_usage_in_micros(); - bool is_read_only() override { - return reader()->is_read_only(); - } - const char* subsystem_path() override { - return reader()->subsystem_path(); - } - bool needs_hierarchy_adjustment() override { - return reader()->needs_hierarchy_adjustment(); - } - void set_subsystem_path(const char* cgroup_path) override { - reader()->set_subsystem_path(cgroup_path); - } - const char* mount_point() override { return reader()->mount_point(); } - const char* cgroup_path() override { return reader()->cgroup_path(); } -}; - -class CgroupV2CpuacctController: public CgroupCpuacctController { - private: - CgroupV2CpuController* _reader; - CgroupV2CpuController* reader() { return _reader; } - public: - CgroupV2CpuacctController(CgroupV2CpuController* reader) : _reader(reader) { - } - // In cgroup v2, cpu usage is a part of the cpu controller. - jlong cpu_usage_in_micros() override { - return reader()->cpu_usage_in_micros(); - } bool is_read_only() override { return reader()->is_read_only(); } @@ -122,7 +94,6 @@ class CgroupV2MemoryController final: public CgroupMemoryController { jlong memory_and_swap_limit_in_bytes(julong host_mem, julong host_swp) override; jlong memory_and_swap_usage_in_bytes(julong host_mem, julong host_swp) override; jlong memory_soft_limit_in_bytes(julong upper_bound) override; - jlong memory_throttle_limit_in_bytes() override; jlong memory_usage_in_bytes() override; jlong memory_max_usage_in_bytes() override; jlong rss_usage_in_bytes() override; @@ -154,14 +125,11 @@ class CgroupV2Subsystem: public CgroupSubsystem { CachingCgroupController* _memory = nullptr; CachingCgroupController* _cpu = nullptr; - CgroupCpuacctController* _cpuacct = nullptr; - CgroupV2Controller* unified() { return &_unified; } public: CgroupV2Subsystem(CgroupV2MemoryController * memory, CgroupV2CpuController* cpu, - CgroupV2CpuacctController* cpuacct, CgroupV2Controller unified); char * cpu_cpuset_cpus() override; @@ -176,7 +144,6 @@ class CgroupV2Subsystem: public CgroupSubsystem { } CachingCgroupController* memory_controller() override { return _memory; } CachingCgroupController* cpu_controller() override { return _cpu; } - CgroupCpuacctController* cpuacct_controller() override { return _cpuacct; }; }; diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp index 9c8c2ee1eeee..5f18730f1d0f 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -126,11 +126,6 @@ jlong OSContainer::memory_soft_limit_in_bytes() { return cgroup_subsystem->memory_soft_limit_in_bytes(); } -jlong OSContainer::memory_throttle_limit_in_bytes() { - assert(cgroup_subsystem != nullptr, "cgroup subsystem not available"); - return cgroup_subsystem->memory_throttle_limit_in_bytes(); -} - jlong OSContainer::memory_usage_in_bytes() { assert(cgroup_subsystem != nullptr, "cgroup subsystem not available"); return cgroup_subsystem->memory_usage_in_bytes(); @@ -188,11 +183,6 @@ int OSContainer::cpu_shares() { return cgroup_subsystem->cpu_shares(); } -jlong OSContainer::cpu_usage_in_micros() { - assert(cgroup_subsystem != nullptr, "cgroup subsystem not available"); - return cgroup_subsystem->cpu_usage_in_micros(); -} - jlong OSContainer::pids_max() { assert(cgroup_subsystem != nullptr, "cgroup subsystem not available"); return cgroup_subsystem->pids_max(); diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp index 50437e8649f6..1e9484c40d8f 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/osContainer_linux.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -60,7 +60,6 @@ class OSContainer: AllStatic { static jlong memory_and_swap_limit_in_bytes(); static jlong memory_and_swap_usage_in_bytes(); static jlong memory_soft_limit_in_bytes(); - static jlong memory_throttle_limit_in_bytes(); static jlong memory_usage_in_bytes(); static jlong memory_max_usage_in_bytes(); static jlong rss_usage_in_bytes(); @@ -76,8 +75,6 @@ class OSContainer: AllStatic { static int cpu_shares(); - static jlong cpu_usage_in_micros(); - static jlong pids_max(); static jlong pids_current(); }; diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp index d78947241ad8..b5d5bc1bd235 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/os_linux.cpp @@ -64,7 +64,9 @@ #include "runtime/osThread.hpp" #include "runtime/perfMemory.hpp" #include "runtime/sharedRuntime.hpp" +#include "runtime/statSampler.hpp" #include "runtime/stubRoutines.hpp" +#include "runtime/threadCritical.hpp" #include "runtime/threads.hpp" #include "runtime/threadSMR.hpp" #include "runtime/timer.hpp" @@ -149,6 +151,11 @@ #define MAX_PATH (2 * K) +#define MAX_SECS 100000000 + +// for timer info max values which include all bits +#define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) + #ifdef MUSL_LIBC // dlvsym is not a part of POSIX // and musl libc doesn't implement it. @@ -237,6 +244,8 @@ typedef int (*malloc_info_func_t)(int options, FILE *stream); static malloc_info_func_t g_malloc_info = nullptr; #endif // __GLIBC__ +static int clock_tics_per_sec = 100; + // If the VM might have been created on the primordial thread, we need to resolve the // primordial thread stack bounds and check if the current thread might be the // primordial thread in places. If we know that the primordial thread is never used, @@ -1092,23 +1101,10 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, ResourceMark rm; pthread_t tid; int ret = 0; - int trials_remaining = 4; - useconds_t next_delay = 1000; - while (true) { + int limit = 3; + do { ret = pthread_create(&tid, &attr, (void* (*)(void*)) thread_native_entry, thread); - - if (ret != EAGAIN) { - break; - } - - if (--trials_remaining <= 0) { - break; - } - - log_debug(os, thread)("Failed to start native thread (%s), retrying after %dus.", os::errno_name(ret), next_delay); - ::usleep(next_delay); - next_delay *= 2; - } + } while (ret == EAGAIN && limit-- > 0); char buf[64]; if (ret == 0) { @@ -1710,7 +1706,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) { } ThreadInVMfromNative tiv(jt); - DEBUG_ONLY(VMNativeEntryWrapper vew;) + debug_only(VMNativeEntryWrapper vew;) VM_LinuxDllLoad op(filename, ebuf, ebuflen); VMThread::execute(&op); @@ -2524,18 +2520,9 @@ bool os::Linux::print_container_info(outputStream* st) { st->print_cr("%s", i == OSCONTAINER_ERROR ? "not supported" : "no shares"); } - jlong j = OSContainer::cpu_usage_in_micros(); - st->print("cpu_usage_in_micros: "); - if (j >= 0) { - st->print_cr(JLONG_FORMAT, j); - } else { - st->print_cr("%s", j == OSCONTAINER_ERROR ? "not supported" : "no usage"); - } - OSContainer::print_container_helper(st, OSContainer::memory_limit_in_bytes(), "memory_limit_in_bytes"); OSContainer::print_container_helper(st, OSContainer::memory_and_swap_limit_in_bytes(), "memory_and_swap_limit_in_bytes"); OSContainer::print_container_helper(st, OSContainer::memory_soft_limit_in_bytes(), "memory_soft_limit_in_bytes"); - OSContainer::print_container_helper(st, OSContainer::memory_throttle_limit_in_bytes(), "memory_throttle_limit_in_bytes"); OSContainer::print_container_helper(st, OSContainer::memory_usage_in_bytes(), "memory_usage_in_bytes"); OSContainer::print_container_helper(st, OSContainer::memory_max_usage_in_bytes(), "memory_max_usage_in_bytes"); OSContainer::print_container_helper(st, OSContainer::rss_usage_in_bytes(), "rss_usage_in_bytes"); @@ -2543,7 +2530,7 @@ bool os::Linux::print_container_info(outputStream* st) { OSContainer::print_version_specific_info(st); - j = OSContainer::pids_max(); + jlong j = OSContainer::pids_max(); st->print("maximum number of tasks: "); if (j > 0) { st->print_cr(JLONG_FORMAT, j); @@ -2792,9 +2779,139 @@ void os::get_summary_cpu_info(char* cpuinfo, size_t length) { #endif } +static char saved_jvm_path[MAXPATHLEN] = {0}; + +// Find the full path to the current module, libjvm.so +void os::jvm_path(char *buf, jint buflen) { + // Error checking. + if (buflen < MAXPATHLEN) { + assert(false, "must use a large-enough buffer"); + buf[0] = '\0'; + return; + } + // Lazy resolve the path to current module. + if (saved_jvm_path[0] != 0) { + strcpy(buf, saved_jvm_path); + return; + } + + char dli_fname[MAXPATHLEN]; + dli_fname[0] = '\0'; + bool ret = dll_address_to_library_name( + CAST_FROM_FN_PTR(address, os::jvm_path), + dli_fname, sizeof(dli_fname), nullptr); + assert(ret, "cannot locate libjvm"); + char *rp = nullptr; + if (ret && dli_fname[0] != '\0') { + rp = os::realpath(dli_fname, buf, buflen); + } + if (rp == nullptr) { + return; + } + + if (Arguments::sun_java_launcher_is_altjvm()) { + // Support for the java launcher's '-XXaltjvm=' option. Typical + // value for buf is "/jre/lib//libjvm.so". + // If "/jre/lib/" appears at the right place in the string, then + // assume we are installed in a JDK and we're done. Otherwise, check + // for a JAVA_HOME environment variable and fix up the path so it + // looks like libjvm.so is installed there (append a fake suffix + // hotspot/libjvm.so). + const char *p = buf + strlen(buf) - 1; + for (int count = 0; p > buf && count < 5; ++count) { + for (--p; p > buf && *p != '/'; --p) + /* empty */ ; + } + + if (strncmp(p, "/jre/lib/", 9) != 0) { + // Look for JAVA_HOME in the environment. + char* java_home_var = ::getenv("JAVA_HOME"); + if (java_home_var != nullptr && java_home_var[0] != 0) { + char* jrelib_p; + int len; + + // Check the current module name "libjvm.so". + p = strrchr(buf, '/'); + if (p == nullptr) { + return; + } + assert(strstr(p, "/libjvm") == p, "invalid library name"); + + rp = os::realpath(java_home_var, buf, buflen); + if (rp == nullptr) { + return; + } + + // determine if this is a legacy image or modules image + // modules image doesn't have "jre" subdirectory + len = checked_cast(strlen(buf)); + assert(len < buflen, "Ran out of buffer room"); + jrelib_p = buf + len; + snprintf(jrelib_p, buflen-len, "/jre/lib"); + if (0 != access(buf, F_OK)) { + snprintf(jrelib_p, buflen-len, "/lib"); + } + + if (0 == access(buf, F_OK)) { + // Use current module name "libjvm.so" + len = (int)strlen(buf); + snprintf(buf + len, buflen-len, "/hotspot/libjvm.so"); + } else { + // Go back to path of .so + rp = os::realpath(dli_fname, buf, buflen); + if (rp == nullptr) { + return; + } + } + } + } + } + + strncpy(saved_jvm_path, buf, MAXPATHLEN); + saved_jvm_path[MAXPATHLEN - 1] = '\0'; +} + //////////////////////////////////////////////////////////////////////////////// // Virtual Memory +// Rationale behind this function: +// current (Mon Apr 25 20:12:18 MSD 2005) oprofile drops samples without executable +// mapping for address (see lookup_dcookie() in the kernel module), thus we cannot get +// samples for JITted code. Here we create private executable mapping over the code cache +// and then we can use standard (well, almost, as mapping can change) way to provide +// info for the reporting script by storing timestamp and location of symbol +void linux_wrap_code(char* base, size_t size) { + static volatile jint cnt = 0; + + static_assert(sizeof(off_t) == 8, "Expected Large File Support in this file"); + + if (!UseOprofile) { + return; + } + + char buf[PATH_MAX+1]; + int num = Atomic::add(&cnt, 1); + + snprintf(buf, sizeof(buf), "%s/hs-vm-%d-%d", + os::get_temp_directory(), os::current_process_id(), num); + unlink(buf); + + int fd = ::open(buf, O_CREAT | O_RDWR, S_IRWXU); + + if (fd != -1) { + off_t rv = ::lseek(fd, size-2, SEEK_SET); + if (rv != (off_t)-1) { + if (::write(fd, "", 1) == 1) { + mmap(base, size, + PROT_READ|PROT_WRITE|PROT_EXEC, + MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE, fd, 0); + } + } + ::close(fd); + unlink(buf); + } +} + static bool recoverable_mmap_error(int err) { // See if the error is one we can let the caller handle. This // list of errno values comes from JBS-6843484. I can't find a @@ -4324,6 +4441,8 @@ static void check_pax(void) { // this is called _before_ most of the global arguments have been parsed void os::init(void) { char dummy; // used to get a guess on initial stack address + + clock_tics_per_sec = checked_cast(sysconf(_SC_CLK_TCK)); int sys_pg_size = checked_cast(sysconf(_SC_PAGESIZE)); if (sys_pg_size < 0) { fatal("os_linux.cpp: os::init: sysconf failed (%s)", @@ -4516,7 +4635,7 @@ static void workaround_expand_exec_shield_cs_limit() { */ char* hint = (char*)(os::Linux::initial_thread_stack_bottom() - (StackOverflow::stack_guard_zone_size() + page_size)); - char* codebuf = os::attempt_reserve_memory_at(hint, page_size, mtThread); + char* codebuf = os::attempt_reserve_memory_at(hint, page_size, false, mtThread); if (codebuf == nullptr) { // JDK-8197429: There may be a stack gap of one megabyte between @@ -4524,7 +4643,7 @@ static void workaround_expand_exec_shield_cs_limit() { // Linux kernel workaround for CVE-2017-1000364. If we failed to // map our codebuf, try again at an address one megabyte lower. hint -= 1 * M; - codebuf = os::attempt_reserve_memory_at(hint, page_size, mtThread); + codebuf = os::attempt_reserve_memory_at(hint, page_size, false, mtThread); } if ((codebuf == nullptr) || (!os::commit_memory(codebuf, page_size, true))) { @@ -5078,21 +5197,21 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { &user_time, &sys_time); if (count != 13) return -1; if (user_sys_cpu_time) { - return ((jlong)sys_time + (jlong)user_time) * (1000000000 / os::Posix::clock_tics_per_second()); + return ((jlong)sys_time + (jlong)user_time) * (1000000000 / clock_tics_per_sec); } else { - return (jlong)user_time * (1000000000 / os::Posix::clock_tics_per_second()); + return (jlong)user_time * (1000000000 / clock_tics_per_sec); } } void os::current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr) { - info_ptr->max_value = all_bits_jlong; // will not wrap in less than 64 bits + info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits info_ptr->may_skip_backward = false; // elapsed time not wall time info_ptr->may_skip_forward = false; // elapsed time not wall time info_ptr->kind = JVMTI_TIMER_TOTAL_CPU; // user+system time is returned } void os::thread_cpu_time_info(jvmtiTimerInfo *info_ptr) { - info_ptr->max_value = all_bits_jlong; // will not wrap in less than 64 bits + info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits info_ptr->may_skip_backward = false; // elapsed time not wall time info_ptr->may_skip_forward = false; // elapsed time not wall time info_ptr->kind = JVMTI_TIMER_TOTAL_CPU; // user+system time is returned diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp index dc1026104838..08f1fed53010 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.cpp @@ -25,7 +25,6 @@ #ifndef NATIVE_IMAGE #include "classfile/classLoader.hpp" -#include "interpreter/interpreter.hpp" #include "jvm.h" #include "jvmtifiles/jvmti.h" #include "logging/log.hpp" @@ -56,7 +55,6 @@ #include "utilities/formatBuffer.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" -#include "utilities/permitForbiddenFunctions.hpp" #include "utilities/vmError.hpp" #if INCLUDE_JFR #include "jfr/support/jfrNativeLibraryLoadEvent.hpp" @@ -65,7 +63,6 @@ #ifdef AIX #include "loadlib_aix.hpp" #include "os_aix.hpp" -#include "porting_aix.hpp" #endif #ifdef LINUX #include "os_linux.hpp" @@ -503,9 +500,9 @@ static char* chop_extra_memory(size_t size, size_t alignment, char* extra_base, // Multiple threads can race in this code, and can remap over each other with MAP_FIXED, // so on posix, unmap the section at the start and at the end of the chunk that we mapped // rather than unmapping and remapping the whole chunk to get requested alignment. -char* os::reserve_memory_aligned(size_t size, size_t alignment, MemTag mem_tag, bool exec) { +char* os::reserve_memory_aligned(size_t size, size_t alignment, bool exec) { size_t extra_size = calculate_aligned_extra_size(size, alignment); - char* extra_base = os::reserve_memory(extra_size, mem_tag, exec); + char* extra_base = os::reserve_memory(extra_size, exec); if (extra_base == nullptr) { return nullptr; } @@ -942,11 +939,11 @@ ssize_t os::connect(int fd, struct sockaddr* him, socklen_t len) { } void os::exit(int num) { - permit_forbidden_function::exit(num); + ALLOW_C_FUNCTION(::exit, ::exit(num);) } void os::_exit(int num) { - permit_forbidden_function::_exit(num); + ALLOW_C_FUNCTION(::_exit, ::_exit(num);) } void os::naked_yield() { @@ -1003,7 +1000,7 @@ char* os::realpath(const char* filename, char* outbuf, size_t outbuflen) { // This assumes platform realpath() is implemented according to POSIX.1-2008. // POSIX.1-2008 allows to specify null for the output buffer, in which case // output buffer is dynamically allocated and must be ::free()'d by the caller. - char* p = permit_forbidden_function::realpath(filename, nullptr); + ALLOW_C_FUNCTION(::realpath, char* p = ::realpath(filename, nullptr);) if (p != nullptr) { if (strlen(p) < outbuflen) { strcpy(outbuf, p); @@ -1011,7 +1008,7 @@ char* os::realpath(const char* filename, char* outbuf, size_t outbuflen) { } else { errno = ENAMETOOLONG; } - permit_forbidden_function::free(p); // *not* os::free + ALLOW_C_FUNCTION(::free, ::free(p);) // *not* os::free } else { // Fallback for platforms struggling with modern Posix standards (AIX 5.3, 6.1). If realpath // returns EINVAL, this may indicate that realpath is not POSIX.1-2008 compatible and @@ -1020,7 +1017,7 @@ char* os::realpath(const char* filename, char* outbuf, size_t outbuflen) { // a memory overwrite. if (errno == EINVAL) { outbuf[outbuflen - 1] = '\0'; - p = permit_forbidden_function::realpath(filename, outbuf); + ALLOW_C_FUNCTION(::realpath, p = ::realpath(filename, outbuf);) if (p != nullptr) { guarantee(outbuf[outbuflen - 1] == '\0', "realpath buffer overwrite detected."); result = p; @@ -1080,95 +1077,6 @@ bool os::same_files(const char* file1, const char* file2) { return is_same; } -static char saved_jvm_path[MAXPATHLEN] = {0}; - -// Find the full path to the current module, libjvm.so -void os::jvm_path(char *buf, jint buflen) { - // Error checking. - if (buflen < MAXPATHLEN) { - assert(false, "must use a large-enough buffer"); - buf[0] = '\0'; - return; - } - // Lazy resolve the path to current module. - if (saved_jvm_path[0] != 0) { - strcpy(buf, saved_jvm_path); - return; - } - - const char* fname; -#ifdef AIX - Dl_info dlinfo; - int ret = dladdr(CAST_FROM_FN_PTR(void *, os::jvm_path), &dlinfo); - assert(ret != 0, "cannot locate libjvm"); - if (ret == 0) { - return; - } - fname = dlinfo.dli_fname; -#else - char dli_fname[MAXPATHLEN]; - dli_fname[0] = '\0'; - bool ret = dll_address_to_library_name( - CAST_FROM_FN_PTR(address, os::jvm_path), - dli_fname, sizeof(dli_fname), nullptr); - assert(ret, "cannot locate libjvm"); - if (!ret) { - return; - } - fname = dli_fname; -#endif // AIX - char* rp = nullptr; - if (fname[0] != '\0') { - rp = os::realpath(fname, buf, buflen); - } - if (rp == nullptr) { - return; - } - - // If executing unit tests we require JAVA_HOME to point to the real JDK. - if (Arguments::executing_unit_tests()) { - // Look for JAVA_HOME in the environment. - char* java_home_var = ::getenv("JAVA_HOME"); - if (java_home_var != nullptr && java_home_var[0] != 0) { - - // Check the current module name "libjvm.so". - const char* p = strrchr(buf, '/'); - if (p == nullptr) { - return; - } - assert(strstr(p, "/libjvm") == p, "invalid library name"); - - stringStream ss(buf, buflen); - rp = os::realpath(java_home_var, buf, buflen); - if (rp == nullptr) { - return; - } - - assert((int)strlen(buf) < buflen, "Ran out of buffer room"); - ss.print("%s/lib", buf); - - // If the path exists within JAVA_HOME, add the VM variant directory and JVM - // library name to complete the path to JVM being overridden. Otherwise fallback - // to the path to the current library. - if (0 == access(buf, F_OK)) { - // Use current module name "libjvm.so" - ss.print("/%s/libjvm%s", Abstract_VM_Version::vm_variant(), JNI_LIB_SUFFIX); - assert(strcmp(buf + strlen(buf) - strlen(JNI_LIB_SUFFIX), JNI_LIB_SUFFIX) == 0, - "buf has been truncated"); - } else { - // Go back to path of .so - rp = os::realpath(fname, buf, buflen); - if (rp == nullptr) { - return; - } - } - } - } - - strncpy(saved_jvm_path, buf, MAXPATHLEN); - saved_jvm_path[MAXPATHLEN - 1] = '\0'; -} - // Called when creating the thread. The minimum stack sizes have already been calculated size_t os::Posix::get_initial_stack_size(ThreadType thr_type, size_t req_stack_size) { size_t stack_size; @@ -1436,19 +1344,6 @@ void os::Posix::init_2(void) { _use_clock_monotonic_condattr ? "CLOCK_MONOTONIC" : "the default clock"); } -int os::Posix::clock_tics_per_second() { - return clock_tics_per_sec; -} - -#ifdef ASSERT -bool os::Posix::ucontext_is_interpreter(const ucontext_t* uc) { - assert(uc != nullptr, "invariant"); - address pc = os::Posix::ucontext_get_pc(uc); - assert(pc != nullptr, "invariant"); - return Interpreter::contains(pc); -} -#endif - // Utility to convert the given timeout to an absolute timespec // (based on the appropriate clock) to use with pthread_cond_timewait, // and sem_timedwait(). @@ -1596,9 +1491,12 @@ jlong os::javaTimeNanos() { return result; } +// for timer info max values which include all bits +#define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) + void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) { // CLOCK_MONOTONIC - amount of time since some arbitrary point in the past - info_ptr->max_value = all_bits_jlong; + info_ptr->max_value = ALL_64_BITS; info_ptr->may_skip_backward = false; // not subject to resetting or drifting info_ptr->may_skip_forward = false; // not subject to resetting or drifting info_ptr->kind = JVMTI_TIMER_ELAPSED; // elapsed not CPU time diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp index bd92702bd097..b6dae92257c5 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/posix/os_posix.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, 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 @@ -94,13 +94,8 @@ class os::Posix { static address ucontext_get_pc(const ucontext_t* ctx); static void ucontext_set_pc(ucontext_t* ctx, address pc); - DEBUG_ONLY(static bool ucontext_is_interpreter(const ucontext_t* ctx);) - static void to_RTC_abstime(timespec* abstime, int64_t millis); - // clock ticks per second of the system - static int clock_tics_per_second(); - static bool handle_stack_overflow(JavaThread* thread, address addr, address pc, const void* ucVoid, address* stub); diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp index 970446354c0e..092e55a722ea 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.hpp @@ -319,12 +319,7 @@ class MetaspaceObj { f(ConstantPoolCache) \ f(Annotations) \ f(MethodCounters) \ - f(RecordComponent) \ - f(KlassTrainingData) \ - f(MethodTrainingData) \ - f(CompileTrainingData) \ - f(AdapterHandlerEntry) \ - f(AdapterFingerPrint) + f(RecordComponent) #define METASPACE_OBJ_TYPE_DECLARE(name) name ## Type, #define METASPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name; @@ -362,8 +357,6 @@ class MetaspaceObj { void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, Type type) throw(); - // This is used for allocating training data. We are allocating training data in many cases where a GC cannot be triggered. - void* operator new(size_t size, MemTag flags); void operator delete(void* p) = delete; // Declare a *static* method with the same signature in any subclass of MetaspaceObj diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp index 9304d21b704b..39047a40e010 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/memory/allocation.inline.hpp @@ -69,7 +69,7 @@ template E* MmapArrayAllocator::allocate_or_null(size_t length, MemTag mem_tag) { size_t size = size_for(length); - char* addr = os::reserve_memory(size, mem_tag); + char* addr = os::reserve_memory(size, !ExecMem, mem_tag); if (addr == nullptr) { return nullptr; } @@ -86,7 +86,7 @@ template E* MmapArrayAllocator::allocate(size_t length, MemTag mem_tag) { size_t size = size_for(length); - char* addr = os::reserve_memory(size, mem_tag); + char* addr = os::reserve_memory(size, !ExecMem, mem_tag); if (addr == nullptr) { vm_exit_out_of_memory(size, OOM_MMAP_ERROR, "Allocator (reserve)"); } diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp index 714fcc806931..d4f7b258f954 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.cpp @@ -84,11 +84,7 @@ #include "utilities/defaultStream.hpp" #include "utilities/events.hpp" #include "utilities/fastrand.hpp" -#include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" -#endif // !NATIVE_IMAGE -#include "utilities/permitForbiddenFunctions.hpp" -#ifndef NATIVE_IMAGE #include "utilities/powerOfTwo.hpp" #ifdef LINUX @@ -141,7 +137,7 @@ int os::snprintf_checked(char* buf, size_t len, const char* fmt, ...) { } int os::vsnprintf(char* buf, size_t len, const char* fmt, va_list args) { - int result = permit_forbidden_function::vsnprintf(buf, len, fmt, args); + ALLOW_C_FUNCTION(::vsnprintf, int result = ::vsnprintf(buf, len, fmt, args);) // If an encoding error occurred (result < 0) then it's not clear // whether the buffer is NUL terminated, so ensure it is. if ((result < 0) && (len > 0)) { @@ -266,7 +262,7 @@ char* os::iso8601_time(jlong milliseconds_since_19700101, char* buffer, size_t b } OSReturn os::set_priority(Thread* thread, ThreadPriority p) { - DEBUG_ONLY(Thread::check_for_dangling_thread_pointer(thread);) + debug_only(Thread::check_for_dangling_thread_pointer(thread);) if ((p >= MinPriority && p <= MaxPriority) || (p == CriticalPriority && thread->is_ConcurrentGC_thread())) { @@ -622,7 +618,7 @@ char *os::strdup(const char *str, MemTag mem_tag) { size_t size = strlen(str); char *dup_str = (char *)malloc(size + 1, mem_tag); if (dup_str == nullptr) return nullptr; - memcpy(dup_str, str, size + 1); + strcpy(dup_str, str); return dup_str; } @@ -710,7 +706,7 @@ void* os::malloc(size_t size, MemTag mem_tag, const NativeCallStack& stack) { return nullptr; } - void* const outer_ptr = permit_forbidden_function::malloc(outer_size); + ALLOW_C_FUNCTION(::malloc, void* const outer_ptr = ::malloc(outer_size);) if (outer_ptr == nullptr) { return nullptr; } @@ -777,7 +773,7 @@ void* os::realloc(void *memblock, size_t size, MemTag mem_tag, const NativeCallS header->mark_block_as_dead(); // the real realloc - void* const new_outer_ptr = permit_forbidden_function::realloc(header, new_outer_size); + ALLOW_C_FUNCTION(::realloc, void* const new_outer_ptr = ::realloc(header, new_outer_size);) if (new_outer_ptr == nullptr) { // realloc(3) failed and the block still exists. @@ -805,7 +801,7 @@ void* os::realloc(void *memblock, size_t size, MemTag mem_tag, const NativeCallS } else { // NMT disabled. - rc = permit_forbidden_function::realloc(memblock, size); + ALLOW_C_FUNCTION(::realloc, rc = ::realloc(memblock, size);) if (rc == nullptr) { return nullptr; } @@ -833,7 +829,7 @@ void os::free(void *memblock) { // When NMT is enabled this checks for heap overwrites, then deaccounts the old block. void* const old_outer_ptr = MemTracker::record_free(memblock); - permit_forbidden_function::free(old_outer_ptr); + ALLOW_C_FUNCTION(::free, ::free(old_outer_ptr);) } void os::init_random(unsigned int initval) { @@ -1222,7 +1218,7 @@ void os::print_cpu_info(outputStream* st, char* buf, size_t buflen) { // We access the raw value here because the assert in the accessor will // fail if the crash occurs before initialization of this value. st->print(" (initial active %d)", _initial_active_processor_count); - st->print(" %s", VM_Version::cpu_info_string()); + st->print(" %s", VM_Version::features_string()); st->cr(); pd_print_cpu_info(st, buf, buflen); } @@ -1592,57 +1588,6 @@ bool os::set_boot_path(char fileSep, char pathSep) { return false; } -static char* _image_release_file_content = nullptr; - -void os::read_image_release_file() { - assert(_image_release_file_content == nullptr, "release file content must not be already set"); - const char* home = Arguments::get_java_home(); - stringStream ss; - ss.print("%s/release", home); - - FILE* file = fopen(ss.base(), "rb"); - if (file == nullptr) { - return; - } - fseek(file, 0, SEEK_END); - long sz = ftell(file); - if (sz == -1) { - fclose(file); - return; - } - fseek(file, 0, SEEK_SET); - - char* tmp = (char*) os::malloc(sz + 1, mtInternal); - if (tmp == nullptr) { - fclose(file); - return; - } - - size_t elements_read = fread(tmp, 1, sz, file); - if (elements_read < (size_t)sz) { - tmp[elements_read] = '\0'; - } else { - tmp[sz] = '\0'; - } - // issues with \r in line endings on Windows, so better replace those - for (size_t i = 0; i < elements_read; i++) { - if (tmp[i] == '\r') { - tmp[i] = ' '; - } - } - Atomic::release_store(&_image_release_file_content, tmp); - fclose(file); -} - -void os::print_image_release_file(outputStream* st) { - char* ifrc = Atomic::load_acquire(&_image_release_file_content); - if (ifrc != nullptr) { - st->print_cr("%s", ifrc); - } else { - st->print_cr(""); - } -} - #endif // !NATIVE_IMAGE bool os::file_exists(const char* filename) { struct stat statbuf; @@ -2029,7 +1974,7 @@ bool os::create_stack_guard_pages(char* addr, size_t bytes) { return os::pd_create_stack_guard_pages(addr, bytes); } -char* os::reserve_memory(size_t bytes, MemTag mem_tag, bool executable) { +char* os::reserve_memory(size_t bytes, bool executable, MemTag mem_tag) { char* result = pd_reserve_memory(bytes, executable); if (result != nullptr) { MemTracker::record_virtual_memory_reserve(result, bytes, CALLER_PC, mem_tag); @@ -2040,7 +1985,7 @@ char* os::reserve_memory(size_t bytes, MemTag mem_tag, bool executable) { return result; } -char* os::attempt_reserve_memory_at(char* addr, size_t bytes, MemTag mem_tag, bool executable) { +char* os::attempt_reserve_memory_at(char* addr, size_t bytes, bool executable, MemTag mem_tag) { char* result = SimulateFullAddressSpace ? nullptr : pd_attempt_reserve_memory_at(addr, bytes, executable); if (result != nullptr) { MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC, mem_tag); @@ -2246,7 +2191,7 @@ char* os::attempt_reserve_memory_between(char* min, char* max, size_t bytes, siz assert(is_aligned(result, alignment), "alignment invalid (" ERRFMT ")", ERRFMTARGS); log_trace(os, map)(ERRFMT, ERRFMTARGS); log_debug(os, map)("successfully attached at " PTR_FORMAT, p2i(result)); - MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC, mtNone); + MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC); } else { log_debug(os, map)("failed to attach anywhere in [" PTR_FORMAT "-" PTR_FORMAT ")", p2i(min), p2i(max)); } @@ -2314,11 +2259,6 @@ void os::commit_memory_or_exit(char* addr, size_t size, size_t alignment_hint, MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC); } -// The scope of NmtVirtualMemoryLocker covers both pd_uncommit_memory and record_virtual_memory_uncommit because -// these operations must happen atomically to avoid races causing NMT to fall out os sync with the OS reality. -// We do not have the same lock protection for pd_commit_memory and record_virtual_memory_commit. -// We assume that there is some external synchronization that prevents a region from being uncommitted -// before it is finished being committed. bool os::uncommit_memory(char* addr, size_t bytes, bool executable) { assert_nonempty_range(addr, bytes); bool res; @@ -2341,11 +2281,6 @@ bool os::uncommit_memory(char* addr, size_t bytes, bool executable) { return res; } -// The scope of NmtVirtualMemoryLocker covers both pd_release_memory and record_virtual_memory_release because -// these operations must happen atomically to avoid races causing NMT to fall out os sync with the OS reality. -// We do not have the same lock protection for pd_reserve_memory and record_virtual_memory_reserve. -// We assume that there is some external synchronization that prevents a region from being released -// before it is finished being reserved. bool os::release_memory(char* addr, size_t bytes) { assert_nonempty_range(addr, bytes); bool res; @@ -2423,8 +2358,8 @@ char* os::attempt_map_memory_to_file_at(char* addr, size_t bytes, int file_desc, } char* os::map_memory(int fd, const char* file_name, size_t file_offset, - char *addr, size_t bytes, MemTag mem_tag, - bool read_only, bool allow_exec) { + char *addr, size_t bytes, bool read_only, + bool allow_exec, MemTag mem_tag) { char* result = pd_map_memory(fd, file_name, file_offset, addr, bytes, read_only, allow_exec); if (result != nullptr) { MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, CALLER_PC, mem_tag); @@ -2462,7 +2397,7 @@ char* os::reserve_memory_special(size_t size, size_t alignment, size_t page_size char* result = pd_reserve_memory_special(size, alignment, page_size, addr, executable); if (result != nullptr) { // The memory is committed - MemTracker::record_virtual_memory_reserve_and_commit((address)result, size, CALLER_PC, mtNone); + MemTracker::record_virtual_memory_reserve_and_commit((address)result, size, CALLER_PC); log_debug(os, map)("Reserved and committed " RANGEFMT, RANGEFMTARGS(result, size)); } else { log_info(os, map)("Reserve and commit failed (%zu bytes)", size); @@ -2658,7 +2593,7 @@ char* os::build_agent_function_name(const char *sym_name, const char *lib_name, if ((start = strrchr(lib_name, *os::file_separator())) != nullptr) { lib_name = ++start; } -#ifdef _WINDOWS +#ifdef WINDOWS else { // Need to check for drive prefix e.g. C:L.dll if ((start = strchr(lib_name, ':')) != nullptr) { lib_name = ++start; diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp index 187f48caccac..c443cd12adaa 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/runtime/os.hpp @@ -478,14 +478,14 @@ class os: AllStatic { inline static size_t cds_core_region_alignment(); // Reserves virtual memory. - static char* reserve_memory(size_t bytes, MemTag mem_tag, bool executable = false); + static char* reserve_memory(size_t bytes, bool executable = false, MemTag mem_tag = mtNone); // Reserves virtual memory that starts at an address that is aligned to 'alignment'. - static char* reserve_memory_aligned(size_t size, size_t alignment, MemTag mem_tag, bool executable = false); + static char* reserve_memory_aligned(size_t size, size_t alignment, bool executable = false); // Attempts to reserve the virtual memory at [addr, addr + bytes). // Does not overwrite existing mappings. - static char* attempt_reserve_memory_at(char* addr, size_t bytes, MemTag mem_tag, bool executable = false); + static char* attempt_reserve_memory_at(char* addr, size_t bytes, bool executable = false, MemTag mem_tag = mtNone); // Given an address range [min, max), attempts to reserve memory within this area, with the given alignment. // If randomize is true, the location will be randomized. @@ -537,16 +537,16 @@ class os: AllStatic { static int create_file_for_heap(const char* dir); // Map memory to the file referred by fd. This function is slightly different from map_memory() // and is added to be used for implementation of -XX:AllocateHeapAt - static char* map_memory_to_file(size_t size, int fd, MemTag mem_tag); - static char* map_memory_to_file_aligned(size_t size, size_t alignment, int fd, MemTag mem_tag); + static char* map_memory_to_file(size_t size, int fd, MemTag mem_tag = mtNone); + static char* map_memory_to_file_aligned(size_t size, size_t alignment, int fd, MemTag mem_tag = mtNone); static char* map_memory_to_file(char* base, size_t size, int fd); - static char* attempt_map_memory_to_file_at(char* base, size_t size, int fd, MemTag mem_tag); + static char* attempt_map_memory_to_file_at(char* base, size_t size, int fd, MemTag mem_tag = mtNone); // Replace existing reserved memory with file mapping static char* replace_existing_mapping_with_file_mapping(char* base, size_t size, int fd); static char* map_memory(int fd, const char* file_name, size_t file_offset, - char *addr, size_t bytes, MemTag mem_tag, bool read_only = false, - bool allow_exec = false); + char *addr, size_t bytes, bool read_only = false, + bool allow_exec = false, MemTag mem_tag = mtNone); static bool unmap_memory(char *addr, size_t bytes); static void disclaim_memory(char *addr, size_t bytes); static void realign_memory(char *addr, size_t bytes, size_t alignment_hint); @@ -644,7 +644,6 @@ class os: AllStatic { static address fetch_frame_from_context(const void* ucVoid, intptr_t** sp, intptr_t** fp); static frame fetch_frame_from_context(const void* ucVoid); static frame fetch_compiled_frame_from_context(const void* ucVoid); - static intptr_t* fetch_bcp_from_context(const void* ucVoid); // For saving an os specific context generated by an assert or guarantee. static void save_assert_context(const void* ucVoid); @@ -695,12 +694,7 @@ class os: AllStatic { static jlong lseek(int fd, jlong offset, int whence); #endif // !NATIVE_IMAGE static bool file_exists(const char* file); - #ifndef NATIVE_IMAGE - // read/store and print the release file of the image - static void read_image_release_file(); - static void print_image_release_file(outputStream* st); - // This function, on Windows, canonicalizes a given path (see os_windows.cpp for details). // On Posix, this function is a noop: it does not change anything and just returns // the input pointer. diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp index 56f19cb5f4f6..a71f641b3311 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -63,6 +63,9 @@ #ifndef PRAGMA_FORMAT_NONLITERAL_IGNORED #define PRAGMA_FORMAT_NONLITERAL_IGNORED #endif +#ifndef PRAGMA_FORMAT_IGNORED +#define PRAGMA_FORMAT_IGNORED +#endif #ifndef PRAGMA_STRINGOP_TRUNCATION_IGNORED #define PRAGMA_STRINGOP_TRUNCATION_IGNORED @@ -86,61 +89,23 @@ // Support warnings for use of certain C functions, except where explicitly // permitted. - -// FORBID_C_FUNCTION(Signature, Alternative) -// - Signature: the function that should not normally be used. -// - Alternative: a string literal that may be used in a warning about a use, -// often suggesting an alternative. -// Declares the C-linkage function designated by Signature to be deprecated, -// using the `deprecated` attribute with Alternative as an argument. // -// The variants with IMPORTED in the name are to deal with Windows -// requirements, using FORBIDDEN_FUNCTION_IMPORT_SPEC. See the Visual -// Studio definition of that macro for more details. The default has -// an empty expansion. The potentially added spec must precede the -// base signature but follow all attributes. +// FORBID_C_FUNCTION(signature, alternative) +// - signature: the function that should not normally be used. +// - alternative: a string that may be used in a warning about a use, typically +// suggesting an alternative. // -// FORBID_NORETURN_C_FUNCTION deals with a clang issue. See the clang -// definition of FORBIDDEN_FUNCTION_NORETURN_ATTRIBUTE for more -// details. The default expands to `[[noreturn]]`. -#define FORBID_C_FUNCTION(Signature, Alternative) \ - extern "C" { [[deprecated(Alternative)]] Signature; } +// ALLOW_C_FUNCTION(name, ... using statement ...) +// - name: the name of a forbidden function whose use is permitted in statement. +// - statement: a use of the otherwise forbidden function. Using a variadic +// tail allows the statement to contain non-nested commas. -#ifndef FORBIDDEN_FUNCTION_IMPORT_SPEC -#define FORBIDDEN_FUNCTION_IMPORT_SPEC +#ifndef FORBID_C_FUNCTION +#define FORBID_C_FUNCTION(signature, alternative) #endif -#ifndef FORBIDDEN_FUNCTION_NORETURN_ATTRIBUTE -#define FORBIDDEN_FUNCTION_NORETURN_ATTRIBUTE [[noreturn]] +#ifndef ALLOW_C_FUNCTION +#define ALLOW_C_FUNCTION(name, ...) __VA_ARGS__ #endif -#ifndef FORBIDDEN_FUNCTION_IGNORE_CLANG_FORTIFY_WARNING -#define FORBIDDEN_FUNCTION_IGNORE_CLANG_FORTIFY_WARNING -#endif - -#define FORBID_IMPORTED_C_FUNCTION(Signature, Alternative) \ - FORBID_C_FUNCTION(FORBIDDEN_FUNCTION_IMPORT_SPEC Signature, Alternative) - -#define FORBID_NORETURN_C_FUNCTION(Signature, Alternative) \ - FORBID_C_FUNCTION(FORBIDDEN_FUNCTION_NORETURN_ATTRIBUTE Signature, Alternative) - -#define FORBID_IMPORTED_NORETURN_C_FUNCTION(Signature, Alternative) \ - FORBID_NORETURN_C_FUNCTION(FORBIDDEN_FUNCTION_IMPORT_SPEC Signature, Alternative) - -// A BEGIN/END_ALLOW_FORBIDDEN_FUNCTIONS pair establishes a scope in which the -// deprecation warnings used to forbid the use of certain functions are -// suppressed. These macros are not intended for warning suppression at -// individual call sites; see permitForbiddenFunctions.hpp for the approach -// taken for that where needed. Rather, these are used to suppress warnings -// from 3rd-party code included by HotSpot, such as the gtest framework and -// C++ Standard Library headers, which may refer to functions that are -// disallowed in other parts of HotSpot. They are also used in the -// implementation of the "permit" mechanism. -#define BEGIN_ALLOW_FORBIDDEN_FUNCTIONS \ - PRAGMA_DIAG_PUSH \ - PRAGMA_DEPRECATED_IGNORED - -#define END_ALLOW_FORBIDDEN_FUNCTIONS \ - PRAGMA_DIAG_POP - #endif // SHARE_UTILITIES_COMPILERWARNINGS_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp index 0687b784399a..f11b4eb8af24 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/compilerWarnings_gcc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -52,6 +52,8 @@ PRAGMA_DISABLE_GCC_WARNING("-Wformat-nonliteral") \ PRAGMA_DISABLE_GCC_WARNING("-Wformat-security") +#define PRAGMA_FORMAT_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wformat") + // Disable -Wstringop-truncation which is introduced in GCC 8. // https://gcc.gnu.org/gcc-8/changes.html #if !defined(__clang_major__) && (__GNUC__ >= 8) @@ -69,71 +71,32 @@ #define PRAGMA_ZERO_AS_NULL_POINTER_CONSTANT_IGNORED \ PRAGMA_DISABLE_GCC_WARNING("-Wzero-as-null-pointer-constant") -#define PRAGMA_DEPRECATED_IGNORED \ - PRAGMA_DISABLE_GCC_WARNING("-Wdeprecated-declarations") - -// This macro is used by the NORETURN variants of FORBID_C_FUNCTION. -// -// The [[noreturn]] attribute requires that the first declaration of a -// function has it if any have it. -// -// gcc, clang, and MSVC all provide compiler-specific alternatives to that -// attribute: __attribute__((noreturn)) for gcc and clang, -// __declspec(noreturn) for MSVC and clang. gcc and MSVC treat their -// respective compiler-specific alternatives as satisfying that requirement. -// clang does not. -// -// So clang warns if we use [[noreturn]] in the forbidding declaration and the -// library header has already been included and uses the compiler-specific -// attribute. Similarly, clang warns if we use the compiler-specific attribute -// while the library uses [[noreturn]] and the library header is included -// after the forbidding declaration. -// -// For now, we're only going to worry about the standard library, and not -// noreturn functions in some other library that we might want to forbid in -// the future. If there's more than one library to be accounted for, then -// things may get more complicated. -// -// There are several ways we could deal with this. -// -// Probably the most robust is to use the same style of noreturn attribute as -// is used by the library providing the function. That way it doesn't matter -// in which order the inclusion of the library header and the forbidding are -// performed. We could use configure to determine which to use and provide a -// macro to select on here. -// -// Another approach is to always use __attribute__ noreturn in the forbidding -// declaration, but ensure the relevant library header has been included -// before the forbidding declaration. Since there are currently only a couple -// of affected functions, this is easier to implement. So this is the -// approach being taken for now. -// -// clang's failure to treat the compiler-specific form as counting toward the -// [[noreturn]] requirement is arguably a clang bug. -// https://github.com/llvm/llvm-project/issues/131700 - -#ifdef __clang__ -#define FORBIDDEN_FUNCTION_NORETURN_ATTRIBUTE __attribute__((__noreturn__)) -#endif +#if (__GNUC__ >= 10) +// TODO: Re-enable warning attribute for Clang once +// https://github.com/llvm/llvm-project/issues/56519 is fixed and released. +// || (defined(__clang_major__) && (__clang_major__ >= 14)) -// This macro is used to suppress a warning for some uses of FORBID_C_FUNCTION. +// Use "warning" attribute to detect uses of "forbidden" functions. // -// libstdc++ provides inline definitions of some functions to support -// _FORTIFY_SOURCE. clang warns about our forbidding declaration adding the -// [[deprecated]] attribute following such a definition: -// "warning: attribute declaration must precede definition [-Wignored-attributes]" -// Use this macro to suppress the warning, not getting protection when using -// that combination. Other build combinations should provide sufficient -// coverage. +// Note: The warning attribute is available since GCC 9, but disabling pragmas +// does not work reliably in ALLOW_C_FUNCTION. GCC 10+ and up work fine. // -// clang's warning in this case is arguably a clang bug. -// https://github.com/llvm/llvm-project/issues/135481 -// This issue has been fixed, with the fix probably appearing in clang 21. -#if defined(__clang__) && defined(_FORTIFY_SOURCE) -#if _FORTIFY_SOURCE > 0 -#define FORBIDDEN_FUNCTION_IGNORE_CLANG_FORTIFY_WARNING \ - PRAGMA_DISABLE_GCC_WARNING("-Wignored-attributes") -#endif -#endif +// Note: _FORTIFY_SOURCE transforms calls to certain functions into calls to +// associated "checking" functions, and that transformation seems to occur +// *before* the attribute check. We use fortification in fastdebug builds, +// so uses of functions that are both forbidden and fortified won't cause +// forbidden warnings in such builds. +#define FORBID_C_FUNCTION(signature, alternative) \ + extern "C" __attribute__((__warning__(alternative))) signature; + +// Disable warning attribute over the scope of the affected statement. +// The name serves only to document the intended function. +#define ALLOW_C_FUNCTION(name, ...) \ + PRAGMA_DIAG_PUSH \ + PRAGMA_DISABLE_GCC_WARNING("-Wattribute-warning") \ + __VA_ARGS__ \ + PRAGMA_DIAG_POP + +#endif // gcc10+ #endif // SHARE_UTILITIES_COMPILERWARNINGS_GCC_HPP diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp index b475b02dbcee..5223f0f8ed4b 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/globalDefinitions.hpp @@ -28,9 +28,6 @@ #include "utilities/compilerWarnings.hpp" #include "utilities/debug.hpp" -#ifndef NATIVE_IMAGE -#include "utilities/forbiddenFunctions.hpp" -#endif // !NATIVE_IMAGE #include "utilities/macros.hpp" #ifndef NATIVE_IMAGE @@ -193,6 +190,35 @@ inline uintptr_t p2u(const volatile void* p) { #define BOOL_TO_STR(_b_) ((_b_) ? "true" : "false") +//---------------------------------------------------------------------------------------------------- +// Forbid the use of various C library functions. +// Some of these have os:: replacements that should normally be used instead. +// Others are considered security concerns, with preferred alternatives. + +FORBID_C_FUNCTION(void exit(int), "use os::exit"); +FORBID_C_FUNCTION(void _exit(int), "use os::exit"); +FORBID_C_FUNCTION(char* strerror(int), "use os::strerror"); +FORBID_C_FUNCTION(char* strtok(char*, const char*), "use strtok_r"); +FORBID_C_FUNCTION(int sprintf(char*, const char*, ...), "use os::snprintf"); +FORBID_C_FUNCTION(int vsprintf(char*, const char*, va_list), "use os::vsnprintf"); +FORBID_C_FUNCTION(int vsnprintf(char*, size_t, const char*, va_list), "use os::vsnprintf"); + +// All of the following functions return raw C-heap pointers (sometimes as an option, e.g. realpath or getwd) +// or, in case of free(), take raw C-heap pointers. Don't use them unless you are really sure you must. +FORBID_C_FUNCTION(void* malloc(size_t size), "use os::malloc"); +FORBID_C_FUNCTION(void* calloc(size_t nmemb, size_t size), "use os::malloc and zero out manually"); +FORBID_C_FUNCTION(void free(void *ptr), "use os::free"); +FORBID_C_FUNCTION(void* realloc(void *ptr, size_t size), "use os::realloc"); +FORBID_C_FUNCTION(char* strdup(const char *s), "use os::strdup"); +FORBID_C_FUNCTION(char* strndup(const char *s, size_t n), "don't use"); +FORBID_C_FUNCTION(int posix_memalign(void **memptr, size_t alignment, size_t size), "don't use"); +FORBID_C_FUNCTION(void* aligned_alloc(size_t alignment, size_t size), "don't use"); +FORBID_C_FUNCTION(char* realpath(const char* path, char* resolved_path), "use os::realpath"); +FORBID_C_FUNCTION(char* get_current_dir_name(void), "use os::get_current_directory()"); +FORBID_C_FUNCTION(char* getwd(char *buf), "use os::get_current_directory()"); +FORBID_C_FUNCTION(wchar_t* wcsdup(const wchar_t *s), "don't use"); +FORBID_C_FUNCTION(void* reallocf(void *ptr, size_t size), "don't use"); + //---------------------------------------------------------------------------------------------------- // Constants @@ -295,9 +321,6 @@ namespace svm_container { const jlong min_jlong = CONST64(0x8000000000000000); const jlong max_jlong = CONST64(0x7fffffffffffffff); -// for timer info max values which include all bits, 0xffffffffffffffff -const jlong all_bits_jlong = ~jlong(0); - #ifndef NATIVE_IMAGE //------------------------------------------- // Constant for jdouble @@ -311,6 +334,7 @@ const size_t K = 1024; const size_t M = K*K; const size_t G = M*K; #ifndef NATIVE_IMAGE +const size_t HWperKB = K / sizeof(HeapWord); // Constants for converting from a base unit to milli-base units. For // example from seconds to milliseconds and microseconds @@ -1183,7 +1207,7 @@ inline bool is_even(intx x) { return !is_odd(x); } // abs methods which cannot overflow and so are well-defined across // the entire domain of integer types. -static inline unsigned int g_uabs(unsigned int n) { +static inline unsigned int uabs(unsigned int n) { union { unsigned int result; int value; @@ -1192,7 +1216,7 @@ static inline unsigned int g_uabs(unsigned int n) { if (value < 0) result = 0-result; return result; } -static inline julong g_uabs(julong n) { +static inline julong uabs(julong n) { union { julong result; jlong value; @@ -1201,8 +1225,8 @@ static inline julong g_uabs(julong n) { if (value < 0) result = 0-result; return result; } -static inline julong g_uabs(jlong n) { return g_uabs((julong)n); } -static inline unsigned int g_uabs(int n) { return g_uabs((unsigned int)n); } +static inline julong uabs(jlong n) { return uabs((julong)n); } +static inline unsigned int uabs(int n) { return uabs((unsigned int)n); } // "to" should be greater than "from." inline size_t byte_size(void* from, void* to) { diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp index 876af4e1e74c..5dbec43da020 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/macros.hpp @@ -378,10 +378,13 @@ #define DEBUG_ONLY(code) code #define NOT_DEBUG(code) #define NOT_DEBUG_RETURN /*next token must be ;*/ +// Historical. +#define debug_only(code) code #else // ASSERT #define DEBUG_ONLY(code) #define NOT_DEBUG(code) code #define NOT_DEBUG_RETURN {} +#define debug_only(code) #endif // ASSERT #ifdef _LP64 diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp index d1b72989cb67..812c6ba19afb 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.cpp @@ -170,12 +170,6 @@ void outputStream::do_vsnprintf_and_write(const char* format, va_list ap, bool a } } -bool outputStream::set_autoindent(bool value) { - const bool old = _autoindent; - _autoindent = value; - return old; -} - void outputStream::print(const char* format, ...) { va_list ap; va_start(ap, format); @@ -250,6 +244,10 @@ void outputStream::cr() { this->write("\n", 1); } +void outputStream::cr_indent() { + cr(); indent(); +} + void outputStream::stamp() { if (! _stamp.is_updated()) { _stamp.update(); // start at 0 on first call to stamp() @@ -298,6 +296,12 @@ outputStream& outputStream::indent() { return *this; } +bool outputStream::set_autoindent(bool value) { + const bool old = _autoindent; + _autoindent = value; + return old; +} + void outputStream::print_jlong(jlong value) { print(JLONG_FORMAT, value); } @@ -315,16 +319,16 @@ void outputStream::print_julong(julong value) { * 0000020: 0000 0000 0000 0040 0000 0000 0000 015d .......@.......] * ... * - * Ends with a CR. + * indent is applied to each line. Ends with a CR. */ void outputStream::print_data(void* data, size_t len, bool with_ascii, bool rel_addr) { size_t limit = (len + 16) / 16 * 16; for (size_t i = 0; i < limit; ++i) { if (i % 16 == 0) { if (rel_addr) { - print("%07" PRIxPTR ":", i); + indent().print("%07" PRIxPTR ":", i); } else { - print(PTR_FORMAT ":", p2i((unsigned char*)data + i)); + indent().print(PTR_FORMAT ":", p2i((unsigned char*)data + i)); } } if (i % 2 == 0) { diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp index 24c66ca59d74..494d90d5ce8d 100644 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp +++ b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/ostream.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -58,8 +58,6 @@ DEBUG_ONLY(class ResourceMark;) namespace svm_container { class outputStream : public CHeapObjBase { - friend class StreamIndentor; - #ifndef NATIVE_IMAGE private: NONCOPYABLE(outputStream); @@ -105,9 +103,6 @@ class outputStream : public CHeapObjBase { void do_vsnprintf_and_write(const char* format, va_list ap, bool add_cr) ATTRIBUTE_PRINTF(2, 0); #endif // !NATIVE_IMAGE - // Automatic indentation. Returns old autoindent state. - bool set_autoindent(bool value); - public: #ifndef NATIVE_IMAGE class TestSupport; // Unit test support @@ -126,6 +121,14 @@ class outputStream : public CHeapObjBase { int fill_to(int col); void move_to(int col, int slop = 6, int min_space = 2); + // Automatic indentation: + // If autoindent mode is on, the following APIs will automatically indent + // line starts depending on the current indentation level: + // print(), print_cr(), print_raw(), print_raw_cr() + // Other APIs are unaffected + // Returns old autoindent state. + bool set_autoindent(bool value); + // sizing int position() const { return _position; } julong count() const { return _precount + _position; } @@ -151,6 +154,7 @@ class outputStream : public CHeapObjBase { void put(char ch); void sp(int count = 1); void cr(); + void cr_indent(); void bol() { if (_position > 0) cr(); } @@ -194,29 +198,25 @@ class outputStream : public CHeapObjBase { // ANSI C++ name collision extern outputStream* tty; // tty output -// outputStream indentation. When used, indentation is automatically applied -// when printing on the stream using the following APIs: -// print(), print_cr(), print_raw(), print_raw_cr() -class StreamIndentor { - private: - outputStream* const _stream; - const int _indentation; - const bool _old_autoindent; - NONCOPYABLE(StreamIndentor); - - public: - StreamIndentor(outputStream* os, int indentation) : - _stream(os), - _indentation(indentation), - _old_autoindent(_stream->set_autoindent(true)) { - - _stream->inc(_indentation); +class streamIndentor : public StackObj { + outputStream* const _str; + const int _amount; + NONCOPYABLE(streamIndentor); +public: + streamIndentor(outputStream* str, int amt = 2) : _str(str), _amount(amt) { + _str->inc(_amount); } + ~streamIndentor() { _str->dec(_amount); } +}; - ~StreamIndentor() { - _stream->dec(_indentation); - _stream->set_autoindent(_old_autoindent); - } +class StreamAutoIndentor : public StackObj { + outputStream* const _os; + const bool _old; + NONCOPYABLE(StreamAutoIndentor); + public: + StreamAutoIndentor(outputStream* os) : + _os(os), _old(os->set_autoindent(true)) {} + ~StreamAutoIndentor() { _os->set_autoindent(_old); } }; // advisory locking for the shared tty stream: diff --git a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/permitForbiddenFunctions.hpp b/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/permitForbiddenFunctions.hpp deleted file mode 100644 index 6b9e406bcdee..000000000000 --- a/substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/share/utilities/permitForbiddenFunctions.hpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2024, 2025, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -#ifndef SHARE_UTILITIES_PERMITFORBIDDENFUNCTIONS_HPP -#define SHARE_UTILITIES_PERMITFORBIDDENFUNCTIONS_HPP - -#include "utilities/compilerWarnings.hpp" -#include "utilities/globalDefinitions.hpp" - -#ifndef NATIVE_IMAGE -#ifdef _WINDOWS -#include "permitForbiddenFunctions_windows.hpp" -#else -#include "permitForbiddenFunctions_posix.hpp" -#endif -#endif // !NATIVE_IMAGE - -// Provide wrappers for some functions otherwise forbidden from use in HotSpot. -// -// There may be special circumstances where an otherwise forbidden function -// really does need to be used. One example is in the implementation of a -// corresponding os:: function. -// -// Wrapper functions are provided for such forbidden functions. These -// wrappers are defined in a context where the forbidding warnings are -// suppressed. They are defined in a special namespace, to highlight uses as -// unusual and requiring increased scrutiny. -// -// Note that there are several seemingly plausible shorter alternatives to -// these written-out wrapper functions. All that have been tried don't work -// for one reason or another. - - -namespace svm_container { - -namespace permit_forbidden_function { -BEGIN_ALLOW_FORBIDDEN_FUNCTIONS - -#ifndef NATIVE_IMAGE -[[noreturn]] inline void exit(int status) { ::exit(status); } -[[noreturn]] inline void _exit(int status) { ::_exit(status); } -#endif // !NATIVE_IMAGE - -ATTRIBUTE_PRINTF(3, 0) -inline int vsnprintf(char* str, size_t size, const char* format, va_list ap) { - return ::vsnprintf(str, size, format, ap); -} - -#ifndef NATIVE_IMAGE -inline void* malloc(size_t size) { return ::malloc(size); } -inline void free(void* ptr) { return ::free(ptr); } -inline void* calloc(size_t nmemb, size_t size) { return ::calloc(nmemb, size); } -inline void* realloc(void* ptr, size_t size) { return ::realloc(ptr, size); } - -inline char* strdup(const char* s) { return ::strdup(s); } -#endif // !NATIVE_IMAGE - -END_ALLOW_FORBIDDEN_FUNCTIONS -} // namespace permit_forbidden_function - - -} // namespace svm_container - -#endif // SHARE_UTILITIES_PERMITFORBIDDENFUNCTIONS_HPP diff --git a/substratevm/src/com.oracle.svm.truffle.tck/src/com/oracle/svm/truffle/tck/resources/jdk_allowed_methods.json b/substratevm/src/com.oracle.svm.truffle.tck/src/com/oracle/svm/truffle/tck/resources/jdk_allowed_methods.json index 29f6e80d2189..abdd1534f245 100644 --- a/substratevm/src/com.oracle.svm.truffle.tck/src/com/oracle/svm/truffle/tck/resources/jdk_allowed_methods.json +++ b/substratevm/src/com.oracle.svm.truffle.tck/src/com/oracle/svm/truffle/tck/resources/jdk_allowed_methods.json @@ -38,15 +38,6 @@ "justification" : "Bits are package private class used by direct buffers which uses Unsafe to access off heap memory.", "allDeclaredMethods" : true }, - { - "name" : "java.nio.BufferCleaner$PhantomCleaner", - "methods" : [ - { "name" : "clean" , - "justification" : "Calls System.exit if a failure occurs during VM boot.", - "parameterTypes" : [ - ]} - ] - }, { "name" : "java.nio.DirectByteBuffer", "justification" : "DirectByteBuffer uses Unsafe to allocate and initialize off heap memory.", @@ -348,5 +339,16 @@ "justification": "In native-image resource bundles are statically configured." } ] + }, + { + "name": "jdk.internal.ref.Cleaner", + "methods": [ + { + "name": "clean", + "parameterTypes" : [ + ], + "justification": "Internal JDK Cleaner which does System.exit if it fails during JVM boot." + } + ] } ] diff --git a/substratevm/src/com.oracle.svm.truffle.tck/src/com/oracle/svm/truffle/tck/resources/jdk_privileged_methods.json b/substratevm/src/com.oracle.svm.truffle.tck/src/com/oracle/svm/truffle/tck/resources/jdk_privileged_methods.json index 38290834d06b..78332d3abd36 100644 --- a/substratevm/src/com.oracle.svm.truffle.tck/src/com/oracle/svm/truffle/tck/resources/jdk_privileged_methods.json +++ b/substratevm/src/com.oracle.svm.truffle.tck/src/com/oracle/svm/truffle/tck/resources/jdk_privileged_methods.json @@ -1072,6 +1072,13 @@ "parameterTypes": [ "java.net.DatagramPacket" ] + }, + { + "name": "send", + "parameterTypes": [ + "java.net.DatagramPacket", + "byte" + ] } ] }, @@ -2839,6 +2846,17 @@ } ] }, + { + "name": "java.applet.Applet", + "methods": [ + { + "name": "setStub", + "parameterTypes": [ + "java.applet.AppletStub" + ] + } + ] + }, { "name": "java.awt.Button", "methods": [ diff --git a/tools/src/com.oracle.truffle.tools.chromeinspector.test/src/com/oracle/truffle/tools/chromeinspector/test/EnginesGCedTest.java b/tools/src/com.oracle.truffle.tools.chromeinspector.test/src/com/oracle/truffle/tools/chromeinspector/test/EnginesGCedTest.java index 74f76cf4f696..2eff548caba0 100644 --- a/tools/src/com.oracle.truffle.tools.chromeinspector.test/src/com/oracle/truffle/tools/chromeinspector/test/EnginesGCedTest.java +++ b/tools/src/com.oracle.truffle.tools.chromeinspector.test/src/com/oracle/truffle/tools/chromeinspector/test/EnginesGCedTest.java @@ -28,12 +28,13 @@ import java.util.HashSet; import java.util.Set; -import org.graalvm.polyglot.Context; -import org.graalvm.polyglot.Engine; import org.junit.After; import org.junit.Assert; import org.junit.Before; +import org.graalvm.polyglot.Context; +import org.graalvm.polyglot.Engine; + import com.oracle.truffle.api.test.GCUtils; public abstract class EnginesGCedTest { @@ -88,10 +89,6 @@ void checkCollected() { // A libgraal thread continue; } - if (t.getClass().getName().equals("java.nio.BufferCleaner$CleaningThread")) { - // BufferCleaner::CleaningThread JDK-8344332 (JDK 26+6) [GR-67693] - continue; - } Assert.fail("An extra thread " + t + " is found after test finished."); } } diff --git a/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedTruffleRuntime.java b/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedTruffleRuntime.java index f9e9827833f1..0d2736ba9700 100644 --- a/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedTruffleRuntime.java +++ b/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedTruffleRuntime.java @@ -170,6 +170,24 @@ public abstract class OptimizedTruffleRuntime implements TruffleRuntime, Truffle private static final int JAVA_SPECIFICATION_VERSION = Runtime.version().feature(); + private static final class Lazy { + /** + * True if the {@link InliningRoot} annotation is supported by the compiler. + */ + private static final boolean INLINING_ROOT_SUPPORTED; + + static { + boolean supported; + try { + HostMethodInfo.class.getDeclaredConstructor(boolean.class, boolean.class, boolean.class, boolean.class, boolean.class); + supported = true; + } catch (NoSuchMethodException e) { + supported = false; + } + INLINING_ROOT_SUPPORTED = supported; + } + } + /** * Used only to reset state for native image compilation. */ @@ -540,7 +558,7 @@ protected void installDefaultListeners() { @Override public HostMethodInfo getHostMethodInfo(ResolvedJavaMethod method) { - if (JAVA_SPECIFICATION_VERSION >= 26) { + if (Lazy.INLINING_ROOT_SUPPORTED) { return new HostMethodInfo(isTruffleBoundary(method), isBytecodeInterpreterSwitch(method), isBytecodeInterpreterSwitchBoundary(method), diff --git a/web-image/mx.web-image/suite.py b/web-image/mx.web-image/suite.py index e6d4dd6e5ef3..f8baadbc0029 100644 --- a/web-image/mx.web-image/suite.py +++ b/web-image/mx.web-image/suite.py @@ -186,11 +186,7 @@ "java.compiler", ], "requiresConcealed": { - "java.base": [ - "sun.nio.ch", - "sun.security.provider", - "jdk.internal.reflect", - ], + "java.base": ["sun.nio.ch", "sun.security.provider", "jdk.internal.reflect"], "jdk.internal.vm.ci": ["jdk.vm.ci.code.site", "jdk.vm.ci.code", "jdk.vm.ci.common", "jdk.vm.ci.meta"], }, "javaCompliance": "21+", diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/ResetStableSupplierTransformer.java b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/ResetStableSupplierTransformer.java deleted file mode 100644 index 71c027d459cc..000000000000 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/ResetStableSupplierTransformer.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2025, 2025, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package com.oracle.svm.hosted.webimage; - -import java.lang.reflect.Method; -import java.util.function.Supplier; - -import org.graalvm.nativeimage.hosted.FieldValueTransformer; - -import com.oracle.svm.util.ReflectionUtil; - -/** - * Field value transformer that creates a new StableSupplier with the same {@link Supplier} as the - * original that was not initialized yet. - *

- * This can be used to reset caches that are based on stable value suppliers. - *

- * Uses reflection because StableSupplier is from JDK25 and proguard does not yet support class - * files from that version. - */ -public final class ResetStableSupplierTransformer implements FieldValueTransformer { - @Override - public Object transform(Object receiver, Object originalValue) { - Class stableSupplierClass = ReflectionUtil.lookupClass("jdk.internal.lang.stable.StableSupplier"); - Method stableSupplierOf = ReflectionUtil.lookupMethod(stableSupplierClass, "of", Supplier.class); - Method stableSupplierOriginal = ReflectionUtil.lookupMethod(stableSupplierClass, "original"); - Object originalSupplier = ReflectionUtil.invokeMethod(stableSupplierOriginal, originalValue); - return ReflectionUtil.invokeMethod(stableSupplierOf, null, originalSupplier); - } -} diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageFeature.java b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageFeature.java index 2e68e92a761e..b3d6b0fe820a 100644 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageFeature.java +++ b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageFeature.java @@ -35,6 +35,7 @@ import java.util.List; import java.util.Map; import java.util.function.Predicate; +import java.util.function.Supplier; import org.graalvm.nativeimage.AnnotationAccess; import org.graalvm.nativeimage.ImageSingletons; @@ -189,12 +190,35 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { * * These caches can contribute ~1MB to the image size, clearing them avoids this overhead at * the cost of having to recreate the Locale and BaseLocale objects once when they're - * requested at run-time. + * requested. + * + * On JDK21, ReferencedKeySet and ReferencedKeyMap don't exist. We have to go through + * reflection to access them because analysis tools like spotbugs still run on JDK21 */ - Field baseLocaleCacheField = accessImpl.findField("sun.util.locale.BaseLocale", "CACHE"); - Field localeCacheField = accessImpl.findField("java.util.Locale", "LOCALE_CACHE"); - access.registerFieldValueTransformer(baseLocaleCacheField, new ResetStableSupplierTransformer()); - access.registerFieldValueTransformer(localeCacheField, new ResetStableSupplierTransformer()); + Field baseLocaleCacheField = accessImpl.findField("sun.util.locale.BaseLocale$1InterningCache", "CACHE"); + Field localeCacheField = accessImpl.findField("java.util.Locale$LocaleCache", "LOCALE_CACHE"); + + access.registerFieldValueTransformer(baseLocaleCacheField, (receiver, originalValue) -> { + /* + * Executes `ReferencedKeySet.create(true, + * ReferencedKeySet.concurrentHashMapSupplier())` with reflection. + */ + Class referencedKeySetClazz = ReflectionUtil.lookupClass("jdk.internal.util.ReferencedKeySet"); + Method createMethod = ReflectionUtil.lookupMethod(referencedKeySetClazz, "create", boolean.class, Supplier.class); + Method concurrentHashMapSupplierMethod = ReflectionUtil.lookupMethod(referencedKeySetClazz, "concurrentHashMapSupplier"); + return ReflectionUtil.invokeMethod(createMethod, null, true, ReflectionUtil.invokeMethod(concurrentHashMapSupplierMethod, null)); + }); + + access.registerFieldValueTransformer(localeCacheField, (receiver, originalValue) -> { + /* + * Executes `ReferencedKeyMap.create(true, + * ReferencedKeyMap.concurrentHashMapSupplier())` with reflection. + */ + Class referencedKeyMapClazz = ReflectionUtil.lookupClass("jdk.internal.util.ReferencedKeyMap"); + Method createMethod = ReflectionUtil.lookupMethod(referencedKeyMapClazz, "create", boolean.class, Supplier.class); + Method concurrentHashMapSupplierMethod = ReflectionUtil.lookupMethod(referencedKeyMapClazz, "concurrentHashMapSupplier"); + return ReflectionUtil.invokeMethod(createMethod, null, true, ReflectionUtil.invokeMethod(concurrentHashMapSupplierMethod, null)); + }); } @Override @@ -319,5 +343,4 @@ private boolean neverInlineTrivial(@SuppressWarnings("unused") AnalysisMethod ca */ return AnnotationAccess.isAnnotationPresent(callee, JS.class); } - } diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/WasmImports.java b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/WasmImports.java index b389c01885e8..befd0374e052 100644 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/WasmImports.java +++ b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/WasmImports.java @@ -60,7 +60,6 @@ public class WasmImports { public static final ImportDescriptor.Function F64Log = new ImportDescriptor.Function(MODULE_COMPAT, "f64log", TypeUse.forUnary(f64, f64), "Math.log"); public static final ImportDescriptor.Function F64Log10 = new ImportDescriptor.Function(MODULE_COMPAT, "f64log10", TypeUse.forUnary(f64, f64), "Math.log10"); public static final ImportDescriptor.Function F64Sin = new ImportDescriptor.Function(MODULE_COMPAT, "f64sin", TypeUse.forUnary(f64, f64), "Math.sin"); - public static final ImportDescriptor.Function F64Sinh = new ImportDescriptor.Function(MODULE_COMPAT, "f64sinh", TypeUse.forUnary(f64, f64), "Math.sinh"); public static final ImportDescriptor.Function F64Cos = new ImportDescriptor.Function(MODULE_COMPAT, "f64cos", TypeUse.forUnary(f64, f64), "Math.cos"); public static final ImportDescriptor.Function F64Tan = new ImportDescriptor.Function(MODULE_COMPAT, "f64tan", TypeUse.forUnary(f64, f64), "Math.tan"); public static final ImportDescriptor.Function F64Tanh = new ImportDescriptor.Function(MODULE_COMPAT, "f64tanh", TypeUse.forUnary(f64, f64), "Math.tanh"); diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/codegen/WebImageWasmNodeLowerer.java b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/codegen/WebImageWasmNodeLowerer.java index de863d53c723..e79af8d3cf98 100644 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/codegen/WebImageWasmNodeLowerer.java +++ b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/codegen/WebImageWasmNodeLowerer.java @@ -939,7 +939,6 @@ private Instruction lowerUnaryMathIntrinsic(UnaryMathIntrinsicNode node) { case LOG -> WasmImports.F64Log; case LOG10 -> WasmImports.F64Log10; case SIN -> WasmImports.F64Sin; - case SINH -> WasmImports.F64Sinh; case COS -> WasmImports.F64Cos; case TAN -> WasmImports.F64Tan; case TANH -> WasmImports.F64Tanh; diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/codegen/runtime/wasm-bootstrap.js b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/codegen/runtime/wasm-bootstrap.js index 0da6cc686b12..51b697f45a24 100644 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/codegen/runtime/wasm-bootstrap.js +++ b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/codegen/runtime/wasm-bootstrap.js @@ -38,7 +38,6 @@ wasmImports.compat = { f64log: Math.log, f64log10: Math.log10, f64sin: Math.sin, - f64sinh: Math.sinh, f64cos: Math.cos, f64tan: Math.tan, f64tanh: Math.tanh,