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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « tools/turbolizer/disassembly-view.js ('k') | tools/turbolizer/empty-view.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var MINIMUM_EDGE_SEPARATION = 20;
6
7 function isEdgeInitiallyVisible(target, index, source, type) {
8 return type == "control" && (target.cfg || source.cfg);
9 }
10
11 var Edge = function(target, index, source, type) {
12 this.target = target;
13 this.source = source;
14 this.index = index;
15 this.type = type;
16 this.backEdgeNumber = 0;
17 this.visible = isEdgeInitiallyVisible(target, index, source, type);
18 };
19
20 Edge.prototype.stringID = function() {
21 return this.source.id + "," + this.index + "," + this.target.id;
22 };
23
24 Edge.prototype.isVisible = function() {
25 return this.visible && this.source.visible && this.target.visible;
26 };
27
28 Edge.prototype.getInputHorizontalPosition = function(graph) {
29 if (this.backEdgeNumber > 0) {
30 return graph.maxGraphNodeX + this.backEdgeNumber * MINIMUM_EDGE_SEPARATION;
31 }
32 var source = this.source;
33 var target = this.target;
34 var index = this.index;
35 var input_x = target.x + target.getInputX(index);
36 var inputApproach = target.getInputApproach(this.index);
37 var outputApproach = source.getOutputApproach(graph);
38 if (inputApproach > outputApproach) {
39 return input_x;
40 } else {
41 var inputOffset = MINIMUM_EDGE_SEPARATION * (index + 1);
42 return (target.x < source.x)
43 ? (target.x + target.getTotalNodeWidth() + inputOffset)
44 : (target.x - inputOffset)
45 }
46 }
47
48 Edge.prototype.generatePath = function(graph) {
49 var target = this.target;
50 var source = this.source;
51 var input_x = target.x + target.getInputX(this.index);
52 var output_x = source.x + source.getOutputX();
53 var output_y = source.y + DEFAULT_NODE_HEIGHT + DEFAULT_NODE_BUBBLE_RADIUS;
54 var inputApproach = target.getInputApproach(this.index);
55 var outputApproach = source.getOutputApproach(graph);
56 var horizontalPos = this.getInputHorizontalPosition(graph);
57
58 var result = "M" + output_x + "," + output_y +
59 "L" + output_x + "," + outputApproach +
60 "L" + horizontalPos + "," + outputApproach;
61
62 if (horizontalPos != input_x) {
63 result += "L" + horizontalPos + "," + inputApproach;
64 } else {
65 if (inputApproach < outputApproach) {
66 inputApproach = outputApproach;
67 }
68 }
69
70 result += "L" + input_x + "," + inputApproach +
71 "L" + input_x + "," + (target.y - DEFAULT_NODE_BUBBLE_RADIUS - 12);
72 return result;
73 }
74
75 Edge.prototype.isBackEdge = function() {
76 return this.target.hasBackEdges() && (this.target.rank < this.source.rank);
77 }
OLDNEW
« 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