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