Skip to content

Commit

Permalink
dead code elimination, started to fix issue vmprof-python #97 and vmp…
Browse files Browse the repository at this point in the history
…rof-server #14
  • Loading branch information
planrich committed Aug 19, 2016
1 parent cade1d2 commit a567a3a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 44 deletions.
73 changes: 31 additions & 42 deletions vmlog/static/log/jitlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ JitLog.prototype.set_meta = function(meta) {
this._resops = meta.resops
this.machine = meta.machine
this.word_size = meta.word_size
this._bridges = meta.bridges
var total_entries = 0
var traces = meta.traces
for (var key in traces) {
Expand All @@ -173,6 +174,15 @@ JitLog.prototype.set_meta = function(meta) {
}
trace.entry_percent = p
}
for (var key in this._bridges) {
var bridge = this.get_trace_by_id(key)
var value = this._bridges[key]
for (var descr_nmr in value) {
var addr = value[descr_nmr]
var trace = this.get_trace_by_addr(addr)
this._descrnmr_to_trace[descr_nmr] = trace
}
}
}

JitLog.prototype.filter_and_sort_traces = function(text, type, ordering) {
Expand Down Expand Up @@ -229,6 +239,10 @@ JitLog.prototype.get_trace_by_id = function(id) {
return this._id_to_traces[id]
}

JitLog.prototype.get_trace_by_addr = function(addr) {
return this._addr_to_trace[addr]
}

Trace = function(jitlog, id, meta) {
this._jitlog = jitlog
this.id = id
Expand All @@ -238,7 +252,6 @@ Trace = function(jitlog, id, meta) {
this.type = meta.type
this._parent = meta.parent
this.counter_points = meta.counter_points
this._bridges = []
this._stages = {}
this.jd_name = meta.jd_name
this.recording_stamp = meta.stamp
Expand Down Expand Up @@ -272,37 +285,12 @@ Trace.prototype.get_id = function() {
return this.id
}

Trace.prototype.bridge_count = function(fn) {
return this._bridges.length;
}
Trace.prototype.walk_bridges = function(fn) {
var _this = this;
this._bridges.forEach(function(bridge){
var trace = _this._jitlog._addr_to_trace[bridge.target]
fn.call(_this, trace);
})
}

Trace.prototype.walk_trace_tree = function(fn) {
fn.call(this, this);
var _this = this
this._bridges.forEach(function(bridge){
var trace = _this._jitlog._addr_to_trace[bridge.target]
fn.call(trace, trace);
trace.walk_trace_tree(fn)
})
}

Trace.prototype.link = function() {
var _this = this;
this._bridges.forEach(function(bridge){
var trace = _this._jitlog._addr_to_trace[bridge.target]
_this._jitlog._descrnmr_to_trace[bridge.descr_number] = trace
bridge.target_obj = trace;
})
this.forEachOp(function(op){
if (op.get_descr_nmr()) {
_this._jitlog._descrnmr_to_op[op.get_descr_nmr()] = op
var descr_nmr = op.get_descr_nmr()
if (descr_nmr) {
_this._jitlog._descrnmr_to_op[descr_nmr] = op
}
return true
})
Expand All @@ -316,18 +304,6 @@ Trace.prototype.is_trunk = function() {
return this.get_type() === 'loop'
}

Trace.prototype.branch_count = function() {
if (this._branch_count !== undefined) {
return this._branch_count
}
var count = 1;
this.walk_bridges(function(bridge){
count += bridge.branch_count()
})
this._branch_count = count;
return count
}

Trace.prototype.ends_with_jump = function() {
var ops = this.get_stage('asm')
var oplist = ops.list()
Expand Down Expand Up @@ -499,14 +475,18 @@ ResOp.prototype.has_stitched_trace = function() {
}

ResOp.prototype.get_stitched_trace = function() {
var stitched = this._jitlog._descrnmr_to_trace[this._data.descr_number]
var stitched = this._jitlog._descrnmr_to_trace[parseInt(this._data.descr_number,16)]
return stitched
}

ResOp.prototype.get_stitch_id = function() {
return this._data.descr_number
}

ResOp.prototype.has_descr = function() {
return this._data.descr_number !== undefined
}

ResOp.prototype.to_s = function(index) {
var humanindex = index
index = index - 1
Expand Down Expand Up @@ -555,6 +535,15 @@ ResOp.prototype.to_s = function(index) {
suffix += ' <span class="resop-run-count">passed '+numeral(count).format('0.0 a')+' times</span>'
}
}
if (this.has_descr()) {
var trace = this.get_stitched_trace()
if (trace) {
var id = trace.id
var name = 'switch to trace';
var link = ' <a ng-click="switch_trace(\''+id+'\', $storage.trace_type, $storage.show_asm)">'+name+'</a>'
suffix = link + ' ' + suffix
}
}
return format(prefix, opname, args, descr, suffix);
}

Expand Down
14 changes: 14 additions & 0 deletions vmlog/static/log/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ app.controller('jit-trace-forest', function ($scope, $http, $routeParams, $timeo
$scope.jitlog = jitlog
$scope.gotmeta = false

var error = function(message) {
$scope.error = {
'message': message,
}
}

var http_request_errored = function(response, url){
var http = response.status + ' ' + response.statusText + '.'
$scope.error = {
Expand Down Expand Up @@ -111,6 +117,14 @@ app.controller('jit-trace-forest', function ($scope, $http, $routeParams, $timeo
});

$scope.switch_trace = function(trace, type, asm) {
if (typeof(trace) == "string"){
var id = trace
trace = $scope.jitlog.get_trace_by_id(trace)
if (!trace) {
error("could not switch to trace with "+id)
return
}
}
if (!$scope.loader.complete()) { return; }
$scope.$storage.show_asm = asm
$scope.$storage.trace_type = type
Expand Down
6 changes: 4 additions & 2 deletions vmlog/static/log/traces.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

<div id="error" ng-show="error" class="alert alert-danger" role="alert">
<i class="glyphicon glyphicon-exclamation-sign"></i> Oh no!
Error: <strong>{{error.message}}</strong><br>
Http: {{error.http}} URL: <strong>{{error.url}}</strong>
Error: <strong>{{error.message}}</strong>
<span ng-if="error.http"><br>
Http: {{error.http}} URL: <strong>{{error.url}}</strong>
</span>
</div>

<div id="loading_img" ng-class loading="traces" ng-show="loading && !noprofile">
Expand Down
2 changes: 2 additions & 0 deletions vmlog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def to_representation(self, jlog):
counter_points = trace.get_counter_points()
mp_meta = { 'scope': 'unknown', 'lineno': -1, 'filename': '',
'type': trace.type, 'counter_points': counter_points }
if trace.is_assembled():
mp_meta['addr'] = trace.get_addrs()
if trace.jd_name:
mp_meta['jd_name'] = trace.jd_name
traces[id] = mp_meta
Expand Down

0 comments on commit a567a3a

Please sign in to comment.