comparison src/share/vm/graal/graalCodeInstaller.cpp @ 16573:a2ec1ac769e4

Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 18 Jul 2014 11:14:54 +0200
parents 9a07bf8467a6
children a7d9b88ecd68
comparison
equal deleted inserted replaced
16572:7531cdfed73c 16573:a2ec1ac769e4
543 _constants->relocate(dest, oop_Relocation::spec(oop_index)); 543 _constants->relocate(dest, oop_Relocation::spec(oop_index));
544 } else { 544 } else {
545 ShouldNotReachHere(); 545 ShouldNotReachHere();
546 } 546 }
547 } 547 }
548 548 jint last_pc_offset = -1;
549 for (int i = 0; i < _sites->length(); i++) { 549 for (int i = 0; i < _sites->length(); i++) {
550 oop site = ((objArrayOop) (_sites))->obj_at(i); 550 oop site = ((objArrayOop) (_sites))->obj_at(i);
551 jint pc_offset = CompilationResult_Site::pcOffset(site); 551 jint pc_offset = CompilationResult_Site::pcOffset(site);
552 552
553 if (site->is_a(CompilationResult_Call::klass())) { 553 if (site->is_a(CompilationResult_Call::klass())) {
561 site_Safepoint(buffer, pc_offset, site); 561 site_Safepoint(buffer, pc_offset, site);
562 } else { 562 } else {
563 // if the infopoint is not an actual safepoint, it must have one of the other reasons 563 // if the infopoint is not an actual safepoint, it must have one of the other reasons
564 // (safeguard against new safepoint types that require handling above) 564 // (safeguard against new safepoint types that require handling above)
565 assert(InfopointReason::METHOD_START() == reason || InfopointReason::METHOD_END() == reason || InfopointReason::LINE_NUMBER() == reason, ""); 565 assert(InfopointReason::METHOD_START() == reason || InfopointReason::METHOD_END() == reason || InfopointReason::LINE_NUMBER() == reason, "");
566 site_Infopoint(buffer, pc_offset, site);
566 } 567 }
567 } else if (site->is_a(CompilationResult_DataPatch::klass())) { 568 } else if (site->is_a(CompilationResult_DataPatch::klass())) {
568 TRACE_graal_4("datapatch at %i", pc_offset); 569 TRACE_graal_4("datapatch at %i", pc_offset);
569 site_DataPatch(buffer, pc_offset, site); 570 site_DataPatch(buffer, pc_offset, site);
570 } else if (site->is_a(CompilationResult_Mark::klass())) { 571 } else if (site->is_a(CompilationResult_Mark::klass())) {
571 TRACE_graal_4("mark at %i", pc_offset); 572 TRACE_graal_4("mark at %i", pc_offset);
572 site_Mark(buffer, pc_offset, site); 573 site_Mark(buffer, pc_offset, site);
573 } else { 574 } else {
574 fatal("unexpected Site subclass"); 575 fatal("unexpected Site subclass");
575 } 576 }
577 last_pc_offset = pc_offset;
576 } 578 }
577 579
578 #ifndef PRODUCT 580 #ifndef PRODUCT
579 if (_comments != NULL) { 581 if (_comments != NULL) {
580 for (int i = 0; i < _comments->length(); i++) { 582 for (int i = 0; i < _comments->length(); i++) {
668 return true; 670 return true;
669 } 671 }
670 return true; 672 return true;
671 } 673 }
672 674
673 void CodeInstaller::record_scope(jint pc_offset, oop frame, GrowableArray<ScopeValue*>* objects) { 675 void CodeInstaller::record_scope(jint pc_offset, oop position, GrowableArray<ScopeValue*>* objects) {
674 assert(frame->klass() == BytecodeFrame::klass(), "BytecodeFrame expected"); 676 oop frame = NULL;
675 oop caller_frame = BytecodePosition::caller(frame); 677 if (position->is_a(BytecodeFrame::klass())) {
678 frame = position;
679 }
680 oop caller_frame = BytecodePosition::caller(position);
676 if (caller_frame != NULL) { 681 if (caller_frame != NULL) {
677 record_scope(pc_offset, caller_frame, objects); 682 record_scope(pc_offset, caller_frame, objects);
678 } 683 }
679 684
680 oop hotspot_method = BytecodePosition::method(frame); 685 oop hotspot_method = BytecodePosition::method(position);
681 Method* method = getMethodFromHotSpotMethod(hotspot_method); 686 Method* method = getMethodFromHotSpotMethod(hotspot_method);
682 jint bci = BytecodePosition::bci(frame); 687 jint bci = BytecodePosition::bci(position);
683 if (bci == BytecodeFrame::BEFORE_BCI()) { 688 if (bci == BytecodeFrame::BEFORE_BCI()) {
684 bci = SynchronizationEntryBCI; 689 bci = SynchronizationEntryBCI;
685 } 690 }
686 bool reexecute;
687 if (bci == SynchronizationEntryBCI){
688 reexecute = false;
689 } else {
690 Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci));
691 reexecute = bytecode_should_reexecute(code);
692 if (frame != NULL) {
693 reexecute = (BytecodeFrame::duringCall(frame) == JNI_FALSE);
694 }
695 }
696 691
697 if (TraceGraal >= 2) { 692 if (TraceGraal >= 2) {
698 tty->print_cr("Recording scope pc_offset=%d bci=%d method=%s", pc_offset, bci, method->name_and_sig_as_C_string()); 693 tty->print_cr("Recording scope pc_offset=%d bci=%d method=%s", pc_offset, bci, method->name_and_sig_as_C_string());
699 } 694 }
700 695
701 jint local_count = BytecodeFrame::numLocals(frame); 696 bool reexecute = false;
702 jint expression_count = BytecodeFrame::numStack(frame); 697 if (frame != NULL) {
703 jint monitor_count = BytecodeFrame::numLocks(frame); 698 if (bci == SynchronizationEntryBCI){
704 arrayOop values = (arrayOop) BytecodeFrame::values(frame); 699 reexecute = false;
705 700 } else {
706 assert(local_count + expression_count + monitor_count == values->length(), "unexpected values length"); 701 Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci));
707 702 reexecute = bytecode_should_reexecute(code);
708 GrowableArray<ScopeValue*>* locals = new GrowableArray<ScopeValue*> (); 703 if (frame != NULL) {
709 GrowableArray<ScopeValue*>* expressions = new GrowableArray<ScopeValue*> (); 704 reexecute = (BytecodeFrame::duringCall(frame) == JNI_FALSE);
710 GrowableArray<MonitorValue*>* monitors = new GrowableArray<MonitorValue*> (); 705 }
711 706 }
712 if (TraceGraal >= 2) { 707 }
713 tty->print_cr("Scope at bci %d with %d values", bci, values->length()); 708
714 tty->print_cr("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count); 709 DebugToken* locals_token = NULL;
715 } 710 DebugToken* expressions_token = NULL;
716 711 DebugToken* monitors_token = NULL;
717 for (jint i = 0; i < values->length(); i++) { 712 bool throw_exception = false;
718 ScopeValue* second = NULL; 713
719 oop value=((objArrayOop) (values))->obj_at(i); 714 if (frame != NULL) {
720 if (i < local_count) { 715 jint local_count = BytecodeFrame::numLocals(frame);
721 ScopeValue* first = get_scope_value(value, _total_frame_size, objects, second, _oop_recorder); 716 jint expression_count = BytecodeFrame::numStack(frame);
717 jint monitor_count = BytecodeFrame::numLocks(frame);
718 arrayOop values = (arrayOop) BytecodeFrame::values(frame);
719
720 assert(local_count + expression_count + monitor_count == values->length(), "unexpected values length");
721
722 GrowableArray<ScopeValue*>* locals = new GrowableArray<ScopeValue*> ();
723 GrowableArray<ScopeValue*>* expressions = new GrowableArray<ScopeValue*> ();
724 GrowableArray<MonitorValue*>* monitors = new GrowableArray<MonitorValue*> ();
725
726 if (TraceGraal >= 2) {
727 tty->print_cr("Scope at bci %d with %d values", bci, values->length());
728 tty->print_cr("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count);
729 }
730
731 for (jint i = 0; i < values->length(); i++) {
732 ScopeValue* second = NULL;
733 oop value=((objArrayOop) (values))->obj_at(i);
734 if (i < local_count) {
735 ScopeValue* first = get_scope_value(value, _total_frame_size, objects, second, _oop_recorder);
736 if (second != NULL) {
737 locals->append(second);
738 }
739 locals->append(first);
740 } else if (i < local_count + expression_count) {
741 ScopeValue* first = get_scope_value(value, _total_frame_size, objects, second, _oop_recorder);
742 if (second != NULL) {
743 expressions->append(second);
744 }
745 expressions->append(first);
746 } else {
747 monitors->append(get_monitor_value(value, _total_frame_size, objects, _oop_recorder));
748 }
722 if (second != NULL) { 749 if (second != NULL) {
723 locals->append(second); 750 i++;
724 } 751 assert(i < values->length(), "double-slot value not followed by Value.ILLEGAL");
725 locals->append(first); 752 assert(((objArrayOop) (values))->obj_at(i) == Value::ILLEGAL(), "double-slot value not followed by Value.ILLEGAL");
726 } else if (i < local_count + expression_count) { 753 }
727 ScopeValue* first = get_scope_value(value, _total_frame_size, objects, second, _oop_recorder); 754 }
728 if (second != NULL) { 755
729 expressions->append(second); 756 _debug_recorder->dump_object_pool(objects);
730 } 757
731 expressions->append(first); 758 locals_token = _debug_recorder->create_scope_values(locals);
732 } else { 759 expressions_token = _debug_recorder->create_scope_values(expressions);
733 monitors->append(get_monitor_value(value, _total_frame_size, objects, _oop_recorder)); 760 monitors_token = _debug_recorder->create_monitor_values(monitors);
734 } 761
735 if (second != NULL) { 762 throw_exception = BytecodeFrame::rethrowException(frame) == JNI_TRUE;
736 i++; 763 }
737 assert(i < values->length(), "double-slot value not followed by Value.ILLEGAL");
738 assert(((objArrayOop) (values))->obj_at(i) == Value::ILLEGAL(), "double-slot value not followed by Value.ILLEGAL");
739 }
740 }
741
742
743 _debug_recorder->dump_object_pool(objects);
744
745 DebugToken* locals_token = _debug_recorder->create_scope_values(locals);
746 DebugToken* expressions_token = _debug_recorder->create_scope_values(expressions);
747 DebugToken* monitors_token = _debug_recorder->create_monitor_values(monitors);
748
749 bool throw_exception = BytecodeFrame::rethrowException(frame) == JNI_TRUE;
750 764
751 _debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, false, false, locals_token, expressions_token, monitors_token); 765 _debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, false, false, locals_token, expressions_token, monitors_token);
752 } 766 }
753 767
754 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, oop site) { 768 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, oop site) {
765 } else { 779 } else {
766 // Stubs do not record scope info, just oop maps 780 // Stubs do not record scope info, just oop maps
767 } 781 }
768 782
769 _debug_recorder->end_safepoint(pc_offset); 783 _debug_recorder->end_safepoint(pc_offset);
784 }
785
786 void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, oop site) {
787 oop debug_info = CompilationResult_Infopoint::debugInfo(site);
788 assert(debug_info != NULL, "debug info expected");
789
790 _debug_recorder->add_non_safepoint(pc_offset);
791
792 oop position = DebugInfo::bytecodePosition(debug_info);
793 if (position != NULL) {
794 record_scope(pc_offset, position, NULL);
795 }
796
797 _debug_recorder->end_non_safepoint(pc_offset);
770 } 798 }
771 799
772 void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, oop site) { 800 void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, oop site) {
773 oop target = CompilationResult_Call::target(site); 801 oop target = CompilationResult_Call::target(site);
774 InstanceKlass* target_klass = InstanceKlass::cast(target->klass()); 802 InstanceKlass* target_klass = InstanceKlass::cast(target->klass());