169 bool is_top_frame, |
169 bool is_top_frame, |
170 bool is_bottom_frame, |
170 bool is_bottom_frame, |
171 int exec_mode) { |
171 int exec_mode) { |
172 JavaThread* thread = (JavaThread*) Thread::current(); |
172 JavaThread* thread = (JavaThread*) Thread::current(); |
173 |
173 |
|
174 bool realloc_failure_exception = thread->frames_to_pop_failed_realloc() > 0; |
|
175 |
174 // Look at bci and decide on bcp and continuation pc |
176 // Look at bci and decide on bcp and continuation pc |
175 address bcp; |
177 address bcp; |
176 // C++ interpreter doesn't need a pc since it will figure out what to do when it |
178 // C++ interpreter doesn't need a pc since it will figure out what to do when it |
177 // begins execution |
179 // begins execution |
178 address pc; |
180 address pc; |
202 // exception was processed, the bytecode pointer would have to be extended one bytecode beyond |
204 // exception was processed, the bytecode pointer would have to be extended one bytecode beyond |
203 // the monitorenter to place it in the proper exception range. |
205 // the monitorenter to place it in the proper exception range. |
204 // |
206 // |
205 // For Compiler1, deoptimization can occur while throwing a NullPointerException at monitorenter, |
207 // For Compiler1, deoptimization can occur while throwing a NullPointerException at monitorenter, |
206 // in which case bcp should point to the monitorenter since it is within the exception's range. |
208 // in which case bcp should point to the monitorenter since it is within the exception's range. |
|
209 // |
|
210 // For realloc failure exception we just pop frames, skip the guarantee. |
207 |
211 |
208 assert(*bcp != Bytecodes::_monitorenter || is_top_frame, "a _monitorenter must be a top frame"); |
212 assert(*bcp != Bytecodes::_monitorenter || is_top_frame, "a _monitorenter must be a top frame"); |
209 assert(thread->deopt_compiled_method() != NULL, "compiled method should be known"); |
213 assert(thread->deopt_compiled_method() != NULL, "compiled method should be known"); |
210 guarantee(!(thread->deopt_compiled_method()->is_compiled_by_c2() && |
214 guarantee(realloc_failure_exception || !(thread->deopt_compiled_method()->is_compiled_by_c2() && |
211 *bcp == Bytecodes::_monitorenter && |
215 *bcp == Bytecodes::_monitorenter && |
212 exec_mode == Deoptimization::Unpack_exception), |
216 exec_mode == Deoptimization::Unpack_exception), |
213 "shouldn't get exception during monitorenter"); |
217 "shouldn't get exception during monitorenter"); |
214 |
218 |
215 int popframe_preserved_args_size_in_bytes = 0; |
219 int popframe_preserved_args_size_in_bytes = 0; |
235 popframe_preserved_args_size_in_bytes = in_bytes(thread->popframe_preserved_args_size()); |
239 popframe_preserved_args_size_in_bytes = in_bytes(thread->popframe_preserved_args_size()); |
236 // Note: the PopFrame-related extension of the expression stack size is done in |
240 // Note: the PopFrame-related extension of the expression stack size is done in |
237 // Deoptimization::fetch_unroll_info_helper |
241 // Deoptimization::fetch_unroll_info_helper |
238 popframe_preserved_args_size_in_words = in_words(thread->popframe_preserved_args_size_in_words()); |
242 popframe_preserved_args_size_in_words = in_words(thread->popframe_preserved_args_size_in_words()); |
239 } |
243 } |
240 } else if (JvmtiExport::can_force_early_return() && state != NULL && state->is_earlyret_pending()) { |
244 } else if (!realloc_failure_exception && JvmtiExport::can_force_early_return() && state != NULL && state->is_earlyret_pending()) { |
241 // Force early return from top frame after deoptimization |
245 // Force early return from top frame after deoptimization |
242 #ifndef CC_INTERP |
246 #ifndef CC_INTERP |
243 pc = Interpreter::remove_activation_early_entry(state->earlyret_tos()); |
247 pc = Interpreter::remove_activation_early_entry(state->earlyret_tos()); |
244 #endif |
248 #endif |
245 } else { |
249 } else { |
|
250 if (realloc_failure_exception && JvmtiExport::can_force_early_return() && state != NULL && state->is_earlyret_pending()) { |
|
251 state->clr_earlyret_pending(); |
|
252 state->set_earlyret_oop(NULL); |
|
253 state->clr_earlyret_value(); |
|
254 } |
246 // Possibly override the previous pc computation of the top (youngest) frame |
255 // Possibly override the previous pc computation of the top (youngest) frame |
247 switch (exec_mode) { |
256 switch (exec_mode) { |
248 case Deoptimization::Unpack_deopt: |
257 case Deoptimization::Unpack_deopt: |
249 // use what we've got |
258 // use what we've got |
250 break; |
259 break; |