src/share/vm/oops/compiledICHolder.hpp

Print this page
rev 6521 : 8044775: Improve usage of umbrella header atomic.inline.hpp.


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP
  26 #define SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP
  27 
  28 #include "oops/oop.hpp"

  29 
  30 // A CompiledICHolder* is a helper object for the inline cache implementation.
  31 // It holds an intermediate value (method+klass pair) used when converting from
  32 // compiled to an interpreted call.
  33 //
  34 // These are always allocated in the C heap and are freed during a
  35 // safepoint by the ICBuffer logic.  It's unsafe to free them earlier
  36 // since they might be in use.
  37 //
  38 
  39 
  40 class CompiledICHolder : public CHeapObj<mtCompiler> {
  41   friend class VMStructs;
  42  private:
  43   static volatile int _live_count; // allocated
  44   static volatile int _live_not_claimed_count; // allocated but not yet in use so not
  45                                                // reachable by iterating over nmethods
  46 
  47   Method* _holder_method;
  48   Klass*    _holder_klass;    // to avoid name conflict with oopDesc::_klass
  49   CompiledICHolder* _next;
  50 
  51  public:
  52   // Constructor
  53   CompiledICHolder(Method* method, Klass* klass)
  54       : _holder_method(method), _holder_klass(klass) {
  55 #ifdef ASSERT
  56     Atomic::inc(&_live_count);
  57     Atomic::inc(&_live_not_claimed_count);


  58 #endif
  59   }
  60 
  61   ~CompiledICHolder() {
  62 #ifdef ASSERT
  63     assert(_live_count > 0, "underflow");
  64     Atomic::dec(&_live_count);
  65 #endif
  66   }
  67 
  68   static int live_count() { return _live_count; }
  69   static int live_not_claimed_count() { return _live_not_claimed_count; }
  70 
  71   // accessors
  72   Method* holder_method() const     { return _holder_method; }
  73   Klass*    holder_klass()  const     { return _holder_klass; }
  74 
  75   void set_holder_method(Method* m) { _holder_method = m; }
  76   void set_holder_klass(Klass* k)   { _holder_klass = k; }
  77 
  78   // interpreter support (offsets in bytes)
  79   static int holder_method_offset()   { return offset_of(CompiledICHolder, _holder_method); }
  80   static int holder_klass_offset()    { return offset_of(CompiledICHolder, _holder_klass); }
  81 
  82   CompiledICHolder* next()     { return _next; }
  83   void set_next(CompiledICHolder* n) { _next = n; }
  84 
  85   // Verify
  86   void verify_on(outputStream* st);
  87 
  88   // Printing
  89   void print_on(outputStream* st) const;
  90   void print_value_on(outputStream* st) const;
  91 
  92   const char* internal_name() const { return "{compiledICHolder}"; }
  93 
  94   void claim() {
  95 #ifdef ASSERT
  96     Atomic::dec(&_live_not_claimed_count);
  97 #endif
  98   }
  99 };
 100 
 101 #endif // SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP
  26 #define SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP
  27 
  28 #include "oops/oop.hpp"
  29 #include "utilities/macros.hpp"
  30 
  31 // A CompiledICHolder* is a helper object for the inline cache implementation.
  32 // It holds an intermediate value (method+klass pair) used when converting from
  33 // compiled to an interpreted call.
  34 //
  35 // These are always allocated in the C heap and are freed during a
  36 // safepoint by the ICBuffer logic.  It's unsafe to free them earlier
  37 // since they might be in use.
  38 //
  39 
  40 
  41 class CompiledICHolder : public CHeapObj<mtCompiler> {
  42   friend class VMStructs;
  43  private:
  44   static volatile int _live_count; // allocated
  45   static volatile int _live_not_claimed_count; // allocated but not yet in use so not
  46                                                // reachable by iterating over nmethods
  47 
  48   Method* _holder_method;
  49   Klass*    _holder_klass;    // to avoid name conflict with oopDesc::_klass
  50   CompiledICHolder* _next;
  51 
  52  public:
  53   // Constructor


  54 #ifdef ASSERT
  55   CompiledICHolder(Method* method, Klass* klass);
  56 #else
  57   CompiledICHolder(Method* method, Klass* klass)
  58     : _holder_method(method), _holder_klass(klass) {};
  59 #endif

  60 
  61   ~CompiledICHolder() NOT_DEBUG_RETURN;





  62 
  63   static int live_count() { return _live_count; }
  64   static int live_not_claimed_count() { return _live_not_claimed_count; }
  65 
  66   // accessors
  67   Method* holder_method() const     { return _holder_method; }
  68   Klass*    holder_klass()  const     { return _holder_klass; }
  69 
  70   void set_holder_method(Method* m) { _holder_method = m; }
  71   void set_holder_klass(Klass* k)   { _holder_klass = k; }
  72 
  73   // interpreter support (offsets in bytes)
  74   static int holder_method_offset()   { return offset_of(CompiledICHolder, _holder_method); }
  75   static int holder_klass_offset()    { return offset_of(CompiledICHolder, _holder_klass); }
  76 
  77   CompiledICHolder* next()     { return _next; }
  78   void set_next(CompiledICHolder* n) { _next = n; }
  79 
  80   // Verify
  81   void verify_on(outputStream* st);
  82 
  83   // Printing
  84   void print_on(outputStream* st) const;
  85   void print_value_on(outputStream* st) const;
  86 
  87   const char* internal_name() const { return "{compiledICHolder}"; }
  88 
  89   void claim() NOT_DEBUG_RETURN;




  90 };
  91 
  92 #endif // SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP