Mercurial > hg > truffle
annotate src/share/vm/oops/typeArrayOop.hpp @ 17716:cdb71841f4bc
6498581: ThreadInterruptTest3 produces wrong output on Windows
Summary: There is race condition between os::interrupt and os::is_interrupted on Windows. In JVM_Sleep(Thread.sleep), check if thread gets interrupted, it may see interrupted but not really interrupted so cause spurious waking up (early return from sleep). Fix by checking if interrupt event really gets set thus prevent false return. For intrinsic of _isInterrupted, on Windows, go fastpath only on bit not set.
Reviewed-by: acorn, kvn
Contributed-by: david.holmes@oracle.com, yumin.qi@oracle.com
author | minqi |
---|---|
date | Wed, 26 Feb 2014 15:20:41 -0800 |
parents | d8ce2825b193 |
children | bdd155477289 |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 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" | |
30 #ifdef TARGET_OS_ARCH_linux_x86 | |
31 # include "orderAccess_linux_x86.inline.hpp" | |
32 #endif | |
33 #ifdef TARGET_OS_ARCH_linux_sparc | |
34 # include "orderAccess_linux_sparc.inline.hpp" | |
35 #endif | |
36 #ifdef TARGET_OS_ARCH_linux_zero | |
37 # include "orderAccess_linux_zero.inline.hpp" | |
38 #endif | |
39 #ifdef TARGET_OS_ARCH_solaris_x86 | |
40 # include "orderAccess_solaris_x86.inline.hpp" | |
41 #endif | |
42 #ifdef TARGET_OS_ARCH_solaris_sparc | |
43 # include "orderAccess_solaris_sparc.inline.hpp" | |
44 #endif | |
45 #ifdef TARGET_OS_ARCH_windows_x86 | |
46 # include "orderAccess_windows_x86.inline.hpp" | |
47 #endif | |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
48 #ifdef TARGET_OS_ARCH_linux_arm |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
49 # include "orderAccess_linux_arm.inline.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
50 #endif |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
51 #ifdef TARGET_OS_ARCH_linux_ppc |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
52 # include "orderAccess_linux_ppc.inline.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
53 #endif |
3960 | 54 #ifdef TARGET_OS_ARCH_bsd_x86 |
55 # include "orderAccess_bsd_x86.inline.hpp" | |
56 #endif | |
57 #ifdef TARGET_OS_ARCH_bsd_zero | |
58 # include "orderAccess_bsd_zero.inline.hpp" | |
59 #endif | |
1972 | 60 |
0 | 61 // A typeArrayOop is an array containing basic types (non oop elements). |
62 // It is used for arrays of {characters, singles, doubles, bytes, shorts, integers, longs} | |
63 #include <limits.h> | |
64 | |
65 class typeArrayOopDesc : public arrayOopDesc { | |
66 protected: | |
67 jchar* char_base() const { return (jchar*) base(T_CHAR); } | |
68 jboolean* bool_base() const { return (jboolean*)base(T_BOOLEAN); } | |
69 jbyte* byte_base() const { return (jbyte*) base(T_BYTE); } | |
70 jint* int_base() const { return (jint*) base(T_INT); } | |
71 jlong* long_base() const { return (jlong*) base(T_LONG); } | |
72 jshort* short_base() const { return (jshort*) base(T_SHORT); } | |
73 jfloat* float_base() const { return (jfloat*) base(T_FLOAT); } | |
74 jdouble* double_base() const { return (jdouble*) base(T_DOUBLE); } | |
75 | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
76 friend class TypeArrayKlass; |
0 | 77 |
78 public: | |
79 jbyte* byte_at_addr(int which) const { | |
80 assert(is_within_bounds(which), "index out of bounds"); | |
81 return &byte_base()[which]; | |
82 } | |
83 | |
84 jboolean* bool_at_addr(int which) const { | |
85 assert(is_within_bounds(which), "index out of bounds"); | |
86 return &bool_base()[which]; | |
87 } | |
88 | |
89 jchar* char_at_addr(int which) const { | |
90 assert(is_within_bounds(which), "index out of bounds"); | |
91 return &char_base()[which]; | |
92 } | |
93 | |
94 jint* int_at_addr(int which) const { | |
95 assert(is_within_bounds(which), "index out of bounds"); | |
96 return &int_base()[which]; | |
97 } | |
98 | |
99 jshort* short_at_addr(int which) const { | |
100 assert(is_within_bounds(which), "index out of bounds"); | |
101 return &short_base()[which]; | |
102 } | |
103 | |
104 jushort* ushort_at_addr(int which) const { // for field descriptor arrays | |
105 assert(is_within_bounds(which), "index out of bounds"); | |
106 return (jushort*) &short_base()[which]; | |
107 } | |
108 | |
109 jlong* long_at_addr(int which) const { | |
110 assert(is_within_bounds(which), "index out of bounds"); | |
111 return &long_base()[which]; | |
112 } | |
113 | |
114 jfloat* float_at_addr(int which) const { | |
115 assert(is_within_bounds(which), "index out of bounds"); | |
116 return &float_base()[which]; | |
117 } | |
118 | |
119 jdouble* double_at_addr(int which) const { | |
120 assert(is_within_bounds(which), "index out of bounds"); | |
121 return &double_base()[which]; | |
122 } | |
123 | |
124 jbyte byte_at(int which) const { return *byte_at_addr(which); } | |
125 void byte_at_put(int which, jbyte contents) { *byte_at_addr(which) = contents; } | |
126 | |
127 jboolean bool_at(int which) const { return *bool_at_addr(which); } | |
128 void bool_at_put(int which, jboolean contents) { *bool_at_addr(which) = contents; } | |
129 | |
130 jchar char_at(int which) const { return *char_at_addr(which); } | |
131 void char_at_put(int which, jchar contents) { *char_at_addr(which) = contents; } | |
132 | |
133 jint int_at(int which) const { return *int_at_addr(which); } | |
134 void int_at_put(int which, jint contents) { *int_at_addr(which) = contents; } | |
135 | |
136 jshort short_at(int which) const { return *short_at_addr(which); } | |
137 void short_at_put(int which, jshort contents) { *short_at_addr(which) = contents; } | |
138 | |
139 jushort ushort_at(int which) const { return *ushort_at_addr(which); } | |
140 void ushort_at_put(int which, jushort contents) { *ushort_at_addr(which) = contents; } | |
141 | |
142 jlong long_at(int which) const { return *long_at_addr(which); } | |
143 void long_at_put(int which, jlong contents) { *long_at_addr(which) = contents; } | |
144 | |
145 jfloat float_at(int which) const { return *float_at_addr(which); } | |
146 void float_at_put(int which, jfloat contents) { *float_at_addr(which) = contents; } | |
147 | |
148 jdouble double_at(int which) const { return *double_at_addr(which); } | |
149 void double_at_put(int which, jdouble contents) { *double_at_addr(which) = contents; } | |
150 | |
151 jbyte byte_at_acquire(int which) const { return OrderAccess::load_acquire(byte_at_addr(which)); } | |
152 void release_byte_at_put(int which, jbyte contents) { OrderAccess::release_store(byte_at_addr(which), contents); } | |
153 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
154 // Java thinks metadata arrays are just arrays of either long or int, since |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
155 // there doesn't seem to be T_ADDRESS, so this is a bit of unfortunate |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
156 // casting |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
157 #ifdef _LP64 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
158 Metadata* metadata_at(int which) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
159 return (Metadata*)*long_at_addr(which); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
160 void metadata_at_put(int which, Metadata* contents) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
161 *long_at_addr(which) = (long)contents; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
162 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
163 #else |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
164 Metadata* metadata_at(int which) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
165 return (Metadata*)*int_at_addr(which); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
166 void metadata_at_put(int which, Metadata* contents) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
167 *int_at_addr(which) = (int)contents; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
168 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
169 #endif // _LP64 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
170 |
0 | 171 // Sizing |
172 | |
173 // Returns the number of words necessary to hold an array of "len" | |
174 // elements each of the given "byte_size". | |
175 private: | |
176 static int object_size(int lh, int length) { | |
177 int instance_header_size = Klass::layout_helper_header_size(lh); | |
178 int element_shift = Klass::layout_helper_log2_element_size(lh); | |
179 DEBUG_ONLY(BasicType etype = Klass::layout_helper_element_type(lh)); | |
180 assert(length <= arrayOopDesc::max_array_length(etype), "no overflow"); | |
181 | |
182 julong size_in_bytes = length; | |
183 size_in_bytes <<= element_shift; | |
184 size_in_bytes += instance_header_size; | |
185 julong size_in_words = ((size_in_bytes + (HeapWordSize-1)) >> LogHeapWordSize); | |
186 assert(size_in_words <= (julong)max_jint, "no overflow"); | |
187 | |
188 return align_object_size((intptr_t)size_in_words); | |
189 } | |
190 | |
191 public: | |
192 int object_size() { | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
193 TypeArrayKlass* tk = TypeArrayKlass::cast(klass()); |
0 | 194 return object_size(tk->layout_helper(), length()); |
195 } | |
196 }; | |
1972 | 197 |
198 #endif // SHARE_VM_OOPS_TYPEARRAYOOP_HPP |