Mercurial > hg > graal-compiler
annotate src/share/vm/oops/klass.inline.hpp @ 17794:3514ee402842
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
Reviewed-by: dholmes, kvn
Contributed-by: martin.doerr@sap.com
author | goetz |
---|---|
date | Thu, 16 Jan 2014 14:25:51 +0100 |
parents | 740e263c80c6 |
children | 78bbf4d43a14 |
rev | line source |
---|---|
0 | 1 /* |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
2 * Copyright (c) 2005, 2013, 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_KLASS_INLINE_HPP |
26 #define SHARE_VM_OOPS_KLASS_INLINE_HPP | |
27 | |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
28 #include "memory/universe.hpp" |
1972 | 29 #include "oops/klass.hpp" |
30 #include "oops/markOop.hpp" | |
31 | |
0 | 32 inline void Klass::set_prototype_header(markOop header) { |
33 assert(!header->has_bias_pattern() || oop_is_instance(), "biased locking currently only supported for Java instances"); | |
34 _prototype_header = header; | |
35 } | |
1972 | 36 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
37 inline bool Klass::is_null(Klass* obj) { return obj == NULL; } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
38 inline bool Klass::is_null(narrowKlass obj) { return obj == 0; } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
39 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
40 // Encoding and decoding for klass field. |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
41 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
42 inline bool check_klass_alignment(Klass* obj) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
43 return (intptr_t)obj % KlassAlignmentInBytes == 0; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
44 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
45 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
46 inline narrowKlass Klass::encode_klass_not_null(Klass* v) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
47 assert(!is_null(v), "klass value can never be zero"); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
48 assert(check_klass_alignment(v), "Address not aligned"); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
49 int shift = Universe::narrow_klass_shift(); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
50 uint64_t pd = (uint64_t)(pointer_delta((void*)v, Universe::narrow_klass_base(), 1)); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
51 assert(KlassEncodingMetaspaceMax > pd, "change encoding max if new encoding"); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
52 uint64_t result = pd >> shift; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
53 assert((result & CONST64(0xffffffff00000000)) == 0, "narrow klass pointer overflow"); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
54 assert(decode_klass(result) == v, "reversibility"); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
55 return (narrowKlass)result; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
56 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
57 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
58 inline narrowKlass Klass::encode_klass(Klass* v) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
59 return is_null(v) ? (narrowKlass)0 : encode_klass_not_null(v); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
60 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
61 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
62 inline Klass* Klass::decode_klass_not_null(narrowKlass v) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
63 assert(!is_null(v), "narrow klass value can never be zero"); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
64 int shift = Universe::narrow_klass_shift(); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
65 Klass* result = (Klass*)(void*)((uintptr_t)Universe::narrow_klass_base() + ((uintptr_t)v << shift)); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
66 assert(check_klass_alignment(result), err_msg("address not aligned: " PTR_FORMAT, (void*) result)); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
67 return result; |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
68 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
69 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
70 inline Klass* Klass::decode_klass(narrowKlass v) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
71 return is_null(v) ? (Klass*)NULL : decode_klass_not_null(v); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
72 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
1972
diff
changeset
|
73 |
1972 | 74 #endif // SHARE_VM_OOPS_KLASS_INLINE_HPP |