changeset 2574:069e50dcd06a

Support CompressedOops for jstack.stp. * tapset/jstack.stp.in (NarrowOopStruct): New global. (hotspot.vm_init_end): Initialize NarrowOopStruct. (hotspot.vm_shutdown): Delete NarrowOopStruct for pid. (jstack_call): Use NarrowOopStruct to calculate methodOopKlass.
author Yasumasa Suenaga <suenaga.yasumasa@lab.ntt.co.jp>
date Sun, 05 Aug 2012 22:16:29 +0200
parents f61cb5d6d39b
children cbaab02d2dda
files ChangeLog tapset/jstack.stp.in
diffstat 2 files changed, 36 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Jul 27 09:26:20 2012 +0100
+++ b/ChangeLog	Sun Aug 05 22:16:29 2012 +0200
@@ -1,3 +1,10 @@
+2012-08-03  Yasumasa Suenaga  <suenaga.yasumasa@lab.ntt.co.jp>
+
+	* tapset/jstack.stp.in (NarrowOopStruct): New global.
+	(hotspot.vm_init_end): Initialize NarrowOopStruct.
+	(hotspot.vm_shutdown): Delete NarrowOopStruct for pid.
+	(jstack_call): Use NarrowOopStruct to calculate methodOopKlass.
+
 2012-07-27  Andrew John Hughes  <gnu_andrew@member.fsf.org>
 
 	* Makefile.am:
--- a/tapset/jstack.stp.in	Fri Jul 27 09:26:20 2012 +0100
+++ b/tapset/jstack.stp.in	Sun Aug 05 22:16:29 2012 +0200
@@ -49,6 +49,7 @@
 global Universe_collectedHeap;
 global HeapWordSize;
 global CodeCache_heap;
+global NarrowOopStruct;
 
 global sp_register;
 global fp_register;
@@ -71,9 +72,6 @@
                                      %? @var("_methodKlassObj@universe.cpp")
                                      %: $_methodKlassObj %);
 
-  // For compressed oops.
-  // Universe_heap_base = $_heap_base;
-
   /**
    * The Universe class holds some of the interesting statics for
    * introspection into HotSpot. The CollectedHeap
@@ -109,6 +107,17 @@
                             %? @var("_heap@codeCache.cpp")
                             %: $_heap %);
 
+  /**
+   * Does target process use CompressedOops ?
+   */
+  NarrowOopStruct[pid()] = 0;
+  %( systemtap_v >= "1.8"
+    %? if (@var("UseCompressedOops@globals.cpp"))
+         NarrowOopStruct[pid()] = &@var("_narrow_oop@universe.cpp");
+    %: if($UseCompressedOops)
+         NarrowOopStruct[pid()] = $_narrow_oop;
+  %)
+
   // Should really check arch of user space (for 32bit jvm on 64bit kernel).
   %( arch == "i386" %?
      sp_register = "esp";
@@ -142,6 +151,7 @@
   delete(Universe_collectedHeap[pid()]);
   delete(HeapWordSize[pid()]);
   delete(CodeCache_heap[pid()]);
+  delete(NarrowOopStruct[pid()]);
   delete(vm_inited[pid()]);
 }
 
@@ -353,8 +363,22 @@
                 isMethodOop = 0
               else
                 {
-                  methodOopKlass = @cast(methodOopPtr, "methodOopDesc",
-                                         "@ABS_SERVER_LIBJVM_SO@")->_metadata->_klass;
+                  if (NarrowOopStruct[pid()])
+                    {
+                      methodOopKlass = @cast(methodOopPtr, "methodOopDesc",
+                                             "@ABS_SERVER_LIBJVM_SO@")->_metadata->_compressed_klass;
+                      methodOopKlass = (@cast(NarrowOopStruct[pid()],
+                                              "NarrowOopStruct",
+                                              "@ABS_SERVER_LIBJVM_SO@")->_base
+                                        + (methodOopKlass
+                                           << @cast(NarrowOopStruct[pid()],
+                                                    "NarrowOopStruct",
+                                                    "@ABS_SERVER_LIBJVM_SO@")->_shift));
+                    }
+                  else
+                    methodOopKlass = @cast(methodOopPtr, "methodOopDesc",
+                                           "@ABS_SERVER_LIBJVM_SO@")->_metadata->_klass;
+
                   isMethodOop = (methodOopKlass == Universe_methodKlassObj[pid()]);
                 }