hotspot/src/share/vm/oops/objArrayKlass.hpp
author coleenp
Mon, 27 Jul 2009 17:23:52 -0400
changeset 3579 b18b94266d60
parent 1388 3677f5f3d66b
child 4584 e2a449e8cc6f
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
670
ddf3e9583f2f 6719955: Update copyright year
xdono
parents: 360
diff changeset
     2
 * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// objArrayKlass is the klass for objArrays
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
class objArrayKlass : public arrayKlass {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  klassOop _element_klass;            // The klass of the elements of this array type
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  klassOop _bottom_klass;             // The one-dimensional type (instanceKlass or typeArrayKlass)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  // Instance variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  klassOop element_klass() const      { return _element_klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  void set_element_klass(klassOop k)  { oop_store_without_check((oop*) &_element_klass, (oop) k); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  oop* element_klass_addr()           { return (oop*)&_element_klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  klassOop bottom_klass() const       { return _bottom_klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  void set_bottom_klass(klassOop k)   { oop_store_without_check((oop*) &_bottom_klass, (oop) k); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  oop* bottom_klass_addr()            { return (oop*)&_bottom_klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  // Compiler/Interpreter offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  static int element_klass_offset_in_bytes() { return offset_of(objArrayKlass, _element_klass); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // Dispatched operation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  bool can_be_primary_super_slow() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  objArrayOop compute_secondary_supers(int num_extra_slots, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  bool compute_is_subtype_of(klassOop k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  bool oop_is_objArray_slow()  const  { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  int oop_size(oop obj) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  int klass_oop_size() const          { return object_size(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // Allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  DEFINE_ALLOCATE_PERMANENT(objArrayKlass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  objArrayOop allocate(int length, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  oop multi_allocate(int rank, jint* sizes, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // Copying
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  void  copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // Compute protection domain
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  oop protection_domain() { return Klass::cast(bottom_klass())->protection_domain(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  // Compute class loader
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  oop class_loader() const { return Klass::cast(bottom_klass())->class_loader(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    66
 private:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    67
  // Either oop or narrowOop depending on UseCompressedOops.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    68
  // must be called from within objArrayKlass.cpp
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    69
  template <class T> void do_copy(arrayOop s, T* src, arrayOop d,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    70
                                  T* dst, int length, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // Returns the objArrayKlass for n'th dimension.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  virtual klassOop array_klass_impl(bool or_null, int n, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // Returns the array class with this class as element type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  virtual klassOop array_klass_impl(bool or_null, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // Casting from klassOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  static objArrayKlass* cast(klassOop k) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    assert(k->klass_part()->oop_is_objArray_slow(), "cast to objArrayKlass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    return (objArrayKlass*) k->klass_part();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // Sizing
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  static int header_size()                { return oopDesc::header_size() + sizeof(objArrayKlass)/HeapWordSize; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  int object_size() const                 { return arrayKlass::object_size(header_size()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // Initialization (virtual from Klass)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  void initialize(TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // Garbage collection
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  void oop_follow_contents(oop obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  int  oop_adjust_pointers(oop obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // Parallel Scavenge and Parallel Old
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  PARALLEL_GC_DECLS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // Iterators
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  int oop_oop_iterate(oop obj, OopClosure* blk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    return oop_oop_iterate_v(obj, blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    return oop_oop_iterate_v_m(obj, blk, mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
#define ObjArrayKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk);         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk,      \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   109
                                     MemRegion mr);                     \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   110
  int oop_oop_iterate_range##nv_suffix(oop obj, OopClosureType* blk,    \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   111
                                     int start, int end);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DECL)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   114
  ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DECL)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // JVM support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  jint compute_modifier_flags(TRAPS) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
   static klassOop array_klass_impl   (objArrayKlassHandle this_oop, bool or_null, int n, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // Printing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  void oop_print_on      (oop obj, outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  void oop_print_value_on(oop obj, outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // Verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  const char* internal_name() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  void oop_verify_on(oop obj, outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  void oop_verify_old_oop(oop obj, oop* p, bool allow_dirty);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   134
  void oop_verify_old_oop(oop obj, narrowOop* p, bool allow_dirty);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
};