Integrated: JDK-8293480: IGV: Update Bytecode and ControlFlow Component immediately when opening a new graph

Tobias Holenstein tholenstein at openjdk.org
Wed Sep 21 08:11:38 UTC 2022


On Wed, 7 Sep 2022 09:36:02 GMT, Tobias Holenstein <tholenstein at openjdk.org> wrote:

> The `BytecodeViewTopComponent` and `ControlFlowTopComponent` represent information depending on which graph is opened in `EditorTopComponent`. Previously `BytecodeViewTopComponent` and `ControlFlowTopComponent` did not update their contents immediately when a new graph from another group was opened in `EditorTopComponent`. They were also not updated when switching between two tabs of an open graph. 
> `OutlineTopComponent` had the same problem to update the selected graphs according to the `EditorTopComponent`
> 
> <img width="1291" alt="Update" src="https://user-images.githubusercontent.com/71546117/188860123-825a67fd-aab3-4500-8a47-8fa56eb9aeed.png">
> 
> **Analysis**
> `BytecodeViewTopComponent`, `ControlFlowTopComponent` and `OutlineTopComponent` each represent information that depends on the `InputGraph` of the currently or last active `EditorTopComponent`. This information is made available globally by adding a new `InputGraphProvider` to the `Lookup` of `EditorTopComponent` each time the `InputGraph` changes. `BytecodeViewTopComponent`, `ControlFlowTopComponent` and `OutlineTopComponent` implement a `LookupListener` that calls `resultChanged(LookupEvent lookupEvent)` whenever a `InputGraphProvider` changes in in the lookup of `Utilities.actionsGlobalContext()`. When such a change happens the last active `InputGraphProvider` is retrieved from the `LookupHistory` by the listening components. 
> 
> **Problem** 
> First, we missed to `fire()` a `diagramChangedEvent` in the constructor of `EditorTopComponent` which trigger to add the `InputGraphProvider` to the `Lookup`
> 
> Second, `Utilities.actionsGlobalContext()` returns a `Lookup` of the active (focused) `TopComponent's` `Lookup`. Unfortunately, when the last `EditorTopComponent` the `LookupListener` does not get called and there is no way to call is manually. 
> 
> **New Approach**
> We extends the `LookupHistory` class such that we can add a `ChangedListener` that gets called whenever the last active `InputGraphProvider` is cached. So instead of listening to changes in `Utilities.actionsGlobalContext()` and then consulting the `LookupHistory`, now  `BytecodeViewTopComponent`, `ControlFlowTopComponent` and `OutlineTopComponent` listen to changes in the `LookupHistory` directly. This way we can now call `terminate` in the `LookupHistory` whenever we close a `EditorTopComponent`, which directly notifies the listeners.

This pull request has now been integrated.

Changeset: 4e7cb156
Author:    Tobias Holenstein <tholenstein at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/4e7cb156c843ead88c0b9b01673b9d1db66f08d5
Stats:     402 lines in 11 files changed: 135 ins; 202 del; 65 mod

8293480: IGV: Update Bytecode and ControlFlow Component immediately when opening a new graph

Reviewed-by: rcastanedalo, chagedorn

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

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


More information about the hotspot-compiler-dev mailing list