< prev index next > src/hotspot/share/gc/z/zObjArrayAllocator.cpp
Print this page
#include "gc/z/zObjArrayAllocator.hpp"
#include "gc/z/zUtils.inline.hpp"
#include "oops/arrayKlass.hpp"
#include "runtime/interfaceSupport.inline.hpp"
#include "utilities/debug.hpp"
+ #include "utilities/globalDefinitions.hpp"
ZObjArrayAllocator::ZObjArrayAllocator(Klass* klass, size_t word_size, int length, bool do_zero, Thread* thread)
: ObjArrayAllocator(klass, word_size, length, do_zero, thread) {}
void ZObjArrayAllocator::yield_for_safepoint() const {
const size_t segment_max = ZUtils::bytes_to_words(64 * K);
const BasicType element_type = ArrayKlass::cast(_klass)->element_type();
const size_t header = arrayOopDesc::header_size(element_type);
const size_t payload_size = _word_size - header;
! if (payload_size <= segment_max) {
// To small to use segmented clearing
return ObjArrayAllocator::initialize(mem);
}
// Segmented clearing
const size_t segment_max = ZUtils::bytes_to_words(64 * K);
const BasicType element_type = ArrayKlass::cast(_klass)->element_type();
const size_t header = arrayOopDesc::header_size(element_type);
const size_t payload_size = _word_size - header;
! if (payload_size <= segment_max || ArrayKlass::cast(_klass)->is_flatArray_klass()) {
// To small to use segmented clearing
return ObjArrayAllocator::initialize(mem);
}
// Segmented clearing
// cleared, therefore we can't expose the header at the end of this
// function. Instead explicitly initialize it according to our needs.
// Signal to the ZIterator that this is an invisible root, by setting
// the mark word to "marked". Reset to prototype() after the clearing.
! arrayOopDesc::set_mark(mem, markWord::prototype().set_marked());
arrayOopDesc::release_set_klass(mem, _klass);
assert(_length >= 0, "length should be non-negative");
arrayOopDesc::set_length(mem, _length);
// Keep the array alive across safepoints through an invisible
// cleared, therefore we can't expose the header at the end of this
// function. Instead explicitly initialize it according to our needs.
// Signal to the ZIterator that this is an invisible root, by setting
// the mark word to "marked". Reset to prototype() after the clearing.
! arrayOopDesc::set_mark(mem, Klass::default_prototype_header(_klass).set_marked());
arrayOopDesc::release_set_klass(mem, _klass);
assert(_length >= 0, "length should be non-negative");
arrayOopDesc::set_length(mem, _length);
// Keep the array alive across safepoints through an invisible
}
ZThreadLocalData::clear_invisible_root(_thread);
// Signal to the ZIterator that this is no longer an invisible root
! oopDesc::release_set_mark(mem, markWord::prototype());
return cast_to_oop(mem);
}
}
ZThreadLocalData::clear_invisible_root(_thread);
// Signal to the ZIterator that this is no longer an invisible root
! oopDesc::release_set_mark(mem, Klass::default_prototype_header(_klass));
return cast_to_oop(mem);
}
< prev index next >