134 135 // Deoptimizes a frame lazily. nmethod gets patched deopt happens on return to the frame 136 static void deoptimize(JavaThread* thread, frame fr, RegisterMap *reg_map); 137 static void deoptimize(JavaThread* thread, frame fr, RegisterMap *reg_map, DeoptReason reason); 138 139 #if INCLUDE_JVMCI 140 static address deoptimize_for_missing_exception_handler(CompiledMethod* cm); 141 #endif 142 143 private: 144 // Does the actual work for deoptimizing a single frame 145 static void deoptimize_single_frame(JavaThread* thread, frame fr, DeoptReason reason); 146 147 // Helper function to revoke biases of all monitors in frame if UseBiasedLocking 148 // is enabled 149 static void revoke_biases_of_monitors(JavaThread* thread, frame fr, RegisterMap* map); 150 // Helper function to revoke biases of all monitors in frames 151 // executing in a particular CodeBlob if UseBiasedLocking is enabled 152 static void revoke_biases_of_monitors(CodeBlob* cb); 153 154 #if defined(COMPILER2) || INCLUDE_JVMCI 155 JVMCI_ONLY(public:) 156 157 // Support for restoring non-escaping objects 158 static bool realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS); 159 static void reassign_type_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, typeArrayOop obj, BasicType type); 160 static void reassign_object_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, objArrayOop obj); 161 static void reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, bool realloc_failures, bool skip_internal); 162 static void relock_objects(GrowableArray<MonitorInfo*>* monitors, JavaThread* thread, bool realloc_failures); 163 static void pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array); 164 NOT_PRODUCT(static void print_objects(GrowableArray<ScopeValue*>* objects, bool realloc_failures);) 165 #endif // COMPILER2 || INCLUDE_JVMCI 166 167 public: 168 static vframeArray* create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures); 169 170 // Interface used for unpacking deoptimized frames 171 172 // UnrollBlock is returned by fetch_unroll_info() to the deoptimization handler (blob). 173 // This is only a CheapObj to ease debugging after a deopt failure 174 class UnrollBlock : public CHeapObj<mtCompiler> { 175 friend class VMStructs; 176 friend class JVMCIVMStructs; 177 private: 178 int _size_of_deoptimized_frame; // Size, in bytes, of current deoptimized frame 179 int _caller_adjustment; // Adjustment, in bytes, to caller's SP by initial interpreted frame 180 int _number_of_frames; // Number frames to unroll 181 int _total_frame_sizes; // Total of number*sizes frames 182 intptr_t* _frame_sizes; // Array of frame sizes, in bytes, for unrolling the stack 183 address* _frame_pcs; // Array of frame pc's, in bytes, for unrolling the stack 184 intptr_t* _register_block; // Block for storing callee-saved registers. 185 BasicType _return_type; // Tells if we have to restore double or long return value | 134 135 // Deoptimizes a frame lazily. nmethod gets patched deopt happens on return to the frame 136 static void deoptimize(JavaThread* thread, frame fr, RegisterMap *reg_map); 137 static void deoptimize(JavaThread* thread, frame fr, RegisterMap *reg_map, DeoptReason reason); 138 139 #if INCLUDE_JVMCI 140 static address deoptimize_for_missing_exception_handler(CompiledMethod* cm); 141 #endif 142 143 private: 144 // Does the actual work for deoptimizing a single frame 145 static void deoptimize_single_frame(JavaThread* thread, frame fr, DeoptReason reason); 146 147 // Helper function to revoke biases of all monitors in frame if UseBiasedLocking 148 // is enabled 149 static void revoke_biases_of_monitors(JavaThread* thread, frame fr, RegisterMap* map); 150 // Helper function to revoke biases of all monitors in frames 151 // executing in a particular CodeBlob if UseBiasedLocking is enabled 152 static void revoke_biases_of_monitors(CodeBlob* cb); 153 154 #if COMPILER2_OR_JVMCI 155 JVMCI_ONLY(public:) 156 157 // Support for restoring non-escaping objects 158 static bool realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS); 159 static void reassign_type_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, typeArrayOop obj, BasicType type); 160 static void reassign_object_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, objArrayOop obj); 161 static void reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, bool realloc_failures, bool skip_internal); 162 static void relock_objects(GrowableArray<MonitorInfo*>* monitors, JavaThread* thread, bool realloc_failures); 163 static void pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array); 164 NOT_PRODUCT(static void print_objects(GrowableArray<ScopeValue*>* objects, bool realloc_failures);) 165 #endif // COMPILER2_OR_JVMCI 166 167 public: 168 static vframeArray* create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures); 169 170 // Interface used for unpacking deoptimized frames 171 172 // UnrollBlock is returned by fetch_unroll_info() to the deoptimization handler (blob). 173 // This is only a CheapObj to ease debugging after a deopt failure 174 class UnrollBlock : public CHeapObj<mtCompiler> { 175 friend class VMStructs; 176 friend class JVMCIVMStructs; 177 private: 178 int _size_of_deoptimized_frame; // Size, in bytes, of current deoptimized frame 179 int _caller_adjustment; // Adjustment, in bytes, to caller's SP by initial interpreted frame 180 int _number_of_frames; // Number frames to unroll 181 int _total_frame_sizes; // Total of number*sizes frames 182 intptr_t* _frame_sizes; // Array of frame sizes, in bytes, for unrolling the stack 183 address* _frame_pcs; // Array of frame pc's, in bytes, for unrolling the stack 184 intptr_t* _register_block; // Block for storing callee-saved registers. 185 BasicType _return_type; // Tells if we have to restore double or long return value |