GithubHelp home page GithubHelp logo

Comments (4)

keithc-ca avatar keithc-ca commented on June 26, 2024 1

The AIX compiler leaves us in a difficult position. We need to support types which use the default (power?) alignment rules as well as "natural" alignment. I don't think we should undo the fixes we've made to handle the default alignment rules.

I agree those pragma lines should be removed, unless tests specifically account for the non-default alignment.

from openj9.

ChengJin01 avatar ChengJin01 commented on June 26, 2024

It is weird that the issue with downcall or upcall at #18941, #18942, #18943 never occurred on other platforms or in JDK21. It is most likely something new happens to the JD22 test suites or something else we were unaware of before on AIX.

from openj9.

ChengJin01 avatar ChengJin01 commented on June 26, 2024

The crash was triggered by the following code that was added recently in test to enforce the 8-byte alignment for double in struct at https://github.com/ibmruntimes/openj9-openjdk-jdk22/blob/687a1453366566440768237f7c69361b2ec21406/test/jdk/java/foreign/shared.h#L37

#ifdef _AIX
#pragma align (natural)  <-------------
#endif
...
#ifdef _AIX
#pragma align (reset) <-------------
#endif

as mentioned at the new code on AIX at https://github.com/ibmruntimes/openj9-openjdk-jdk22/blob/687a1453366566440768237f7c69361b2ec21406/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/aix/AixPPC64Linker.java#L60

    protected void checkStructMember(MemoryLayout member, long offset) {
        // special case double members that are not the first member
        // see: https://www.ibm.com/docs/en/xl-c-and-cpp-aix/16.1?topic=data-using-alignment-modes <-----
        // Note: It is possible to enforce 8-byte alignment by #pragma align (natural)
        // Therefore, we use normal checks if we are already 8-byte aligned.
        if ((offset % 8 != 0) && (member instanceof ValueLayout vl && vl.carrier() == double.class)) {
            if (vl.byteAlignment() != 4) {
                throw new IllegalArgumentException("double struct member " + vl + " at offset " + offset + " should be 4-byte aligned");
            }
            if (vl.order() != linkerByteOrder()) {
                throw new IllegalArgumentException("double struct member " + vl + " at offset " + offset + " has an unexpected byte order");
            }
        } else {
            super.checkStructMember(member, offset);
        }
    }

which conflicts with our previous changes in OpenJDK at https://github.com/ibmruntimes/openj9-openjdk-jdk22/blob/687a1453366566440768237f7c69361b2ec21406/src/java.base/share/classes/jdk/internal/foreign/layout/ValueLayouts.java#L292

        public static OfDouble of(ByteOrder order) {
            return new OfDoubleImpl(order, Utils.IS_AIX ? 4 : ADDRESS_SIZE_BYTES, Optional.empty()); <---------
        } 

        @Override
        public boolean hasNaturalAlignment() {
            return Utils.IS_AIX ? (byteAlignment() == 4) : super.hasNaturalAlignment(); <--------
        }
    }

As discussed at #18287 (comment), we should always allow the default setting by the compiler and never assume that users are aware of the platform-specific difference by imposing #pragma in the applications for AIX.

To address the issue with alignment on double on AIX, I'd suggest to remove the #pragma related test code in the test header file without any modification in our code as to the 4-byte alignment adjustment on double.

FYI: @keithc-ca

from openj9.

ChengJin01 avatar ChengJin01 commented on June 26, 2024

Close the issue as resolved via ibmruntimes/openj9-openjdk-jdk22#32.

from openj9.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.