arrayKlass.hpp 6.0 KB
Newer Older
D
duke 已提交
1
/*
2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
19 20 21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
D
duke 已提交
22 23 24
 *
 */

25 26 27 28 29
#ifndef SHARE_VM_OOPS_ARRAYKLASS_HPP
#define SHARE_VM_OOPS_ARRAYKLASS_HPP

#include "memory/universe.hpp"
#include "oops/klass.hpp"
30 31

class klassVtable;
32

33
// ArrayKlass is the abstract baseclass for all array classes
D
duke 已提交
34

35
class ArrayKlass: public Klass {
D
duke 已提交
36 37 38
  friend class VMStructs;
 private:
  int      _dimension;         // This is n'th-dimensional array.
39 40
  Klass* volatile _higher_dimension;  // Refers the (n+1)'th-dimensional array (if present).
  Klass* volatile _lower_dimension;   // Refers the (n-1)'th-dimensional array (if present).
D
duke 已提交
41 42 43 44
  int      _vtable_len;        // size of vtable for this klass
  juint    _alloc_size;        // allocation profiling support
  oop      _component_mirror;  // component type, as a java/lang/Class

45 46 47 48
 protected:
  // Constructors
  // The constructor with the Symbol argument does the real array
  // initialization, the other is a dummy
49 50
  ArrayKlass(Symbol* name);
  ArrayKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for cds"); }
51

D
duke 已提交
52 53
 public:
  // Testing operation
54
  bool oop_is_array_slow() const { return true; }
D
duke 已提交
55 56 57 58 59

  // Instance variables
  int dimension() const                 { return _dimension;      }
  void set_dimension(int dimension)     { _dimension = dimension; }

60 61 62
  Klass* higher_dimension() const     { return _higher_dimension; }
  void set_higher_dimension(Klass* k) { _higher_dimension = k; }
  Klass** adr_higher_dimension()      { return (Klass**)&this->_higher_dimension;}
D
duke 已提交
63

64 65 66
  Klass* lower_dimension() const      { return _lower_dimension; }
  void set_lower_dimension(Klass* k)  { _lower_dimension = k; }
  Klass** adr_lower_dimension()       { return (Klass**)&this->_lower_dimension;}
D
duke 已提交
67 68 69 70 71 72 73 74 75 76 77 78

  // Allocation profiling support
  juint alloc_size() const              { return _alloc_size; }
  void set_alloc_size(juint n)          { _alloc_size = n; }

  // offset of first element, including any padding for the sake of alignment
  int  array_header_in_bytes() const    { return layout_helper_header_size(layout_helper()); }
  int  log2_element_size() const        { return layout_helper_log2_element_size(layout_helper()); }
  // type of elements (T_OBJECT for both oop arrays and array-arrays)
  BasicType element_type() const        { return layout_helper_element_type(layout_helper()); }

  oop  component_mirror() const         { return _component_mirror; }
79
  void set_component_mirror(oop m)      { klass_oop_store(&_component_mirror, m); }
D
duke 已提交
80 81 82
  oop* adr_component_mirror()           { return (oop*)&this->_component_mirror;}

  // Compiler/Interpreter offset
83
  static ByteSize component_mirror_offset() { return in_ByteSize(offset_of(ArrayKlass, _component_mirror)); }
D
duke 已提交
84

85
  virtual Klass* java_super() const;//{ return SystemDictionary::Object_klass(); }
D
duke 已提交
86 87 88 89 90 91 92 93

  // Allocation
  // Sizes points to the first dimension of the array, subsequent dimensions
  // are always in higher memory.  The callers of these set that up.
  virtual oop multi_allocate(int rank, jint* sizes, TRAPS);
  objArrayOop allocate_arrayArray(int n, int length, TRAPS);

  // Lookup operations
94
  Method* uncached_lookup_method(Symbol* name, Symbol* signature) const;
D
duke 已提交
95

96
  // Casting from Klass*
97 98 99
  static ArrayKlass* cast(Klass* k) {
    assert(k->oop_is_array(), "cast to ArrayKlass");
    return (ArrayKlass*) k;
D
duke 已提交
100 101
  }

102 103
  GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots);
  bool compute_is_subtype_of(Klass* k);
D
duke 已提交
104 105

  // Sizing
106
  static int header_size()                 { return sizeof(ArrayKlass)/HeapWordSize; }
107
  static int static_size(int header_size);
D
duke 已提交
108

109 110 111 112 113 114 115 116
#if INCLUDE_SERVICES
  virtual void collect_statistics(KlassSizeStats *sz) const {
    Klass::collect_statistics(sz);
    // Do nothing for now, but remember to modify if you add new
    // stuff to ArrayKlass.
  }
#endif

D
duke 已提交
117 118 119 120 121 122 123 124 125 126
  // Java vtable
  klassVtable* vtable() const;             // return new klassVtable
  int  vtable_length() const               { return _vtable_len; }
  static int base_vtable_length()          { return Universe::base_vtable_size(); }
  void set_vtable_length(int len)          { assert(len == base_vtable_length(), "bad length"); _vtable_len = len; }
 protected:
  inline intptr_t* start_of_vtable() const;

 public:
  // Iterators
127 128 129 130 131 132 133
  void array_klasses_do(void f(Klass* k));
  void array_klasses_do(void f(Klass* k, TRAPS), TRAPS);
  void with_array_klasses_do(void f(Klass* k));

  // GC support
  virtual void oops_do(OopClosure* cl);

D
duke 已提交
134
  // Return a handle.
135
  static void     complete_create_array_klass(ArrayKlass* k, KlassHandle super_klass, TRAPS);
136

D
duke 已提交
137

138 139
  // jvm support
  jint compute_modifier_flags(TRAPS) const;
D
duke 已提交
140

141 142
  // JVMTI support
  jint jvmti_class_status() const;
D
duke 已提交
143

144 145 146 147
  // CDS support - remove and restore oops from metadata. Oops are not shared.
  virtual void remove_unshareable_info();
  virtual void restore_unshareable_info(TRAPS);

D
duke 已提交
148
  // Printing
149 150 151
  void print_on(outputStream* st) const;
  void print_value_on(outputStream* st) const;

D
duke 已提交
152
  void oop_print_on(oop obj, outputStream* st);
153

D
duke 已提交
154
  // Verification
155 156
  void verify_on(outputStream* st);

D
duke 已提交
157 158
  void oop_verify_on(oop obj, outputStream* st);
};
159 160

#endif // SHARE_VM_OOPS_ARRAYKLASS_HPP