74b02f5
diff -r c728621e76f2 tapset/jstack.stp.in
74b02f5
--- tapset/jstack-1.8.0.stp.in	Mon Jun 02 18:41:24 2014 +0100
74b02f5
+++ tapset/jstack-1.8.0.stp.in	Sat Jun 14 00:21:14 2014 +0900
74b02f5
@@ -45,11 +45,7 @@
74b02f5
  semantic error: failed to retrieve location attribute for local
74b02f5
 */
74b02f5
 
74b02f5
-global Universe_methodKlassObj;
74b02f5
-global Universe_collectedHeap;
74b02f5
-global HeapWordSize;
74b02f5
 global CodeCache_heap;
74b02f5
-global NarrowOopStruct;
74b02f5
 
74b02f5
 global sp_register;
74b02f5
 global fp_register;
74b02f5
@@ -57,9 +53,8 @@
74b02f5
 global ptr_size;
74b02f5
 global ptr_mask;
74b02f5
 
74b02f5
-global constantPoolOopDesc_size;
74b02f5
+global constantPool_size;
74b02f5
 global HeapBlock_Header_size;
74b02f5
-global oopDesc_size;
74b02f5
 
74b02f5
 global vm_inited;
74b02f5
 
74b02f5
@@ -67,26 +62,6 @@
74b02f5
    in a bare function and vm_init_end seems a good place to use. */
74b02f5
 probe hotspot.vm_init_end
74b02f5
 {
74b02f5
-  // The parent/type oop for a methodOop.
74b02f5
-  Universe_methodKlassObj[pid()] = %( systemtap_v >= "1.8"
74b02f5
-                                     %? @var("_methodKlassObj@universe.cpp")
74b02f5
-                                     %: $_methodKlassObj %);
74b02f5
-
74b02f5
-  /**
74b02f5
-   * The Universe class holds some of the interesting statics for
74b02f5
-   * introspection into HotSpot. The CollectedHeap
74b02f5
-   * (Universe::_collectedHeap) is an abstraction of a java heap for Hotspot
74b02f5
-   * it contains a _reserved MemRegion which represents a contigous
74b02f5
-   * region of the address space consisting of HeapWords (which just
74b02f5
-   * have one field member char *i).
74b02f5
-   *
74b02f5
-   * Note that we access it through its "short name" _collectedHeap.
74b02f5
-   */
74b02f5
-  Universe_collectedHeap[pid()] = %( systemtap_v >= "1.8"
74b02f5
-                                    %? @var("_collectedHeap@universe.cpp")
74b02f5
-                                    %: $_collectedHeap %);
74b02f5
-  HeapWordSize[pid()] = $HeapWordSize;
74b02f5
-
74b02f5
   /**
74b02f5
    * The CodeCache class contains the static CodeHeap _heap that
74b02f5
    * is malloced at the start of the vm run and holds all generated
74b02f5
@@ -107,17 +82,6 @@
74b02f5
                             %? @var("_heap@codeCache.cpp")
74b02f5
                             %: $_heap %);
74b02f5
 
74b02f5
-  /**
74b02f5
-   * Does target process use CompressedOops ?
74b02f5
-   */
74b02f5
-  NarrowOopStruct[pid()] = 0;
74b02f5
-  %( systemtap_v >= "1.8"
74b02f5
-    %? if (@var("UseCompressedOops@globals.cpp"))
74b02f5
-         NarrowOopStruct[pid()] = &@var("_narrow_oop@universe.cpp");
74b02f5
-    %: if($UseCompressedOops)
74b02f5
-         NarrowOopStruct[pid()] = $_narrow_oop;
74b02f5
-  %)
74b02f5
-
74b02f5
   // Should really check arch of user space (for 32bit jvm on 64bit kernel).
74b02f5
   %( arch == "i386" %?
74b02f5
      sp_register = "esp";
74b02f5
@@ -136,22 +100,17 @@
74b02f5
 
74b02f5
   // Pretend we have an array at address zero and take address of second
74b02f5
   // element and we have the size.
74b02f5
-  constantPoolOopDesc_size = &@cast(0, "constantPoolOopDesc")[1];
74b02f5
+  constantPool_size = &@cast(0, "ConstantPool")[1];
74b02f5
 
74b02f5
   // Really should get from dwarf: @size("HeapBlock::Header"), @size("oopDesc")
74b02f5
   HeapBlock_Header_size = 2 * ptr_size;
74b02f5
-  oopDesc_size = 2 * ptr_size;
74b02f5
 
74b02f5
   vm_inited[pid()] = 1;
74b02f5
 }
74b02f5
 
74b02f5
 probe hotspot.vm_shutdown
74b02f5
 {
74b02f5
-  delete(Universe_methodKlassObj[pid()]);
74b02f5
-  delete(Universe_collectedHeap[pid()]);
74b02f5
-  delete(HeapWordSize[pid()]);
74b02f5
   delete(CodeCache_heap[pid()]);
74b02f5
-  delete(NarrowOopStruct[pid()]);
74b02f5
   delete(vm_inited[pid()]);
74b02f5
 }
74b02f5
 
74b02f5
@@ -262,15 +221,7 @@
74b02f5
         return frame;
74b02f5
     }
