comparison src/share/vm/graal/graalCompilerToVM.cpp @ 15092:c73ce0dd3583

add support for skipping stack frames in StackIntrospection.getStackTrace
author Lukas Stadler <lukas.stadler@oracle.com>
date Mon, 14 Apr 2014 19:11:47 +0200
parents d3add9b82b71
children ed29f7ff71eb
comparison
equal deleted inserted replaced
15091:607e33885130 15092:c73ce0dd3583
795 } 795 }
796 } 796 }
797 return false; 797 return false;
798 } 798 }
799 799
800 // public native HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, ResolvedJavaMethod method); 800 C2V_VMENTRY(jobject, getNextStackFrame, (JNIEnv *env, jobject compilerToVM, jobject hs_frame, jlongArray methods, jint initialSkip))
801 C2V_VMENTRY(jobject, getNextStackFrame, (JNIEnv *env, jobject compilerToVM, jobject hs_frame, jlongArray methods))
802 ResourceMark rm; 801 ResourceMark rm;
803 802
804 if (!thread->has_last_Java_frame()) return NULL; 803 if (!thread->has_last_Java_frame()) return NULL;
805 Handle result = InstanceKlass::cast(HotSpotStackFrameReference::klass())->allocate_instance(thread); 804 Handle result = InstanceKlass::cast(HotSpotStackFrameReference::klass())->allocate_instance(thread);
806 HotSpotStackFrameReference::klass()->initialize(thread); 805 HotSpotStackFrameReference::klass()->initialize(thread);
849 StackValueCollection* locals = NULL; 848 StackValueCollection* locals = NULL;
850 if (vf->is_compiled_frame()) { 849 if (vf->is_compiled_frame()) {
851 // compiled method frame 850 // compiled method frame
852 compiledVFrame* cvf = compiledVFrame::cast(vf); 851 compiledVFrame* cvf = compiledVFrame::cast(vf);
853 if (methods == NULL || matches(methods, cvf->method())) { 852 if (methods == NULL || matches(methods, cvf->method())) {
854 GrowableArray<ScopeValue*>* objects = cvf->scope()->objects(); 853 if (initialSkip > 0) {
855 bool reallocated = false; 854 initialSkip --;
856 if (objects != NULL) { 855 } else {
857 reallocated = Deoptimization::realloc_objects(thread, fst.current(), objects, THREAD); 856 GrowableArray<ScopeValue*>* objects = cvf->scope()->objects();
858 if (reallocated) { 857 bool reallocated = false;
859 Deoptimization::reassign_fields(fst.current(), fst.register_map(), objects); 858 if (objects != NULL) {
859 reallocated = Deoptimization::realloc_objects(thread, fst.current(), objects, THREAD);
860 if (reallocated) {
861 Deoptimization::reassign_fields(fst.current(), fst.register_map(), objects);
862 }
863
864 GrowableArray<ScopeValue*>* local_values = cvf->scope()->locals();
865 typeArrayHandle array = oopFactory::new_boolArray(local_values->length(), thread);
866 for (int i = 0; i < local_values->length(); i++) {
867 ScopeValue* value = local_values->at(i);
868 if (value->is_object()) {
869 array->bool_at_put(i, true);
870 }
871 }
872 HotSpotStackFrameReference::set_localIsVirtual(result, array());
873 } else {
874 HotSpotStackFrameReference::set_localIsVirtual(result, NULL);
860 } 875 }
861 876
862 GrowableArray<ScopeValue*>* local_values = cvf->scope()->locals(); 877 locals = cvf->locals();
863 typeArrayHandle array = oopFactory::new_boolArray(local_values->length(), thread); 878 HotSpotStackFrameReference::set_bci(result, cvf->bci());
864 for (int i = 0; i < local_values->length(); i++) { 879 HotSpotStackFrameReference::set_metaspaceMethod(result, (jlong) cvf->method());
865 ScopeValue* value = local_values->at(i);
866 if (value->is_object()) {
867 array->bool_at_put(i, true);
868 }
869 }
870 HotSpotStackFrameReference::set_localIsVirtual(result, array());
871 } else {
872 HotSpotStackFrameReference::set_localIsVirtual(result, NULL);
873 } 880 }
874
875 locals = cvf->locals();
876 HotSpotStackFrameReference::set_bci(result, cvf->bci());
877 HotSpotStackFrameReference::set_metaspaceMethod(result, (jlong) cvf->method());
878 } 881 }
879 } else if (vf->is_interpreted_frame()) { 882 } else if (vf->is_interpreted_frame()) {
880 // interpreted method frame 883 // interpreted method frame
881 interpretedVFrame* ivf = interpretedVFrame::cast(vf); 884 interpretedVFrame* ivf = interpretedVFrame::cast(vf);
882 if (methods == NULL || matches(methods, ivf->method())) { 885 if (methods == NULL || matches(methods, ivf->method())) {
883 locals = ivf->locals(); 886 if (initialSkip > 0) {
884 HotSpotStackFrameReference::set_bci(result, ivf->bci()); 887 initialSkip --;
885 HotSpotStackFrameReference::set_metaspaceMethod(result, (jlong) ivf->method()); 888 } else {
886 HotSpotStackFrameReference::set_localIsVirtual(result, NULL); 889 locals = ivf->locals();
890 HotSpotStackFrameReference::set_bci(result, ivf->bci());
891 HotSpotStackFrameReference::set_metaspaceMethod(result, (jlong) ivf->method());
892 HotSpotStackFrameReference::set_localIsVirtual(result, NULL);
893 }
887 } 894 }
888 } 895 }
889 896
890 // locals != NULL means that we found a matching frame and result is already partially initialized 897 // locals != NULL means that we found a matching frame and result is already partially initialized
891 if (locals != NULL) { 898 if (locals != NULL) {
1094 {CC"getGPUs", CC"()"STRING, FN_PTR(getGPUs)}, 1101 {CC"getGPUs", CC"()"STRING, FN_PTR(getGPUs)},
1095 {CC"allocateCompileId", CC"("METASPACE_METHOD"I)I", FN_PTR(allocateCompileId)}, 1102 {CC"allocateCompileId", CC"("METASPACE_METHOD"I)I", FN_PTR(allocateCompileId)},
1096 {CC"isMature", CC"("METASPACE_METHOD_DATA")Z", FN_PTR(isMature)}, 1103 {CC"isMature", CC"("METASPACE_METHOD_DATA")Z", FN_PTR(isMature)},
1097 {CC"hasCompiledCodeForOSR", CC"("METASPACE_METHOD"II)Z", FN_PTR(hasCompiledCodeForOSR)}, 1104 {CC"hasCompiledCodeForOSR", CC"("METASPACE_METHOD"II)Z", FN_PTR(hasCompiledCodeForOSR)},
1098 {CC"getTimeStamp", CC"()J", FN_PTR(getTimeStamp)}, 1105 {CC"getTimeStamp", CC"()J", FN_PTR(getTimeStamp)},
1099 {CC"getNextStackFrame", CC"("HS_STACK_FRAME_REF "[J)"HS_STACK_FRAME_REF, FN_PTR(getNextStackFrame)}, 1106 {CC"getNextStackFrame", CC"("HS_STACK_FRAME_REF "[JI)"HS_STACK_FRAME_REF, FN_PTR(getNextStackFrame)},
1100 {CC"materializeVirtualObjects", CC"("HS_STACK_FRAME_REF"Z)V", FN_PTR(materializeVirtualObjects)}, 1107 {CC"materializeVirtualObjects", CC"("HS_STACK_FRAME_REF"Z)V", FN_PTR(materializeVirtualObjects)},
1101 }; 1108 };
1102 1109
1103 int CompilerToVM_methods_count() { 1110 int CompilerToVM_methods_count() {
1104 return sizeof(CompilerToVM_methods) / sizeof(JNINativeMethod); 1111 return sizeof(CompilerToVM_methods) / sizeof(JNINativeMethod);