|
1 /* |
|
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
|
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 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 */ |
|
23 |
|
24 #ifndef SHARE_GC_Z_ZNMETHODTABLEENTRY_HPP |
|
25 #define SHARE_GC_Z_ZNMETHODTABLEENTRY_HPP |
|
26 |
|
27 #include "gc/z/zBitField.hpp" |
|
28 #include "memory/allocation.hpp" |
|
29 |
|
30 // |
|
31 // NMethod table entry layout |
|
32 // -------------------------- |
|
33 // |
|
34 // 6 |
|
35 // 3 3 2 1 0 |
|
36 // +--------------------------------------------------------------------+-+-+-+ |
|
37 // |11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111|1|1|1| |
|
38 // +--------------------------------------------------------------------+-+-+-+ |
|
39 // | | | | |
|
40 // | 2-2 Non-immediate Oops Flag (1-bits) * | | |
|
41 // | | | |
|
42 // | 1-1 Immediate Oops/Unregistered Flag (1-bits) * | |
|
43 // | | |
|
44 // | 0-0 Registered Flag (1-bits) * |
|
45 // | |
|
46 // * 63-3 NMethod/ZNMethodWithImmediateOops Address (61-bits) |
|
47 // |
|
48 |
|
49 class nmethod; |
|
50 class ZNMethodWithImmediateOops; |
|
51 |
|
52 class ZNMethodTableEntry : public CHeapObj<mtGC> { |
|
53 private: |
|
54 typedef ZBitField<uint64_t, bool, 0, 1> field_registered; |
|
55 typedef ZBitField<uint64_t, bool, 1, 1> field_unregistered; |
|
56 typedef ZBitField<uint64_t, bool, 1, 1> field_immediate_oops; |
|
57 typedef ZBitField<uint64_t, bool, 2, 1> field_non_immediate_oops; |
|
58 typedef ZBitField<uint64_t, nmethod*, 3, 61, 3> field_method; |
|
59 typedef ZBitField<uint64_t, ZNMethodWithImmediateOops*, 3, 61, 3> field_method_with_immediate_oops; |
|
60 |
|
61 uint64_t _entry; |
|
62 |
|
63 public: |
|
64 ZNMethodTableEntry(bool unregistered = false) : |
|
65 _entry(field_unregistered::encode(unregistered) | |
|
66 field_registered::encode(false)) {} |
|
67 |
|
68 ZNMethodTableEntry(nmethod* method, bool non_immediate_oops) : |
|
69 _entry(field_method::encode(method) | |
|
70 field_non_immediate_oops::encode(non_immediate_oops) | |
|
71 field_immediate_oops::encode(false) | |
|
72 field_registered::encode(true)) {} |
|
73 |
|
74 ZNMethodTableEntry(ZNMethodWithImmediateOops* method_with_immediate_oops, bool non_immediate_oops) : |
|
75 _entry(field_method_with_immediate_oops::encode(method_with_immediate_oops) | |
|
76 field_non_immediate_oops::encode(non_immediate_oops) | |
|
77 field_immediate_oops::encode(true) | |
|
78 field_registered::encode(true)) {} |
|
79 |
|
80 bool registered() const { |
|
81 return field_registered::decode(_entry); |
|
82 } |
|
83 |
|
84 bool unregistered() const { |
|
85 return field_unregistered::decode(_entry); |
|
86 } |
|
87 |
|
88 bool immediate_oops() const { |
|
89 return field_immediate_oops::decode(_entry); |
|
90 } |
|
91 |
|
92 bool non_immediate_oops() const { |
|
93 return field_non_immediate_oops::decode(_entry); |
|
94 } |
|
95 |
|
96 nmethod* method() const { |
|
97 return field_method::decode(_entry); |
|
98 } |
|
99 |
|
100 ZNMethodWithImmediateOops* method_with_immediate_oops() const { |
|
101 return field_method_with_immediate_oops::decode(_entry); |
|
102 } |
|
103 }; |
|
104 |
|
105 #endif // SHARE_GC_Z_ZNMETHODTABLEENTRY_HPP |