src/share/vm/code/scopeDesc.hpp

Mon, 19 Aug 2019 10:11:31 +0200

author
neugens
date
Mon, 19 Aug 2019 10:11:31 +0200
changeset 9861
a248d0be1309
parent 4037
da91efe96a93
child 6876
710a3c8b516e
permissions
-rw-r--r--

8229401: Fix JFR code cache test failures
8223689: Add JFR Thread Sampling Support
8223690: Add JFR BiasedLock Event Support
8223691: Add JFR G1 Region Type Change Event Support
8223692: Add JFR G1 Heap Summary Event Support
Summary: Backport JFR from JDK11, additional fixes
Reviewed-by: neugens, apetushkov
Contributed-by: denghui.ddh@alibaba-inc.com

     1 /*
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef SHARE_VM_CODE_SCOPEDESC_HPP
    26 #define SHARE_VM_CODE_SCOPEDESC_HPP
    28 #include "code/debugInfo.hpp"
    29 #include "code/pcDesc.hpp"
    30 #include "oops/method.hpp"
    31 #include "utilities/growableArray.hpp"
    33 // SimpleScopeDesc is used when all you need to extract from
    34 // a given pc,nmethod pair is a Method* and a bci. This is
    35 // quite a bit faster than allocating a full ScopeDesc, but
    36 // very limited in abilities.
    38 class SimpleScopeDesc : public StackObj {
    39  private:
    40   Method* _method;
    41   int _bci;
    43  public:
    44   SimpleScopeDesc(nmethod* code,address pc) {
    45     PcDesc* pc_desc = code->pc_desc_at(pc);
    46     assert(pc_desc != NULL, "Must be able to find matching PcDesc");
    47     DebugInfoReadStream buffer(code, pc_desc->scope_decode_offset());
    48     int ignore_sender = buffer.read_int();
    49     _method           = buffer.read_method();
    50     _bci              = buffer.read_bci();
    51   }
    53   Method* method() { return _method; }
    54   int bci() { return _bci; }
    55 };
    57 // ScopeDescs contain the information that makes source-level debugging of
    58 // nmethods possible; each scopeDesc describes a method activation
    60 class ScopeDesc : public ResourceObj {
    61  public:
    62   // Constructor
    63   ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool return_oop);
    65   // Calls above, giving default value of "serialized_null" to the
    66   // "obj_decode_offset" argument.  (We don't use a default argument to
    67   // avoid a .hpp-.hpp dependency.)
    68   ScopeDesc(const nmethod* code, int decode_offset, bool reexecute, bool return_oop);
    70   // JVM state
    71   Method* method()      const { return _method; }
    72   int          bci()      const { return _bci;    }
    73   bool should_reexecute() const { return _reexecute; }
    74   bool return_oop()       const { return _return_oop; }
    76   GrowableArray<ScopeValue*>*   locals();
    77   GrowableArray<ScopeValue*>*   expressions();
    78   GrowableArray<MonitorValue*>* monitors();
    79   GrowableArray<ScopeValue*>*   objects();
    81   // Stack walking, returns NULL if this is the outer most scope.
    82   ScopeDesc* sender() const;
    84   // Returns where the scope was decoded
    85   int decode_offset() const { return _decode_offset; }
    87   // Tells whether sender() returns NULL
    88   bool is_top() const;
    89   // Tells whether sd is equal to this
    90   bool is_equal(ScopeDesc* sd) const;
    92  private:
    93   // Alternative constructor
    94   ScopeDesc(const ScopeDesc* parent);
    96   // JVM state
    97   Method*       _method;
    98   int           _bci;
    99   bool          _reexecute;
   100   bool          _return_oop;
   102   // Decoding offsets
   103   int _decode_offset;
   104   int _sender_decode_offset;
   105   int _locals_decode_offset;
   106   int _expressions_decode_offset;
   107   int _monitors_decode_offset;
   109   // Object pool
   110   GrowableArray<ScopeValue*>* _objects;
   112   // Nmethod information
   113   const nmethod* _code;
   115   // Decoding operations
   116   void decode_body();
   117   GrowableArray<ScopeValue*>* decode_scope_values(int decode_offset);
   118   GrowableArray<MonitorValue*>* decode_monitor_values(int decode_offset);
   119   GrowableArray<ScopeValue*>* decode_object_values(int decode_offset);
   121   DebugInfoReadStream* stream_at(int decode_offset) const;
   124  public:
   125   // Verification
   126   void verify();
   128 #ifndef PRODUCT
   129  public:
   130   // Printing support
   131   void print_on(outputStream* st) const;
   132   void print_on(outputStream* st, PcDesc* pd) const;
   133   void print_value_on(outputStream* st) const;
   134 #endif
   135 };
   137 #endif // SHARE_VM_CODE_SCOPEDESC_HPP

mercurial