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

@@ -134,10 +134,15 @@
   _ArrayIndexOutOfBoundsException_instance = NULL;
   _ArrayStoreException_instance = NULL;
   _ClassCastException_instance = NULL;
   _the_null_string = NULL;
   _the_min_jint_string = NULL;
+
+  _jvmti_can_hotswap_or_post_breakpoint = false;
+  _jvmti_can_access_local_variables = false;
+  _jvmti_can_post_on_exceptions = false;
+  _jvmti_can_pop_frame = false;
 }
 
 ciEnv::ciEnv(Arena* arena) {
   ASSERT_IN_VM;
 

@@ -184,10 +189,15 @@
   _ArrayIndexOutOfBoundsException_instance = NULL;
   _ArrayStoreException_instance = NULL;
   _ClassCastException_instance = NULL;
   _the_null_string = NULL;
   _the_min_jint_string = NULL;
+
+  _jvmti_can_hotswap_or_post_breakpoint = false;
+  _jvmti_can_access_local_variables = false;
+  _jvmti_can_post_on_exceptions = false;
+  _jvmti_can_pop_frame = false;
 }
 
 ciEnv::~ciEnv() {
   CompilerThread* current_thread = CompilerThread::current();
   _factory->remove_symbols();

@@ -203,10 +213,35 @@
   // Get Jvmti capabilities under lock to get consistant values.
   MutexLocker mu(JvmtiThreadState_lock);
   _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint();
   _jvmti_can_access_local_variables     = JvmtiExport::can_access_local_variables();
   _jvmti_can_post_on_exceptions         = JvmtiExport::can_post_on_exceptions();
+  _jvmti_can_pop_frame                  = JvmtiExport::can_pop_frame();
+}
+
+bool ciEnv::should_retain_local_variables() const {
+  return _jvmti_can_access_local_variables || _jvmti_can_pop_frame;
+}
+
+bool ciEnv::jvmti_state_changed() const {
+  if (!_jvmti_can_access_local_variables &&
+    JvmtiExport::can_access_local_variables()) {
+      return true;
+  }
+  if (!_jvmti_can_hotswap_or_post_breakpoint &&
+    JvmtiExport::can_hotswap_or_post_breakpoint()) {
+      return true;
+  }
+  if (!_jvmti_can_post_on_exceptions &&
+    JvmtiExport::can_post_on_exceptions()) {
+      return true;
+  }
+  if (!_jvmti_can_pop_frame &&
+    JvmtiExport::can_pop_frame()) {
+      return true;
+  }
+  return false;
 }
 
 // ------------------------------------------------------------------
 // Cache DTrace flags
 void ciEnv::cache_dtrace_flags() {

@@ -938,17 +973,11 @@
     // No safepoints are allowed. Otherwise, class redefinition can occur in between.
     MutexLocker ml(Compile_lock);
     No_Safepoint_Verifier nsv;
 
     // Change in Jvmti state may invalidate compilation.
-    if (!failing() &&
-        ( (!jvmti_can_hotswap_or_post_breakpoint() &&
-           JvmtiExport::can_hotswap_or_post_breakpoint()) ||
-          (!jvmti_can_access_local_variables() &&
-           JvmtiExport::can_access_local_variables()) ||
-          (!jvmti_can_post_on_exceptions() &&
-           JvmtiExport::can_post_on_exceptions()) )) {
+    if (!failing() && jvmti_state_changed()) {
       record_failure("Jvmti state change invalidated dependencies");
     }
 
     // Change in DTrace flags may invalidate compilation.
     if (!failing() &&