src/hotspot/share/oops/typeArrayOop.hpp
author coleenp
Thu, 10 Jan 2019 15:13:51 -0500
changeset 53244 9807daeb47c4
parent 50389 7e8c0409a747
permissions -rw-r--r--
8216167: Update include guards to reflect correct directories Summary: Use script and some manual fixup to fix directores names in include guards. Reviewed-by: lfoltan, eosterlund, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50389
diff changeset
     2
 * Copyright (c) 1997, 2019, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50389
diff changeset
    25
#ifndef SHARE_OOPS_TYPEARRAYOOP_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50389
diff changeset
    26
#define SHARE_OOPS_TYPEARRAYOOP_HPP
7397
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 "oops/arrayOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "oops/typeArrayKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// A typeArrayOop is an array containing basic types (non oop elements).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// It is used for arrays of {characters, singles, doubles, bytes, shorts, integers, longs}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
#include <limits.h>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    35
namespace TypeToBT {
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    36
  template<typename T> BasicType to_basic_type();
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    37
  template<> inline BasicType to_basic_type<jboolean>() { return T_BOOLEAN; }
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    38
  template<> inline BasicType to_basic_type<jbyte>()    { return T_BYTE;    }
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    39
  template<> inline BasicType to_basic_type<jchar>()    { return T_CHAR;    }
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    40
  template<> inline BasicType to_basic_type<jshort>()   { return T_SHORT;   }
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    41
  template<> inline BasicType to_basic_type<jint>()     { return T_INT;     }
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    42
  template<> inline BasicType to_basic_type<jlong>()    { return T_LONG;    }
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    43
  template<> inline BasicType to_basic_type<jfloat>()   { return T_FLOAT;   }
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    44
  template<> inline BasicType to_basic_type<jdouble>()  { return T_DOUBLE;  }
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    45
};
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    46
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
class typeArrayOopDesc : public arrayOopDesc {
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    48
private:
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    49
  template <typename T>
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    50
  static BasicType bt() { return TypeToBT::to_basic_type<T>(); }
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    51
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
 protected:
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    53
  jchar*    char_base()   const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    54
  jboolean* bool_base()   const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    55
  jbyte*    byte_base()   const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    56
  jint*     int_base()    const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    57
  jlong*    long_base()   const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    58
  jshort*   short_base()  const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    59
  jfloat*   float_base()  const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    60
  jdouble*  double_base() const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    62
  friend class TypeArrayKlass;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
 public:
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    65
  template <typename T>
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    66
  static ptrdiff_t element_offset(int index) {
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    67
    return arrayOopDesc::base_offset_in_bytes(bt<T>()) + sizeof(T) * index;
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    68
  }
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49480
diff changeset
    69
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    70
  jbyte* byte_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    71
  jboolean* bool_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    72
  jchar* char_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    73
  jint* int_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    74
  jshort* short_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    75
  jushort* ushort_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    76
  jlong* long_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    77
  jfloat* float_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    78
  jdouble* double_at_addr(int which) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    80
  jbyte byte_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    81
  void byte_at_put(int which, jbyte contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    83
  jboolean bool_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    84
  void bool_at_put(int which, jboolean contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    86
  jchar char_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    87
  void char_at_put(int which, jchar contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    89
  jint int_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    90
  void int_at_put(int which, jint contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    92
  jshort short_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    93
  void short_at_put(int which, jshort contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    95
  jushort ushort_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    96
  void ushort_at_put(int which, jushort contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    98
  jlong long_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    99
  void long_at_put(int which, jlong contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
   101
  jfloat float_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
   102
  void float_at_put(int which, jfloat contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
   104
  jdouble double_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
   105
  void double_at_put(int which, jdouble contents);
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
   106
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
   107
  jbyte byte_at_acquire(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
   108
  void release_byte_at_put(int which, jbyte contents);
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
   109
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
   110
  Symbol* symbol_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
   111
  void symbol_at_put(int which, Symbol* contents);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10565
diff changeset
   112
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // Sizing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // Returns the number of words necessary to hold an array of "len"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // elements each of the given "byte_size".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  static int object_size(int lh, int length) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    int instance_header_size = Klass::layout_helper_header_size(lh);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    int element_shift = Klass::layout_helper_log2_element_size(lh);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    DEBUG_ONLY(BasicType etype = Klass::layout_helper_element_type(lh));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    assert(length <= arrayOopDesc::max_array_length(etype), "no overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
27428
c5ace5b96ae2 8049542: C2: assert(size_in_words <= (julong)max_jint) failed: no overflow
kvn
parents: 24351
diff changeset
   124
    julong size_in_bytes = (juint)length;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    size_in_bytes <<= element_shift;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    size_in_bytes += instance_header_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    julong size_in_words = ((size_in_bytes + (HeapWordSize-1)) >> LogHeapWordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    assert(size_in_words <= (julong)max_jint, "no overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    return align_object_size((intptr_t)size_in_words);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
 public:
35498
392b50de06c6 8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents: 33628
diff changeset
   134
  inline int object_size();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   136
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50389
diff changeset
   137
#endif // SHARE_OOPS_TYPEARRAYOOP_HPP