277 int locks = monitors() == NULL ? 0 : monitors()->number_of_monitors();
278
279 Interpreter::layout_activation(method(),
280 temps + callee_parameters,
281 popframe_preserved_args_size_in_words,
282 locks,
283 caller_actual_parameters,
284 callee_parameters,
285 callee_locals,
286 caller,
287 iframe(),
288 is_top_frame,
289 is_bottom_frame);
290
291 // Update the pc in the frame object and overwrite the temporary pc
292 // we placed in the skeletal frame now that we finally know the
293 // exact interpreter address we should use.
294
295 _frame.patch_pc(thread, pc);
296
297 assert (!method()->is_synchronized() || locks > 0 || _removed_monitors, "synchronized methods must have monitors");
298
299 BasicObjectLock* top = iframe()->interpreter_frame_monitor_begin();
300 for (int index = 0; index < locks; index++) {
301 top = iframe()->previous_monitor_in_interpreter_frame(top);
302 BasicObjectLock* src = _monitors->at(index);
303 top->set_obj(src->obj());
304 src->lock()->move_to(src->obj(), top->lock());
305 }
306 if (ProfileInterpreter) {
307 iframe()->interpreter_frame_set_mdp(0); // clear out the mdp.
308 }
309 iframe()->interpreter_frame_set_bcp(bcp);
310 if (ProfileInterpreter) {
311 MethodData* mdo = method()->method_data();
312 if (mdo != NULL) {
313 int bci = iframe()->interpreter_frame_bci();
314 if (use_next_mdp) ++bci;
315 address mdp = mdo->bci_to_dp(bci);
316 iframe()->interpreter_frame_set_mdp(mdp);
317 }
318 }
319
320 // Unpack expression stack
321 // If this is an intermediate frame (i.e. not top frame) then this
322 // only unpacks the part of the expression stack not used by callee
323 // as parameters. The callee parameters are unpacked as part of the
324 // callee locals.
325 int i;
326 for(i = 0; i < expressions()->size(); i++) {
327 StackValue *value = expressions()->at(i);
328 intptr_t* addr = iframe()->interpreter_frame_expression_stack_at(i);
329 switch(value->type()) {
330 case T_INT:
331 *addr = value->get_int();
332 break;
333 case T_OBJECT:
334 *addr = value->get_int(T_OBJECT);
335 break;
336 case T_CONFLICT:
337 // A dead stack slot. Initialize to null in case it is an oop.
338 *addr = NULL_WORD;
339 break;
340 default:
341 ShouldNotReachHere();
342 }
343 }
344
345
346 // Unpack the locals
347 for(i = 0; i < locals()->size(); i++) {
348 StackValue *value = locals()->at(i);
349 intptr_t* addr = iframe()->interpreter_frame_local_at(i);
350 switch(value->type()) {
351 case T_INT:
352 *addr = value->get_int();
353 break;
354 case T_OBJECT:
355 *addr = value->get_int(T_OBJECT);
356 break;
357 case T_CONFLICT:
358 // A dead location. If it is an oop then we need a NULL to prevent GC from following it
359 *addr = NULL_WORD;
360 break;
361 default:
362 ShouldNotReachHere();
363 }
364 }
365
366 if (is_top_frame && JvmtiExport::can_pop_frame() && thread->popframe_forcing_deopt_reexecution()) {
367 // An interpreted frame was popped but it returns to a deoptimized
368 // frame. The incoming arguments to the interpreted activation
369 // were preserved in thread-local storage by the
370 // remove_activation_preserving_args_entry in the interpreter; now
371 // we put them back into the just-unpacked interpreter frame.
372 // Note that this assumes that the locals arena grows toward lower
373 // addresses.
374 if (popframe_preserved_args_size_in_words != 0) {
375 void* saved_args = thread->popframe_preserved_args();
377 #ifdef ASSERT
378 assert(popframe_preserved_args_size_in_words <=
379 iframe()->interpreter_frame_expression_stack_size()*Interpreter::stackElementWords,
380 "expression stack size should have been extended");
381 #endif // ASSERT
382 int top_element = iframe()->interpreter_frame_expression_stack_size()-1;
383 intptr_t* base;
384 if (frame::interpreter_frame_expression_stack_direction() < 0) {
385 base = iframe()->interpreter_frame_expression_stack_at(top_element);
386 } else {
387 base = iframe()->interpreter_frame_expression_stack();
388 }
389 Copy::conjoint_jbytes(saved_args,
390 base,
391 popframe_preserved_args_size_in_bytes);
392 thread->popframe_free_preserved_args();
393 }
394 }
395
396 #ifndef PRODUCT
397 if (TraceDeoptimization && Verbose) {
398 ttyLocker ttyl;
399 tty->print_cr("[%d Interpreted Frame]", ++unpack_counter);
400 iframe()->print_on(tty);
401 RegisterMap map(thread);
402 vframe* f = vframe::new_vframe(iframe(), &map, thread);
403 f->print();
404
405 tty->print_cr("locals size %d", locals()->size());
406 tty->print_cr("expression size %d", expressions()->size());
407
408 method()->print_value();
409 tty->cr();
410 // method()->print_codes();
411 } else if (TraceDeoptimization) {
412 tty->print(" ");
413 method()->print_value();
414 Bytecodes::Code code = Bytecodes::java_code_at(method(), bcp);
415 int bci = method()->bci_from(bcp);
416 tty->print(" - %s", Bytecodes::name(code));
417 tty->print(" @ bci %d ", bci);
|
277 int locks = monitors() == NULL ? 0 : monitors()->number_of_monitors();
278
279 Interpreter::layout_activation(method(),
280 temps + callee_parameters,
281 popframe_preserved_args_size_in_words,
282 locks,
283 caller_actual_parameters,
284 callee_parameters,
285 callee_locals,
286 caller,
287 iframe(),
288 is_top_frame,
289 is_bottom_frame);
290
291 // Update the pc in the frame object and overwrite the temporary pc
292 // we placed in the skeletal frame now that we finally know the
293 // exact interpreter address we should use.
294
295 _frame.patch_pc(thread, pc);
296
297 assert (!method()->is_synchronized() || locks > 0 || _removed_monitors || raw_bci() == SynchronizationEntryBCI, "synchronized methods must have monitors");
298
299 BasicObjectLock* top = iframe()->interpreter_frame_monitor_begin();
300 for (int index = 0; index < locks; index++) {
301 top = iframe()->previous_monitor_in_interpreter_frame(top);
302 BasicObjectLock* src = _monitors->at(index);
303 top->set_obj(src->obj());
304 src->lock()->move_to(src->obj(), top->lock());
305 }
306 if (ProfileInterpreter) {
307 iframe()->interpreter_frame_set_mdp(0); // clear out the mdp.
308 }
309 iframe()->interpreter_frame_set_bcp(bcp);
310 if (ProfileInterpreter) {
311 MethodData* mdo = method()->method_data();
312 if (mdo != NULL) {
313 int bci = iframe()->interpreter_frame_bci();
314 if (use_next_mdp) ++bci;
315 address mdp = mdo->bci_to_dp(bci);
316 iframe()->interpreter_frame_set_mdp(mdp);
317 }
318 }
319
320 if (PrintDeoptimizationDetails) {
321 tty->print_cr("Expressions size: %d", expressions()->size());
322 }
323
324 // Unpack expression stack
325 // If this is an intermediate frame (i.e. not top frame) then this
326 // only unpacks the part of the expression stack not used by callee
327 // as parameters. The callee parameters are unpacked as part of the
328 // callee locals.
329 int i;
330 for(i = 0; i < expressions()->size(); i++) {
331 StackValue *value = expressions()->at(i);
332 intptr_t* addr = iframe()->interpreter_frame_expression_stack_at(i);
333 switch(value->type()) {
334 case T_INT:
335 *addr = value->get_int();
336 #ifndef PRODUCT
337 if (PrintDeoptimizationDetails) {
338 tty->print_cr("Reconstructed expression %d (INT): %d", i, (int)(*addr));
339 }
340 #endif
341 break;
342 case T_OBJECT:
343 *addr = value->get_int(T_OBJECT);
344 #ifndef PRODUCT
345 if (PrintDeoptimizationDetails) {
346 tty->print("Reconstructed expression %d (OBJECT): ", i);
347 oop o = (oop)(address)(*addr);
348 if (o == NULL) {
349 tty->print_cr("NULL");
350 } else {
351 ResourceMark rm;
352 tty->print_raw_cr(o->klass()->name()->as_C_string());
353 }
354 }
355 #endif
356 break;
357 case T_CONFLICT:
358 // A dead stack slot. Initialize to null in case it is an oop.
359 *addr = NULL_WORD;
360 break;
361 default:
362 ShouldNotReachHere();
363 }
364 }
365
366
367 // Unpack the locals
368 for(i = 0; i < locals()->size(); i++) {
369 StackValue *value = locals()->at(i);
370 intptr_t* addr = iframe()->interpreter_frame_local_at(i);
371 switch(value->type()) {
372 case T_INT:
373 *addr = value->get_int();
374 #ifndef PRODUCT
375 if (PrintDeoptimizationDetails) {
376 tty->print_cr("Reconstructed local %d (INT): %d", i, (int)(*addr));
377 }
378 #endif
379 break;
380 case T_OBJECT:
381 *addr = value->get_int(T_OBJECT);
382 #ifndef PRODUCT
383 if (PrintDeoptimizationDetails) {
384 tty->print("Reconstructed local %d (OBJECT): ", i);
385 oop o = (oop)(address)(*addr);
386 if (o == NULL) {
387 tty->print_cr("NULL");
388 } else {
389 ResourceMark rm;
390 tty->print_raw_cr(o->klass()->name()->as_C_string());
391 }
392 }
393 #endif
394 break;
395 case T_CONFLICT:
396 // A dead location. If it is an oop then we need a NULL to prevent GC from following it
397 *addr = NULL_WORD;
398 break;
399 default:
400 ShouldNotReachHere();
401 }
402 }
403
404 if (is_top_frame && JvmtiExport::can_pop_frame() && thread->popframe_forcing_deopt_reexecution()) {
405 // An interpreted frame was popped but it returns to a deoptimized
406 // frame. The incoming arguments to the interpreted activation
407 // were preserved in thread-local storage by the
408 // remove_activation_preserving_args_entry in the interpreter; now
409 // we put them back into the just-unpacked interpreter frame.
410 // Note that this assumes that the locals arena grows toward lower
411 // addresses.
412 if (popframe_preserved_args_size_in_words != 0) {
413 void* saved_args = thread->popframe_preserved_args();
415 #ifdef ASSERT
416 assert(popframe_preserved_args_size_in_words <=
417 iframe()->interpreter_frame_expression_stack_size()*Interpreter::stackElementWords,
418 "expression stack size should have been extended");
419 #endif // ASSERT
420 int top_element = iframe()->interpreter_frame_expression_stack_size()-1;
421 intptr_t* base;
422 if (frame::interpreter_frame_expression_stack_direction() < 0) {
423 base = iframe()->interpreter_frame_expression_stack_at(top_element);
424 } else {
425 base = iframe()->interpreter_frame_expression_stack();
426 }
427 Copy::conjoint_jbytes(saved_args,
428 base,
429 popframe_preserved_args_size_in_bytes);
430 thread->popframe_free_preserved_args();
431 }
432 }
433
434 #ifndef PRODUCT
435 if (PrintDeoptimizationDetails) {
436 ttyLocker ttyl;
437 tty->print_cr("[%d Interpreted Frame]", ++unpack_counter);
438 iframe()->print_on(tty);
439 RegisterMap map(thread);
440 vframe* f = vframe::new_vframe(iframe(), &map, thread);
441 f->print();
442
443 tty->print_cr("locals size %d", locals()->size());
444 tty->print_cr("expression size %d", expressions()->size());
445
446 method()->print_value();
447 tty->cr();
448 // method()->print_codes();
449 } else if (TraceDeoptimization) {
450 tty->print(" ");
451 method()->print_value();
452 Bytecodes::Code code = Bytecodes::java_code_at(method(), bcp);
453 int bci = method()->bci_from(bcp);
454 tty->print(" - %s", Bytecodes::name(code));
455 tty->print(" @ bci %d ", bci);
|