Author: Richard Plangger <[email protected]>
Branch: vmprof-address
Changeset: r272:0d1b70823758
Date: 2015-06-10 10:50 +0200
http://bitbucket.org/pypy/jitviewer/changeset/0d1b70823758/

Log:    adding vmprof address to the right side of a loop extended the
        search to be able to lookup hex addresses (must start with 0x...)

diff --git a/_jitviewer/app.py b/_jitviewer/app.py
--- a/_jitviewer/app.py
+++ b/_jitviewer/app.py
@@ -102,8 +102,10 @@
                                                     limit=1,
                                                     inputargs=loop.inputargs,
                                                     loopname=name)
+                func.start_ofs = loop.start_ofs
             except CannotFindFile:
                 func = DummyFunc()
+                func.start_ofs = -1
             func.count = getattr(loop, 'count', '?')
             func.descr = mangle_descr(loop.descr)
             loops.append(func)
@@ -177,7 +179,11 @@
                 source = CodeRepr(source, code, loop)
             except (IOError, OSError):
                 source = CodeReprNoFile(loop)
+        loop_addr = None
+        if hasattr(orig_loop, 'start_ofs'):
+            loop_addr = hex(orig_loop.start_ofs)[:-1]
         d = {'html': flask.render_template('loop.html',
+                                           loop_addr=loop_addr,
                                            source=source,
                                            current_loop=name,
                                            upper_path=up,
diff --git a/_jitviewer/static/app.js b/_jitviewer/static/app.js
--- a/_jitviewer/static/app.js
+++ b/_jitviewer/static/app.js
@@ -74,9 +74,18 @@
     },
     "#inp-bar keyup": function(el, ev){
         var v = el.val();
+        var number = 0;
+        if (v.indexOf("0x") === 0) {
+          // search for the start offset vmprof address
+          var number = parseInt(v.substring(2), 16);
+        }
         $(".loopitem").each(function (i, l) {
             var name = $(l).attr('name');
-            if(name.search(v) != -1){
+            var show = name.search(v) != -1;
+            if (number !== 0) {
+              show = parseInt($(l).data('start-ofs')) === number;
+            }
+            if(show){
                 $(l).show();
             } else {
                 $(l).hide();
diff --git a/_jitviewer/static/style.css b/_jitviewer/static/style.css
--- a/_jitviewer/static/style.css
+++ b/_jitviewer/static/style.css
@@ -249,5 +249,12 @@
     font-size: 25px;
 }
 
+.vmprof-address {
+    float: right;
+    font-size: 12px;
+    font-weight: bold;
+    padding-right: 10px;
+}
+
 /* End of Formatting 
 -----------------------------------------*/
diff --git a/_jitviewer/templates/index.html b/_jitviewer/templates/index.html
--- a/_jitviewer/templates/index.html
+++ b/_jitviewer/templates/index.html
@@ -38,7 +38,9 @@
   <div id="loops">
     <ul>
       {% for item in loops %}
-      <li class="loopitem" id="{{item.descr}}" name="{{item.repr()}}"><span><a 
href="#" data-name="{{ item.descr }}">{{item.repr()}}</a> run {{item.count}} 
times</span></li>
+      <li class="loopitem" id="{{item.descr}}" name="{{item.repr()}}" 
data-start-ofs="{{item.start_ofs}}">
+        <span><a href="#" data-name="{{ item.descr }}">{{item.repr()}}</a> run 
{{item.count}} times</span>
+      </li>
       {% endfor %}
     </ul>
     {% if extra_data %}
diff --git a/_jitviewer/templates/loop.html b/_jitviewer/templates/loop.html
--- a/_jitviewer/templates/loop.html
+++ b/_jitviewer/templates/loop.html
@@ -7,6 +7,9 @@
        <div id="line-{{loop.index + source.firstlineno - 1}}" class="source 
visible">{{sourceline.line}}</div>
        {% if sourceline.chunks %}
           <div class="operations">
+              {% if loop_addr %}
+              <div class="vmprof-address"> vmprof-address {{ loop_addr }}</div>
+              {% endif %}
               {% for chunk in sourceline.chunks %}
                  {% if chunk.is_bytecode %}
                    <span class="{{chunk.cssclass}}"><span 
class="bytecodepos">{{chunk.bytecode_no}} 
</span>{{chunk.html_repr()}}</span><br/>
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to