RFR: 8295486: Inconsistent constant field values observed during compilation [v2]

Tobias Hartmann thartmann at openjdk.org
Wed Jan 11 06:31:14 UTC 2023


On Tue, 10 Jan 2023 18:38:43 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:

>> src/hotspot/share/ci/ciEnv.hpp line 487:
>> 
>>> 485:   };
>>> 486: 
>>> 487:   GrowableArray<StableValue>* _stable_values; // Cache of stable values
>> 
>> Aren't `ciInstance` and `ciArray` provide a better place to cache field/element values (logic can be encapsulated in `ciInstance::field_value()` and `ciArray::element_value()`)?
>
> And it would seamlessly cover all possible cases, like static final fields (which can be concurrently updated through Reflection API or Unsafe).

But wouldn't that require duplication of the `ciEnv::check_stable_value` logic and having a `GrowableArray` per `ciObject` instance? 

Regarding covering more cases like static final fields: I intentionally omitted them because I don't think it's possible to delay constant folding of such loads until CCP (since `null` is a valid value) and the lookup is done only once during (I)GVN. The regression test includes a corresponding case (see `testFinal`). Even with unsafe accesses, if the field holder is not known at parse time, the access is conservatively marked as mismatched and thus no constant folding is attempted later.

-------------

PR: https://git.openjdk.org/jdk/pull/11861


More information about the hotspot-compiler-dev mailing list