Blame SOURCES/jstack-pr1845.patch

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