RFR: 8266789: devirtualize find_node and remove of LinkedList

Ioi Lam iklam at openjdk.java.net
Wed May 26 23:39:04 UTC 2021


On Mon, 10 May 2021 07:49:49 GMT, Xin Liu <xliu at openjdk.org> wrote:

> Devirtualize find, find_node and remove. This patch make both LinkedListImpl
> and SortedLinkedList more generic. If the client doesn't use those member functions,
> it's not necessary to define equals() for the user-defined class E.
> 
> Remove those 3 member functions from the pure interface LinkedList. subclasses
> implement them using regular member functions.

If I understand correctly, the design of `LinkedList` provides an abstract base type `LinkedList<T>`, so that you can use


LinkedList<MyType>* list = .....;
MyType v = ....;
bool exists = list->find(v);


If you remove  the`virtual LinkedList<T>::find() = 0;` declaration, the above code will not work anymore.

Your patch can compile because `find` is currently used only once here, where the implementation type is known at compile time:


bool MemBaseline::aggregate_virtual_memory_allocation_sites() {
  SortedLinkedList<VirtualMemoryAllocationSite, compare_allocation_site> allocation_sites;
  ...
    site = allocation_sites.find(tmp);


However, this will not work in the future when we have other use of `find` where the exact implementation type is not known.

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

PR: https://git.openjdk.java.net/jdk/pull/3944


More information about the hotspot-dev mailing list