2015-04-02 10:04:27 +02:00
|
|
|
/*
|
2020-04-30 06:05:53 -04:00
|
|
|
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
2015-04-02 10:04:27 +02:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-01-10 15:13:51 -05:00
|
|
|
#ifndef SHARE_OOPS_INSTANCEKLASS_INLINE_HPP
|
|
|
|
#define SHARE_OOPS_INSTANCEKLASS_INLINE_HPP
|
2015-04-02 10:04:27 +02:00
|
|
|
|
|
|
|
#include "memory/iterator.hpp"
|
|
|
|
#include "oops/instanceKlass.hpp"
|
2015-05-25 11:39:43 +02:00
|
|
|
#include "oops/klass.hpp"
|
2015-04-02 10:04:27 +02:00
|
|
|
#include "oops/oop.inline.hpp"
|
2019-11-26 10:47:46 +01:00
|
|
|
#include "runtime/atomic.hpp"
|
2015-04-02 10:04:27 +02:00
|
|
|
#include "utilities/debug.hpp"
|
|
|
|
#include "utilities/globalDefinitions.hpp"
|
|
|
|
#include "utilities/macros.hpp"
|
|
|
|
|
2020-04-30 06:05:53 -04:00
|
|
|
inline ObjArrayKlass* InstanceKlass::array_klasses_acquire() const {
|
2019-11-25 12:22:13 +01:00
|
|
|
return Atomic::load_acquire(&_array_klasses);
|
2016-08-29 20:13:45 -04:00
|
|
|
}
|
|
|
|
|
2020-04-30 06:05:53 -04:00
|
|
|
inline void InstanceKlass::release_set_array_klasses(ObjArrayKlass* k) {
|
2019-11-25 12:22:13 +01:00
|
|
|
Atomic::release_store(&_array_klasses, k);
|
2016-08-29 20:13:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
inline jmethodID* InstanceKlass::methods_jmethod_ids_acquire() const {
|
2019-11-25 12:22:13 +01:00
|
|
|
return Atomic::load_acquire(&_methods_jmethod_ids);
|
2016-08-29 20:13:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void InstanceKlass::release_set_methods_jmethod_ids(jmethodID* jmeths) {
|
2019-11-25 12:22:13 +01:00
|
|
|
Atomic::release_store(&_methods_jmethod_ids, jmeths);
|
2016-08-29 20:13:45 -04:00
|
|
|
}
|
|
|
|
|
2015-04-02 10:04:27 +02:00
|
|
|
// The iteration over the oops in objects is a hot path in the GC code.
|
|
|
|
// By force inlining the following functions, we get similar GC performance
|
|
|
|
// as the previous macro based implementation.
|
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
template <typename T, class OopClosureType>
|
2016-03-11 16:39:38 +01:00
|
|
|
ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_map(OopMapBlock* map, oop obj, OopClosureType* closure) {
|
2018-02-22 10:39:42 +01:00
|
|
|
T* p = (T*)obj->obj_field_addr_raw<T>(map->offset());
|
2015-04-02 10:04:27 +02:00
|
|
|
T* const end = p + map->count();
|
|
|
|
|
|
|
|
for (; p < end; ++p) {
|
2018-05-26 06:59:49 +02:00
|
|
|
Devirtualizer::do_oop(closure, p);
|
2015-04-02 10:04:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
template <typename T, class OopClosureType>
|
2016-03-11 16:39:38 +01:00
|
|
|
ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_map_reverse(OopMapBlock* map, oop obj, OopClosureType* closure) {
|
2018-02-22 10:39:42 +01:00
|
|
|
T* const start = (T*)obj->obj_field_addr_raw<T>(map->offset());
|
2015-04-02 10:04:27 +02:00
|
|
|
T* p = start + map->count();
|
|
|
|
|
|
|
|
while (start < p) {
|
|
|
|
--p;
|
2018-05-26 06:59:49 +02:00
|
|
|
Devirtualizer::do_oop(closure, p);
|
2015-04-02 10:04:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
template <typename T, class OopClosureType>
|
2016-03-11 16:39:38 +01:00
|
|
|
ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_map_bounded(OopMapBlock* map, oop obj, OopClosureType* closure, MemRegion mr) {
|
2018-02-22 10:39:42 +01:00
|
|
|
T* p = (T*)obj->obj_field_addr_raw<T>(map->offset());
|
2015-04-02 10:04:27 +02:00
|
|
|
T* end = p + map->count();
|
|
|
|
|
|
|
|
T* const l = (T*)mr.start();
|
|
|
|
T* const h = (T*)mr.end();
|
|
|
|
assert(mask_bits((intptr_t)l, sizeof(T)-1) == 0 &&
|
|
|
|
mask_bits((intptr_t)h, sizeof(T)-1) == 0,
|
|
|
|
"bounded region must be properly aligned");
|
|
|
|
|
|
|
|
if (p < l) {
|
|
|
|
p = l;
|
|
|
|
}
|
|
|
|
if (end > h) {
|
|
|
|
end = h;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;p < end; ++p) {
|
2018-05-26 06:59:49 +02:00
|
|
|
Devirtualizer::do_oop(closure, p);
|
2015-04-02 10:04:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
template <typename T, class OopClosureType>
|
|
|
|
ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_maps(oop obj, OopClosureType* closure) {
|
2015-04-02 10:04:27 +02:00
|
|
|
OopMapBlock* map = start_of_nonstatic_oop_maps();
|
|
|
|
OopMapBlock* const end_map = map + nonstatic_oop_map_count();
|
|
|
|
|
|
|
|
for (; map < end_map; ++map) {
|
2018-05-26 06:59:49 +02:00
|
|
|
oop_oop_iterate_oop_map<T>(map, obj, closure);
|
2015-04-02 10:04:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
template <typename T, class OopClosureType>
|
|
|
|
ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_maps_reverse(oop obj, OopClosureType* closure) {
|
2015-04-02 10:04:27 +02:00
|
|
|
OopMapBlock* const start_map = start_of_nonstatic_oop_maps();
|
|
|
|
OopMapBlock* map = start_map + nonstatic_oop_map_count();
|
|
|
|
|
|
|
|
while (start_map < map) {
|
|
|
|
--map;
|
2018-05-26 06:59:49 +02:00
|
|
|
oop_oop_iterate_oop_map_reverse<T>(map, obj, closure);
|
2015-04-02 10:04:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
template <typename T, class OopClosureType>
|
|
|
|
ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_maps_bounded(oop obj, OopClosureType* closure, MemRegion mr) {
|
2015-04-02 10:04:27 +02:00
|
|
|
OopMapBlock* map = start_of_nonstatic_oop_maps();
|
|
|
|
OopMapBlock* const end_map = map + nonstatic_oop_map_count();
|
|
|
|
|
|
|
|
for (;map < end_map; ++map) {
|
2018-05-26 06:59:49 +02:00
|
|
|
oop_oop_iterate_oop_map_bounded<T>(map, obj, closure, mr);
|
2015-04-02 10:04:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
template <typename T, class OopClosureType>
|
2018-10-18 11:23:54 +02:00
|
|
|
ALWAYSINLINE void InstanceKlass::oop_oop_iterate(oop obj, OopClosureType* closure) {
|
2018-05-26 06:59:49 +02:00
|
|
|
if (Devirtualizer::do_metadata(closure)) {
|
|
|
|
Devirtualizer::do_klass(closure, this);
|
2015-04-02 10:04:27 +02:00
|
|
|
}
|
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
oop_oop_iterate_oop_maps<T>(obj, closure);
|
2015-04-02 10:04:27 +02:00
|
|
|
}
|
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
template <typename T, class OopClosureType>
|
2018-10-18 11:23:54 +02:00
|
|
|
ALWAYSINLINE void InstanceKlass::oop_oop_iterate_reverse(oop obj, OopClosureType* closure) {
|
2018-05-26 06:59:49 +02:00
|
|
|
assert(!Devirtualizer::do_metadata(closure),
|
2015-04-02 10:04:27 +02:00
|
|
|
"Code to handle metadata is not implemented");
|
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
oop_oop_iterate_oop_maps_reverse<T>(obj, closure);
|
2015-04-02 10:04:27 +02:00
|
|
|
}
|
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
template <typename T, class OopClosureType>
|
2018-10-18 11:23:54 +02:00
|
|
|
ALWAYSINLINE void InstanceKlass::oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr) {
|
2018-05-26 06:59:49 +02:00
|
|
|
if (Devirtualizer::do_metadata(closure)) {
|
2015-04-02 10:04:27 +02:00
|
|
|
if (mr.contains(obj)) {
|
2018-05-26 06:59:49 +02:00
|
|
|
Devirtualizer::do_klass(closure, this);
|
2015-04-02 10:04:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
oop_oop_iterate_oop_maps_bounded<T>(obj, closure, mr);
|
2015-04-02 10:04:27 +02:00
|
|
|
}
|
|
|
|
|
2019-01-10 15:13:51 -05:00
|
|
|
#endif // SHARE_OOPS_INSTANCEKLASS_INLINE_HPP
|