Mercurial > hg > graal-compiler
annotate src/share/vm/oops/objArrayOop.hpp @ 21814:5f07d936a14e
8058982: Better verification of an exceptional invokespecial
Summary: Throw VerifyError for illegal accesses
Reviewed-by: acorn, ahgross, coleenp
author | hseigel |
---|---|
date | Mon, 20 Oct 2014 15:14:56 -0400 |
parents | b9a9ed0f8eeb |
children | f31986da9319 |
rev | line source |
---|---|
0 | 1 /* |
6842
b9a9ed0f8eeb
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
6831
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:
1095
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1095
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:
1095
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_OOPS_OBJARRAYOOP_HPP |
26 #define SHARE_VM_OOPS_OBJARRAYOOP_HPP | |
27 | |
28 #include "oops/arrayOop.hpp" | |
29 | |
0 | 30 // An objArrayOop is an array containing oops. |
31 // Evaluating "String arg[10]" will create an objArrayOop. | |
32 | |
33 class objArrayOopDesc : public arrayOopDesc { | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
4097
diff
changeset
|
34 friend class ObjArrayKlass; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
35 friend class Runtime1; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
36 friend class psPromotionManager; |
4097
dc467e8b2c5e
7112743: G1: Reduce overhead of marking closure during evacuation pauses
johnc
parents:
1972
diff
changeset
|
37 friend class CSetMarkOopClosure; |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
38 friend class G1ParScanPartialArrayClosure; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
39 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
40 template <class T> T* obj_at_addr(int index) const { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
41 assert(is_within_bounds(index), "index out of bounds"); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
42 return &((T*)base())[index]; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
43 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
44 |
1091
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
45 private: |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
46 // Give size of objArrayOop in HeapWords minus the header |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
47 static int array_size(int length) { |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
48 const int OopsPerHeapWord = HeapWordSize/heapOopSize; |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
49 assert(OopsPerHeapWord >= 1 && (HeapWordSize % heapOopSize == 0), |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
50 "Else the following (new) computation would be in error"); |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
51 #ifdef ASSERT |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
52 // The old code is left in for sanity-checking; it'll |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
53 // go away pretty soon. XXX |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
54 // Without UseCompressedOops, this is simply: |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
55 // oop->length() * HeapWordsPerOop; |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
56 // With narrowOops, HeapWordsPerOop is 1/2 or equal 0 as an integer. |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
57 // The oop elements are aligned up to wordSize |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
58 const int HeapWordsPerOop = heapOopSize/HeapWordSize; |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
59 int old_res; |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
60 if (HeapWordsPerOop > 0) { |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
61 old_res = length * HeapWordsPerOop; |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
62 } else { |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
63 old_res = align_size_up(length, OopsPerHeapWord)/OopsPerHeapWord; |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
64 } |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
65 #endif // ASSERT |
1095
7bfd295ec074
6908208: UseCompressedOops: array_size() returns incorrect size for MAX_INT object array following 6906727
ysr
parents:
1091
diff
changeset
|
66 int res = ((uint)length + OopsPerHeapWord - 1)/OopsPerHeapWord; |
1091
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
67 assert(res == old_res, "Inconsistency between old and new."); |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
68 return res; |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
69 } |
6aa7255741f3
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
948
diff
changeset
|
70 |
0 | 71 public: |
895
94b6d06fd759
6860920: serialize.cpp shouldn't use objArrayOopDesc::base_offset_in_bytes(T_BYTE)
twisti
parents:
356
diff
changeset
|
72 // Returns the offset of the first element. |
94b6d06fd759
6860920: serialize.cpp shouldn't use objArrayOopDesc::base_offset_in_bytes(T_BYTE)
twisti
parents:
356
diff
changeset
|
73 static int base_offset_in_bytes() { |
94b6d06fd759
6860920: serialize.cpp shouldn't use objArrayOopDesc::base_offset_in_bytes(T_BYTE)
twisti
parents:
356
diff
changeset
|
74 return arrayOopDesc::base_offset_in_bytes(T_OBJECT); |
94b6d06fd759
6860920: serialize.cpp shouldn't use objArrayOopDesc::base_offset_in_bytes(T_BYTE)
twisti
parents:
356
diff
changeset
|
75 } |
94b6d06fd759
6860920: serialize.cpp shouldn't use objArrayOopDesc::base_offset_in_bytes(T_BYTE)
twisti
parents:
356
diff
changeset
|
76 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
77 // base is the address following the header. |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
78 HeapWord* base() const { return (HeapWord*) arrayOopDesc::base(T_OBJECT); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
79 |
0 | 80 // Accessing |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
81 oop obj_at(int index) const { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
82 // With UseCompressedOops decode the narrow oop in the objArray to an |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
83 // uncompressed oop. Otherwise this is simply a "*" operator. |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
84 if (UseCompressedOops) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
85 return load_decode_heap_oop(obj_at_addr<narrowOop>(index)); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
86 } else { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
87 return load_decode_heap_oop(obj_at_addr<oop>(index)); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
88 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
89 } |
0 | 90 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
91 void obj_at_put(int index, oop value) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
92 if (UseCompressedOops) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
93 oop_store(obj_at_addr<narrowOop>(index), value); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
94 } else { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
95 oop_store(obj_at_addr<oop>(index), value); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
96 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
97 } |
0 | 98 // Sizing |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
99 static int header_size() { return arrayOopDesc::header_size(T_OBJECT); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
100 int object_size() { return object_size(length()); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
101 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
102 static int object_size(int length) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
103 // This returns the object size in HeapWords. |
1095
7bfd295ec074
6908208: UseCompressedOops: array_size() returns incorrect size for MAX_INT object array following 6906727
ysr
parents:
1091
diff
changeset
|
104 uint asz = array_size(length); |
7bfd295ec074
6908208: UseCompressedOops: array_size() returns incorrect size for MAX_INT object array following 6906727
ysr
parents:
1091
diff
changeset
|
105 uint osz = align_object_size(header_size() + asz); |
7bfd295ec074
6908208: UseCompressedOops: array_size() returns incorrect size for MAX_INT object array following 6906727
ysr
parents:
1091
diff
changeset
|
106 assert(osz >= asz, "no overflow"); |
7bfd295ec074
6908208: UseCompressedOops: array_size() returns incorrect size for MAX_INT object array following 6906727
ysr
parents:
1091
diff
changeset
|
107 assert((int)osz > 0, "no overflow"); |
7bfd295ec074
6908208: UseCompressedOops: array_size() returns incorrect size for MAX_INT object array following 6906727
ysr
parents:
1091
diff
changeset
|
108 return (int)osz; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
109 } |
0 | 110 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
111 // special iterators for index ranges, returns size of object |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
112 #define ObjArrayOop_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \ |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
113 int oop_iterate_range(OopClosureType* blk, int start, int end); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
114 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
115 ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayOop_OOP_ITERATE_DECL) |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
116 ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayOop_OOP_ITERATE_DECL) |
0 | 117 }; |
1972 | 118 |
119 #endif // SHARE_VM_OOPS_OBJARRAYOOP_HPP |