74b02f5
 
74b02f5
-  // Extract heap and code bounds.
74b02f5
-  heap_start = @cast(Universe_collectedHeap[pid()],
74b02f5
-                     "CollectedHeap",
74b02f5
-                     "@ABS_SERVER_LIBJVM_SO@")->_reserved->_start;
74b02f5
-  heap_size = HeapWordSize[pid()] * @cast(Universe_collectedHeap[pid()],
74b02f5
-                                   "CollectedHeap",
74b02f5
-                                   "@ABS_SERVER_LIBJVM_SO@")->_reserved->_word_size;
74b02f5
-  heap_end = heap_start + heap_size;
74b02f5
-
74b02f5
+  // Extract code bounds.
74b02f5
   CodeCache_low = @cast(CodeCache_heap[pid()], "CodeHeap",
74b02f5
                         "@ABS_SERVER_LIBJVM_SO@")->_memory->_low;
74b02f5
   CodeCache_high =  @cast(CodeCache_heap[pid()], "CodeHeap",
74b02f5
@@ -351,105 +302,69 @@
74b02f5
               // For the interpreter (and other code blobs) it is on the
74b02f5
               // stack relative to the frame pointer.
74b02f5
               if (blob_name == "nmethod")
74b02f5
-                methodOopPtr = @cast(blob, "nmethod",
74b02f5
+                methodPtr = @cast(blob, "nmethod",
74b02f5
                                      "@ABS_SERVER_LIBJVM_SO@")->_method
74b02f5
               else 
74b02f5
-                methodOopPtr = user_long(fp + (-3 * ptr_size)) & ptr_mask
74b02f5
-
74b02f5
-              // Start optimistic. A methodOop is only valid if it was
74b02f5
-              // heap allocated. And if the "type class" oop equals the
74b02f5
-              // Universe::methodKlassObj.
74b02f5
-              if (heap_start > methodOopPtr || methodOopPtr >= heap_end)
74b02f5
-                isMethodOop = 0
74b02f5
-              else
74b02f5
-                {
74b02f5
-                  if (NarrowOopStruct[pid()])
74b02f5
-                    {
74b02f5
-                      methodOopKlass = @cast(methodOopPtr, "methodOopDesc",
74b02f5
-                                             "@ABS_SERVER_LIBJVM_SO@")->_metadata->_compressed_klass;
74b02f5
-                      methodOopKlass = (@cast(NarrowOopStruct[pid()],
74b02f5
-                                              "NarrowOopStruct",
74b02f5
-                                              "@ABS_SERVER_LIBJVM_SO@")->_base
74b02f5
-                                        + (methodOopKlass
74b02f5
-                                           << @cast(NarrowOopStruct[pid()],
74b02f5
-                                                    "NarrowOopStruct",
74b02f5
-                                                    "@ABS_SERVER_LIBJVM_SO@")->_shift));
74b02f5
-                    }
74b02f5
-                  else
74b02f5
-                    methodOopKlass = @cast(methodOopPtr, "methodOopDesc",
74b02f5
-                                           "@ABS_SERVER_LIBJVM_SO@")->_metadata->_klass;
74b02f5
+                methodPtr = user_long(fp + (-3 * ptr_size)) & ptr_mask
74b02f5
 
74b02f5
-                  isMethodOop = (methodOopKlass == Universe_methodKlassObj[pid()]);
74b02f5
-                }
74b02f5
+              // The java class is the holder of the constants (strings)
74b02f5
+              // that describe the method and signature. This constant pool
74b02f5
+              // contains symbolic information that describe the properties
74b02f5
+              // of the class. The indexes for methods and signaturates in
74b02f5
+              // the constant pool are Symbols that contain utf8
74b02f5
+              // strings (plus lenghts). (We could also sanity check that
74b02f5
+              // the tag value is correct [CONSTANT_String = 8]).
74b02f5
+              // Note that the class name uses '/' instead of '.' as
74b02f5
+              // package name separator and that the method signature is
74b02f5
+              // encoded as a method descriptor string. Both of which we
74b02f5
+              // don't demangle here.
74b02f5
+              constMethod = @cast(methodPtr, "Method",
74b02f5
+                                          "@ABS_SERVER_LIBJVM_SO@")->_constMethod;
74b02f5
+              constantPool = @cast(constMethod, "ConstMethod",
74b02f5
+                                          "@ABS_SERVER_LIBJVM_SO@")->_constants;
74b02f5
+              constantPool_base = constantPool + constantPool_size;
74b02f5
+
74b02f5
+              klass = @cast(constantPool, "ConstantPool",
74b02f5
+                               "@ABS_SERVER_LIBJVM_SO@")->_pool_holder;
74b02f5
+              klassSymbol = @cast(klass, "Klass",
74b02f5
+                                  "@ABS_SERVER_LIBJVM_SO@")->_name;
74b02f5
+              klassName = &@cast(klassSymbol, "Symbol",
74b02f5
+                                 "@ABS_SERVER_LIBJVM_SO@")->_body[0];
74b02f5
+              klassLength = @cast(klassSymbol, "Symbol",
74b02f5
+                                  "@ABS_SERVER_LIBJVM_SO@")->_length;
74b02f5
+
74b02f5
+              methodIndex = @cast(constMethod, "ConstMethod",
74b02f5
+                                  "@ABS_SERVER_LIBJVM_SO@")->_name_index;
74b02f5
+              methodSymbol = user_long(constantPool_base + (methodIndex * ptr_size));
74b02f5
+              methodName = &@cast(methodSymbol, "Symbol",
74b02f5
+                                  "@ABS_SERVER_LIBJVM_SO@")->_body[0];
74b02f5
+              methodLength = @cast(methodSymbol, "Symbol",
74b02f5
+                                   "@ABS_SERVER_LIBJVM_SO@")->_length;
74b02f5
 
74b02f5
-              if (isMethodOop)
74b02f5
+              if (log_sig)
74b02f5
                 {
74b02f5
-                  // The java class is the holder of the constants (strings)
74b02f5
-                  // that describe the method and signature. This constant pool
74b02f5
-                  // contains symbolic information that describe the properties
74b02f5
-                  // of the class. The indexes for methods and signaturates in
74b02f5
-                  // the constant pool are Symbols that contain utf8
74b02f5
-                  // strings (plus lenghts). (We could also sanity check that
74b02f5
-                  // the tag value is correct [CONSTANT_String = 8]).
74b02f5
-                  // Note that the class name uses '/' instead of '.' as
74b02f5
-                  // package name separator and that the method signature is
74b02f5
-                  // encoded as a method descriptor string. Both of which we
74b02f5
-                  // don't demangle here.
74b02f5
-                  constantPoolOopDesc = @cast(methodOopPtr, "methodOopDesc",
74b02f5
-                                              "@ABS_SERVER_LIBJVM_SO@")->_constants;
74b02f5
-                  constantPoolOop_base = constantPoolOopDesc + constantPoolOopDesc_size;
74b02f5
-
74b02f5
-                  klassPtr = @cast(constantPoolOopDesc, "constantPoolOopDesc",
74b02f5
-                                   "@ABS_SERVER_LIBJVM_SO@")->_pool_holder;
74b02f5
-                  klassSymbol = @cast(klassPtr + oopDesc_size, "Klass",
74b02f5
-                                      "@ABS_SERVER_LIBJVM_SO@")->_name;
74b02f5
-                  klassName = &@cast(klassSymbol, "Symbol",
74b02f5
-                                     "@ABS_SERVER_LIBJVM_SO@")->_body[0];
74b02f5
-                  klassLength = @cast(klassSymbol, "Symbol",
74b02f5
-                                      "@ABS_SERVER_LIBJVM_SO@")->_length;
74b02f5
-
74b02f5
-                  methodIndex = @cast(methodOopPtr, "methodOopDesc",
74b02f5
-                                      "@ABS_SERVER_LIBJVM_SO@")->_constMethod->_name_index;
74b02f5
-                  methodOopDesc = user_long(constantPoolOop_base + (methodIndex * ptr_size)) - 1;
74b02f5
-                  methodName = &@cast(methodOopDesc, "Symbol",
74b02f5
-                                      "@ABS_SERVER_LIBJVM_SO@")->_body[0];
74b02f5
-                  methodLength = @cast(methodOopDesc, "Symbol",
74b02f5
-                                       "@ABS_SERVER_LIBJVM_SO@")->_length;
74b02f5
-
74b02f5
-                  if (log_sig)
74b02f5
-                    {
74b02f5
-                      sigIndex = @cast(methodOopPtr, "methodOopDesc",
74b02f5
-                                       "@ABS_SERVER_LIBJVM_SO@")->_constMethod->_signature_index;
74b02f5
-                      sigOopDesc = user_long(constantPoolOop_base
74b02f5
-                                             + (sigIndex * ptr_size)) - 1;
74b02f5
-                      sigName = &@cast(sigOopDesc, "Symbol",
74b02f5
-                                       "@ABS_SERVER_LIBJVM_SO@")->_body[0];
74b02f5
-                      sigLength = @cast(sigOopDesc, "Symbol",
74b02f5
-                                        "@ABS_SERVER_LIBJVM_SO@")->_length;
74b02f5
-                      sig = user_string_n(sigName, sigLength);
74b02f5
-                    }
74b02f5
-                  else
74b02f5
-                    sig = "";
74b02f5
-
74b02f5
-                  code_name = (log_native
74b02f5
-                               ? sprintf("<%s@0x%x>",
74b02f5
-                                         str_replace(blob_name, " ", "_"), pc)
74b02f5
-                               : "");
74b02f5
-
74b02f5
-                  frame = sprintf("%s.%s%s%s",
74b02f5
-                                  user_string_n(klassName, klassLength),
74b02f5
-                                  user_string_n(methodName, methodLength),
74b02f5
-                                  sig, code_name);
74b02f5
+                  sigIndex = @cast(constMethod, "ConstMethod",
74b02f5
+                                   "@ABS_SERVER_LIBJVM_SO@")->_signature_index;
74b02f5
+                  sigSymbol = user_long(constantPool_base
74b02f5
+                                         + (sigIndex * ptr_size));
74b02f5
+                  sigName = &@cast(sigSymbol, "Symbol",
74b02f5
+                                   "@ABS_SERVER_LIBJVM_SO@")->_body[0];
74b02f5
+                  sigLength = @cast(sigSymbol, "Symbol",
74b02f5
+                                    "@ABS_SERVER_LIBJVM_SO@")->_length;
74b02f5
+                  sig = user_string_n(sigName, sigLength);
74b02f5
                 }
74b02f5
               else
74b02f5
-                {
74b02f5
-                  // This is probably just an internal function, not a java
74b02f5
-                  // method, just print the blob_name and continue.
74b02f5
-                  // fp is probably still trusted.
74b02f5
-                  if (log_native)
74b02f5
-                    frame = sprintf("<%s@0x%x>",
74b02f5
-                                    str_replace(blob_name, " ", "_"), pc);
74b02f5
-                }
74b02f5
+                sig = "";
74b02f5
+
74b02f5
+              code_name = (log_native
74b02f5
+                           ? sprintf("<%s@0x%x>",
74b02f5
+                                     str_replace(blob_name, " ", "_"), pc)
74b02f5
+                           : "");
74b02f5
+
74b02f5
+              frame = sprintf("%s.%s%s%s",
74b02f5
+                              user_string_n(klassName, klassLength),
74b02f5
+                              user_string_n(methodName, methodLength),
74b02f5
+                              sig, code_name);
74b02f5
 
74b02f5
               // We cannot trust the frame pointer of compiled methods.
74b02f5
               // The server (c2) jit compiler uses the fp register.