comparison src/share/vm/graal/graalCodeInstaller.cpp @ 5129:51111665eda6

Support for recording a leaf graph id for each deoptimization point in the debug info.
author Lukas Stadler <lukas.stadler@jku.at>
date Wed, 21 Mar 2012 10:47:02 +0100
parents b5dc2403c1e7
children ab038e0d6b43
comparison
equal deleted inserted replaced
5128:e2da6471a9a1 5129:51111665eda6
426 _exception_handler_table.add_entry(HandlerTableEntry(-1, handler_offset, 0)); 426 _exception_handler_table.add_entry(HandlerTableEntry(-1, handler_offset, 0));
427 } 427 }
428 } 428 }
429 } 429 }
430 430
431 void CodeInstaller::record_scope(jint pc_offset, oop code_pos, GrowableArray<ScopeValue*>* objects) { 431 void CodeInstaller::record_scope(jint pc_offset, oop frame, GrowableArray<ScopeValue*>* objects) {
432 oop caller_pos = CiCodePos::caller(code_pos); 432 assert(frame->klass() == CiFrame::klass(), "CiFrame expected");
433 if (caller_pos != NULL) { 433 oop caller_frame = CiCodePos::caller(frame);
434 record_scope(pc_offset, caller_pos, objects); 434 if (caller_frame != NULL) {
435 } 435 record_scope(pc_offset, caller_frame, objects);
436 oop frame = NULL; 436 }
437 if (code_pos->klass()->klass_part()->name() == vmSymbols::com_oracle_max_cri_ci_CiFrame()) { 437
438 frame = code_pos; 438 oop hotspot_method = CiCodePos::method(frame);
439 }
440
441 oop hotspot_method = CiCodePos::method(code_pos);
442 methodOop method = getMethodFromHotSpotMethod(hotspot_method); 439 methodOop method = getMethodFromHotSpotMethod(hotspot_method);
443 jint bci = CiCodePos::bci(code_pos); 440 jint bci = CiCodePos::bci(frame);
444 bool reexecute; 441 bool reexecute;
445 if (bci == -1) { 442 if (bci == -1) {
446 reexecute = false; 443 reexecute = false;
447 } else { 444 } else {
448 Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci)); 445 Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci));
454 451
455 if (TraceGraal >= 2) { 452 if (TraceGraal >= 2) {
456 tty->print_cr("Recording scope pc_offset=%d bci=%d frame=%d", pc_offset, bci, frame); 453 tty->print_cr("Recording scope pc_offset=%d bci=%d frame=%d", pc_offset, bci, frame);
457 } 454 }
458 455
459 if (frame != NULL) { 456 jint local_count = CiFrame::numLocals(frame);
460 jint local_count = CiFrame::numLocals(frame); 457 jint expression_count = CiFrame::numStack(frame);
461 jint expression_count = CiFrame::numStack(frame); 458 jint monitor_count = CiFrame::numLocks(frame);
462 jint monitor_count = CiFrame::numLocks(frame); 459 arrayOop values = (arrayOop) CiFrame::values(frame);
463 arrayOop values = (arrayOop) CiFrame::values(frame); 460
464 461 assert(local_count + expression_count + monitor_count == values->length(), "unexpected values length");
465 assert(local_count + expression_count + monitor_count == values->length(), "unexpected values length"); 462
466 463 GrowableArray<ScopeValue*>* locals = new GrowableArray<ScopeValue*> ();
467 GrowableArray<ScopeValue*>* locals = new GrowableArray<ScopeValue*> (); 464 GrowableArray<ScopeValue*>* expressions = new GrowableArray<ScopeValue*> ();
468 GrowableArray<ScopeValue*>* expressions = new GrowableArray<ScopeValue*> (); 465 GrowableArray<MonitorValue*>* monitors = new GrowableArray<MonitorValue*> ();
469 GrowableArray<MonitorValue*>* monitors = new GrowableArray<MonitorValue*> (); 466
470 467 if (TraceGraal >= 2) {
471 if (TraceGraal >= 2) { 468 tty->print_cr("Scope at bci %d with %d values", bci, values->length());
472 tty->print_cr("Scope at bci %d with %d values", bci, values->length()); 469 tty->print_cr("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count);
473 tty->print_cr("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count); 470 }
474 } 471
475 472 for (jint i = 0; i < values->length(); i++) {
476 for (jint i = 0; i < values->length(); i++) { 473 ScopeValue* second = NULL;
477 ScopeValue* second = NULL; 474 oop value = ((oop*) values->base(T_OBJECT))[i];
478 oop value = ((oop*) values->base(T_OBJECT))[i]; 475
479 476 if (i < local_count) {
480 if (i < local_count) { 477 ScopeValue* first = get_hotspot_value(value, _total_frame_size, objects, second);
481 ScopeValue* first = get_hotspot_value(value, _total_frame_size, objects, second);
482 if (second != NULL) {
483 locals->append(second);
484 }
485 locals->append(first);
486 } else if (i < local_count + expression_count) {
487 ScopeValue* first = get_hotspot_value(value, _total_frame_size, objects, second);
488 if (second != NULL) {
489 expressions->append(second);
490 }
491 expressions->append(first);
492 } else {
493 monitors->append(get_monitor_value(value, _total_frame_size, objects));
494 }
495 if (second != NULL) { 478 if (second != NULL) {
496 i++; 479 locals->append(second);
497 assert(i < values->length(), "double-slot value not followed by CiValue.IllegalValue"); 480 }
498 assert(((oop*) values->base(T_OBJECT))[i] == CiValue::IllegalValue(), "double-slot value not followed by CiValue.IllegalValue"); 481 locals->append(first);
499 } 482 } else if (i < local_count + expression_count) {
500 } 483 ScopeValue* first = get_hotspot_value(value, _total_frame_size, objects, second);
501 484 if (second != NULL) {
502 _debug_recorder->dump_object_pool(objects); 485 expressions->append(second);
503 486 }
504 DebugToken* locals_token = _debug_recorder->create_scope_values(locals); 487 expressions->append(first);
505 DebugToken* expressions_token = _debug_recorder->create_scope_values(expressions); 488 } else {
506 DebugToken* monitors_token = _debug_recorder->create_monitor_values(monitors); 489 monitors->append(get_monitor_value(value, _total_frame_size, objects));
507 490 }
508 bool throw_exception = false; 491 if (second != NULL) {
509 if (CiFrame::rethrowException(frame)) { 492 i++;
510 throw_exception = true; 493 assert(i < values->length(), "double-slot value not followed by CiValue.IllegalValue");
511 } 494 assert(((oop*) values->base(T_OBJECT))[i] == CiValue::IllegalValue(), "double-slot value not followed by CiValue.IllegalValue");
512 495 }
513 _debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, false, false, locals_token, expressions_token, monitors_token); 496 }
514 } else { 497
515 _debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, false, false, false, NULL, NULL, NULL); 498 _debug_recorder->dump_object_pool(objects);
516 } 499
500 DebugToken* locals_token = _debug_recorder->create_scope_values(locals);
501 DebugToken* expressions_token = _debug_recorder->create_scope_values(expressions);
502 DebugToken* monitors_token = _debug_recorder->create_monitor_values(monitors);
503
504 bool throw_exception = false;
505 if (CiFrame::rethrowException(frame)) {
506 throw_exception = true;
507 }
508
509 _debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, false, false, locals_token, expressions_token, monitors_token);
517 } 510 }
518 511
519 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, oop site) { 512 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, oop site) {
520 oop debug_info = CiTargetMethod_Safepoint::debugInfo(site); 513 oop debug_info = CiTargetMethod_Safepoint::debugInfo(site);
521 assert(debug_info != NULL, "debug info expected"); 514 assert(debug_info != NULL, "debug info expected");
522 515
523 // address instruction = _instructions->start() + pc_offset; 516 // address instruction = _instructions->start() + pc_offset;
524 // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start(); 517 // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start();
525 _debug_recorder->add_safepoint(pc_offset, create_oop_map(_total_frame_size, _parameter_count, debug_info)); 518 _debug_recorder->add_safepoint(pc_offset, -1, create_oop_map(_total_frame_size, _parameter_count, debug_info));
526 519
527 oop code_pos = CiDebugInfo::codePos(debug_info); 520 oop code_pos = CiDebugInfo::codePos(debug_info);
528 record_scope(pc_offset, code_pos, new GrowableArray<ScopeValue*>()); 521 record_scope(pc_offset, code_pos, new GrowableArray<ScopeValue*>());
529 522
530 _debug_recorder->end_safepoint(pc_offset); 523 _debug_recorder->end_safepoint(pc_offset);
634 627
635 return; 628 return;
636 } 629 }
637 630
638 if (debug_info != NULL) { 631 if (debug_info != NULL) {
639 _debug_recorder->add_safepoint(next_pc_offset, create_oop_map(_total_frame_size, _parameter_count, debug_info)); 632 oop frame = CiDebugInfo::codePos(debug_info);
640 oop code_pos = CiDebugInfo::codePos(debug_info); 633 _debug_recorder->add_safepoint(next_pc_offset, CiFrame::leafGraphId(frame), create_oop_map(_total_frame_size, _parameter_count, debug_info));
641 record_scope(next_pc_offset, code_pos, new GrowableArray<ScopeValue*>()); 634 record_scope(next_pc_offset, frame, new GrowableArray<ScopeValue*>());
642 } 635 }
643 636
644 if (runtime_call != NULL) { 637 if (runtime_call != NULL) {
645 if (runtime_call != CiRuntimeCall::Debug()) { 638 if (runtime_call != CiRuntimeCall::Debug()) {
646 address target_addr = runtime_call_target_address(runtime_call); 639 address target_addr = runtime_call_target_address(runtime_call);