src/share/vm/runtime/sharedRuntime.cpp

Print this page
rev 13113 : 8182651: Add TRACE_ONLY conditional macro to support more fine-grained INCLUDE_TRACE programming
Reviewed-by:


  44 #include "oops/klass.hpp"
  45 #include "oops/objArrayKlass.hpp"
  46 #include "oops/oop.inline.hpp"
  47 #include "prims/forte.hpp"
  48 #include "prims/jvmtiExport.hpp"
  49 #include "prims/methodHandles.hpp"
  50 #include "prims/nativeLookup.hpp"
  51 #include "runtime/arguments.hpp"
  52 #include "runtime/atomic.hpp"
  53 #include "runtime/biasedLocking.hpp"
  54 #include "runtime/compilationPolicy.hpp"
  55 #include "runtime/handles.inline.hpp"
  56 #include "runtime/init.hpp"
  57 #include "runtime/interfaceSupport.hpp"
  58 #include "runtime/java.hpp"
  59 #include "runtime/javaCalls.hpp"
  60 #include "runtime/sharedRuntime.hpp"
  61 #include "runtime/stubRoutines.hpp"
  62 #include "runtime/vframe.hpp"
  63 #include "runtime/vframeArray.hpp"
  64 #include "trace/tracing.hpp"
  65 #include "utilities/copy.hpp"
  66 #include "utilities/dtrace.hpp"
  67 #include "utilities/events.hpp"
  68 #include "utilities/hashtable.inline.hpp"
  69 #include "utilities/macros.hpp"
  70 #include "utilities/xmlstream.hpp"
  71 #ifdef COMPILER1
  72 #include "c1/c1_Runtime1.hpp"
  73 #endif



  74 
  75 // Shared stub locations
  76 RuntimeStub*        SharedRuntime::_wrong_method_blob;
  77 RuntimeStub*        SharedRuntime::_wrong_method_abstract_blob;
  78 RuntimeStub*        SharedRuntime::_ic_miss_blob;
  79 RuntimeStub*        SharedRuntime::_resolve_opt_virtual_call_blob;
  80 RuntimeStub*        SharedRuntime::_resolve_virtual_call_blob;
  81 RuntimeStub*        SharedRuntime::_resolve_static_call_blob;
  82 address             SharedRuntime::_resolve_static_call_entry;
  83 
  84 DeoptimizationBlob* SharedRuntime::_deopt_blob;
  85 SafepointBlob*      SharedRuntime::_polling_page_vectors_safepoint_handler_blob;
  86 SafepointBlob*      SharedRuntime::_polling_page_safepoint_handler_blob;
  87 SafepointBlob*      SharedRuntime::_polling_page_return_handler_blob;
  88 
  89 #ifdef COMPILER2
  90 UncommonTrapBlob*   SharedRuntime::_uncommon_trap_blob;
  91 #endif // COMPILER2
  92 
  93 


3112   _adapter_trampoline = (AdapterHandlerEntry**)MetaspaceShared::misc_data_space_alloc(sizeof(AdapterHandlerEntry*));
3113 };
3114 
3115 #endif // INCLUDE_CDS
3116 
3117 
3118 #ifndef PRODUCT
3119 
3120 void AdapterHandlerLibrary::print_statistics() {
3121   _adapters->print_statistics();
3122 }
3123 
3124 #endif /* PRODUCT */
3125 
3126 JRT_LEAF(void, SharedRuntime::enable_stack_reserved_zone(JavaThread* thread))
3127   assert(thread->is_Java_thread(), "Only Java threads have a stack reserved zone");
3128   thread->enable_stack_reserved_zone();
3129   thread->set_reserved_stack_activation(thread->stack_base());
3130 JRT_END
3131 










