src/share/vm/ci/ciInstanceKlass.hpp

Wed, 02 Jul 2008 12:55:16 -0700

author
xdono
date
Wed, 02 Jul 2008 12:55:16 -0700
changeset 631
d1605aabd0a1
parent 548
ba764ed4b6f2
child 1515
7c57aead6d3e
permissions
-rw-r--r--

6719955: Update copyright year
Summary: Update copyright year for files that have been modified in 2008
Reviewed-by: ohair, tbell

     1 /*
     2  * Copyright 1999-2008 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 // ciInstanceKlass
    26 //
    27 // This class represents a klassOop in the HotSpot virtual machine
    28 // whose Klass part is an instanceKlass.  It may or may not
    29 // be loaded.
    30 class ciInstanceKlass : public ciKlass {
    31   CI_PACKAGE_ACCESS
    32   friend class ciEnv;
    33   friend class ciMethod;
    34   friend class ciField;
    35   friend class ciBytecodeStream;
    37 private:
    38   jobject                _loader;
    39   jobject                _protection_domain;
    41   bool                   _is_shared;
    42   bool                   _is_initialized;
    43   bool                   _is_linked;
    44   bool                   _has_finalizer;
    45   bool                   _has_subklass;
    46   bool                   _has_nonstatic_fields;
    48   ciFlags                _flags;
    49   jint                   _nonstatic_field_size;
    50   jint                   _nonstatic_oop_map_size;
    52   // Lazy fields get filled in only upon request.
    53   ciInstanceKlass*       _super;
    54   ciInstance*            _java_mirror;
    56   ciConstantPoolCache*   _field_cache;  // cached map index->field
    57   GrowableArray<ciField*>* _nonstatic_fields;
    59   enum { implementors_limit = instanceKlass::implementors_limit };
    60   ciInstanceKlass*       _implementors[implementors_limit];
    61   jint                   _nof_implementors;
    63   GrowableArray<ciField*>* _non_static_fields;
    65 protected:
    66   ciInstanceKlass(KlassHandle h_k);
    67   ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain);
    69   instanceKlass* get_instanceKlass() const {
    70     return (instanceKlass*)get_Klass();
    71   }
    73   oop loader();
    74   jobject loader_handle();
    76   oop protection_domain();
    77   jobject protection_domain_handle();
    79   const char* type_string() { return "ciInstanceKlass"; }
    81   void print_impl(outputStream* st);
    83   ciConstantPoolCache* field_cache();
    85   bool is_shared() { return _is_shared; }
    87   bool compute_shared_is_initialized();
    88   bool compute_shared_is_linked();
    89   bool compute_shared_has_subklass();
    90   int  compute_shared_nof_implementors();
    91   int  compute_nonstatic_fields();
    92   GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
    94 public:
    95   // Has this klass been initialized?
    96   bool                   is_initialized() {
    97     if (_is_shared && !_is_initialized) {
    98       return is_loaded() && compute_shared_is_initialized();
    99     }
   100     return _is_initialized;
   101   }
   102   // Has this klass been linked?
   103   bool                   is_linked() {
   104     if (_is_shared && !_is_linked) {
   105       return is_loaded() && compute_shared_is_linked();
   106     }
   107     return _is_linked;
   108   }
   110   // General klass information.
   111   ciFlags                flags()          {
   112     assert(is_loaded(), "must be loaded");
   113     return _flags;
   114   }
   115   bool                   has_finalizer()  {
   116     assert(is_loaded(), "must be loaded");
   117     return _has_finalizer; }
   118   bool                   has_subklass()   {
   119     assert(is_loaded(), "must be loaded");
   120     if (_is_shared && !_has_subklass) {
   121       if (flags().is_final()) {
   122         return false;
   123       } else {
   124         return compute_shared_has_subklass();
   125       }
   126     }
   127     return _has_subklass;
   128   }
   129   jint                   size_helper()  {
   130     return (Klass::layout_helper_size_in_bytes(layout_helper())
   131             >> LogHeapWordSize);
   132   }
   133   jint                   nonstatic_field_size()  {
   134     assert(is_loaded(), "must be loaded");
   135     return _nonstatic_field_size; }
   136   jint                   has_nonstatic_fields()  {
   137     assert(is_loaded(), "must be loaded");
   138     return _has_nonstatic_fields; }
   139   jint                   nonstatic_oop_map_size()  {
   140     assert(is_loaded(), "must be loaded");
   141     return _nonstatic_oop_map_size; }
   142   ciInstanceKlass*       super();
   143   jint                   nof_implementors()  {
   144     assert(is_loaded(), "must be loaded");
   145     if (_is_shared)  return compute_shared_nof_implementors();
   146     return _nof_implementors;
   147   }
   149   ciInstanceKlass* get_canonical_holder(int offset);
   150   ciField* get_field_by_offset(int field_offset, bool is_static);
   152   GrowableArray<ciField*>* non_static_fields();
   154   // total number of nonstatic fields (including inherited):
   155   int nof_nonstatic_fields() {
   156     if (_nonstatic_fields == NULL)
   157       return compute_nonstatic_fields();
   158     else
   159       return _nonstatic_fields->length();
   160   }
   161   // nth nonstatic field (presented by ascending address)
   162   ciField* nonstatic_field_at(int i) {
   163     assert(_nonstatic_fields != NULL, "");
   164     return _nonstatic_fields->at(i);
   165   }
   167   ciInstanceKlass* unique_concrete_subklass();
   168   bool has_finalizable_subclass();
   170   bool contains_field_offset(int offset) {
   171     return instanceOopDesc::contains_field_offset(offset, nonstatic_field_size());
   172   }
   174   // Get the instance of java.lang.Class corresponding to
   175   // this klass.  This instance is used for locking of
   176   // synchronized static methods of this klass.
   177   ciInstance*            java_mirror();
   179   // Java access flags
   180   bool is_public      () { return flags().is_public(); }
   181   bool is_final       () { return flags().is_final(); }
   182   bool is_super       () { return flags().is_super(); }
   183   bool is_interface   () { return flags().is_interface(); }
   184   bool is_abstract    () { return flags().is_abstract(); }
   186   ciMethod* find_method(ciSymbol* name, ciSymbol* signature);
   187   // Note:  To find a method from name and type strings, use ciSymbol::make,
   188   // but consider adding to vmSymbols.hpp instead.
   190   bool is_leaf_type();
   191   ciInstanceKlass* implementor(int n);
   193   // Is the defining class loader of this class the default loader?
   194   bool uses_default_loader();
   196   bool is_java_lang_Object();
   198   // What kind of ciObject is this?
   199   bool is_instance_klass() { return true; }
   200   bool is_java_klass()     { return true; }
   201 };

mercurial