Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw ArrayStoreException if null is stored in non-nullable array #20291

Commits on Oct 7, 2024

  1. Throw ArrayStoreException if null is stored in non-nullable array

    Attempting to store a null reference to a non-nullable array is expected
    to throw an ArrayStoreException.  Previously that was expected to result
    in a NullPointerException.  This modifies Tree Lowering optimization's
    transformation of calls to <nonNullableArrayNullStoreCheckhelper> to use
    ZEROCHK to call jitArrayStoreException if the value to be stored is null
    and the array is non-nullable.
    
    Further, if Value Propagation determines at compile-time that an array
    is non-nullable, it used to generate a NULLCHK for the value.  With this
    change, it will generate a ZEROCHK that tests whether the value is a
    null reference.
    
    Finally, this change renames the utility method
    TR_J9VMBase::checkArrayCompClassPrimitiveValueType to
    TR_J9VMBase::testIsArrayClassNullRestrictedType, to reflect more recent
    terminology.  It also removes the argument that expected an "if" OpCode
    and will instead generate IL that yields a zero or non-zero result to
    indicate whether the array is null-restricted, leaving it to the caller
    to decide whether to generate IL that will branch or perform some other
    action based on the result.
    
    Signed-off-by:  Henry Zongaro <zongaro@ca.ibm.com>
    hzongaro committed Oct 7, 2024
    Configuration menu
    Copy the full SHA
    3cd0898 View commit details
    Browse the repository at this point in the history