3082 thread->set_reserved_stack_activation(thread->stack_base()); |
3082 thread->set_reserved_stack_activation(thread->stack_base()); |
3083 JRT_END |
3083 JRT_END |
3084 |
3084 |
3085 frame SharedRuntime::look_for_reserved_stack_annotated_method(JavaThread* thread, frame fr) { |
3085 frame SharedRuntime::look_for_reserved_stack_annotated_method(JavaThread* thread, frame fr) { |
3086 frame activation; |
3086 frame activation; |
3087 int decode_offset = 0; |
3087 CompiledMethod* nm = NULL; |
3088 nmethod* nm = NULL; |
|
3089 frame prv_fr = fr; |
|
3090 int count = 1; |
3088 int count = 1; |
3091 |
3089 |
3092 assert(fr.is_java_frame(), "Must start on Java frame"); |
3090 assert(fr.is_java_frame(), "Must start on Java frame"); |
3093 |
3091 |
3094 while (!fr.is_first_frame()) { |
3092 while (true) { |
3095 Method* method = NULL; |
3093 Method* method = NULL; |
3096 // Compiled java method case. |
3094 if (fr.is_interpreted_frame()) { |
3097 if (decode_offset != 0) { |
3095 method = fr.interpreter_frame_method(); |
3098 DebugInfoReadStream stream(nm, decode_offset); |
|
3099 decode_offset = stream.read_int(); |
|
3100 method = (Method*)nm->metadata_at(stream.read_int()); |
|
3101 } else { |
3096 } else { |
3102 if (fr.is_first_java_frame()) break; |
3097 CodeBlob* cb = fr.cb(); |
3103 address pc = fr.pc(); |
3098 if (cb != NULL && cb->is_compiled()) { |
3104 prv_fr = fr; |
3099 nm = cb->as_compiled_method(); |
3105 if (fr.is_interpreted_frame()) { |
3100 method = nm->method(); |
3106 method = fr.interpreter_frame_method(); |
3101 } |
3107 fr = fr.java_sender(); |
3102 } |
3108 } else { |
3103 if ((method != NULL) && method->has_reserved_stack_access()) { |
3109 CodeBlob* cb = fr.cb(); |
|
3110 fr = fr.java_sender(); |
|
3111 if (cb == NULL || !cb->is_nmethod()) { |
|
3112 continue; |
|
3113 } |
|
3114 nm = (nmethod*)cb; |
|
3115 if (nm->method()->is_native()) { |
|
3116 method = nm->method(); |
|
3117 } else { |
|
3118 PcDesc* pd = nm->pc_desc_at(pc); |
|
3119 assert(pd != NULL, "PcDesc must not be NULL"); |
|
3120 decode_offset = pd->scope_decode_offset(); |
|
3121 // if decode_offset is not equal to 0, it will execute the |
|
3122 // "compiled java method case" at the beginning of the loop. |
|
3123 continue; |
|
3124 } |
|
3125 } |
|
3126 } |
|
3127 if (method->has_reserved_stack_access()) { |
|
3128 ResourceMark rm(thread); |
3104 ResourceMark rm(thread); |
3129 activation = prv_fr; |
3105 activation = fr; |
3130 warning("Potentially dangerous stack overflow in " |
3106 warning("Potentially dangerous stack overflow in " |
3131 "ReservedStackAccess annotated method %s [%d]", |
3107 "ReservedStackAccess annotated method %s [%d]", |
3132 method->name_and_sig_as_C_string(), count++); |
3108 method->name_and_sig_as_C_string(), count++); |
3133 EventReservedStackActivation event; |
3109 EventReservedStackActivation event; |
3134 if (event.should_commit()) { |
3110 if (event.should_commit()) { |
3135 event.set_method(method); |
3111 event.set_method(method); |
3136 event.commit(); |
3112 event.commit(); |
3137 } |
3113 } |
3138 } |
3114 } |
|
3115 if (fr.is_first_java_frame()) { |
|
3116 break; |
|
3117 } else { |
|
3118 fr = fr.java_sender(); |
|
3119 } |
3139 } |
3120 } |
3140 return activation; |
3121 return activation; |
3141 } |
3122 } |
3142 |
3123 |