From a567a3a98e9d2c48848925401eac0d66df50809f Mon Sep 17 00:00:00 2001 From: Richard Plangger Date: Fri, 19 Aug 2016 15:51:09 +0200 Subject: [PATCH] dead code elimination, started to fix issue vmprof-python #97 and vmprof-server #14 --- vmlog/static/log/jitlog.js | 73 +++++++++++++++--------------------- vmlog/static/log/main.js | 14 +++++++ vmlog/static/log/traces.html | 6 ++- vmlog/views.py | 2 + 4 files changed, 51 insertions(+), 44 deletions(-) diff --git a/vmlog/static/log/jitlog.js b/vmlog/static/log/jitlog.js index b4b370a..7ecdc81 100644 --- a/vmlog/static/log/jitlog.js +++ b/vmlog/static/log/jitlog.js @@ -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) { @@ -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) { @@ -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 @@ -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 @@ -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 }) @@ -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() @@ -499,7 +475,7 @@ 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 } @@ -507,6 +483,10 @@ 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 @@ -555,6 +535,15 @@ ResOp.prototype.to_s = function(index) { suffix += ' passed '+numeral(count).format('0.0 a')+' times' } } + if (this.has_descr()) { + var trace = this.get_stitched_trace() + if (trace) { + var id = trace.id + var name = 'switch to trace'; + var link = ' '+name+'' + suffix = link + ' ' + suffix + } + } return format(prefix, opname, args, descr, suffix); } diff --git a/vmlog/static/log/main.js b/vmlog/static/log/main.js index b9caf26..bb739a3 100644 --- a/vmlog/static/log/main.js +++ b/vmlog/static/log/main.js @@ -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 = { @@ -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 diff --git a/vmlog/static/log/traces.html b/vmlog/static/log/traces.html index c28b131..5890b9e 100644 --- a/vmlog/static/log/traces.html +++ b/vmlog/static/log/traces.html @@ -1,8 +1,10 @@
diff --git a/vmlog/views.py b/vmlog/views.py index 96c8d8a..5886471 100644 --- a/vmlog/views.py +++ b/vmlog/views.py @@ -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