2016-05-19 08:17:29 +00:00
|
|
|
// 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 TYPE_HEIGHT = 25;
|
2016-08-11 16:46:00 +00:00
|
|
|
var DEFAULT_NODE_BUBBLE_RADIUS = 12;
|
|
|
|
var NODE_INPUT_WIDTH = 50;
|
|
|
|
var MINIMUM_NODE_INPUT_APPROACH = 15 + 2 * DEFAULT_NODE_BUBBLE_RADIUS;
|
2016-05-19 08:17:29 +00:00
|
|
|
var MINIMUM_NODE_OUTPUT_APPROACH = 15;
|
|
|
|
|
|
|
|
function isNodeInitiallyVisible(node) {
|
|
|
|
return node.cfg;
|
|
|
|
}
|
|
|
|
|
|
|
|
var Node = {
|
|
|
|
isControl: function() {
|
|
|
|
return this.control;
|
|
|
|
},
|
|
|
|
isInput: function() {
|
|
|
|
return this.opcode == 'Parameter' || this.opcode.endsWith('Constant');
|
|
|
|
},
|
2016-08-09 16:20:15 +00:00
|
|
|
isLive: function() {
|
2016-08-11 16:46:00 +00:00
|
|
|
return this.live !== false;
|
2016-08-09 16:20:15 +00:00
|
|
|
},
|
2016-05-19 08:17:29 +00:00
|
|
|
isJavaScript: function() {
|
|
|
|
return this.opcode.startsWith('JS');
|
|
|
|
},
|
|
|
|
isSimplified: function() {
|
2016-11-24 15:32:30 +00:00
|
|
|
if (this.isJavaScript()) return false;
|
2016-05-19 08:17:29 +00:00
|
|
|
return this.opcode.endsWith('Phi') ||
|
|
|
|
this.opcode.startsWith('Boolean') ||
|
|
|
|
this.opcode.startsWith('Number') ||
|
|
|
|
this.opcode.startsWith('String') ||
|
|
|
|
this.opcode.startsWith('Change') ||
|
|
|
|
this.opcode.startsWith('Object') ||
|
|
|
|
this.opcode.startsWith('Reference') ||
|
|
|
|
this.opcode.startsWith('Any') ||
|
|
|
|
this.opcode.endsWith('ToNumber') ||
|
|
|
|
(this.opcode == 'AnyToBoolean') ||
|
|
|
|
(this.opcode.startsWith('Load') && this.opcode.length > 4) ||
|
|
|
|
(this.opcode.startsWith('Store') && this.opcode.length > 5);
|
|
|
|
},
|
|
|
|
isMachine: function() {
|
|
|
|
return !(this.isControl() || this.isInput() ||
|
|
|
|
this.isJavaScript() || this.isSimplified());
|
|
|
|
},
|
|
|
|
getTotalNodeWidth: function() {
|
|
|
|
var inputWidth = this.inputs.length * NODE_INPUT_WIDTH;
|
|
|
|
return Math.max(inputWidth, this.width);
|
|
|
|
},
|
[turbolizer] Show a label with a shorter parameter for some opcodes.
With this patch, every node in turbo-*.json has an opcode, a title, and
a label. The label field is new; the opcode and title were already
there. The title is for the mouseover text. The label is what will be
displayed in the graph view, unless it's too long, in which case only
the opcode will be displayed. (This is similar to the preexisting
behaviour of putting titles in labels, except that the titles were
rarely short enough to fit in a label.)
With this patch, the labels generated are in practice the same as the
titles we had before, except for LoadField and StoreField, which will be
rendered as LoadField[[+432]] and StoreField[[+432]] (if 432 was the
offset).
This diff adds an overloadable method
virtual void Operator1<T>::PrintParameter(ostream&, PrintVerbosity)
for each type T to Operator1. Its default implementation just uses
operator<<(ostream&, T const&) and adds square brackets around it, but
it is overridden for FieldAccess to print "[+432]" in the example case.
BUG=
R=jarin,danno
Review-Url: https://codereview.chromium.org/2093013002
Cr-Commit-Position: refs/heads/master@{#37795}
2016-07-15 12:05:54 +00:00
|
|
|
getTitle: function() {
|
2016-08-09 15:45:30 +00:00
|
|
|
var propsString;
|
|
|
|
if (this.properties === undefined) {
|
|
|
|
propsString = "";
|
|
|
|
} else if (this.properties === "") {
|
|
|
|
propsString = "no properties";
|
|
|
|
} else {
|
|
|
|
propsString = "[" + this.properties + "]";
|
|
|
|
}
|
|
|
|
return this.title + "\n" + propsString + "\n" + this.opinfo;
|
2016-05-19 08:17:29 +00:00
|
|
|
},
|
|
|
|
getDisplayLabel: function() {
|
|
|
|
var result = this.id + ":" + this.label;
|
2016-08-10 20:23:45 +00:00
|
|
|
if (result.length > 40) {
|
2016-05-19 08:17:29 +00:00
|
|
|
return this.id + ":" + this.opcode;
|
|
|
|
} else {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getType: function() {
|
|
|
|
return this.type;
|
|
|
|
},
|
|
|
|
getDisplayType: function() {
|
|
|
|
var type_string = this.type;
|
|
|
|
if (type_string == undefined) return "";
|
|
|
|
if (type_string.length > 24) {
|
|
|
|
type_string = type_string.substr(0, 25) + "...";
|
|
|
|
}
|
|
|
|
return type_string;
|
|
|
|
},
|
|
|
|
deepestInputRank: function() {
|
|
|
|
var deepestRank = 0;
|
|
|
|
this.inputs.forEach(function(e) {
|
|
|
|
if (e.isVisible() && !e.isBackEdge()) {
|
|
|
|
if (e.source.rank > deepestRank) {
|
|
|
|
deepestRank = e.source.rank;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return deepestRank;
|
|
|
|
},
|
|
|
|
areAnyOutputsVisible: function() {
|
|
|
|
var visibleCount = 0;
|
|
|
|
this.outputs.forEach(function(e) { if (e.isVisible()) ++visibleCount; });
|
|
|
|
if (this.outputs.length == visibleCount) return 2;
|
|
|
|
if (visibleCount != 0) return 1;
|
|
|
|
return 0;
|
|
|
|
},
|
|
|
|
setOutputVisibility: function(v) {
|
|
|
|
var result = false;
|
|
|
|
this.outputs.forEach(function(e) {
|
|
|
|
e.visible = v;
|
|
|
|
if (v) {
|
|
|
|
if (!e.target.visible) {
|
|
|
|
e.target.visible = true;
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
setInputVisibility: function(i, v) {
|
|
|
|
var edge = this.inputs[i];
|
|
|
|
edge.visible = v;
|
|
|
|
if (v) {
|
|
|
|
if (!edge.source.visible) {
|
|
|
|
edge.source.visible = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
getInputApproach: function(index) {
|
|
|
|
return this.y - MINIMUM_NODE_INPUT_APPROACH -
|
|
|
|
(index % 4) * MINIMUM_EDGE_SEPARATION - DEFAULT_NODE_BUBBLE_RADIUS
|
|
|
|
},
|
|
|
|
getOutputApproach: function(graph, index) {
|
2016-08-11 16:46:00 +00:00
|
|
|
return this.y + this.outputApproach + graph.getNodeHeight(this) +
|
2016-05-19 08:17:29 +00:00
|
|
|
+ DEFAULT_NODE_BUBBLE_RADIUS;
|
|
|
|
},
|
|
|
|
getInputX: function(index) {
|
|
|
|
var result = this.getTotalNodeWidth() - (NODE_INPUT_WIDTH / 2) +
|
|
|
|
(index - this.inputs.length + 1) * NODE_INPUT_WIDTH;
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
getOutputX: function() {
|
|
|
|
return this.getTotalNodeWidth() - (NODE_INPUT_WIDTH / 2);
|
|
|
|
},
|
|
|
|
getFunctionRelativeSourcePosition: function(graph) {
|
|
|
|
return this.pos - graph.sourcePosition;
|
|
|
|
},
|
|
|
|
hasBackEdges: function() {
|
|
|
|
return (this.opcode == "Loop") ||
|
|
|
|
((this.opcode == "Phi" || this.opcode == "EffectPhi") &&
|
|
|
|
this.inputs[this.inputs.length - 1].source.opcode == "Loop");
|
|
|
|
}
|
|
|
|
};
|