< 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 {
// A max segment size of 64K was chosen because microbenchmarking
// suggested that it offered a good trade-off between allocation
// time and time-to-safepoint
const size_t segment_max = ZUtils::bytes_to_words(64 * K);
! if (_word_size <= segment_max) {
// To small to use segmented clearing
return ObjArrayAllocator::initialize(mem);
}
// Segmented clearing
// A max segment size of 64K was chosen because microbenchmarking
// suggested that it offered a good trade-off between allocation
// time and time-to-safepoint
const size_t segment_max = ZUtils::bytes_to_words(64 * K);
! if (_word_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
mem_zap_end_padding(mem);
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);
}
mem_zap_end_padding(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 >