Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Unified Diff: tools/turbolizer/edge.js

Issue 729913004: Add a html-based visualizer for TurboFan graphs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review feedback Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/turbolizer/disassembly-view.js ('k') | tools/turbolizer/empty-view.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/turbolizer/edge.js
diff --git a/tools/turbolizer/edge.js b/tools/turbolizer/edge.js
new file mode 100644
index 0000000000000000000000000000000000000000..7e46391df8cbd266b8ac7d49c51b37476594e856
--- /dev/null
+++ b/tools/turbolizer/edge.js
@@ -0,0 +1,77 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var MINIMUM_EDGE_SEPARATION = 20;
+
+function isEdgeInitiallyVisible(target, index, source, type) {
+ return type == "control" && (target.cfg || source.cfg);
+}
+
+var Edge = function(target, index, source, type) {
+ this.target = target;
+ this.source = source;
+ this.index = index;
+ this.type = type;
+ this.backEdgeNumber = 0;
+ this.visible = isEdgeInitiallyVisible(target, index, source, type);
+};
+
+Edge.prototype.stringID = function() {
+ return this.source.id + "," + this.index + "," + this.target.id;
+};
+
+Edge.prototype.isVisible = function() {
+ return this.visible && this.source.visible && this.target.visible;
+};
+
+Edge.prototype.getInputHorizontalPosition = function(graph) {
+ if (this.backEdgeNumber > 0) {
+ return graph.maxGraphNodeX + this.backEdgeNumber * MINIMUM_EDGE_SEPARATION;
+ }
+ var source = this.source;
+ var target = this.target;
+ var index = this.index;
+ var input_x = target.x + target.getInputX(index);
+ var inputApproach = target.getInputApproach(this.index);
+ var outputApproach = source.getOutputApproach(graph);
+ if (inputApproach > outputApproach) {
+ return input_x;
+ } else {
+ var inputOffset = MINIMUM_EDGE_SEPARATION * (index + 1);
+ return (target.x < source.x)
+ ? (target.x + target.getTotalNodeWidth() + inputOffset)
+ : (target.x - inputOffset)
+ }
+}
+
+Edge.prototype.generatePath = function(graph) {
+ var target = this.target;
+ var source = this.source;
+ var input_x = target.x + target.getInputX(this.index);
+ var output_x = source.x + source.getOutputX();
+ var output_y = source.y + DEFAULT_NODE_HEIGHT + DEFAULT_NODE_BUBBLE_RADIUS;
+ var inputApproach = target.getInputApproach(this.index);
+ var outputApproach = source.getOutputApproach(graph);
+ var horizontalPos = this.getInputHorizontalPosition(graph);
+
+ var result = "M" + output_x + "," + output_y +
+ "L" + output_x + "," + outputApproach +
+ "L" + horizontalPos + "," + outputApproach;
+
+ if (horizontalPos != input_x) {
+ result += "L" + horizontalPos + "," + inputApproach;
+ } else {
+ if (inputApproach < outputApproach) {
+ inputApproach = outputApproach;
+ }
+ }
+
+ result += "L" + input_x + "," + inputApproach +
+ "L" + input_x + "," + (target.y - DEFAULT_NODE_BUBBLE_RADIUS - 12);
+ return result;
+}
+
+Edge.prototype.isBackEdge = function() {
+ return this.target.hasBackEdges() && (this.target.rank < this.source.rank);
+}
« no previous file with comments | « tools/turbolizer/disassembly-view.js ('k') | tools/turbolizer/empty-view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698