< prev index next >

src/hotspot/share/runtime/deoptimization.hpp

Print this page




  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  */
  24 
  25 #ifndef SHARE_RUNTIME_DEOPTIMIZATION_HPP
  26 #define SHARE_RUNTIME_DEOPTIMIZATION_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "runtime/frame.hpp"
  30 
  31 class ProfileData;
  32 class vframeArray;
  33 class MonitorInfo;
  34 class MonitorValue;
  35 class ObjectValue;
  36 class AutoBoxObjectValue;
  37 class ScopeValue;
  38 class compiledVFrame;
  39 
  40 template<class E> class GrowableArray;
  41 
  42 class Deoptimization : AllStatic {
  43   friend class VMStructs;
  44 
  45  public:
  46   // What condition caused the deoptimization?
  47   enum DeoptReason {
  48     Reason_many = -1,             // indicates presence of several reasons
  49     Reason_none = 0,              // indicates absence of a relevant deopt.
  50     // Next 8 reasons are recorded per bytecode in DataLayout::trap_bits.
  51     // This is more complicated for JVMCI as JVMCI may deoptimize to *some* bytecode before the
  52     // bytecode that actually caused the deopt (with inlining, JVMCI may even deoptimize to a
  53     // bytecode in another method):
  54     //  - bytecode y in method b() causes deopt
  55     //  - JVMCI deoptimizes to bytecode x in method a()
  56     // -> the deopt reason will be recorded for method a() at bytecode x


 137     Unpack_LIMIT                = 4
 138   };
 139 
 140   static void deoptimize_all_marked();
 141 
 142  private:
 143   // Checks all compiled methods. Invalid methods are deleted and
 144   // corresponding activations are deoptimized.
 145   static int deoptimize_dependents();
 146   static void revoke_using_handshake(JavaThread* thread, frame fr, RegisterMap* map);
 147   static void revoke_using_safepoint(JavaThread* thread, frame fr, RegisterMap* map);
 148   static void deopt_thread(bool in_handshake, JavaThread* thread, frame fr, RegisterMap *map, DeoptReason reason);
 149 
 150  public:
 151   // Deoptimizes a frame lazily. nmethod gets patched deopt happens on return to the frame
 152   static void deoptimize(JavaThread* thread, frame fr, RegisterMap *map, bool in_handshake = false);
 153   static void deoptimize(JavaThread* thread, frame fr, RegisterMap *reg_map, DeoptReason reason);
 154 
 155 #if INCLUDE_JVMCI
 156   static address deoptimize_for_missing_exception_handler(CompiledMethod* cm);
 157   static oop get_cached_box(AutoBoxObjectValue* bv, frame* fr, RegisterMap* reg_map, TRAPS);
 158 #endif
 159 
 160   private:
 161   // Does the actual work for deoptimizing a single frame
 162   static void deoptimize_single_frame(JavaThread* thread, frame fr, DeoptReason reason);
 163 
 164   // Helper function to revoke biases of all monitors in frame if UseBiasedLocking
 165   // is enabled
 166   static void revoke_biases_of_monitors(JavaThread* thread, frame fr, RegisterMap* map) {
 167     revoke_using_safepoint(thread, fr, map);
 168   }
 169 
 170 #if COMPILER2_OR_JVMCI
 171 JVMCI_ONLY(public:)
 172 
 173   // Support for restoring non-escaping objects
 174   static bool realloc_objects(JavaThread* thread, frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, TRAPS);
 175   static void reassign_type_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, typeArrayOop obj, BasicType type);
 176   static void reassign_object_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, objArrayOop obj);
 177   static void reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, bool realloc_failures, bool skip_internal);
 178   static void relock_objects(GrowableArray<MonitorInfo*>* monitors, JavaThread* thread, bool realloc_failures);
 179   static void pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array);
 180   NOT_PRODUCT(static void print_objects(GrowableArray<ScopeValue*>* objects, bool realloc_failures);)
 181 #endif // COMPILER2_OR_JVMCI
 182 
 183   public:
 184   static vframeArray* create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures);
 185 
 186   // Interface used for unpacking deoptimized frames
 187 
 188   // UnrollBlock is returned by fetch_unroll_info() to the deoptimization handler (blob).
 189   // This is only a CheapObj to ease debugging after a deopt failure
 190   class UnrollBlock : public CHeapObj<mtCompiler> {
 191     friend class VMStructs;
 192     friend class JVMCIVMStructs;
 193    private:
 194     int       _size_of_deoptimized_frame; // Size, in bytes, of current deoptimized frame




  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  */
  24 
  25 #ifndef SHARE_RUNTIME_DEOPTIMIZATION_HPP
  26 #define SHARE_RUNTIME_DEOPTIMIZATION_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "runtime/frame.hpp"
  30 
  31 class ProfileData;
  32 class vframeArray;
  33 class MonitorInfo;
  34 class MonitorValue;
  35 class ObjectValue;

  36 class ScopeValue;
  37 class compiledVFrame;
  38 
  39 template<class E> class GrowableArray;
  40 
  41 class Deoptimization : AllStatic {
  42   friend class VMStructs;
  43 
  44  public:
  45   // What condition caused the deoptimization?
  46   enum DeoptReason {
  47     Reason_many = -1,             // indicates presence of several reasons
  48     Reason_none = 0,              // indicates absence of a relevant deopt.
  49     // Next 8 reasons are recorded per bytecode in DataLayout::trap_bits.
  50     // This is more complicated for JVMCI as JVMCI may deoptimize to *some* bytecode before the
  51     // bytecode that actually caused the deopt (with inlining, JVMCI may even deoptimize to a
  52     // bytecode in another method):
  53     //  - bytecode y in method b() causes deopt
  54     //  - JVMCI deoptimizes to bytecode x in method a()
  55     // -> the deopt reason will be recorded for method a() at bytecode x


 136     Unpack_LIMIT                = 4
 137   };
 138 
 139   static void deoptimize_all_marked();
 140 
 141  private:
 142   // Checks all compiled methods. Invalid methods are deleted and
 143   // corresponding activations are deoptimized.
 144   static int deoptimize_dependents();
 145   static void revoke_using_handshake(JavaThread* thread, frame fr, RegisterMap* map);
 146   static void revoke_using_safepoint(JavaThread* thread, frame fr, RegisterMap* map);
 147   static void deopt_thread(bool in_handshake, JavaThread* thread, frame fr, RegisterMap *map, DeoptReason reason);
 148 
 149  public:
 150   // Deoptimizes a frame lazily. nmethod gets patched deopt happens on return to the frame
 151   static void deoptimize(JavaThread* thread, frame fr, RegisterMap *map, bool in_handshake = false);
 152   static void deoptimize(JavaThread* thread, frame fr, RegisterMap *reg_map, DeoptReason reason);
 153 
 154 #if INCLUDE_JVMCI
 155   static address deoptimize_for_missing_exception_handler(CompiledMethod* cm);

 156 #endif
 157 
 158   private:
 159   // Does the actual work for deoptimizing a single frame
 160   static void deoptimize_single_frame(JavaThread* thread, frame fr, DeoptReason reason);
 161 
 162   // Helper function to revoke biases of all monitors in frame if UseBiasedLocking
 163   // is enabled
 164   static void revoke_biases_of_monitors(JavaThread* thread, frame fr, RegisterMap* map) {
 165     revoke_using_safepoint(thread, fr, map);
 166   }
 167 
 168 #if COMPILER2_OR_JVMCI
 169 JVMCI_ONLY(public:)
 170 
 171   // Support for restoring non-escaping objects
 172   static bool realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS);
 173   static void reassign_type_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, typeArrayOop obj, BasicType type);
 174   static void reassign_object_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, objArrayOop obj);
 175   static void reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, bool realloc_failures, bool skip_internal);
 176   static void relock_objects(GrowableArray<MonitorInfo*>* monitors, JavaThread* thread, bool realloc_failures);
 177   static void pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array);
 178   NOT_PRODUCT(static void print_objects(GrowableArray<ScopeValue*>* objects, bool realloc_failures);)
 179 #endif // COMPILER2_OR_JVMCI
 180 
 181   public:
 182   static vframeArray* create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures);
 183 
 184   // Interface used for unpacking deoptimized frames
 185 
 186   // UnrollBlock is returned by fetch_unroll_info() to the deoptimization handler (blob).
 187   // This is only a CheapObj to ease debugging after a deopt failure
 188   class UnrollBlock : public CHeapObj<mtCompiler> {
 189     friend class VMStructs;
 190     friend class JVMCIVMStructs;
 191    private:
 192     int       _size_of_deoptimized_frame; // Size, in bytes, of current deoptimized frame


< prev index next >