hotspot/src/share/vm/oops/objArrayKlass.hpp
author brutisso
Tue, 28 Jun 2011 14:23:27 +0200
changeset 10002 2d83be3a0927
parent 7397 5b173b4ca846
child 11430 718fc06da49a
permissions -rw-r--r--
7016112: CMS: crash during promotion testing Summary: Also reviewed by mikael.gerdin@oracle.com; stdlib:qsort() does byte-by-byte swapping on Windows. This leads to pointer shearing. Fix is to implement a quicksort that does full pointer updates. Reviewed-by: never, coleenp, ysr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5076
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5076
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5076
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_OOPS_OBJARRAYKLASS_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_OOPS_OBJARRAYKLASS_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/specialized_oop_closures.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "oops/arrayKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "oops/instanceKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// objArrayKlass is the klass for objArrays
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class objArrayKlass : public arrayKlass {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  klassOop _element_klass;            // The klass of the elements of this array type
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  klassOop _bottom_klass;             // The one-dimensional type (instanceKlass or typeArrayKlass)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  // Instance variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  klassOop element_klass() const      { return _element_klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  void set_element_klass(klassOop k)  { oop_store_without_check((oop*) &_element_klass, (oop) k); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  oop* element_klass_addr()           { return (oop*)&_element_klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  klassOop bottom_klass() const       { return _bottom_klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  void set_bottom_klass(klassOop k)   { oop_store_without_check((oop*) &_bottom_klass, (oop) k); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  oop* bottom_klass_addr()            { return (oop*)&_bottom_klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  // Compiler/Interpreter offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  static int element_klass_offset_in_bytes() { return offset_of(objArrayKlass, _element_klass); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  // Dispatched operation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  bool can_be_primary_super_slow() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  objArrayOop compute_secondary_supers(int num_extra_slots, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  bool compute_is_subtype_of(klassOop k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  bool oop_is_objArray_slow()  const  { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  int oop_size(oop obj) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  int klass_oop_size() const          { return object_size(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // Allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  DEFINE_ALLOCATE_PERMANENT(objArrayKlass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  objArrayOop allocate(int length, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  oop multi_allocate(int rank, jint* sizes, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  // Copying
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  void  copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // Compute protection domain
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  oop protection_domain() { return Klass::cast(bottom_klass())->protection_domain(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  // Compute class loader
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  oop class_loader() const { return Klass::cast(bottom_klass())->class_loader(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    73
 private:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    74
  // 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
    75
  // 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
    76
  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
    77
                                  T* dst, int length, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // Returns the objArrayKlass for n'th dimension.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  virtual klassOop array_klass_impl(bool or_null, int n, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // Returns the array class with this class as element type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  virtual klassOop array_klass_impl(bool or_null, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // Casting from klassOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  static objArrayKlass* cast(klassOop k) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    assert(k->klass_part()->oop_is_objArray_slow(), "cast to objArrayKlass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    return (objArrayKlass*) k->klass_part();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // Sizing
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  static int header_size()                { return oopDesc::header_size() + sizeof(objArrayKlass)/HeapWordSize; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  int object_size() const                 { return arrayKlass::object_size(header_size()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // Initialization (virtual from Klass)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  void initialize(TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // Garbage collection
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  void oop_follow_contents(oop obj);
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   101
  inline void oop_follow_contents(oop obj, int index);
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   102
  template <class T> inline void objarray_follow_contents(oop obj, int index);
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   103
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  int  oop_adjust_pointers(oop obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // Parallel Scavenge and Parallel Old
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  PARALLEL_GC_DECLS
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   108
#ifndef SERIALGC
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   109
  inline void oop_follow_contents(ParCompactionManager* cm, oop obj, int index);
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   110
  template <class T> inline void
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   111
    objarray_follow_contents(ParCompactionManager* cm, oop obj, int index);
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   112
#endif // !SERIALGC
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // Iterators
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  int oop_oop_iterate(oop obj, OopClosure* blk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    return oop_oop_iterate_v(obj, blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    return oop_oop_iterate_v_m(obj, blk, mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
#define ObjArrayKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk);         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  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
   124
                                     MemRegion mr);                     \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   125
  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
   126
                                     int start, int end);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  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
   129
  ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DECL)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  // JVM support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  jint compute_modifier_flags(TRAPS) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
   static klassOop array_klass_impl   (objArrayKlassHandle this_oop, bool or_null, int n, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // Printing
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1388
diff changeset
   139
  void oop_print_value_on(oop obj, outputStream* st);
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1388
diff changeset
   140
#ifndef PRODUCT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  void oop_print_on      (oop obj, outputStream* st);
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1388
diff changeset
   142
#endif //PRODUCT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  // Verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  const char* internal_name() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  void oop_verify_on(oop obj, outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  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
   148
  void oop_verify_old_oop(oop obj, narrowOop* p, bool allow_dirty);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   150
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   151
#endif // SHARE_VM_OOPS_OBJARRAYKLASS_HPP