RFR: 8309203: C2: remove copy-by-value of GrowableArray for InterfaceSet

Roland Westrelin roland at openjdk.org
Tue Nov 14 09:10:44 UTC 2023


On Mon, 23 Oct 2023 13:16:35 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:

>> The `InterfaceSet` component of types is immutable (once it is fully
>> constructed). In that way, it's similar to other type components. In
>> this change I propose making `InterfaceSet` a subtype of `Type` (and
>> renaming it `TypeInterfaces`). It's then feasible to `hashcons`
>> `TypeInterfaces` instances the way it's done for other `Type`
>> instance.  A single copy of a `TypeInterfaces` for a particular set of
>> interfaces is live during a compilation (and for the entire length of
>> the compilation) and pointer equality can be used to check two sets of
>> interfaces for equality. I think that change makes interface support
>> fit better with the type system implementation and has the added
>> benefits that there's no copy by value of the GrowableArray that holds
>> the set of interfaces anymore.
>> 
>> A couple of required virtual methods for `Type` are not implemented
>> for `TypeInterfaces`: `xmeet` and `singleton` (their body now calls
>> `ShouldNotReachHere`). They would need a way to tell whether
>> `TypeInterfaces` instances are above the center line or not. I thought
>> about (and tried) having a root class `Type` that would contain the
>> bare minimum for type that can be `hashcons`'ed so this method
>> wouldn't need to be implemented by `TypeInterfaces`. That proved to be
>> quite complicated and I gave up.
>
> I'm seeing a build failure:
> 
> 
> [2023-10-23T13:15:09,517Z] /workspace/open/src/hotspot/share/opto/type.hpp:896:8: error: 'eq' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
> [2023-10-23T13:15:09,517Z]   bool eq(const Type* other) const;
> [2023-10-23T13:15:09,517Z]        ^
> [2023-10-23T13:15:09,517Z] //workspace/open/src/hotspot/share/opto/type.hpp:162:16: note: overridden virtual function is here
> [2023-10-23T13:15:09,517Z]   virtual bool eq( const Type *t ) const;
> [2023-10-23T13:15:09,517Z]                ^
> [2023-10-23T13:15:09,517Z] /workspace/open/src/hotspot/share/opto/type.hpp:898:8: error: 'hash' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
> [2023-10-23T13:15:09,517Z]   uint hash() const;
> [2023-10-23T13:15:09,517Z]        ^
> [2023-10-23T13:15:09,517Z] /workspace/open/src/hotspot/share/opto/type.hpp:358:16: note: overridden virtual function is here
> [2023-10-23T13:15:09,517Z]   virtual uint hash() const;
> [2023-10-23T13:15:09,517Z]                ^
> [2023-10-23T13:15:09,517Z]    ... (rest of output omitted)

@TobiHartmann @vnkozlov thanks for the reviews.

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

PR Comment: https://git.openjdk.org/jdk/pull/16309#issuecomment-1809802133


More information about the hotspot-compiler-dev mailing list