mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-02 21:11:12 -06:00
Merge branch 'master' of https://github.com/mattgodbolt/compiler-explorer
Conflicts: lib/base-compiler.js lib/cfg.js
This commit is contained in:
@@ -22,3 +22,7 @@ static/ast-view.js @TartanLlama
|
||||
static/haskell-mode.js @TartanLlama
|
||||
lib/compilers/haskell.js @TartanLlama
|
||||
views/example.hs @TartanLlama
|
||||
|
||||
# cppchedy
|
||||
static/cfg-view.js @cppchedy
|
||||
lib/cfg.js @cppchedy
|
||||
|
||||
@@ -272,4 +272,4 @@ libs.xtensor.versions.trunk.path=/opt/compiler-explorer/libs/xtensor/include
|
||||
libs.abseil.name=Abseil
|
||||
libs.abseil.versions=trunk
|
||||
libs.abseil.versions.trunk.version=trunk
|
||||
libs.abseil.versions.trunk.path=/opt/compiler-explorer/libs/abseil
|
||||
libs.abseil.versions.trunk.path=/opt/compiler-explorer/libs/abseil:/opt/compiler-explorer/libs/cctz/include
|
||||
|
||||
@@ -62,7 +62,7 @@ Compile.prototype.readFile = Promise.denodeify(fs.readFile);
|
||||
Compile.prototype.stat = Promise.denodeify(fs.stat);
|
||||
|
||||
Compile.prototype.optOutputRequested = function (options) {
|
||||
return options.some((x) => x == "-fsave-optimization-record");
|
||||
return options.some((x) => x === "-fsave-optimization-record");
|
||||
};
|
||||
|
||||
Compile.prototype.getRemote = function () {
|
||||
@@ -373,7 +373,7 @@ Compile.prototype.couldSupportASTDump = function (options, version) {
|
||||
};
|
||||
|
||||
Compile.prototype.isCfgCompiler = function(compilerVersion) {
|
||||
return compilerVersion.includes("clang") || (compilerVersion.indexOf("g++") == 0);
|
||||
return compilerVersion.includes("clang") || compilerVersion.indexOf("g++") === 0;
|
||||
};
|
||||
|
||||
Compile.prototype.processAstOutput = function (output) {
|
||||
|
||||
+17
-17
@@ -104,27 +104,27 @@ function separateCodeFromData_(asmArr) {
|
||||
.value();
|
||||
}
|
||||
|
||||
var clangX86 = {
|
||||
filterData: separateCodeFromData_,
|
||||
isFunctionEnd:function(x) { return ((x[0] !== ' ') && (x[0] !== '.') &&
|
||||
(x.indexOf(':') !== -1)) ;},
|
||||
var clangX86 = {
|
||||
filterData: separateCodeFromData_,
|
||||
isFunctionEnd:function(x) { return ((x[0] !== ' ') && (x[0] !== '.') &&
|
||||
(x.indexOf(':') !== -1)) ;},
|
||||
|
||||
isBasicBlockEnd: function(inst, prevInst) { return inst[0] === "." || prevInst.includes(" ret");} ,
|
||||
isBasicBlockEnd: function(inst, prevInst) { return inst[0] === "." || prevInst.includes(" ret");} ,
|
||||
|
||||
getInstructionType:function(inst) {
|
||||
if(inst.includes("jmp")) return InstructionType_jmp;
|
||||
else if(inst.trim()[0] === 'j') return InstructionType_conditionalJmpInst;
|
||||
else if(!inst.includes(" ret")) return InstructionType_notRetInst;
|
||||
else return InstructionType_retInst;
|
||||
},
|
||||
getInstructionType:function(inst) {
|
||||
if(inst.includes("jmp")) return InstructionType_jmp;
|
||||
else if(inst.trim()[0] === 'j') return InstructionType_conditionalJmpInst;
|
||||
else if(!inst.includes(" ret")) return InstructionType_notRetInst;
|
||||
else return InstructionType_retInst;
|
||||
},
|
||||
|
||||
extractNodeName:function(inst) {
|
||||
var name = inst.match(/\.LBB\d+_\d+/);
|
||||
return name + ":";
|
||||
},
|
||||
extractNodeName:function(inst) {
|
||||
var name = inst.match(/\.LBB\d+_\d+/);
|
||||
return name + ":";
|
||||
},
|
||||
|
||||
isJmpInstruction: function(x) { var trimed = x.trim(); return ( trimed[0] === 'j');}
|
||||
};
|
||||
isJmpInstruction: function(x) { var trimed = x.trim(); return ( trimed[0] === 'j');}
|
||||
};
|
||||
|
||||
function ControlFlowGraph(compiler){
|
||||
if(compiler.includes("clang"))
|
||||
|
||||
+19
-19
@@ -23,24 +23,24 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function(require){
|
||||
"use strict";
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery');
|
||||
var vis = require('vis');
|
||||
var _ = require('underscore');
|
||||
|
||||
require('asm-mode');
|
||||
require('selectize');
|
||||
|
||||
function Cfg(hub, container, state){
|
||||
function Cfg(hub, container, state) {
|
||||
this.container = container;
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.domRoot = container.getElement();
|
||||
this.domRoot.html($('#cfg').html());
|
||||
this.functions = state.cfgResult;
|
||||
this.defaultCfgOuput = {nodes: [{id: 0, label: 'No Output'}], edges: []};
|
||||
this.fnNames = this.functions? Object.keys(this.functions): [];
|
||||
this.currentFunc = this.fnNames.length? this.fnNames[0]: "";
|
||||
this.fnNames = this.functions ? Object.keys(this.functions) : [];
|
||||
this.currentFunc = this.fnNames.length ? this.fnNames[0] : "";
|
||||
|
||||
this.networkOpts = {
|
||||
autoResize: true,
|
||||
@@ -79,9 +79,9 @@ define(function(require){
|
||||
};
|
||||
|
||||
this.cfgVisualiser = new vis.Network(this.domRoot.find(".graph-placeholder")[0],
|
||||
this.defaultCfgOuput, this.networkOpts);
|
||||
this.defaultCfgOuput, this.networkOpts);
|
||||
this.restButton = this.domRoot.find(".show-hide-btn")
|
||||
.on('click', _.bind(function(){
|
||||
.on('click', _.bind(function () {
|
||||
this.networkOpts.interaction.navigationButtons = !this.networkOpts.interaction.navigationButtons;
|
||||
this.cfgVisualiser.setOptions(this.networkOpts);
|
||||
}, this));
|
||||
@@ -101,11 +101,11 @@ define(function(require){
|
||||
container.on('resize', this.resize, this);
|
||||
container.on('shown', this.resize, this);
|
||||
|
||||
this.adaptStructure = function(names){
|
||||
this.adaptStructure = function (names) {
|
||||
var options = [];
|
||||
|
||||
for(var i = 0; i < names.length; ++i){
|
||||
options.push({name:names[i]});
|
||||
for (var i = 0; i < names.length; ++i) {
|
||||
options.push({name: names[i]});
|
||||
}
|
||||
return options;
|
||||
};
|
||||
@@ -115,9 +115,9 @@ define(function(require){
|
||||
valueField: 'name',
|
||||
labelField: 'name',
|
||||
searchField: ['name'],
|
||||
options: this.fnNames.length ? this.adaptStructure(this.fnNames) : [{name:"The input does not contain any function"}],
|
||||
options: this.fnNames.length ? this.adaptStructure(this.fnNames) : [{name: "The input does not contain any function"}],
|
||||
items: this.fnNames.length ? [this.currentFunc] : ["Please select a function"]
|
||||
}).on('change', _.bind(function(event){
|
||||
}).on('change', _.bind(function (event) {
|
||||
this.onFunctionChange(this.functions, event.target.value);
|
||||
}, this));
|
||||
|
||||
@@ -129,7 +129,7 @@ define(function(require){
|
||||
if (result.supportsCfg && !$.isEmptyObject(result.cfg)) {
|
||||
this.functions = result.cfg;
|
||||
this.fnNames = Object.keys(this.functions);
|
||||
if(this.fnNames.indexOf(this.currentFunc) === -1)
|
||||
if (this.fnNames.indexOf(this.currentFunc) === -1)
|
||||
this.currentFunc = this.fnNames[0];
|
||||
this.showCfgResults({
|
||||
'nodes': this.functions[this.currentFunc].nodes,
|
||||
@@ -148,8 +148,8 @@ define(function(require){
|
||||
valueField: 'name',
|
||||
labelField: 'name',
|
||||
searchField: ['name'],
|
||||
options: this.fnNames.length ? this.adaptStructure(this.fnNames) : [{name:"The input does not contain any function"}],
|
||||
items: this.fnNames.length ? [this.currentFunc] : ["Please select a function"]
|
||||
options: this.fnNames.length ? this.adaptStructure(this.fnNames) : [{name: "The input does not contain any function"}],
|
||||
items: this.fnNames.length ? [this.currentFunc] : ["Please select a function"]
|
||||
}).on('change', _.bind(function (event) {
|
||||
this.onFunctionChange(this.functions, event.target.value);
|
||||
}, this));
|
||||
@@ -157,15 +157,15 @@ define(function(require){
|
||||
};
|
||||
|
||||
Cfg.prototype.setTitle = function () {
|
||||
this.container.setTitle(this._compilerName + " Graph Viewer (Editor #" + this._editorid + ", Compiler #" + this._compilerid + ")");
|
||||
this.container.setTitle(this._compilerName + " Graph Viewer (Editor #" + this._editorid + ", Compiler #" + this._compilerid + ")");
|
||||
};
|
||||
|
||||
Cfg.prototype.showCfgResults = function(data) {
|
||||
Cfg.prototype.showCfgResults = function (data) {
|
||||
this.cfgVisualiser.setData(data);
|
||||
};
|
||||
|
||||
Cfg.prototype.onCompiler = function (id, compiler, options, editorid) {
|
||||
if(id === this._compilerid) {
|
||||
if (id === this._compilerid) {
|
||||
this._compilerName = compiler.name;
|
||||
this._editorid = editorid;
|
||||
this.setTitle();
|
||||
|
||||
+7
-20
@@ -235,10 +235,10 @@ define(function (require) {
|
||||
this.eventHub.on('findCompilers', this.sendCompiler, this);
|
||||
this.eventHub.on('compilerSetDecorations', this.onCompilerSetDecorations, this);
|
||||
this.eventHub.on('settingsChange', this.onSettingsChange, this);
|
||||
this.eventHub.on('optViewOpened', this.onOptViewOpened, this);
|
||||
this.eventHub.on('optViewClosed', this.onOptViewClosed, this);
|
||||
this.eventHub.on('astViewOpened', this.onAstViewOpened, this);
|
||||
this.eventHub.on('astViewClosed', this.onAstViewClosed, this);
|
||||
this.eventHub.on('optViewOpened', this.onOptViewOpened, this);
|
||||
this.eventHub.on('cfgViewOpened', this.onCfgViewOpened, this);
|
||||
this.eventHub.on('cfgViewClosed', this.onCfgViewClosed, this);
|
||||
this.eventHub.on('resize', this.resize, this);
|
||||
@@ -288,46 +288,30 @@ define(function (require) {
|
||||
}, this));
|
||||
|
||||
this.container.layoutManager.createDragSource(
|
||||
this.optButton, function () {
|
||||
this.wantOptInfo = true;
|
||||
this.compile();
|
||||
return createOptView.apply(this);
|
||||
}.bind(this));
|
||||
this.optButton, createOptView);
|
||||
|
||||
this.optButton.click(_.bind(function () {
|
||||
this.wantOptInfo = true;
|
||||
var insertPoint = hub.findParentRowOrColumn(this.container) ||
|
||||
this.container.layoutManager.root.contentItems[0];
|
||||
insertPoint.addChild(createOptView);
|
||||
this.optButton.prop("disabled", true);
|
||||
this.compile();
|
||||
}, this));
|
||||
|
||||
this.container.layoutManager.createDragSource(
|
||||
this.astButton, function () {
|
||||
this.compile();
|
||||
return createAstView.apply(this);
|
||||
}.bind(this));
|
||||
this.astButton, createAstView);
|
||||
|
||||
this.astButton.click(_.bind(function () {
|
||||
var insertPoint = hub.findParentRowOrColumn(this.container) ||
|
||||
this.container.layoutManager.root.contentItems[0];
|
||||
insertPoint.addChild(createAstView);
|
||||
this.compile();
|
||||
}, this));
|
||||
|
||||
this.container.layoutManager.createDragSource(
|
||||
this.cfgButton, function() {
|
||||
this.compile();
|
||||
return createCfgView.apply(this);
|
||||
}.bind(this));
|
||||
this.cfgButton, createCfgView);
|
||||
|
||||
this.cfgButton.click(_.bind(function () {
|
||||
var insertPoint = hub.findParentRowOrColumn(this.container) ||
|
||||
this.container.layoutManager.root.contentItems[0];
|
||||
insertPoint.addChild(createCfgView);
|
||||
this.cfgButton.prop("disabled", true);
|
||||
this.compile();
|
||||
}, this));
|
||||
|
||||
|
||||
@@ -665,6 +649,7 @@ define(function (require) {
|
||||
if (this.id == id) {
|
||||
this.astButton.prop("disabled", true);
|
||||
this.astViewOpen = true;
|
||||
this.compile();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -679,6 +664,7 @@ define(function (require) {
|
||||
this.optViewOpen = true;
|
||||
this.wantOptInfo = true;
|
||||
this.optButton.prop("disabled", this.optViewOpen);
|
||||
this.compile();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -686,6 +672,7 @@ define(function (require) {
|
||||
if (this.id == id) {
|
||||
this.cfgButton.prop("disabled", true);
|
||||
this.cfgViewOpen = true;
|
||||
this.compile();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ require.config({
|
||||
vs: "ext/monaco-editor/min/vs",
|
||||
'bootstrap-slider': 'ext/seiyria-bootstrap-slider/dist/bootstrap-slider',
|
||||
filesaver: 'ext/file-saver/FileSaver',
|
||||
vis: 'ext/vis/dist/vis'
|
||||
vis: 'ext/vis/dist/vis.min'
|
||||
},
|
||||
shim: {
|
||||
underscore: {exports: '_'},
|
||||
|
||||
Reference in New Issue
Block a user