hotspot/src/share/vm/oops/typeArrayKlass.hpp
author stefank
Thu, 02 Apr 2015 10:04:27 +0200
changeset 30150 d9c940aa42ef
parent 22234 da823d78ad65
child 30880 efe35e08179f
permissions -rw-r--r--
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution Reviewed-by: brutisso, coleenp, kbarrett, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
22234
da823d78ad65 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 17826
diff changeset
     2
 * Copyright (c) 1997, 2013, 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: 2105
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2105
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: 2105
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_TYPEARRAYKLASS_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_OOPS_TYPEARRAYKLASS_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
    28
#include "classfile/classLoaderData.hpp"
7397
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
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    31
// A TypeArrayKlass is the klass of a typeArray
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// It contains the type and size of the elements
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    34
class TypeArrayKlass : public ArrayKlass {
1
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
  jint _max_length;            // maximum number of elements allowed in an array
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
    38
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
    39
  // Constructor
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    40
  TypeArrayKlass(BasicType type, Symbol* name);
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    41
  static TypeArrayKlass* allocate(ClassLoaderData* loader_data, BasicType type, Symbol* name, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
 public:
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    43
  TypeArrayKlass() {} // For dummy objects.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
    44
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // instance variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  jint max_length()                     { return _max_length; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  void set_max_length(jint m)           { _max_length = m;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  // testers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  bool oop_is_typeArray_slow() const    { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  // klass allocation
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    53
  static TypeArrayKlass* create_klass(BasicType type, const char* name_str,
1668
8ec481b8f514 6578152: fill_region_with_object has usability and safety issues
jcoomes
parents: 1
diff changeset
    54
                               TRAPS);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
    55
  static inline Klass* create_klass(BasicType type, int scale, TRAPS) {
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    56
    TypeArrayKlass* tak = create_klass(type, external_name(type), CHECK_NULL);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
    57
    assert(scale == (1 << tak->log2_element_size()), "scale must check out");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
    58
    return tak;
1668
8ec481b8f514 6578152: fill_region_with_object has usability and safety issues
jcoomes
parents: 1
diff changeset
    59
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  int oop_size(oop obj) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
    63
  bool compute_is_subtype_of(Klass* k);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  // Allocation
10566
630c177ec580 7081933: Use zeroing elimination optimization for large array
kvn
parents: 7397
diff changeset
    66
  typeArrayOop allocate_common(int length, bool do_zero, TRAPS);
630c177ec580 7081933: Use zeroing elimination optimization for large array
kvn
parents: 7397
diff changeset
    67
  typeArrayOop allocate(int length, TRAPS) { return allocate_common(length, true, THREAD); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  oop multi_allocate(int rank, jint* sizes, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
17826
9ad5cd464a75 8003421: NPG: Move oops out of InstanceKlass into mirror
coleenp
parents: 13952
diff changeset
    70
  oop protection_domain() const { return NULL; }
9ad5cd464a75 8003421: NPG: Move oops out of InstanceKlass into mirror
coleenp
parents: 13952
diff changeset
    71
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // Copying
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  void  copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    75
  // GC specific object visitors
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    76
  //
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    77
  // Mark Sweep
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    78
  void oop_ms_follow_contents(oop obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    79
  int  oop_ms_adjust_pointers(oop obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    80
#if INCLUDE_ALL_GCS
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    81
  // Parallel Scavenge
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    82
  void oop_ps_push_contents(  oop obj, PSPromotionManager* pm);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    83
  // Parallel Compact
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    84
  void oop_pc_follow_contents(oop obj, ParCompactionManager* cm);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    85
  void oop_pc_update_pointers(oop obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    86
#endif
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    87
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    88
  // Oop iterators. Since there are no oops in TypeArrayKlasses,
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    89
  // these functions only return the size of the object.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    90
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    91
 private:
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    92
  // The implementation used by all oop_oop_iterate functions in TypeArrayKlasses.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    93
  inline int oop_oop_iterate_impl(oop obj, ExtendedOopClosure* closure);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    95
 public:
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    96
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    97
#define TypeArrayKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)    \
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    98
  int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure);       \
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    99
  int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* closure,    \
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   100
                                     MemRegion mr);                       \
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   101
  int oop_oop_iterate_range##nv_suffix(oop obj, OopClosureType* closure,  \
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   102
                                     int start, int end);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   104
  ALL_OOP_OOP_ITERATE_CLOSURES_1(TypeArrayKlass_OOP_OOP_ITERATE_DECL)
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   105
  ALL_OOP_OOP_ITERATE_CLOSURES_2(TypeArrayKlass_OOP_OOP_ITERATE_DECL)
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   106
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   107
#if INCLUDE_ALL_GCS
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   108
#define TypeArrayKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix)  \
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   109
  int  oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   110
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   111
  ALL_OOP_OOP_ITERATE_CLOSURES_1(TypeArrayKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   112
  ALL_OOP_OOP_ITERATE_CLOSURES_2(TypeArrayKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   113
#endif // INCLUDE_ALL_GCS
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   114
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  // Find n'th dimensional array
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
   118
  virtual Klass* array_klass_impl(bool or_null, int n, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // Returns the array class with this class as element type
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
   121
  virtual Klass* array_klass_impl(bool or_null, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
 public:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
   124
  // Casting from Klass*
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   125
  static TypeArrayKlass* cast(Klass* k) {
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   126
    assert(k->oop_is_typeArray(), "cast to TypeArrayKlass");
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   127
    return (TypeArrayKlass*) k;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // Naming
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  static const char* external_name(BasicType type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  // Sizing
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   134
  static int header_size()  { return sizeof(TypeArrayKlass)/HeapWordSize; }
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   135
  int size() const          { return ArrayKlass::static_size(header_size()); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // Initialization (virtual from Klass)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  void initialize(TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // Printing
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
   142
#ifndef PRODUCT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  void oop_print_on(oop obj, outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
#endif
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
   145
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
   146
  void print_on(outputStream* st) const;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
   147
  void print_value_on(outputStream* st) const;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10566
diff changeset
   148
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  const char* internal_name() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   152
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   153
#endif // SHARE_VM_OOPS_TYPEARRAYKLASS_HPP