author | eosterlund |
Thu, 22 Feb 2018 10:39:42 +0100 | |
changeset 49041 | 44122f767467 |
parent 49036 | bc92debe57e4 |
child 49480 | d7df2dd501ce |
permissions | -rw-r--r-- |
1 | 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 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
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 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_OOPS_TYPEARRAYOOP_HPP |
26 |
#define SHARE_VM_OOPS_TYPEARRAYOOP_HPP |
|
27 |
||
28 |
#include "oops/arrayOop.hpp" |
|
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 | 31 |
|
1 | 32 |
// A typeArrayOop is an array containing basic types (non oop elements). |
33 |
// It is used for arrays of {characters, singles, doubles, bytes, shorts, integers, longs} |
|
34 |
#include <limits.h> |
|
35 |
||
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 | 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 | 52 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
53 |
friend class TypeArrayKlass; |
1 | 54 |
|
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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 99 |
// Sizing |
100 |
||
101 |
// Returns the number of words necessary to hold an array of "len" |
|
102 |
// elements each of the given "byte_size". |
|
103 |
private: |
|
104 |
static int object_size(int lh, int length) { |
|
105 |
int instance_header_size = Klass::layout_helper_header_size(lh); |
|
106 |
int element_shift = Klass::layout_helper_log2_element_size(lh); |
|
107 |
DEBUG_ONLY(BasicType etype = Klass::layout_helper_element_type(lh)); |
|
108 |
assert(length <= arrayOopDesc::max_array_length(etype), "no overflow"); |
|
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 | 111 |
size_in_bytes <<= element_shift; |
112 |
size_in_bytes += instance_header_size; |
|
113 |
julong size_in_words = ((size_in_bytes + (HeapWordSize-1)) >> LogHeapWordSize); |
|
114 |
assert(size_in_words <= (julong)max_jint, "no overflow"); |
|
115 |
||
116 |
return align_object_size((intptr_t)size_in_words); |
|
117 |
} |
|
118 |
||
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 | 121 |
}; |
7397 | 122 |
|
123 |
#endif // SHARE_VM_OOPS_TYPEARRAYOOP_HPP |