The JVMCI path to fold constant reads is quite complex because there are multiple paths into it and the introduction of libgraal introduced some more duplication which makes it hard to maintain. It should be simplfied. This cleanup turned out to also a be partial fix for some missing safety checks in the libgraal read folding path, so I'm turning this into a consolidation of those bug fixes. Basically because of code duplication the pure Java paths had bounds checks which the libgraal path was mostly missing. This refactoring ensures that all code goes through the exact same safety check no matter how the path is entered.