objArrayKlass.hpp 5.2 KB
Newer Older
D
duke 已提交
1
/*
X
xdono 已提交
2
 * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
 * 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.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * CA 95054 USA or visit www.sun.com if you need additional information or
 * have any questions.
 *
 */

// objArrayKlass is the klass for objArrays

class objArrayKlass : public arrayKlass {
  friend class VMStructs;
 private:
  klassOop _element_klass;            // The klass of the elements of this array type
  klassOop _bottom_klass;             // The one-dimensional type (instanceKlass or typeArrayKlass)
 public:
  // Instance variables
  klassOop element_klass() const      { return _element_klass; }
  void set_element_klass(klassOop k)  { oop_store_without_check((oop*) &_element_klass, (oop) k); }
  oop* element_klass_addr()           { return (oop*)&_element_klass; }

  klassOop bottom_klass() const       { return _bottom_klass; }
  void set_bottom_klass(klassOop k)   { oop_store_without_check((oop*) &_bottom_klass, (oop) k); }
  oop* bottom_klass_addr()            { return (oop*)&_bottom_klass; }

  // Compiler/Interpreter offset
  static int element_klass_offset_in_bytes() { return offset_of(objArrayKlass, _element_klass); }

  // Dispatched operation
  bool can_be_primary_super_slow() const;
  objArrayOop compute_secondary_supers(int num_extra_slots, TRAPS);
  bool compute_is_subtype_of(klassOop k);
  bool oop_is_objArray_slow()  const  { return true; }
  int oop_size(oop obj) const;
  int klass_oop_size() const          { return object_size(); }

  // Allocation
  DEFINE_ALLOCATE_PERMANENT(objArrayKlass);
  objArrayOop allocate(int length, TRAPS);
  oop multi_allocate(int rank, jint* sizes, TRAPS);

  // Copying
  void  copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);

  // Compute protection domain
  oop protection_domain() { return Klass::cast(bottom_klass())->protection_domain(); }
  // Compute class loader
  oop class_loader() const { return Klass::cast(bottom_klass())->class_loader(); }

66 67 68 69 70
 private:
  // Either oop or narrowOop depending on UseCompressedOops.
  // must be called from within objArrayKlass.cpp
  template <class T> void do_copy(arrayOop s, T* src, arrayOop d,
                                  T* dst, int length, TRAPS);
D
duke 已提交
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
 protected:
  // Returns the objArrayKlass for n'th dimension.
  virtual klassOop array_klass_impl(bool or_null, int n, TRAPS);

  // Returns the array class with this class as element type.
  virtual klassOop array_klass_impl(bool or_null, TRAPS);

 public:
  // Casting from klassOop
  static objArrayKlass* cast(klassOop k) {
    assert(k->klass_part()->oop_is_objArray_slow(), "cast to objArrayKlass");
    return (objArrayKlass*) k->klass_part();
  }

  // Sizing
  static int header_size()                { return oopDesc::header_size() + sizeof(objArrayKlass)/HeapWordSize; }
  int object_size() const                 { return arrayKlass::object_size(header_size()); }

  // Initialization (virtual from Klass)
  void initialize(TRAPS);

  // Garbage collection
  void oop_follow_contents(oop obj);
  int  oop_adjust_pointers(oop obj);

  // Parallel Scavenge and Parallel Old
  PARALLEL_GC_DECLS

  // Iterators
  int oop_oop_iterate(oop obj, OopClosure* blk) {
    return oop_oop_iterate_v(obj, blk);
  }
  int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
    return oop_oop_iterate_v_m(obj, blk, mr);
  }
#define ObjArrayKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)   \
  int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk);         \
  int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk,      \
109 110 111
                                     MemRegion mr);                     \
  int oop_oop_iterate_range##nv_suffix(oop obj, OopClosureType* blk,    \
                                     int start, int end);
D
duke 已提交
112 113

  ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DECL)
114
  ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DECL)
D
duke 已提交
115 116 117 118 119 120 121 122 123 124

  // JVM support
  jint compute_modifier_flags(TRAPS) const;

 private:
   static klassOop array_klass_impl   (objArrayKlassHandle this_oop, bool or_null, int n, TRAPS);

 public:
  // Printing
  void oop_print_value_on(oop obj, outputStream* st);
125 126 127
#ifndef PRODUCT
  void oop_print_on      (oop obj, outputStream* st);
#endif //PRODUCT
D
duke 已提交
128 129 130 131 132

  // Verification
  const char* internal_name() const;
  void oop_verify_on(oop obj, outputStream* st);
  void oop_verify_old_oop(oop obj, oop* p, bool allow_dirty);
133
  void oop_verify_old_oop(oop obj, narrowOop* p, bool allow_dirty);
D
duke 已提交
134 135

};