1 | /* |
2 | * Copyright (c) 2017, 2018, 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 2 1 0 |
36 | // +---------------------------------------------------------------------+-+-+ |
37 | // |11111111 11111111 11111111 11111111 11111111 11111111 11111111 111111|1|1| |
38 | // +---------------------------------------------------------------------+-+-+ |
39 | // | | | |
40 | // | 1-1 Unregistered Flag (1-bits) * | |
41 | // | | |
42 | // | 0-0 Registered Flag (1-bits) * |
43 | // | |
44 | // * 63-2 NMethod Address (62-bits) |
45 | // |
46 | |
47 | class nmethod; |
48 | |
49 | class ZNMethodTableEntry : public CHeapObj<mtGC> { |
50 | private: |
51 | typedef ZBitField<uint64_t, bool, 0, 1> field_registered; |
52 | typedef ZBitField<uint64_t, bool, 1, 1> field_unregistered; |
53 | typedef ZBitField<uint64_t, nmethod*, 2, 62, 2> field_method; |
54 | |
55 | uint64_t _entry; |
56 | |
57 | public: |
58 | explicit ZNMethodTableEntry(bool unregistered = false) : |
59 | _entry(field_registered::encode(false) | |
60 | field_unregistered::encode(unregistered) | |
61 | field_method::encode(NULL)) {} |
62 | |
63 | explicit ZNMethodTableEntry(nmethod* method) : |
64 | _entry(field_registered::encode(true) | |
65 | field_unregistered::encode(false) | |
66 | field_method::encode(method)) {} |
67 | |
68 | bool registered() const { |
69 | return field_registered::decode(_entry); |
70 | } |
71 | |
72 | bool unregistered() const { |
73 | return field_unregistered::decode(_entry); |
74 | } |
75 | |
76 | nmethod* method() const { |
77 | return field_method::decode(_entry); |
78 | } |
79 | }; |
80 | |
81 | #endif // SHARE_GC_Z_ZNMETHODTABLEENTRY_HPP |
82 | |