3132 frame SharedRuntime::look_for_reserved_stack_annotated_method(JavaThread* thread, frame fr) {
3133   frame activation;
3134   CompiledMethod* nm = NULL;
3135   int count = 1;
3136 
3137   assert(fr.is_java_frame(), "Must start on Java frame");
3138 
3139   while (true) {
3140     Method* method = NULL;
3141     if (fr.is_interpreted_frame()) {
3142       method = fr.interpreter_frame_method();
3143     } else {
3144       CodeBlob* cb = fr.cb();
3145       if (cb != NULL && cb->is_compiled()) {
3146         nm = cb->as_compiled_method();
3147         method = nm->method();
3148       }
3149     }
3150     if ((method != NULL) && method->has_reserved_stack_access()) {
3151       ResourceMark rm(thread);
3152       activation = fr;
3153       warning("Potentially dangerous stack overflow in "
3154               "ReservedStackAccess annotated method %s [%d]",
3155               method->name_and_sig_as_C_string(), count++);
3156       EventReservedStackActivation event;
3157       if (event.should_commit()) {
3158         event.set_method(method);
3159         event.commit();
3160       }
3161     }
3162     if (fr.is_first_java_frame()) {
3163       break;
3164     } else {
3165       fr = fr.java_sender();
3166     }
3167   }
3168   return activation;
3169 }
3170 


  44 #include "oops/klass.hpp"
  45 #include "oops/objArrayKlass.hpp"
  46 #include "oops/oop.inline.hpp"
  47 #include "prims/forte.hpp"
  48 #include "prims/jvmtiExport.hpp"
  49 #include "prims/methodHandles.hpp"
  50 #include "prims/nativeLookup.hpp"
  51 #include "runtime/arguments.hpp"
  52 #include "runtime/atomic.hpp"
  53 #include "runtime/biasedLocking.hpp"
  54 #include "runtime/compilationPolicy.hpp"
  55 #include "runtime/handles.inline.hpp"
  56 #include "runtime/init.hpp"
  57 #include "runtime/interfaceSupport.hpp"
  58 #include "runtime/java.hpp"
  59 #include "runtime/javaCalls.hpp"
  60 #include "runtime/sharedRuntime.hpp"
  61 #include "runtime/stubRoutines.hpp"
  62 #include "runtime/vframe.hpp"
  63 #include "runtime/vframeArray.hpp"

  64 #include "utilities/copy.hpp"
  65 #include "utilities/dtrace.hpp"
  66 #include "utilities/events.hpp"
  67 #include "utilities/hashtable.inline.hpp"
  68 #include "utilities/macros.hpp"
  69 #include "utilities/xmlstream.hpp"
  70 #ifdef COMPILER1
  71 #include "c1/c1_Runtime1.hpp"
  72 #endif
  73 #if INCLUDE_TRACE
  74 #include "trace/tracing.hpp"
  75 #endif
  76 
  77 // Shared stub locations
  78 RuntimeStub*        SharedRuntime::_wrong_method_blob;
  79 RuntimeStub*        SharedRuntime::_wrong_method_abstract_blob;
  80 RuntimeStub*        SharedRuntime::_ic_miss_blob;
  81 RuntimeStub*        SharedRuntime::_resolve_opt_virtual_call_blob;
  82 RuntimeStub*        SharedRuntime::_resolve_virtual_call_blob;
  83 RuntimeStub*        SharedRuntime::_resolve_static_call_blob;
  84 address             SharedRuntime::_resolve_static_call_entry;
  85 
  86 DeoptimizationBlob* SharedRuntime::_deopt_blob;
  87 SafepointBlob*      SharedRuntime::_polling_page_vectors_safepoint_handler_blob;
  88 SafepointBlob*      SharedRuntime::_polling_page_safepoint_handler_blob;
  89 SafepointBlob*      SharedRuntime::_polling_page_return_handler_blob;
  90 
  91 #ifdef COMPILER2
  92 UncommonTrapBlob*   SharedRuntime::_uncommon_trap_blob;
  93 #endif // COMPILER2
  94 
  95 


3114   _adapter_trampoline = (AdapterHandlerEntry**)MetaspaceShared::misc_data_space_alloc(sizeof(AdapterHandlerEntry*));
3115 };
3116 
3117 #endif // INCLUDE_CDS
3118 
3119 
3120 #ifndef PRODUCT
3121 
3122 void AdapterHandlerLibrary::print_statistics() {
3123   _adapters->print_statistics();
3124 }
3125 
3126 #endif /* PRODUCT */
3127 
3128 JRT_LEAF(void, SharedRuntime::enable_stack_reserved_zone(JavaThread* thread))
3129   assert(thread->is_Java_thread(), "Only Java threads have a stack reserved zone");
3130   thread->enable_stack_reserved_zone();
3131   thread->set_reserved_stack_activation(thread->stack_base());
3132 JRT_END
3133 
3134 #if INCLUDE_TRACE
3135 static void post_stack_reservation_event(const Method* method) {
3136   EventReservedStackActivation event;
3137   if (event.should_commit()) {
3138     event.set_method(method);
3139     event.commit();
3140   }
3141 }
3142 #endif
3143 
3144 frame SharedRuntime::look_for_reserved_stack_annotated_method(JavaThread* thread, frame fr) {
3145   frame activation;
3146   CompiledMethod* nm = NULL;
3147   int count = 1;
3148 
3149   assert(fr.is_java_frame(), "Must start on Java frame");
3150 
3151   while (true) {
3152     Method* method = NULL;
3153     if (fr.is_interpreted_frame()) {
3154       method = fr.interpreter_frame_method();
3155     } else {
3156       CodeBlob* cb = fr.cb();
3157       if (cb != NULL && cb->is_compiled()) {
3158         nm = cb->as_compiled_method();
3159         method = nm->method();
3160       }
3161     }
3162     if ((method != NULL) && method->has_reserved_stack_access()) {
3163       ResourceMark rm(thread);
3164       activation = fr;
3165       warning("Potentially dangerous stack overflow in "
3166               "ReservedStackAccess annotated method %s [%d]",
3167               method->name_and_sig_as_C_string(), count++);
3168       TRACE_ONLY(post_stack_reservation_event(method);)




3169     }
3170     if (fr.is_first_java_frame()) {
3171       break;
3172     } else {
3173       fr = fr.java_sender();
3174     }
3175   }
3176   return activation;
3177 }