src/share/vm/oops/arrayKlass.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/oops/arrayKlass.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,158 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_OOPS_ARRAYKLASS_HPP
    1.29 +#define SHARE_VM_OOPS_ARRAYKLASS_HPP
    1.30 +
    1.31 +#include "memory/universe.hpp"
    1.32 +#include "oops/klass.hpp"
    1.33 +
    1.34 +class fieldDescriptor;
    1.35 +class klassVtable;
    1.36 +
    1.37 +// ArrayKlass is the abstract baseclass for all array classes
    1.38 +
    1.39 +class ArrayKlass: public Klass {
    1.40 +  friend class VMStructs;
    1.41 + private:
    1.42 +  int      _dimension;         // This is n'th-dimensional array.
    1.43 +  Klass* volatile _higher_dimension;  // Refers the (n+1)'th-dimensional array (if present).
    1.44 +  Klass* volatile _lower_dimension;   // Refers the (n-1)'th-dimensional array (if present).
    1.45 +  int      _vtable_len;        // size of vtable for this klass
    1.46 +  oop      _component_mirror;  // component type, as a java/lang/Class
    1.47 +
    1.48 + protected:
    1.49 +  // Constructors
    1.50 +  // The constructor with the Symbol argument does the real array
    1.51 +  // initialization, the other is a dummy
    1.52 +  ArrayKlass(Symbol* name);
    1.53 +  ArrayKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for cds"); }
    1.54 +
    1.55 + public:
    1.56 +  // Testing operation
    1.57 +  bool oop_is_array_slow() const { return true; }
    1.58 +
    1.59 +  // Instance variables
    1.60 +  int dimension() const                 { return _dimension;      }
    1.61 +  void set_dimension(int dimension)     { _dimension = dimension; }
    1.62 +
    1.63 +  Klass* higher_dimension() const     { return _higher_dimension; }
    1.64 +  void set_higher_dimension(Klass* k) { _higher_dimension = k; }
    1.65 +  Klass** adr_higher_dimension()      { return (Klass**)&this->_higher_dimension;}
    1.66 +
    1.67 +  Klass* lower_dimension() const      { return _lower_dimension; }
    1.68 +  void set_lower_dimension(Klass* k)  { _lower_dimension = k; }
    1.69 +  Klass** adr_lower_dimension()       { return (Klass**)&this->_lower_dimension;}
    1.70 +
    1.71 +  // offset of first element, including any padding for the sake of alignment
    1.72 +  int  array_header_in_bytes() const    { return layout_helper_header_size(layout_helper()); }
    1.73 +  int  log2_element_size() const        { return layout_helper_log2_element_size(layout_helper()); }
    1.74 +  // type of elements (T_OBJECT for both oop arrays and array-arrays)
    1.75 +  BasicType element_type() const        { return layout_helper_element_type(layout_helper()); }
    1.76 +
    1.77 +  oop  component_mirror() const         { return _component_mirror; }
    1.78 +  void set_component_mirror(oop m)      { klass_oop_store(&_component_mirror, m); }
    1.79 +  oop* adr_component_mirror()           { return (oop*)&this->_component_mirror;}
    1.80 +
    1.81 +  // Compiler/Interpreter offset
    1.82 +  static ByteSize component_mirror_offset() { return in_ByteSize(offset_of(ArrayKlass, _component_mirror)); }
    1.83 +
    1.84 +  virtual Klass* java_super() const;//{ return SystemDictionary::Object_klass(); }
    1.85 +
    1.86 +  // Allocation
    1.87 +  // Sizes points to the first dimension of the array, subsequent dimensions
    1.88 +  // are always in higher memory.  The callers of these set that up.
    1.89 +  virtual oop multi_allocate(int rank, jint* sizes, TRAPS);
    1.90 +  objArrayOop allocate_arrayArray(int n, int length, TRAPS);
    1.91 +
    1.92 +  // find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined
    1.93 +  Klass* find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
    1.94 +
    1.95 +  // Lookup operations
    1.96 +  Method* uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const;
    1.97 +
    1.98 +  // Casting from Klass*
    1.99 +  static ArrayKlass* cast(Klass* k) {
   1.100 +    assert(k->oop_is_array(), "cast to ArrayKlass");
   1.101 +    return (ArrayKlass*) k;
   1.102 +  }
   1.103 +
   1.104 +  GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots);
   1.105 +  bool compute_is_subtype_of(Klass* k);
   1.106 +
   1.107 +  // Sizing
   1.108 +  static int header_size()                 { return sizeof(ArrayKlass)/HeapWordSize; }
   1.109 +  static int static_size(int header_size);
   1.110 +
   1.111 +#if INCLUDE_SERVICES
   1.112 +  virtual void collect_statistics(KlassSizeStats *sz) const {
   1.113 +    Klass::collect_statistics(sz);
   1.114 +    // Do nothing for now, but remember to modify if you add new
   1.115 +    // stuff to ArrayKlass.
   1.116 +  }
   1.117 +#endif
   1.118 +
   1.119 +  // Java vtable
   1.120 +  klassVtable* vtable() const;             // return new klassVtable
   1.121 +  int  vtable_length() const               { return _vtable_len; }
   1.122 +  static int base_vtable_length()          { return Universe::base_vtable_size(); }
   1.123 +  void set_vtable_length(int len)          { assert(len == base_vtable_length(), "bad length"); _vtable_len = len; }
   1.124 + protected:
   1.125 +  inline intptr_t* start_of_vtable() const;
   1.126 +
   1.127 + public:
   1.128 +  // Iterators
   1.129 +  void array_klasses_do(void f(Klass* k));
   1.130 +  void array_klasses_do(void f(Klass* k, TRAPS), TRAPS);
   1.131 +
   1.132 +  // GC support
   1.133 +  virtual void oops_do(OopClosure* cl);
   1.134 +
   1.135 +  // Return a handle.
   1.136 +  static void     complete_create_array_klass(ArrayKlass* k, KlassHandle super_klass, TRAPS);
   1.137 +
   1.138 +
   1.139 +  // jvm support
   1.140 +  jint compute_modifier_flags(TRAPS) const;
   1.141 +
   1.142 +  // JVMTI support
   1.143 +  jint jvmti_class_status() const;
   1.144 +
   1.145 +  // CDS support - remove and restore oops from metadata. Oops are not shared.
   1.146 +  virtual void remove_unshareable_info();
   1.147 +  virtual void restore_unshareable_info(TRAPS);
   1.148 +
   1.149 +  // Printing
   1.150 +  void print_on(outputStream* st) const;
   1.151 +  void print_value_on(outputStream* st) const;
   1.152 +
   1.153 +  void oop_print_on(oop obj, outputStream* st);
   1.154 +
   1.155 +  // Verification
   1.156 +  void verify_on(outputStream* st);
   1.157 +
   1.158 +  void oop_verify_on(oop obj, outputStream* st);
   1.159 +};
   1.160 +
   1.161 +#endif // SHARE_VM_OOPS_ARRAYKLASS_HPP

mercurial