1 /*
 2  * Copyright (c) 2017, 2025, 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_VM_OOPS_INLINEKLASS_INLINE_HPP
25 #define SHARE_VM_OOPS_INLINEKLASS_INLINE_HPP
26 
27 #include "oops/inlineKlass.hpp"
28 
29 #include "memory/iterator.hpp"
30 #include "oops/flatArrayKlass.hpp"
31 #include "oops/instanceKlass.inline.hpp"
32 #include "oops/oop.inline.hpp"
33 #include "utilities/devirtualizer.inline.hpp"
34 #include "utilities/macros.hpp"
35 
36 inline address InlineKlass::payload_addr(oop o) const {
37   return ((address) (void*) o) + payload_offset();
38 }
39 
40 template <typename T, class OopClosureType>
41 void InlineKlass::oop_iterate_specialized(const address oop_addr, OopClosureType* closure) {
42   OopMapBlock* map = start_of_nonstatic_oop_maps();
43   OopMapBlock* const end_map = map + nonstatic_oop_map_count();
44 
45   for (; map < end_map; map++) {
46     T* p = (T*) (oop_addr + map->offset());
47     T* const end = p + map->count();
48     for (; p < end; ++p) {
49       Devirtualizer::do_oop(closure, p);
50     }
51   }
52 }
53 
54 template <typename T, class OopClosureType>
55 inline void InlineKlass::oop_iterate_specialized_bounded(const address oop_addr, OopClosureType* closure, void* lo, void* hi) {
56   OopMapBlock* map = start_of_nonstatic_oop_maps();
57   OopMapBlock* const end_map = map + nonstatic_oop_map_count();
58 
59   T* const l   = (T*) lo;
60   T* const h   = (T*) hi;
61 
62   for (; map < end_map; map++) {
63     T* p = (T*) (oop_addr + map->offset());
64     T* end = p + map->count();
65     if (p < l) {
66       p = l;
67     }
68     if (end > h) {
69       end = h;
70     }
71     for (; p < end; ++p) {
72       Devirtualizer::do_oop(closure, p);
73     }
74   }
75 }
76 
77 
78 #endif // SHARE_VM_OOPS_INLINEKLASS_INLINE_HPP