diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000000..fb49f8c2a4e3a --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,130 @@ +{ + "image": "mcr.microsoft.com/devcontainers/universal:2", + "features": {} +} +# +# Copyright (c) 2022, 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. +# + +name: 'Build (macos)' + +on: + workflow_call: + inputs: + platform: + required: false + type: string + runs-on: + required: false + type: string + extra-conf-options: + required: false + type: string + make-target: + required: false + type: string + default: 'product-bundles test-bundles' + debug-levels: + required: false + type: string + default: '[ "debug", "release" ]' + xcode-toolset-version: + required: false + type: string + configure-arguments: + required: false + type: string + make-arguments: + required: false + type: string + dry-run: + required: false + type: boolean + default: false + +jobs: + build-macos: + name: build + runs-on: ${{ inputs.runs-on }} + + strategy: + fail-fast: false + matrix: + debug-level: ${{ fromJSON(inputs.debug-levels) }} + include: + debug-level: debug + flags: --with-debug-level=fastdebug + suffix: -debug + + steps: + name: 'Checkout the JDK source' + uses: actions/checkout@v6 + + name: 'Get the BootJDK' + id: bootjdk + uses: ./.github/actions/get-bootjdk + with: + platform: ${{ inputs.platform }} + + name: 'Get JTReg' + id: jtreg + uses: ./.github/actions/get-jtreg + + name: 'Get GTest' + id: gtest + uses: ./.github/actions/get-gtest + + name: 'Install toolchain and dependencies' + run: | + # Run Homebrew installation and xcode-select + brew install autoconf make + sudo xcode-select --switch /Applications/Xcode_${{ inputs.xcode-toolset-version }}.app/Contents/Developer + # This will make GNU make available as 'make' and not only as 'gmake' + echo '/usr/local/opt/make/libexec/gnubin' >> $GITHUB_PATH + + name: 'Configure' + run: > + bash configure + --with-conf-name=${{ inputs.platform }} + ${{ matrix.flags }} + --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} + --with-boot-jdk=${{ steps.bootjdk.outputs.path }} + --with-jtreg=${{ steps.jtreg.outputs.path }} + --with-gtest=${{ steps.gtest.outputs.path }} + --with-zlib=system + --with-jmod-compress=zip-1 + --with-external-symbols-in-bundles=none + --with-native-debug-symbols-level=1 + ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( + echo "Dumping config.log:" && + cat config.log && + exit 1) + + name: 'Build' + id: build + uses: ./.github/actions/do-build + with: + make-target: '${{ inputs.make-target }} ${{ inputs.make-arguments }}' + platform: ${{ inputs.platform }} + debug-suffix: '${{ matrix.suffix }}' diff --git a/.github/workflows/ant.yml b/.github/workflows/ant.yml new file mode 100644 index 0000000000000..c2cc53fa7c6a9 --- /dev/null +++ b/.github/workflows/ant.yml @@ -0,0 +1,26 @@ +# This workflow will build a Java project with Ant +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-ant + +name: PP + + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'temurin' + - name: Build with Ant + run: ant -noinput -buildfile build.xml diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 435576f4afd78..5ccff78946062 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -1,27 +1,4 @@ -# -# Copyright (c) 2022, 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. -# + name: 'Build (macos)' @@ -29,10 +6,10 @@ on: workflow_call: inputs: platform: - required: true + required: false type: string runs-on: - required: true + required: false type: string extra-conf-options: required: false @@ -46,7 +23,7 @@ on: type: string default: '[ "debug", "release" ]' xcode-toolset-version: - required: true + required: false type: string configure-arguments: required: false @@ -69,29 +46,29 @@ jobs: matrix: debug-level: ${{ fromJSON(inputs.debug-levels) }} include: - - debug-level: debug + debug-level: debug flags: --with-debug-level=fastdebug suffix: -debug steps: - - name: 'Checkout the JDK source' + name: 'Checkout the JDK source' uses: actions/checkout@v6 - - name: 'Get the BootJDK' + name: 'Get the BootJDK' id: bootjdk uses: ./.github/actions/get-bootjdk with: platform: ${{ inputs.platform }} - - name: 'Get JTReg' + name: 'Get JTReg' id: jtreg uses: ./.github/actions/get-jtreg - - name: 'Get GTest' + name: 'Get GTest' id: gtest uses: ./.github/actions/get-gtest - - name: 'Install toolchain and dependencies' + name: 'Install toolchain and dependencies' run: | # Run Homebrew installation and xcode-select brew install autoconf make @@ -99,7 +76,7 @@ jobs: # This will make GNU make available as 'make' and not only as 'gmake' echo '/usr/local/opt/make/libexec/gnubin' >> $GITHUB_PATH - - name: 'Configure' + name: 'Configure' run: > bash configure --with-conf-name=${{ inputs.platform }} @@ -117,7 +94,7 @@ jobs: cat config.log && exit 1) - - name: 'Build' + name: 'Build' id: build uses: ./.github/actions/do-build with: @@ -126,7 +103,7 @@ jobs: debug-suffix: '${{ matrix.suffix }}' if: ${{ inputs.dry-run == false }} - - name: 'Upload bundles' + name: 'Upload bundles' uses: ./.github/actions/upload-bundles with: platform: ${{ inputs.platform }} diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000000000..81d72e2cf2a7f --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,67 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Java with Gradle + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. + # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md + - name: Setup Gradle + uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 + + - name: Build with Gradle Wrapper + run: ./gradlew build + + # NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html). + # If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version. + # + # - name: Setup Gradle + # uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 + # with: + # gradle-version: '8.9' + # + # - name: Build with Gradle 8.9 + # run: gradle build + + dependency-submission: + + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. + # See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md + - name: Generate and submit dependency graph + uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 diff --git a/.github/workflows/objective-c-xcode.yml b/.github/workflows/objective-c-xcode.yml new file mode 100644 index 0000000000000..fe52a69307eea --- /dev/null +++ b/.github/workflows/objective-c-xcode.yml @@ -0,0 +1,30 @@ +name: Xcode - Build and Analyze + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + name: Build and analyse default scheme using xcodebuild command + runs-on: macos-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set Default Scheme + run: | + scheme_list=$(xcodebuild -list -json | tr -d "\n") + default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets'][0]") + echo $default | cat >default + echo Using default scheme: $default + - name: Build + env: + scheme: ${{ 'default' }} + run: | + if [ $scheme = default ]; then scheme=$(cat default); fi + if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi + file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` + xcodebuild clean build analyze -scheme "$scheme" -"$filetype_parameter" "$file_to_build" | xcpretty && exit ${PIPESTATUS[0]} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 98ede25b88df5..2d5cef8fd6dee 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,3 @@ # Contributing to the JDK - +... Please see the [OpenJDK Developers' Guide](https://openjdk.org/guide/). diff --git a/README.md b/README.md index e939f6a9ca4b9..dc07337e3cc03 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ For build instructions please see the [online documentation](https://git.openjdk.org/jdk/blob/master/doc/building.md), or either of these files: -- [doc/building.html](doc/building.html) (html version) -- [doc/building.md](doc/building.md) (markdown version) + [doc/building.html](doc/building.html) (html version) + [doc/building.md](doc/building.md) (markdown version) See for more information about the OpenJDK Community and the JDK and see for JDK issue diff --git a/src/hotspot/share/code/nmethod.hpp b/src/hotspot/share/code/nmethod.hpp index 3bb4030afdeda..540b24f5c78ec 100644 --- a/src/hotspot/share/code/nmethod.hpp +++ b/src/hotspot/share/code/nmethod.hpp @@ -268,26 +268,36 @@ class nmethod : public CodeBlob { volatile signed char _state; // {not_installed, in_use, not_entrant} public: - union Flags { - uint8_t _raw; - struct { - bool _has_unsafe_access:1; // May fault due to unsafe access. - bool _has_wide_vectors:1; // Preserve wide vectors at safepoints - bool _has_monitors:1; // Fastpath monitor detection for continuations - bool _has_scoped_access:1; // Used by shared scope closure (scopedMemoryAccess.cpp) + struct Flags { + uint8_t const _bits; + + enum : uint8_t { + UNSAFE_ACCESS = 1 << 0, + WIDE_VECTORS = 1 << 1, + MONITORS = 1 << 2, + SCOPED_ACCESS = 1 << 3 }; - Flags() { - _raw = 0; - } - Flags(bool has_unsafe_access, bool has_wide_vectors, bool has_monitors, bool has_scoped_access) : Flags() { - _has_unsafe_access = has_unsafe_access; - _has_wide_vectors = has_wide_vectors; - _has_monitors = has_monitors; - _has_scoped_access = has_scoped_access; - } - }; - static_assert(sizeof(Flags) == sizeof(uint8_t), "Must fit exactly"); + Flags() : _bits(0) {} + Flags(bool has_unsafe_access, bool has_wide_vectors, bool has_monitors, bool has_scoped_access) : + _bits((has_unsafe_access ? UNSAFE_ACCESS : 0) | + (has_wide_vectors ? WIDE_VECTORS : 0) | + (has_monitors ? MONITORS : 0) | + (has_scoped_access ? SCOPED_ACCESS : 0)) + {} + + // May fault due to unsafe access + bool has_unsafe_access() const { return (_bits & UNSAFE_ACCESS) != 0; } + + // Preserve wide vectors at safepoints + bool has_wide_vectors() const { return (_bits & WIDE_VECTORS) != 0; } + + // Fastpath monitor detection for continuations + bool has_monitors() const { return (_bits & MONITORS) != 0; } + + // Used by shared scope closure (scopedMemoryAccess.cpp) + bool has_scoped_access() const { return (_bits & SCOPED_ACCESS) != 0; } + }; private: // Persistent bits, set once during construction. @@ -779,10 +789,10 @@ class nmethod : public CodeBlob { template void set_gc_data(T* gc_data) { _gc_data = reinterpret_cast(gc_data); } - bool has_unsafe_access() const { return _flags._has_unsafe_access; } - bool has_monitors() const { return _flags._has_monitors; } - bool has_scoped_access() const { return _flags._has_scoped_access; } - bool has_wide_vectors() const { return _flags._has_wide_vectors; } + bool has_unsafe_access() const { return _flags.has_unsafe_access(); } + bool has_monitors() const { return _flags.has_monitors(); } + bool has_scoped_access() const { return _flags.has_scoped_access(); } + bool has_wide_vectors() const { return _flags.has_wide_vectors(); } bool has_flushed_dependencies() const { return _has_flushed_dependencies; } void set_has_flushed_dependencies(bool z) { diff --git a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp index a486a88c48fbc..0a03ce52e238b 100644 --- a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp +++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp @@ -324,6 +324,8 @@ class BarrierSetC2: public CHeapObj { virtual bool is_gc_pre_barrier_node(Node* node) const { return false; } virtual bool is_gc_barrier_node(Node* node) const { return false; } virtual Node* step_over_gc_barrier(Node* c) const { return c; } + // Allow barriers that depend on transitive inputs to be re-evaluated. + virtual void enqueue_dependent_gc_barriers(Unique_Node_List& worklist, Node* use) const {} // Support for macro expanded GC barriers virtual void register_potential_barrier_node(Node* node) const { } diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp index deab648a108ec..f786702a29190 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp @@ -843,6 +843,36 @@ Node* ShenandoahBarrierSetC2::step_over_gc_barrier(Node* c) const { return c; } +static bool is_barrier_traversal_node(int op) { + // Node types that ShenandoahLoadReferenceBarrierNode::Identity traverses via needs_barrier_impl. + return op == Op_Phi || op == Op_DecodeN || op == Op_EncodeP || op == Op_CastPP || + op == Op_CheckCastPP || op == Op_CMoveN || op == Op_CMoveP || op == Op_Proj; +} + +void ShenandoahBarrierSetC2::enqueue_dependent_gc_barriers(Unique_Node_List& worklist, Node* n) const { + if (!is_barrier_traversal_node(n->Opcode())) { + return; + } + Unique_Node_List visited; + Unique_Node_List stack; + stack.push(n); + while (stack.size() > 0) { + Node* cur = stack.pop(); + if (visited.member(cur)) { + continue; + } + visited.push(cur); + for (DUIterator_Fast imax, i = cur->fast_outs(imax); i < imax; i++) { + Node* u = cur->fast_out(i); + if (u->Opcode() == Op_ShenandoahLoadReferenceBarrier) { + worklist.push(u); + } else if (is_barrier_traversal_node(u->Opcode())) { + stack.push(u); + } + } + } +} + bool ShenandoahBarrierSetC2::expand_barriers(Compile* C, PhaseIterGVN& igvn) const { return !ShenandoahBarrierC2Support::expand(C, igvn); } diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp index c77a9da63fc1b..63244ee7751ea 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp @@ -127,6 +127,7 @@ class ShenandoahBarrierSetC2 : public BarrierSetC2 { virtual bool is_gc_pre_barrier_node(Node* node) const; virtual bool is_gc_barrier_node(Node* node) const; virtual Node* step_over_gc_barrier(Node* c) const; + virtual void enqueue_dependent_gc_barriers(Unique_Node_List& worklist, Node* use) const; virtual bool expand_barriers(Compile* C, PhaseIterGVN& igvn) const; virtual bool optimize_loops(PhaseIdealLoop* phase, LoopOptsMode mode, VectorSet& visited, Node_Stack& nstack, Node_List& worklist) const; virtual bool strip_mined_loops_expanded(LoopOptsMode mode) const { return mode == LoopOptsShenandoahExpand; } diff --git a/src/hotspot/share/opto/phaseX.cpp b/src/hotspot/share/opto/phaseX.cpp index a4d6a6c33d081..c166a3f05f79d 100644 --- a/src/hotspot/share/opto/phaseX.cpp +++ b/src/hotspot/share/opto/phaseX.cpp @@ -2797,6 +2797,11 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_ add_users_to_worklist_if(worklist, use, [](Node* u) { return u->Opcode() == Op_VectorMaskToLong; }); } + // Allow GC to enqueue barriers that depend on transitive inputs + if (has_load_barrier_nodes) { + bs->enqueue_dependent_gc_barriers(worklist, use); + } + // From CastX2PNode::Ideal // CastX2P(AddX(x, y)) // CastX2P(SubX(x, y))