src/hotspot/share/oops/typeArrayOop.hpp
author eosterlund
Thu, 22 Feb 2018 10:39:42 +0100
changeset 49041 44122f767467
parent 49036 bc92debe57e4
child 49480 d7df2dd501ce
permissions -rw-r--r--
8198286: Direct memory accessors in typeArrayOop.hpp should use Access API Reviewed-by: pliden, rkennke
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
     2
 * Copyright (c) 1997, 2018, 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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_OOPS_TYPEARRAYOOP_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_OOPS_TYPEARRAYOOP_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 "oops/arrayOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "oops/typeArrayKlass.hpp"
24351
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
    30
#include "runtime/orderAccess.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// A typeArrayOop is an array containing basic types (non oop elements).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// It is used for arrays of {characters, singles, doubles, bytes, shorts, integers, longs}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
#include <limits.h>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class typeArrayOopDesc : public arrayOopDesc {
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    37
private:
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    38
  template <class T>
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    39
  static ptrdiff_t element_offset(BasicType bt, int index) {
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    40
    return arrayOopDesc::base_offset_in_bytes(bt) + sizeof(T) * index;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    41
  }
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    42
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
 protected:
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    44
  jchar*    char_base()   const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    45
  jboolean* bool_base()   const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    46
  jbyte*    byte_base()   const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    47
  jint*     int_base()    const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    48
  jlong*    long_base()   const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    49
  jshort*   short_base()  const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    50
  jfloat*   float_base()  const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    51
  jdouble*  double_base() const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    53
  friend class TypeArrayKlass;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
 public:
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    56
  jbyte* byte_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    57
  jboolean* bool_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    58
  jchar* char_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    59
  jint* int_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    60
  jshort* short_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    61
  jushort* ushort_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    62
  jlong* long_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    63
  jfloat* float_at_addr(int which) const;
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 49036
diff changeset
    64
  jdouble* double_at_addr(int which) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    66
  jbyte byte_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    67
  void byte_at_put(int which, jbyte contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    69
  jboolean bool_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    70
  void bool_at_put(int which, jboolean contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    72
  jchar char_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    73
  void char_at_put(int which, jchar contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    75
  jint int_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    76
  void int_at_put(int which, jint contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    78
  jshort short_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    79
  void short_at_put(int which, jshort contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    81
  jushort ushort_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    82
  void ushort_at_put(int which, jushort contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    84
  jlong long_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    85
  void long_at_put(int which, jlong contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    87
  jfloat float_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    88
  void float_at_put(int which, jfloat contents);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    90
  jdouble double_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    91
  void double_at_put(int which, jdouble contents);
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    92
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    93
  jbyte byte_at_acquire(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    94
  void release_byte_at_put(int which, jbyte contents);
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    95
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    96
  Symbol* symbol_at(int which) const;
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 47216
diff changeset
    97
  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
    98
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // Sizing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // Returns the number of words necessary to hold an array of "len"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // elements each of the given "byte_size".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  static int object_size(int lh, int length) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    int instance_header_size = Klass::layout_helper_header_size(lh);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    int element_shift = Klass::layout_helper_log2_element_size(lh);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    DEBUG_ONLY(BasicType etype = Klass::layout_helper_element_type(lh));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    assert(length <= arrayOopDesc::max_array_length(etype), "no overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
27428
c5ace5b96ae2 8049542: C2: assert(size_in_words <= (julong)max_jint) failed: no overflow
kvn
parents: 24351
diff changeset
   110
    julong size_in_bytes = (juint)length;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    size_in_bytes <<= element_shift;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    size_in_bytes += instance_header_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    julong size_in_words = ((size_in_bytes + (HeapWordSize-1)) >> LogHeapWordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    assert(size_in_words <= (julong)max_jint, "no overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    return align_object_size((intptr_t)size_in_words);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
 public:
35498
392b50de06c6 8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents: 33628
diff changeset
   120
  inline int object_size();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   122
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   123
#endif // SHARE_VM_OOPS_TYPEARRAYOOP_HPP