src/share/vm/ci/ciEnv.cpp

Print this page
rev 5933 : 8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
Reviewed-by: kvn, sla, coleenp


 119   // Preload commonly referenced system ciObjects.
 120 
 121   // During VM initialization, these instances have not yet been created.
 122   // Assertions ensure that these instances are not accessed before
 123   // their initialization.
 124 
 125   assert(Universe::is_fully_initialized(), "should be complete");
 126 
 127   oop o = Universe::null_ptr_exception_instance();
 128   assert(o != NULL, "should have been initialized");
 129   _NullPointerException_instance = get_object(o)->as_instance();
 130   o = Universe::arithmetic_exception_instance();
 131   assert(o != NULL, "should have been initialized");
 132   _ArithmeticException_instance = get_object(o)->as_instance();
 133 
 134   _ArrayIndexOutOfBoundsException_instance = NULL;
 135   _ArrayStoreException_instance = NULL;
 136   _ClassCastException_instance = NULL;
 137   _the_null_string = NULL;
 138   _the_min_jint_string = NULL;





 139 }
 140 
 141 ciEnv::ciEnv(Arena* arena) {
 142   ASSERT_IN_VM;
 143 
 144   // Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc.
 145   CompilerThread* current_thread = CompilerThread::current();
 146   assert(current_thread->env() == NULL, "must be");
 147   current_thread->set_env(this);
 148   assert(ciEnv::current() == this, "sanity");
 149 
 150   _oop_recorder = NULL;
 151   _debug_info = NULL;
 152   _dependencies = NULL;
 153   _failure_reason = NULL;
 154   _compilable = MethodCompilable_never;
 155   _break_at_compile = false;
 156   _compiler_data = NULL;
 157 #ifndef PRODUCT
 158   assert(firstEnv, "must be first");


 169   _name_buffer_len = 0;
 170 
 171   _arena   = arena;
 172   _factory = new (_arena) ciObjectFactory(_arena, 128);
 173 
 174   // Preload commonly referenced system ciObjects.
 175 
 176   // During VM initialization, these instances have not yet been created.
 177   // Assertions ensure that these instances are not accessed before
 178   // their initialization.
 179 
 180   assert(Universe::is_fully_initialized(), "must be");
 181 
 182   _NullPointerException_instance = NULL;
 183   _ArithmeticException_instance = NULL;
 184   _ArrayIndexOutOfBoundsException_instance = NULL;
 185   _ArrayStoreException_instance = NULL;
 186   _ClassCastException_instance = NULL;
 187   _the_null_string = NULL;
 188   _the_min_jint_string = NULL;





 189 }
 190 
 191 ciEnv::~ciEnv() {
 192   CompilerThread* current_thread = CompilerThread::current();
 193   _factory->remove_symbols();
 194   // Need safepoint to clear the env on the thread.  RedefineClasses might
 195   // be reading it.
 196   GUARDED_VM_ENTRY(current_thread->set_env(NULL);)
 197 }
 198 
 199 // ------------------------------------------------------------------
 200 // Cache Jvmti state
 201 void ciEnv::cache_jvmti_state() {
 202   VM_ENTRY_MARK;
 203   // Get Jvmti capabilities under lock to get consistant values.
 204   MutexLocker mu(JvmtiThreadState_lock);
 205   _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint();
 206   _jvmti_can_access_local_variables     = JvmtiExport::can_access_local_variables();
 207   _jvmti_can_post_on_exceptions         = JvmtiExport::can_post_on_exceptions();

























 208 }
 209 
 210 // ------------------------------------------------------------------
 211 // Cache DTrace flags
 212 void ciEnv::cache_dtrace_flags() {
 213   // Need lock?
 214   _dtrace_extended_probes = ExtendedDTraceProbes;
 215   if (_dtrace_extended_probes) {
 216     _dtrace_monitor_probes  = true;
 217     _dtrace_method_probes   = true;
 218     _dtrace_alloc_probes    = true;
 219   } else {
 220     _dtrace_monitor_probes  = DTraceMonitorProbes;
 221     _dtrace_method_probes   = DTraceMethodProbes;
 222     _dtrace_alloc_probes    = DTraceAllocProbes;
 223   }
 224 }
 225 
 226 // ------------------------------------------------------------------
 227 // helper for lazy exception creation


 923                             OopMapSet* oop_map_set,
 924                             ExceptionHandlerTable* handler_table,
 925                             ImplicitExceptionTable* inc_table,
 926                             AbstractCompiler* compiler,
 927                             int comp_level,
 928                             bool has_unsafe_access,
 929                             bool has_wide_vectors) {
 930   VM_ENTRY_MARK;
 931   nmethod* nm = NULL;
 932   {
 933     // To prevent compile queue updates.
 934     MutexLocker locker(MethodCompileQueue_lock, THREAD);
 935 
 936     // Prevent SystemDictionary::add_to_hierarchy from running
 937     // and invalidating our dependencies until we install this method.
 938     // No safepoints are allowed. Otherwise, class redefinition can occur in between.
 939     MutexLocker ml(Compile_lock);
 940     No_Safepoint_Verifier nsv;
 941 
 942     // Change in Jvmti state may invalidate compilation.
 943     if (!failing() &&
 944         ( (!jvmti_can_hotswap_or_post_breakpoint() &&
 945            JvmtiExport::can_hotswap_or_post_breakpoint()) ||
 946           (!jvmti_can_access_local_variables() &&
 947            JvmtiExport::can_access_local_variables()) ||
 948           (!jvmti_can_post_on_exceptions() &&
 949            JvmtiExport::can_post_on_exceptions()) )) {
 950       record_failure("Jvmti state change invalidated dependencies");
 951     }
 952 
 953     // Change in DTrace flags may invalidate compilation.
 954     if (!failing() &&
 955         ( (!dtrace_extended_probes() && ExtendedDTraceProbes) ||
 956           (!dtrace_method_probes() && DTraceMethodProbes) ||
 957           (!dtrace_alloc_probes() && DTraceAllocProbes) )) {
 958       record_failure("DTrace flags change invalidated dependencies");
 959     }
 960 
 961     if (!failing()) {
 962       if (log() != NULL) {
 963         // Log the dependencies which this compilation declares.
 964         dependencies()->log_all_dependencies();
 965       }
 966 
 967       // Encode the dependencies now, so we can check them right away.
 968       dependencies()->encode_content_bytes();
 969 




 119   // Preload commonly referenced system ciObjects.
 120 
 121   // During VM initialization, these instances have not yet been created.
 122   // Assertions ensure that these instances are not accessed before
 123   // their initialization.
 124 
 125   assert(Universe::is_fully_initialized(), "should be complete");
 126 
 127   oop o = Universe::null_ptr_exception_instance();
 128   assert(o != NULL, "should have been initialized");
 129   _NullPointerException_instance = get_object(o)->as_instance();
 130   o = Universe::arithmetic_exception_instance();
 131   assert(o != NULL, "should have been initialized");
 132   _ArithmeticException_instance = get_object(o)->as_instance();
 133 
 134   _ArrayIndexOutOfBoundsException_instance = NULL;
 135   _ArrayStoreException_instance = NULL;
 136   _ClassCastException_instance = NULL;
 137   _the_null_string = NULL;
 138   _the_min_jint_string = NULL;
 139 
 140   _jvmti_can_hotswap_or_post_breakpoint = false;
 141   _jvmti_can_access_local_variables = false;
 142   _jvmti_can_post_on_exceptions = false;
 143   _jvmti_can_pop_frame = false;
 144 }
 145 
 146 ciEnv::ciEnv(Arena* arena) {
 147   ASSERT_IN_VM;
 148 
 149   // Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc.
 150   CompilerThread* current_thread = CompilerThread::current();
 151   assert(current_thread->env() == NULL, "must be");
 152   current_thread->set_env(this);
 153   assert(ciEnv::current() == this, "sanity");
 154 
 155   _oop_recorder = NULL;
 156   _debug_info = NULL;
 157   _dependencies = NULL;
 158   _failure_reason = NULL;
 159   _compilable = MethodCompilable_never;
 160   _break_at_compile = false;
 161   _compiler_data = NULL;
 162 #ifndef PRODUCT
 163   assert(firstEnv, "must be first");


 174   _name_buffer_len = 0;
 175 
 176   _arena   = arena;
 177   _factory = new (_arena) ciObjectFactory(_arena, 128);
 178 
 179   // Preload commonly referenced system ciObjects.
 180 
 181   // During VM initialization, these instances have not yet been created.
 182   // Assertions ensure that these instances are not accessed before
 183   // their initialization.
 184 
 185   assert(Universe::is_fully_initialized(), "must be");
 186 
 187   _NullPointerException_instance = NULL;
 188   _ArithmeticException_instance = NULL;
 189   _ArrayIndexOutOfBoundsException_instance = NULL;
 190   _ArrayStoreException_instance = NULL;
 191   _ClassCastException_instance = NULL;
 192   _the_null_string = NULL;
 193   _the_min_jint_string = NULL;
 194 
 195   _jvmti_can_hotswap_or_post_breakpoint = false;
 196   _jvmti_can_access_local_variables = false;
 197   _jvmti_can_post_on_exceptions = false;
 198   _jvmti_can_pop_frame = false;
 199 }
 200 
 201 ciEnv::~ciEnv() {
 202   CompilerThread* current_thread = CompilerThread::current();
 203   _factory->remove_symbols();
 204   // Need safepoint to clear the env on the thread.  RedefineClasses might
 205   // be reading it.
 206   GUARDED_VM_ENTRY(current_thread->set_env(NULL);)
 207 }
 208 
 209 // ------------------------------------------------------------------
 210 // Cache Jvmti state
 211 void ciEnv::cache_jvmti_state() {
 212   VM_ENTRY_MARK;
 213   // Get Jvmti capabilities under lock to get consistant values.
 214   MutexLocker mu(JvmtiThreadState_lock);
 215   _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint();
 216   _jvmti_can_access_local_variables     = JvmtiExport::can_access_local_variables();
 217   _jvmti_can_post_on_exceptions         = JvmtiExport::can_post_on_exceptions();
 218   _jvmti_can_pop_frame                  = JvmtiExport::can_pop_frame();
 219 }
 220 
 221 bool ciEnv::should_retain_local_variables() const {
 222   return _jvmti_can_access_local_variables || _jvmti_can_pop_frame;
 223 }
 224 
 225 bool ciEnv::jvmti_state_changed() const {
 226   if (!_jvmti_can_access_local_variables &&
 227     JvmtiExport::can_access_local_variables()) {
 228       return true;
 229   }
 230   if (!_jvmti_can_hotswap_or_post_breakpoint &&
 231     JvmtiExport::can_hotswap_or_post_breakpoint()) {
 232       return true;
 233   }
 234   if (!_jvmti_can_post_on_exceptions &&
 235     JvmtiExport::can_post_on_exceptions()) {
 236       return true;
 237   }
 238   if (!_jvmti_can_pop_frame &&
 239     JvmtiExport::can_pop_frame()) {
 240       return true;
 241   }
 242   return false;
 243 }
 244 
 245 // ------------------------------------------------------------------
 246 // Cache DTrace flags
 247 void ciEnv::cache_dtrace_flags() {
 248   // Need lock?
 249   _dtrace_extended_probes = ExtendedDTraceProbes;
 250   if (_dtrace_extended_probes) {
 251     _dtrace_monitor_probes  = true;
 252     _dtrace_method_probes   = true;
 253     _dtrace_alloc_probes    = true;
 254   } else {
 255     _dtrace_monitor_probes  = DTraceMonitorProbes;
 256     _dtrace_method_probes   = DTraceMethodProbes;
 257     _dtrace_alloc_probes    = DTraceAllocProbes;
 258   }
 259 }
 260 
 261 // ------------------------------------------------------------------
 262 // helper for lazy exception creation


 958                             OopMapSet* oop_map_set,
 959                             ExceptionHandlerTable* handler_table,
 960                             ImplicitExceptionTable* inc_table,
 961                             AbstractCompiler* compiler,
 962                             int comp_level,
 963                             bool has_unsafe_access,
 964                             bool has_wide_vectors) {
 965   VM_ENTRY_MARK;
 966   nmethod* nm = NULL;
 967   {
 968     // To prevent compile queue updates.
 969     MutexLocker locker(MethodCompileQueue_lock, THREAD);
 970 
 971     // Prevent SystemDictionary::add_to_hierarchy from running
 972     // and invalidating our dependencies until we install this method.
 973     // No safepoints are allowed. Otherwise, class redefinition can occur in between.
 974     MutexLocker ml(Compile_lock);
 975     No_Safepoint_Verifier nsv;
 976 
 977     // Change in Jvmti state may invalidate compilation.
 978     if (!failing() && jvmti_state_changed()) {






 979       record_failure("Jvmti state change invalidated dependencies");
 980     }
 981 
 982     // Change in DTrace flags may invalidate compilation.
 983     if (!failing() &&
 984         ( (!dtrace_extended_probes() && ExtendedDTraceProbes) ||
 985           (!dtrace_method_probes() && DTraceMethodProbes) ||
 986           (!dtrace_alloc_probes() && DTraceAllocProbes) )) {
 987       record_failure("DTrace flags change invalidated dependencies");
 988     }
 989 
 990     if (!failing()) {
 991       if (log() != NULL) {
 992         // Log the dependencies which this compilation declares.
 993         dependencies()->log_all_dependencies();
 994       }
 995 
 996       // Encode the dependencies now, so we can check them right away.
 997       dependencies()->encode_content_bytes();
 998