src/share/vm/code/debugInfo.hpp

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

author
neugens
date
Mon, 19 Aug 2019 10:11:31 +0200
changeset 9861
a248d0be1309
parent 6628
bd58c9e40d0a
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, 2014, 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_DEBUGINFO_HPP
    26 #define SHARE_VM_CODE_DEBUGINFO_HPP
    28 #include "code/compressedStream.hpp"
    29 #include "code/location.hpp"
    30 #include "code/nmethod.hpp"
    31 #include "code/oopRecorder.hpp"
    32 #include "runtime/stackValue.hpp"
    33 #include "utilities/growableArray.hpp"
    35 // Classes used for serializing debugging information.
    36 // These abstractions are introducted to provide symmetric
    37 // read and write operations.
    39 // ScopeValue        describes the value of a variable/expression in a scope
    40 // - LocationValue   describes a value in a given location (in frame or register)
    41 // - ConstantValue   describes a constant
    43 class ConstantOopReadValue;
    45 class ScopeValue: public ResourceObj {
    46  public:
    47   // Testers
    48   virtual bool is_location() const { return false; }
    49   virtual bool is_object() const { return false; }
    50   virtual bool is_constant_int() const { return false; }
    51   virtual bool is_constant_double() const { return false; }
    52   virtual bool is_constant_long() const { return false; }
    53   virtual bool is_constant_oop() const { return false; }
    54   virtual bool equals(ScopeValue* other) const { return false; }
    56   ConstantOopReadValue* as_ConstantOopReadValue() {
    57     assert(is_constant_oop(), "must be");
    58     return (ConstantOopReadValue*) this;
    59   }
    61   // Serialization of debugging information
    62   virtual void write_on(DebugInfoWriteStream* stream) = 0;
    63   static ScopeValue* read_from(DebugInfoReadStream* stream);
    64 };
    67 // A Location value describes a value in a given location; i.e. the corresponding
    68 // logical entity (e.g., a method temporary) lives in this location.
    70 class LocationValue: public ScopeValue {
    71  private:
    72   Location  _location;
    73  public:
    74   LocationValue(Location location)           { _location = location; }
    75   bool      is_location() const              { return true; }
    76   Location  location() const                 { return _location; }
    78   // Serialization of debugging information
    79   LocationValue(DebugInfoReadStream* stream);
    80   void write_on(DebugInfoWriteStream* stream);
    82   // Printing
    83   void print_on(outputStream* st) const;
    84 };
    87 // An ObjectValue describes an object eliminated by escape analysis.
    89 class ObjectValue: public ScopeValue {
    90  private:
    91   int                        _id;
    92   ScopeValue*                _klass;
    93   GrowableArray<ScopeValue*> _field_values;
    94   Handle                     _value;
    95   bool                       _visited;
    97  public:
    98   ObjectValue(int id, ScopeValue* klass)
    99      : _id(id)
   100      , _klass(klass)
   101      , _field_values()
   102      , _value()
   103      , _visited(false) {
   104     assert(klass->is_constant_oop(), "should be constant java mirror oop");
   105   }
   107   ObjectValue(int id)
   108      : _id(id)
   109      , _klass(NULL)
   110      , _field_values()
   111      , _value()
   112      , _visited(false) {}
   114   // Accessors
   115   bool                        is_object() const         { return true; }
   116   int                         id() const                { return _id; }
   117   ScopeValue*                 klass() const             { return _klass; }
   118   GrowableArray<ScopeValue*>* field_values()            { return &_field_values; }
   119   ScopeValue*                 field_at(int i) const     { return _field_values.at(i); }
   120   int                         field_size()              { return _field_values.length(); }
   121   Handle                      value() const             { return _value; }
   122   bool                        is_visited() const        { return _visited; }
   124   void                        set_value(oop value)      { _value = Handle(value); }
   125   void                        set_visited(bool visited) { _visited = false; }
   127   // Serialization of debugging information
   128   void read_object(DebugInfoReadStream* stream);
   129   void write_on(DebugInfoWriteStream* stream);
   131   // Printing
   132   void print_on(outputStream* st) const;
   133   void print_fields_on(outputStream* st) const;
   134 };
   137 // A ConstantIntValue describes a constant int; i.e., the corresponding logical entity
   138 // is either a source constant or its computation has been constant-folded.
   140 class ConstantIntValue: public ScopeValue {
   141  private:
   142   jint _value;
   143  public:
   144   ConstantIntValue(jint value)         { _value = value; }
   145   jint value() const                   { return _value;  }
   146   bool is_constant_int() const         { return true;    }
   147   bool equals(ScopeValue* other) const { return false;   }
   149   // Serialization of debugging information
   150   ConstantIntValue(DebugInfoReadStream* stream);
   151   void write_on(DebugInfoWriteStream* stream);
   153   // Printing
   154   void print_on(outputStream* st) const;
   155 };
   157 class ConstantLongValue: public ScopeValue {
   158  private:
   159   jlong _value;
   160  public:
   161   ConstantLongValue(jlong value)       { _value = value; }
   162   jlong value() const                  { return _value;  }
   163   bool is_constant_long() const        { return true;    }
   164   bool equals(ScopeValue* other) const { return false;   }
   166   // Serialization of debugging information
   167   ConstantLongValue(DebugInfoReadStream* stream);
   168   void write_on(DebugInfoWriteStream* stream);
   170   // Printing
   171   void print_on(outputStream* st) const;
   172 };
   174 class ConstantDoubleValue: public ScopeValue {
   175  private:
   176   jdouble _value;
   177  public:
   178   ConstantDoubleValue(jdouble value)   { _value = value; }
   179   jdouble value() const                { return _value;  }
   180   bool is_constant_double() const      { return true;    }
   181   bool equals(ScopeValue* other) const { return false;   }
   183   // Serialization of debugging information
   184   ConstantDoubleValue(DebugInfoReadStream* stream);
   185   void write_on(DebugInfoWriteStream* stream);
   187   // Printing
   188   void print_on(outputStream* st) const;
   189 };
   191 // A ConstantOopWriteValue is created by the compiler to
   192 // be written as debugging information.
   194 class ConstantOopWriteValue: public ScopeValue {
   195  private:
   196   jobject _value;
   197  public:
   198   ConstantOopWriteValue(jobject value) { _value = value; }
   199   jobject value() const                { return _value;  }
   200   bool is_constant_oop() const         { return true;    }
   201   bool equals(ScopeValue* other) const { return false;   }
   203   // Serialization of debugging information
   204   void write_on(DebugInfoWriteStream* stream);
   206   // Printing
   207   void print_on(outputStream* st) const;
   208 };
   210 // A ConstantOopReadValue is created by the VM when reading
   211 // debug information
   213 class ConstantOopReadValue: public ScopeValue {
   214  private:
   215   Handle _value;
   216  public:
   217   Handle value() const                 { return _value;  }
   218   bool is_constant_oop() const         { return true;    }
   219   bool equals(ScopeValue* other) const { return false;   }
   221   // Serialization of debugging information
   222   ConstantOopReadValue(DebugInfoReadStream* stream);
   223   void write_on(DebugInfoWriteStream* stream);
   225   // Printing
   226   void print_on(outputStream* st) const;
   227 };
   229 // MonitorValue describes the pair used for monitor_enter and monitor_exit.
   231 class MonitorValue: public ResourceObj {
   232  private:
   233   ScopeValue* _owner;
   234   Location    _basic_lock;
   235   bool        _eliminated;
   236  public:
   237   // Constructor
   238   MonitorValue(ScopeValue* owner, Location basic_lock, bool eliminated = false);
   240   // Accessors
   241   ScopeValue*  owner()      const { return _owner; }
   242   Location     basic_lock() const { return _basic_lock;  }
   243   bool         eliminated() const { return _eliminated; }
   245   // Serialization of debugging information
   246   MonitorValue(DebugInfoReadStream* stream);
   247   void write_on(DebugInfoWriteStream* stream);
   249   // Printing
   250   void print_on(outputStream* st) const;
   251 };
   253 // DebugInfoReadStream specializes CompressedReadStream for reading
   254 // debugging information. Used by ScopeDesc.
   256 class DebugInfoReadStream : public CompressedReadStream {
   257  private:
   258   const nmethod* _code;
   259   const nmethod* code() const { return _code; }
   260   GrowableArray<ScopeValue*>* _obj_pool;
   261  public:
   262   DebugInfoReadStream(const nmethod* code, int offset, GrowableArray<ScopeValue*>* obj_pool = NULL) :
   263     CompressedReadStream(code->scopes_data_begin(), offset) {
   264     _code = code;
   265     _obj_pool = obj_pool;
   267   } ;
   269   oop read_oop() {
   270     oop o = code()->oop_at(read_int());
   271     assert(o == NULL || o->is_oop(), "oop only");
   272     return o;
   273   }
   274   Method* read_method() {
   275     Method* o = (Method*)(code()->metadata_at(read_int()));
   276     // is_metadata() is a faster check than is_metaspace_object()
   277     assert(o == NULL || o->is_metadata(), "meta data only");
   278     return o;
   279   }
   280   ScopeValue* read_object_value();
   281   ScopeValue* get_cached_object();
   282   // BCI encoding is mostly unsigned, but -1 is a distinguished value
   283   int read_bci() { return read_int() + InvocationEntryBci; }
   284 };
   286 // DebugInfoWriteStream specializes CompressedWriteStream for
   287 // writing debugging information. Used by ScopeDescRecorder.
   289 class DebugInfoWriteStream : public CompressedWriteStream {
   290  private:
   291   DebugInformationRecorder* _recorder;
   292   DebugInformationRecorder* recorder() const { return _recorder; }
   293  public:
   294   DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size);
   295   void write_handle(jobject h);
   296   void write_bci(int bci) { write_int(bci - InvocationEntryBci); }
   298   void write_metadata(Metadata* m);
   299 };
   301 #endif // SHARE_VM_CODE_DEBUGINFO_HPP

mercurial