6943485: JVMTI always on capabilities change code generation too much
authornever
Mon, 26 Apr 2010 23:59:45 -0700
changeset 5353 30f4b75f8005
parent 5352 cee8f7acb7bc
child 5354 30df1bf62cca
6943485: JVMTI always on capabilities change code generation too much Reviewed-by: twisti, dcubed
hotspot/src/share/vm/c1/c1_Compilation.cpp
hotspot/src/share/vm/c1/c1_Compilation.hpp
hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
hotspot/src/share/vm/c1/c1_LinearScan.cpp
hotspot/src/share/vm/c1/c1_globals.hpp
hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp
hotspot/src/share/vm/ci/ciEnv.cpp
hotspot/src/share/vm/ci/ciEnv.hpp
hotspot/src/share/vm/opto/c2compiler.cpp
hotspot/src/share/vm/opto/compile.cpp
hotspot/src/share/vm/opto/compile.hpp
hotspot/src/share/vm/opto/graphKit.cpp
hotspot/src/share/vm/prims/jvmtiExport.cpp
hotspot/src/share/vm/prims/jvmtiExport.hpp
hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp
--- a/hotspot/src/share/vm/c1/c1_Compilation.cpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/c1/c1_Compilation.cpp	Mon Apr 26 23:59:45 2010 -0700
@@ -316,7 +316,7 @@
     implicit_exception_table(),
     compiler(),
     _env->comp_level(),
-    needs_debug_information(),
+    true,
     has_unsafe_access()
   );
 }
@@ -449,8 +449,6 @@
   assert(_arena == NULL, "shouldn't only one instance of Compilation in existence at a time");
   _arena = Thread::current()->resource_area();
   _compilation = this;
-  _needs_debug_information = _env->jvmti_can_examine_or_deopt_anywhere() ||
-                               JavaMonitorsInStackTrace || AlwaysEmitDebugInfo || DeoptimizeALot;
   _exception_info_list = new ExceptionInfoList();
   _implicit_exception_table.set_size(0);
   compile_method();
--- a/hotspot/src/share/vm/c1/c1_Compilation.hpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/c1/c1_Compilation.hpp	Mon Apr 26 23:59:45 2010 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1999-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,7 +70,6 @@
   int                _max_spills;
   FrameMap*          _frame_map;
   C1_MacroAssembler* _masm;
-  bool               _needs_debug_information;
   bool               _has_exception_handlers;
   bool               _has_fpu_code;
   bool               _has_unsafe_access;
@@ -117,7 +116,6 @@
   // accessors
   ciEnv* env() const                             { return _env; }
   AbstractCompiler* compiler() const             { return _compiler; }
-  bool needs_debug_information() const           { return _needs_debug_information; }
   bool has_exception_handlers() const            { return _has_exception_handlers; }
   bool has_fpu_code() const                      { return _has_fpu_code; }
   bool has_unsafe_access() const                 { return _has_unsafe_access; }
@@ -132,7 +130,6 @@
   CodeOffsets* offsets()                         { return &_offsets; }
 
   // setters
-  void set_needs_debug_information(bool f)       { _needs_debug_information = f; }
   void set_has_exception_handlers(bool f)        { _has_exception_handlers = f; }
   void set_has_fpu_code(bool f)                  { _has_fpu_code = f; }
   void set_has_unsafe_access(bool f)             { _has_unsafe_access = f; }
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Mon Apr 26 23:59:45 2010 -0700
@@ -1493,7 +1493,6 @@
 
 Dependencies* GraphBuilder::dependency_recorder() const {
   assert(DeoptC1, "need debug information");
-  compilation()->set_needs_debug_information(true);
   return compilation()->dependency_recorder();
 }
 
--- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp	Mon Apr 26 23:59:45 2010 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2005-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2814,9 +2814,6 @@
 
 
 void LinearScan::compute_debug_info(CodeEmitInfo* info, int op_id) {
-  if (!compilation()->needs_debug_information()) {
-    return;
-  }
   TRACE_LINEAR_SCAN(3, tty->print_cr("creating debug information at op_id %d", op_id));
 
   IRScope* innermost_scope = info->scope();
--- a/hotspot/src/share/vm/c1/c1_globals.hpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/c1/c1_globals.hpp	Mon Apr 26 23:59:45 2010 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -252,9 +252,6 @@
   develop(bool, BailoutOnExceptionHandlers, false,                          \
           "bailout of compilation for methods with exception handlers")     \
                                                                             \
-  develop(bool, AlwaysEmitDebugInfo, false,                                 \
-          "always emit debug info")                                         \
-                                                                            \
   develop(bool, InstallMethods, true,                                       \
           "Install methods at the end of successful compilations")          \
                                                                             \
--- a/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp	Mon Apr 26 23:59:45 2010 -0700
@@ -1408,8 +1408,11 @@
 }
 
 void BCEscapeAnalyzer::copy_dependencies(Dependencies *deps) {
-  if(!has_dependencies())
-    return;
+  if (ciEnv::current()->jvmti_can_hotswap_or_post_breakpoint()) {
+    // Also record evol dependencies so redefinition of the
+    // callee will trigger recompilation.
+    deps->assert_evol_method(method());
+  }
   for (int i = 0; i < _dependencies.length(); i+=2) {
     ciKlass *k = _dependencies[i]->as_klass();
     ciMethod *m = _dependencies[i+1]->as_method();
--- a/hotspot/src/share/vm/ci/ciEnv.cpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/ci/ciEnv.cpp	Mon Apr 26 23:59:45 2010 -0700
@@ -176,7 +176,6 @@
   // 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_examine_or_deopt_anywhere  = JvmtiExport::can_examine_or_deopt_anywhere();
   _jvmti_can_access_local_variables     = JvmtiExport::can_access_local_variables();
   _jvmti_can_post_on_exceptions         = JvmtiExport::can_post_on_exceptions();
 }
@@ -887,8 +886,6 @@
     if (!failing() &&
         ( (!jvmti_can_hotswap_or_post_breakpoint() &&
            JvmtiExport::can_hotswap_or_post_breakpoint()) ||
-          (!jvmti_can_examine_or_deopt_anywhere() &&
-           JvmtiExport::can_examine_or_deopt_anywhere()) ||
           (!jvmti_can_access_local_variables() &&
            JvmtiExport::can_access_local_variables()) ||
           (!jvmti_can_post_on_exceptions() &&
--- a/hotspot/src/share/vm/ci/ciEnv.hpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/ci/ciEnv.hpp	Mon Apr 26 23:59:45 2010 -0700
@@ -55,7 +55,6 @@
 
   // Cache Jvmti state
   bool  _jvmti_can_hotswap_or_post_breakpoint;
-  bool  _jvmti_can_examine_or_deopt_anywhere;
   bool  _jvmti_can_access_local_variables;
   bool  _jvmti_can_post_on_exceptions;
 
@@ -257,7 +256,6 @@
   // Cache Jvmti state
   void  cache_jvmti_state();
   bool  jvmti_can_hotswap_or_post_breakpoint() const { return _jvmti_can_hotswap_or_post_breakpoint; }
-  bool  jvmti_can_examine_or_deopt_anywhere()  const { return _jvmti_can_examine_or_deopt_anywhere; }
   bool  jvmti_can_access_local_variables()     const { return _jvmti_can_access_local_variables; }
   bool  jvmti_can_post_on_exceptions()         const { return _jvmti_can_post_on_exceptions; }
 
--- a/hotspot/src/share/vm/opto/c2compiler.cpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp	Mon Apr 26 23:59:45 2010 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1999-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -105,8 +105,7 @@
   }
   bool subsume_loads = true;
   bool do_escape_analysis = DoEscapeAnalysis &&
-                            !(env->jvmti_can_hotswap_or_post_breakpoint() ||
-                              env->jvmti_can_examine_or_deopt_anywhere());
+    !env->jvmti_can_access_local_variables();
   while (!env->failing()) {
     // Attempt to compile while subsuming loads into machine instructions.
     Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis);
--- a/hotspot/src/share/vm/opto/compile.cpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/opto/compile.cpp	Mon Apr 26 23:59:45 2010 -0700
@@ -871,7 +871,6 @@
   set_has_split_ifs(false);
   set_has_loops(has_method() && method()->has_loops()); // first approximation
   set_has_stringbuilder(false);
-  _deopt_happens = true;  // start out assuming the worst
   _trap_can_recompile = false;  // no traps emitted yet
   _major_progress = true; // start out assuming good things will happen
   set_has_unsafe_access(false);
--- a/hotspot/src/share/vm/opto/compile.hpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/opto/compile.hpp	Mon Apr 26 23:59:45 2010 -0700
@@ -146,7 +146,6 @@
   int                   _orig_pc_slot_offset_in_bytes;
 
   int                   _major_progress;        // Count of something big happening
-  bool                  _deopt_happens;         // TRUE if de-optimization CAN happen
   bool                  _has_loops;             // True if the method _may_ have some loops
   bool                  _has_split_ifs;         // True if the method _may_ have some split-if
   bool                  _has_unsafe_access;     // True if the method _may_ produce faults in unsafe loads or stores.
@@ -300,7 +299,6 @@
   void          set_freq_inline_size(int n)     { _freq_inline_size = n; }
   int               freq_inline_size() const    { return _freq_inline_size; }
   void          set_max_inline_size(int n)      { _max_inline_size = n; }
-  bool              deopt_happens() const       { return _deopt_happens; }
   bool              has_loops() const           { return _has_loops; }
   void          set_has_loops(bool z)           { _has_loops = z; }
   bool              has_split_ifs() const       { return _has_split_ifs; }
--- a/hotspot/src/share/vm/opto/graphKit.cpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/opto/graphKit.cpp	Mon Apr 26 23:59:45 2010 -0700
@@ -812,10 +812,6 @@
 
   JVMState* youngest_jvms = sync_jvms();
 
-  // Do we need debug info here?  If it is a SafePoint and this method
-  // cannot de-opt, then we do NOT need any debug info.
-  bool full_info = (C->deopt_happens() || call->Opcode() != Op_SafePoint);
-
   // If we are guaranteed to throw, we can prune everything but the
   // input to the current bytecode.
   bool can_prune_locals = false;
@@ -829,10 +825,9 @@
     }
   }
 
-  if (env()->jvmti_can_examine_or_deopt_anywhere()) {
+  if (env()->jvmti_can_access_local_variables()) {
     // At any safepoint, this method can get breakpointed, which would
     // then require an immediate deoptimization.
-    full_info = true;
     can_prune_locals = false;  // do not prune locals
     stack_slots_not_pruned = 0;
   }
@@ -890,7 +885,7 @@
     k = in_jvms->locoff();
     l = in_jvms->loc_size();
     out_jvms->set_locoff(p);
-    if (full_info && !can_prune_locals) {
+    if (!can_prune_locals) {
       for (j = 0; j < l; j++)
         call->set_req(p++, in_map->in(k+j));
     } else {
@@ -901,7 +896,7 @@
     k = in_jvms->stkoff();
     l = in_jvms->sp();
     out_jvms->set_stkoff(p);
-    if (full_info && !can_prune_locals) {
+    if (!can_prune_locals) {
       for (j = 0; j < l; j++)
         call->set_req(p++, in_map->in(k+j));
     } else if (can_prune_locals && stack_slots_not_pruned != 0) {
--- a/hotspot/src/share/vm/prims/jvmtiExport.cpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp	Mon Apr 26 23:59:45 2010 -0700
@@ -270,7 +270,6 @@
 int               JvmtiExport::_field_modification_count                  = 0;
 
 bool              JvmtiExport::_can_access_local_variables                = false;
-bool              JvmtiExport::_can_examine_or_deopt_anywhere             = false;
 bool              JvmtiExport::_can_hotswap_or_post_breakpoint            = false;
 bool              JvmtiExport::_can_modify_any_class                      = false;
 bool              JvmtiExport::_can_walk_any_space                        = false;
--- a/hotspot/src/share/vm/prims/jvmtiExport.hpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiExport.hpp	Mon Apr 26 23:59:45 2010 -0700
@@ -58,7 +58,6 @@
   static int         _field_modification_count;
 
   static bool        _can_access_local_variables;
-  static bool        _can_examine_or_deopt_anywhere;
   static bool        _can_hotswap_or_post_breakpoint;
   static bool        _can_modify_any_class;
   static bool        _can_walk_any_space;
@@ -112,7 +111,6 @@
 
   // these should only be called by the friend class
   friend class JvmtiManageCapabilities;
-  inline static void set_can_examine_or_deopt_anywhere(bool on)        { _can_examine_or_deopt_anywhere = (on != 0); }
   inline static void set_can_modify_any_class(bool on)                 { _can_modify_any_class = (on != 0); }
   inline static void set_can_access_local_variables(bool on)           { _can_access_local_variables = (on != 0); }
   inline static void set_can_hotswap_or_post_breakpoint(bool on)       { _can_hotswap_or_post_breakpoint = (on != 0); }
@@ -220,7 +218,6 @@
   static void enter_live_phase();
 
   // ------ can_* conditions (below) are set at OnLoad and never changed ------------
-  inline static bool can_examine_or_deopt_anywhere()              { return _can_examine_or_deopt_anywhere; }
   inline static bool can_modify_any_class()                       { return _can_modify_any_class; }
   inline static bool can_access_local_variables()                 { return _can_access_local_variables; }
   inline static bool can_hotswap_or_post_breakpoint()             { return _can_hotswap_or_post_breakpoint; }
--- a/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp	Mon Apr 26 11:27:21 2010 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp	Mon Apr 26 23:59:45 2010 -0700
@@ -332,16 +332,6 @@
   }
 
   JvmtiExport::set_can_get_source_debug_extension(avail.can_get_source_debug_extension);
-  JvmtiExport::set_can_examine_or_deopt_anywhere(
-    avail.can_generate_breakpoint_events ||
-    interp_events ||
-    avail.can_redefine_classes ||
-    avail.can_retransform_classes ||
-    avail.can_access_local_variables ||
-    avail.can_get_owned_monitor_info ||
-    avail.can_get_current_contended_monitor ||
-    avail.can_get_monitor_info ||
-    avail.can_get_owned_monitor_stack_depth_info);
   JvmtiExport::set_can_maintain_original_method_order(avail.can_maintain_original_method_order);
   JvmtiExport::set_can_post_interpreter_events(interp_events);
   JvmtiExport::set_can_hotswap_or_post_breakpoint(
@@ -353,10 +343,13 @@
     avail.can_generate_all_class_hook_events);
   JvmtiExport::set_can_walk_any_space(
     avail.can_tag_objects);   // disable sharing in onload phase
+  // This controls whether the compilers keep extra locals live to
+  // improve the debugging experience so only set them if the selected
+  // capabilities look like a debugger.
   JvmtiExport::set_can_access_local_variables(
-    avail.can_access_local_variables  ||
-    avail.can_redefine_classes ||
-    avail.can_retransform_classes);
+    avail.can_access_local_variables ||
+    avail.can_generate_breakpoint_events ||
+    avail.can_generate_frame_pop_events);
   JvmtiExport::set_can_post_on_exceptions(
     avail.can_generate_exception_events ||
     avail.can_generate_frame_pop_events ||