author | hseigel |
Fri, 15 Dec 2017 11:23:50 -0500 | |
changeset 48463 | 474cec233fb2 |
parent 47216 | 71c04702a3d5 |
child 49036 | bc92debe57e4 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
46257
3e95288ce4ca
8140685: Fix backtrace building to not rely on constant pool merging
coleenp
parents:
37485
diff
changeset
|
2 |
* Copyright (c) 1997, 2017, 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 { |
|
37 |
protected: |
|
38 |
jchar* char_base() const { return (jchar*) base(T_CHAR); } |
|
39 |
jboolean* bool_base() const { return (jboolean*)base(T_BOOLEAN); } |
|
40 |
jbyte* byte_base() const { return (jbyte*) base(T_BYTE); } |
|
41 |
jint* int_base() const { return (jint*) base(T_INT); } |
|
42 |
jlong* long_base() const { return (jlong*) base(T_LONG); } |
|
43 |
jshort* short_base() const { return (jshort*) base(T_SHORT); } |
|
44 |
jfloat* float_base() const { return (jfloat*) base(T_FLOAT); } |
|
45 |
jdouble* double_base() const { return (jdouble*) base(T_DOUBLE); } |
|
46 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
47 |
friend class TypeArrayKlass; |
1 | 48 |
|
49 |
public: |
|
50 |
jbyte* byte_at_addr(int which) const { |
|
33628 | 51 |
assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); |
1 | 52 |
return &byte_base()[which]; |
53 |
} |
|
54 |
||
55 |
jboolean* bool_at_addr(int which) const { |
|
33628 | 56 |
assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); |
1 | 57 |
return &bool_base()[which]; |
58 |
} |
|
59 |
||
60 |
jchar* char_at_addr(int which) const { |
|
33628 | 61 |
assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); |
1 | 62 |
return &char_base()[which]; |
63 |
} |
|
64 |
||
65 |
jint* int_at_addr(int which) const { |
|
33628 | 66 |
assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); |
1 | 67 |
return &int_base()[which]; |
68 |
} |
|
69 |
||
70 |
jshort* short_at_addr(int which) const { |
|
33628 | 71 |
assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); |
1 | 72 |
return &short_base()[which]; |
73 |
} |
|
74 |
||
75 |
jushort* ushort_at_addr(int which) const { // for field descriptor arrays |
|
33628 | 76 |
assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); |
1 | 77 |
return (jushort*) &short_base()[which]; |
78 |
} |
|
79 |
||
80 |
jlong* long_at_addr(int which) const { |
|
33628 | 81 |
assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); |
1 | 82 |
return &long_base()[which]; |
83 |
} |
|
84 |
||
85 |
jfloat* float_at_addr(int which) const { |
|
33628 | 86 |
assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); |
1 | 87 |
return &float_base()[which]; |
88 |
} |
|
89 |
||
90 |
jdouble* double_at_addr(int which) const { |
|
33628 | 91 |
assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); |
1 | 92 |
return &double_base()[which]; |
93 |
} |
|
94 |
||
95 |
jbyte byte_at(int which) const { return *byte_at_addr(which); } |
|
96 |
void byte_at_put(int which, jbyte contents) { *byte_at_addr(which) = contents; } |
|
97 |
||
98 |
jboolean bool_at(int which) const { return *bool_at_addr(which); } |
|
37485 | 99 |
void bool_at_put(int which, jboolean contents) { *bool_at_addr(which) = (((jint)contents) & 1); } |
1 | 100 |
|
101 |
jchar char_at(int which) const { return *char_at_addr(which); } |
|
102 |
void char_at_put(int which, jchar contents) { *char_at_addr(which) = contents; } |
|
103 |
||
104 |
jint int_at(int which) const { return *int_at_addr(which); } |
|
105 |
void int_at_put(int which, jint contents) { *int_at_addr(which) = contents; } |
|
106 |
||
107 |
jshort short_at(int which) const { return *short_at_addr(which); } |
|
108 |
void short_at_put(int which, jshort contents) { *short_at_addr(which) = contents; } |
|
109 |
||
110 |
jushort ushort_at(int which) const { return *ushort_at_addr(which); } |
|
111 |
void ushort_at_put(int which, jushort contents) { *ushort_at_addr(which) = contents; } |
|
112 |
||
113 |
jlong long_at(int which) const { return *long_at_addr(which); } |
|
114 |
void long_at_put(int which, jlong contents) { *long_at_addr(which) = contents; } |
|
115 |
||
116 |
jfloat float_at(int which) const { return *float_at_addr(which); } |
|
117 |
void float_at_put(int which, jfloat contents) { *float_at_addr(which) = contents; } |
|
118 |
||
119 |
jdouble double_at(int which) const { return *double_at_addr(which); } |
|
120 |
void double_at_put(int which, jdouble contents) { *double_at_addr(which) = contents; } |
|
121 |
||
122 |
jbyte byte_at_acquire(int which) const { return OrderAccess::load_acquire(byte_at_addr(which)); } |
|
123 |
void release_byte_at_put(int which, jbyte contents) { OrderAccess::release_store(byte_at_addr(which), contents); } |
|
124 |
||
46257
3e95288ce4ca
8140685: Fix backtrace building to not rely on constant pool merging
coleenp
parents:
37485
diff
changeset
|
125 |
// Java thinks Symbol arrays are just arrays of either long or int, since |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10565
diff
changeset
|
126 |
// there doesn't seem to be T_ADDRESS, so this is a bit of unfortunate |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10565
diff
changeset
|
127 |
// casting |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10565
diff
changeset
|
128 |
#ifdef _LP64 |
46257
3e95288ce4ca
8140685: Fix backtrace building to not rely on constant pool merging
coleenp
parents:
37485
diff
changeset
|
129 |
Symbol* symbol_at(int which) const { |
3e95288ce4ca
8140685: Fix backtrace building to not rely on constant pool merging
coleenp
parents:
37485
diff
changeset
|
130 |
return (Symbol*)*long_at_addr(which); } |
3e95288ce4ca
8140685: Fix backtrace building to not rely on constant pool merging
coleenp
parents:
37485
diff
changeset
|
131 |
void symbol_at_put(int which, Symbol* contents) { |
36359 | 132 |
*long_at_addr(which) = (jlong)contents; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10565
diff
changeset
|
133 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10565
diff
changeset
|
134 |
#else |
46257
3e95288ce4ca
8140685: Fix backtrace building to not rely on constant pool merging
coleenp
parents:
37485
diff
changeset
|
135 |
Symbol* symbol_at(int which) const { |
3e95288ce4ca
8140685: Fix backtrace building to not rely on constant pool merging
coleenp
parents:
37485
diff
changeset
|
136 |
return (Symbol*)*int_at_addr(which); } |
3e95288ce4ca
8140685: Fix backtrace building to not rely on constant pool merging
coleenp
parents:
37485
diff
changeset
|
137 |
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
|
138 |
*int_at_addr(which) = (int)contents; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10565
diff
changeset
|
139 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10565
diff
changeset
|
140 |
#endif // _LP64 |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10565
diff
changeset
|
141 |
|
1 | 142 |
// Sizing |
143 |
||
144 |
// Returns the number of words necessary to hold an array of "len" |
|
145 |
// elements each of the given "byte_size". |
|
146 |
private: |
|
147 |
static int object_size(int lh, int length) { |
|
148 |
int instance_header_size = Klass::layout_helper_header_size(lh); |
|
149 |
int element_shift = Klass::layout_helper_log2_element_size(lh); |
|
150 |
DEBUG_ONLY(BasicType etype = Klass::layout_helper_element_type(lh)); |
|
151 |
assert(length <= arrayOopDesc::max_array_length(etype), "no overflow"); |
|
152 |
||
27428
c5ace5b96ae2
8049542: C2: assert(size_in_words <= (julong)max_jint) failed: no overflow
kvn
parents:
24351
diff
changeset
|
153 |
julong size_in_bytes = (juint)length; |
1 | 154 |
size_in_bytes <<= element_shift; |
155 |
size_in_bytes += instance_header_size; |
|
156 |
julong size_in_words = ((size_in_bytes + (HeapWordSize-1)) >> LogHeapWordSize); |
|
157 |
assert(size_in_words <= (julong)max_jint, "no overflow"); |
|
158 |
||
159 |
return align_object_size((intptr_t)size_in_words); |
|
160 |
} |
|
161 |
||
162 |
public: |
|
35498
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
33628
diff
changeset
|
163 |
inline int object_size(); |
1 | 164 |
}; |
7397 | 165 |
|
166 |
#endif // SHARE_VM_OOPS_TYPEARRAYOOP_HPP |