src/share/vm/oops/compiledICHolder.hpp

Thu, 04 Apr 2019 17:56:29 +0800

author
aoqi
date
Thu, 04 Apr 2019 17:56:29 +0800
changeset 9572
624a0741915c
parent 9203
53eec13fbaa5
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     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  */
    25 #ifndef SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP
    26 #define SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP
    28 #include "oops/oop.hpp"
    29 #include "oops/klass.hpp"
    30 #include "oops/method.hpp"
    32 // A CompiledICHolder* is a helper object for the inline cache implementation.
    33 // It holds:
    34 //   (1) (method+klass pair) when converting from compiled to an interpreted call
    35 //   (2) (klass+klass pair) when calling itable stub from megamorphic compiled call
    36 //
    37 // These are always allocated in the C heap and are freed during a
    38 // safepoint by the ICBuffer logic.  It's unsafe to free them earlier
    39 // since they might be in use.
    40 //
    43 class CompiledICHolder : public CHeapObj<mtCompiler> {
    44   friend class VMStructs;
    45  private:
    46   static volatile int _live_count; // allocated
    47   static volatile int _live_not_claimed_count; // allocated but not yet in use so not
    48                                                // reachable by iterating over nmethods
    50   Metadata* _holder_metadata;
    51   Klass*    _holder_klass;    // to avoid name conflict with oopDesc::_klass
    52   CompiledICHolder* _next;
    53   bool _is_metadata_method;
    55  public:
    56   // Constructor
    57   CompiledICHolder(Metadata* metadata, Klass* klass, bool is_method = true)
    58       : _holder_metadata(metadata), _holder_klass(klass), _is_metadata_method(is_method) {
    59 #ifdef ASSERT
    60     Atomic::inc(&_live_count);
    61     Atomic::inc(&_live_not_claimed_count);
    62 #endif
    63   }
    65   ~CompiledICHolder() {
    66 #ifdef ASSERT
    67     assert(_live_count > 0, "underflow");
    68     Atomic::dec(&_live_count);
    69 #endif
    70   }
    72   static int live_count() { return _live_count; }
    73   static int live_not_claimed_count() { return _live_not_claimed_count; }
    75   // accessors
    76   Klass*    holder_klass()  const     { return _holder_klass; }
    77   Metadata* holder_metadata() const   { return _holder_metadata; }
    79   void set_holder_metadata(Metadata* m) { _holder_metadata = m; }
    80   void set_holder_klass(Klass* k)     { _holder_klass = k; }
    82   static int holder_metadata_offset() { return offset_of(CompiledICHolder, _holder_metadata); }
    83   static int holder_klass_offset()    { return offset_of(CompiledICHolder, _holder_klass); }
    85   CompiledICHolder* next()     { return _next; }
    86   void set_next(CompiledICHolder* n) { _next = n; }
    88   inline bool is_loader_alive(BoolObjectClosure* is_alive) {
    89     Klass* k = _is_metadata_method ? ((Method*)_holder_metadata)->method_holder() : (Klass*)_holder_metadata;
    90     if (!k->is_loader_alive(is_alive)) {
    91       return false;
    92     }
    93     if (!_holder_klass->is_loader_alive(is_alive)) {
    94       return false;
    95     }
    96     return true;
    97   }
    99   // Verify
   100   void verify_on(outputStream* st);
   102   // Printing
   103   void print_on(outputStream* st) const;
   104   void print_value_on(outputStream* st) const;
   106   const char* internal_name() const { return "{compiledICHolder}"; }
   108   void claim() {
   109 #ifdef ASSERT
   110     Atomic::dec(&_live_not_claimed_count);
   111 #endif
   112   }
   113 };
   115 #endif // SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP

mercurial