summaryrefslogtreecommitdiff
path: root/deps/v8/tools/turbolizer/src/graph-view.ts
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/tools/turbolizer/src/graph-view.ts')
-rw-r--r--deps/v8/tools/turbolizer/src/graph-view.ts50
1 files changed, 43 insertions, 7 deletions
diff --git a/deps/v8/tools/turbolizer/src/graph-view.ts b/deps/v8/tools/turbolizer/src/graph-view.ts
index 3cb5e6fbc2..798a5cd340 100644
--- a/deps/v8/tools/turbolizer/src/graph-view.ts
+++ b/deps/v8/tools/turbolizer/src/graph-view.ts
@@ -19,6 +19,13 @@ function nodeToStringKey(n: GNode) {
return "" + n.id;
}
+function nodeOriginToStringKey(n: GNode): string | undefined {
+ if (n.nodeLabel && n.nodeLabel.origin) {
+ return "" + n.nodeLabel.origin.nodeId;
+ }
+ return undefined;
+}
+
interface GraphState {
showTypes: boolean;
selection: MySelection;
@@ -132,7 +139,7 @@ export class GraphView extends PhaseView {
}
};
- view.state.selection = new MySelection(nodeToStringKey);
+ view.state.selection = new MySelection(nodeToStringKey, nodeOriginToStringKey);
const defs = svg.append('svg:defs');
defs.append('svg:marker')
@@ -254,12 +261,14 @@ export class GraphView extends PhaseView {
this.toolbox.appendChild(createImgInput("toggle-types", "toggle types",
partial(this.toggleTypesAction, this)));
+ const adaptedSelection = this.adaptSelectionToCurrentPhase(data.data, rememberedSelection);
+
this.phaseName = data.name;
- this.createGraph(data.data, rememberedSelection);
+ this.createGraph(data.data, adaptedSelection);
this.broker.addNodeHandler(this.selectionHandler);
- if (rememberedSelection != null && rememberedSelection.size > 0) {
- this.attachSelection(rememberedSelection);
+ if (adaptedSelection != null && adaptedSelection.size > 0) {
+ this.attachSelection(adaptedSelection);
this.connectVisibleSelectedNodes();
this.viewSelection();
} else {
@@ -286,14 +295,14 @@ export class GraphView extends PhaseView {
this.deleteContent();
}
- createGraph(data, rememberedSelection) {
+ createGraph(data, selection) {
this.graph = new Graph(data);
this.showControlAction(this);
- if (rememberedSelection != undefined) {
+ if (selection != undefined) {
for (const n of this.graph.nodes()) {
- n.visible = n.visible || rememberedSelection.has(nodeToStringKey(n));
+ n.visible = n.visible || selection.has(nodeToStringKey(n));
}
}
@@ -359,6 +368,33 @@ export class GraphView extends PhaseView {
});
}
+ adaptSelectionToCurrentPhase(data, selection) {
+ const updatedGraphSelection = new Set();
+ if (!data || !(selection instanceof Map)) return updatedGraphSelection;
+ // Adding survived nodes (with the same id)
+ for (const node of data.nodes) {
+ const stringKey = this.state.selection.stringKey(node);
+ if (selection.has(stringKey)) {
+ updatedGraphSelection.add(stringKey);
+ }
+ }
+ // Adding children of nodes
+ for (const node of data.nodes) {
+ const originStringKey = this.state.selection.originStringKey(node);
+ if (originStringKey && selection.has(originStringKey)) {
+ updatedGraphSelection.add(this.state.selection.stringKey(node));
+ }
+ }
+ // Adding ancestors of nodes
+ selection.forEach(selectedNode => {
+ const originStringKey = this.state.selection.originStringKey(selectedNode);
+ if (originStringKey) {
+ updatedGraphSelection.add(originStringKey);
+ }
+ });
+ return updatedGraphSelection;
+ }
+
attachSelection(s) {
if (!(s instanceof Set)) return;
this.selectionHandler.clear();