src/share/vm/ci/ciInstanceKlass.hpp

Wed, 06 Jan 2010 14:22:39 -0800

author
never
date
Wed, 06 Jan 2010 14:22:39 -0800
changeset 1577
4ce7240d622c
parent 1573
dd57230ba8fe
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6914300: ciEnv should export all well known classes
Reviewed-by: kvn, twisti

     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 ciBytecodeStream;
    33   friend class ciEnv;
    34   friend class ciExceptionHandler;
    35   friend class ciMethod;
    36   friend class ciField;
    38 private:
    39   jobject                _loader;
    40   jobject                _protection_domain;
    42   bool                   _is_shared;
    43   bool                   _is_initialized;
    44   bool                   _is_linked;
    45   bool                   _has_finalizer;
    46   bool                   _has_subklass;
    47   bool                   _has_nonstatic_fields;
    49   ciFlags                _flags;
    50   jint                   _nonstatic_field_size;
    51   jint                   _nonstatic_oop_map_size;
    53   // Lazy fields get filled in only upon request.
    54   ciInstanceKlass*       _super;
    55   ciInstance*            _java_mirror;
    57   ciConstantPoolCache*   _field_cache;  // cached map index->field
    58   GrowableArray<ciField*>* _nonstatic_fields;
    60   enum { implementors_limit = instanceKlass::implementors_limit };
    61   ciInstanceKlass*       _implementors[implementors_limit];
    62   jint                   _nof_implementors;
    64   GrowableArray<ciField*>* _non_static_fields;
    66 protected:
    67   ciInstanceKlass(KlassHandle h_k);
    68   ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain);
    70   instanceKlass* get_instanceKlass() const {
    71     return (instanceKlass*)get_Klass();
    72   }
    74   oop loader();
    75   jobject loader_handle();
    77   oop protection_domain();
    78   jobject protection_domain_handle();
    80   const char* type_string() { return "ciInstanceKlass"; }
    82   bool is_in_package_impl(const char* packagename, int len);
    84   void print_impl(outputStream* st);
    86   ciConstantPoolCache* field_cache();
    88   bool is_shared() { return _is_shared; }
    90   bool compute_shared_is_initialized();
    91   bool compute_shared_is_linked();
    92   bool compute_shared_has_subklass();
    93   int  compute_shared_nof_implementors();
    94   int  compute_nonstatic_fields();
    95   GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
    97 public:
    98   // Has this klass been initialized?
    99   bool                   is_initialized() {
   100     if (_is_shared && !_is_initialized) {
   101       return is_loaded() && compute_shared_is_initialized();
   102     }
   103     return _is_initialized;
   104   }
   105   // Has this klass been linked?
   106   bool                   is_linked() {
   107     if (_is_shared && !_is_linked) {
   108       return is_loaded() && compute_shared_is_linked();
   109     }
   110     return _is_linked;
   111   }
   113   // General klass information.
   114   ciFlags                flags()          {
   115     assert(is_loaded(), "must be loaded");
   116     return _flags;
   117   }
   118   bool                   has_finalizer()  {
   119     assert(is_loaded(), "must be loaded");
   120     return _has_finalizer; }
   121   bool                   has_subklass()   {
   122     assert(is_loaded(), "must be loaded");
   123     if (_is_shared && !_has_subklass) {
   124       if (flags().is_final()) {
   125         return false;
   126       } else {
   127         return compute_shared_has_subklass();
   128       }
   129     }
   130     return _has_subklass;
   131   }
   132   jint                   size_helper()  {
   133     return (Klass::layout_helper_size_in_bytes(layout_helper())
   134             >> LogHeapWordSize);
   135   }
   136   jint                   nonstatic_field_size()  {
   137     assert(is_loaded(), "must be loaded");
   138     return _nonstatic_field_size; }
   139   jint                   has_nonstatic_fields()  {
   140     assert(is_loaded(), "must be loaded");
   141     return _has_nonstatic_fields; }
   142   jint                   nonstatic_oop_map_size()  {
   143     assert(is_loaded(), "must be loaded");
   144     return _nonstatic_oop_map_size; }
   145   ciInstanceKlass*       super();
   146   jint                   nof_implementors()  {
   147     assert(is_loaded(), "must be loaded");
   148     if (_is_shared)  return compute_shared_nof_implementors();
   149     return _nof_implementors;
   150   }
   152   ciInstanceKlass* get_canonical_holder(int offset);
   153   ciField* get_field_by_offset(int field_offset, bool is_static);
   154   ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);
   156   GrowableArray<ciField*>* non_static_fields();
   158   // total number of nonstatic fields (including inherited):
   159   int nof_nonstatic_fields() {
   160     if (_nonstatic_fields == NULL)
   161       return compute_nonstatic_fields();
   162     else
   163       return _nonstatic_fields->length();
   164   }
   165   // nth nonstatic field (presented by ascending address)
   166   ciField* nonstatic_field_at(int i) {
   167     assert(_nonstatic_fields != NULL, "");
   168     return _nonstatic_fields->at(i);
   169   }
   171   ciInstanceKlass* unique_concrete_subklass();
   172   bool has_finalizable_subclass();
   174   bool contains_field_offset(int offset) {
   175     return instanceOopDesc::contains_field_offset(offset, nonstatic_field_size());
   176   }
   178   // Get the instance of java.lang.Class corresponding to
   179   // this klass.  This instance is used for locking of
   180   // synchronized static methods of this klass.
   181   ciInstance*            java_mirror();
   183   // Java access flags
   184   bool is_public      () { return flags().is_public(); }
   185   bool is_final       () { return flags().is_final(); }
   186   bool is_super       () { return flags().is_super(); }
   187   bool is_interface   () { return flags().is_interface(); }
   188   bool is_abstract    () { return flags().is_abstract(); }
   190   ciMethod* find_method(ciSymbol* name, ciSymbol* signature);
   191   // Note:  To find a method from name and type strings, use ciSymbol::make,
   192   // but consider adding to vmSymbols.hpp instead.
   194   bool is_leaf_type();
   195   ciInstanceKlass* implementor(int n);
   197   // Is the defining class loader of this class the default loader?
   198   bool uses_default_loader();
   200   bool is_java_lang_Object();
   202   // Is this klass in the given package?
   203   bool is_in_package(const char* packagename) {
   204     return is_in_package(packagename, (int) strlen(packagename));
   205   }
   206   bool is_in_package(const char* packagename, int len);
   208   // What kind of ciObject is this?
   209   bool is_instance_klass() { return true; }
   210   bool is_java_klass()     { return true; }
   211 };

mercurial