RFR: JDK-8293480: IGV: Update Bytecode and ControlFlow Component immediately when opening a new graph [v7]
Tobias Holenstein
tholenstein at openjdk.org
Wed Sep 21 07:35:54 UTC 2022
> 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.
Tobias Holenstein has updated the pull request incrementally with two additional commits since the last revision:
- Update src/utils/IdealGraphVisualizer/Util/src/main/java/com/sun/hotspot/igv/util/LookupHistory.java
remove this
Co-authored-by: Christian Hagedorn <christian.hagedorn at oracle.com>
- remove whitespace
Co-authored-by: Christian Hagedorn <christian.hagedorn at oracle.com>
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/10196/files
- new: https://git.openjdk.org/jdk/pull/10196/files/31b9d673..544bf1d0
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=10196&range=06
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=10196&range=05-06
Stats: 2 lines in 2 files changed: 0 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/10196.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/10196/head:pull/10196
PR: https://git.openjdk.org/jdk/pull/10196
More information about the hotspot-compiler-dev
mailing list