2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2019-01-10 15:13:51 -05:00
|
|
|
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00: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.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* 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.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-01-10 15:13:51 -05:00
|
|
|
#ifndef SHARE_OOPS_OOP_INLINE_HPP
|
|
|
|
#define SHARE_OOPS_OOP_INLINE_HPP
|
2010-11-23 13:22:55 -08:00
|
|
|
|
2018-03-15 21:29:36 +01:00
|
|
|
#include "gc/shared/collectedHeap.hpp"
|
2019-05-09 14:28:30 +02:00
|
|
|
#include "memory/universe.hpp"
|
2017-11-20 13:07:44 +01:00
|
|
|
#include "oops/access.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/arrayKlass.hpp"
|
|
|
|
#include "oops/arrayOop.hpp"
|
2018-03-15 21:24:10 +01:00
|
|
|
#include "oops/compressedOops.inline.hpp"
|
2013-08-15 20:04:10 -04:00
|
|
|
#include "oops/klass.inline.hpp"
|
2019-08-19 11:30:03 +02:00
|
|
|
#include "oops/markWord.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/oop.hpp"
|
2016-08-21 20:56:37 -04:00
|
|
|
#include "runtime/atomic.hpp"
|
2018-06-06 10:45:40 -04:00
|
|
|
#include "runtime/orderAccess.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/os.hpp"
|
2017-07-05 11:33:17 +02:00
|
|
|
#include "utilities/align.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#include "utilities/macros.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Implementation of all inlined member functions defined in oop.hpp
|
|
|
|
// We need a separate file to avoid circular references
|
|
|
|
|
2019-08-06 10:48:21 +02:00
|
|
|
markWord oopDesc::mark() const {
|
|
|
|
uintptr_t v = HeapAccess<MO_VOLATILE>::load_at(as_oop(), mark_offset_in_bytes());
|
|
|
|
return markWord(v);
|
2018-04-05 10:54:53 +02:00
|
|
|
}
|
|
|
|
|
2019-08-06 10:48:21 +02:00
|
|
|
markWord oopDesc::mark_raw() const {
|
|
|
|
return Atomic::load(&_mark);
|
2018-04-05 10:54:53 +02:00
|
|
|
}
|
|
|
|
|
2019-08-06 10:48:21 +02:00
|
|
|
markWord* oopDesc::mark_addr_raw() const {
|
|
|
|
return (markWord*) &_mark;
|
2018-04-05 10:54:53 +02:00
|
|
|
}
|
|
|
|
|
2019-08-06 10:48:21 +02:00
|
|
|
void oopDesc::set_mark(markWord m) {
|
|
|
|
HeapAccess<MO_VOLATILE>::store_at(as_oop(), mark_offset_in_bytes(), m.value());
|
2018-04-05 10:54:53 +02:00
|
|
|
}
|
|
|
|
|
2019-08-06 10:48:21 +02:00
|
|
|
void oopDesc::set_mark_raw(markWord m) {
|
2019-11-25 12:30:24 +01:00
|
|
|
Atomic::store(&_mark, m);
|
2018-04-05 10:54:53 +02:00
|
|
|
}
|
|
|
|
|
2019-08-06 10:48:21 +02:00
|
|
|
void oopDesc::set_mark_raw(HeapWord* mem, markWord m) {
|
|
|
|
*(markWord*)(((char*)mem) + mark_offset_in_bytes()) = m;
|
2018-06-28 14:22:28 +02:00
|
|
|
}
|
|
|
|
|
2019-08-06 10:48:21 +02:00
|
|
|
void oopDesc::release_set_mark(markWord m) {
|
|
|
|
HeapAccess<MO_RELEASE>::store_at(as_oop(), mark_offset_in_bytes(), m.value());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2019-08-06 10:48:21 +02:00
|
|
|
markWord oopDesc::cas_set_mark(markWord new_mark, markWord old_mark) {
|
|
|
|
uintptr_t v = HeapAccess<>::atomic_cmpxchg_at(new_mark.value(), as_oop(), mark_offset_in_bytes(), old_mark.value());
|
|
|
|
return markWord(v);
|
2018-04-05 10:54:53 +02:00
|
|
|
}
|
|
|
|
|
2019-08-06 10:48:21 +02:00
|
|
|
markWord oopDesc::cas_set_mark_raw(markWord new_mark, markWord old_mark, atomic_memory_order order) {
|
2018-06-05 09:29:15 +02:00
|
|
|
return Atomic::cmpxchg(new_mark, &_mark, old_mark, order);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::init_mark() {
|
2019-08-19 12:40:27 +02:00
|
|
|
set_mark(markWord::prototype_for_klass(klass()));
|
2016-01-04 15:41:05 +01:00
|
|
|
}
|
|
|
|
|
2018-04-05 10:54:53 +02:00
|
|
|
void oopDesc::init_mark_raw() {
|
2019-08-19 12:40:27 +02:00
|
|
|
set_mark_raw(markWord::prototype_for_klass(klass()));
|
2018-04-05 10:54:53 +02:00
|
|
|
}
|
|
|
|
|
2016-01-18 10:25:41 +01:00
|
|
|
Klass* oopDesc::klass() const {
|
2013-08-12 17:37:02 +02:00
|
|
|
if (UseCompressedClassPointers) {
|
2019-05-09 14:26:03 +02:00
|
|
|
return CompressedKlassPointers::decode_not_null(_metadata._compressed_klass);
|
2008-05-28 21:06:24 -07:00
|
|
|
} else {
|
|
|
|
return _metadata._klass;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
Klass* oopDesc::klass_or_null() const volatile {
|
2013-08-12 17:37:02 +02:00
|
|
|
if (UseCompressedClassPointers) {
|
2019-05-09 14:26:03 +02:00
|
|
|
return CompressedKlassPointers::decode(_metadata._compressed_klass);
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
} else {
|
|
|
|
return _metadata._klass;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-23 18:23:12 -04:00
|
|
|
Klass* oopDesc::klass_or_null_acquire() const volatile {
|
|
|
|
if (UseCompressedClassPointers) {
|
|
|
|
// Workaround for non-const load_acquire parameter.
|
|
|
|
const volatile narrowKlass* addr = &_metadata._compressed_klass;
|
|
|
|
volatile narrowKlass* xaddr = const_cast<volatile narrowKlass*>(addr);
|
2019-11-25 12:22:13 +01:00
|
|
|
return CompressedKlassPointers::decode(Atomic::load_acquire(xaddr));
|
2016-09-23 18:23:12 -04:00
|
|
|
} else {
|
2019-11-25 12:22:13 +01:00
|
|
|
return Atomic::load_acquire(&_metadata._klass);
|
2016-09-23 18:23:12 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-28 14:22:28 +02:00
|
|
|
Klass** oopDesc::klass_addr(HeapWord* mem) {
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
// Only used internally and with CMS and will not work with
|
|
|
|
// UseCompressedOops
|
2013-08-12 17:37:02 +02:00
|
|
|
assert(!UseCompressedClassPointers, "only supported with uncompressed klass pointers");
|
2018-06-28 14:22:28 +02:00
|
|
|
ByteSize offset = byte_offset_of(oopDesc, _metadata._klass);
|
|
|
|
return (Klass**) (((char*)mem) + in_bytes(offset));
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
}
|
|
|
|
|
2018-06-28 14:22:28 +02:00
|
|
|
narrowKlass* oopDesc::compressed_klass_addr(HeapWord* mem) {
|
2013-08-12 17:37:02 +02:00
|
|
|
assert(UseCompressedClassPointers, "only called by compressed klass pointers");
|
2018-06-28 14:22:28 +02:00
|
|
|
ByteSize offset = byte_offset_of(oopDesc, _metadata._compressed_klass);
|
|
|
|
return (narrowKlass*) (((char*)mem) + in_bytes(offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
Klass** oopDesc::klass_addr() {
|
|
|
|
return klass_addr((HeapWord*)this);
|
|
|
|
}
|
|
|
|
|
|
|
|
narrowKlass* oopDesc::compressed_klass_addr() {
|
|
|
|
return compressed_klass_addr((HeapWord*)this);
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
}
|
|
|
|
|
2016-09-15 12:10:43 -04:00
|
|
|
#define CHECK_SET_KLASS(k) \
|
|
|
|
do { \
|
|
|
|
assert(Universe::is_bootstrapping() || k != NULL, "NULL Klass"); \
|
|
|
|
assert(Universe::is_bootstrapping() || k->is_klass(), "not a Klass"); \
|
|
|
|
} while (0)
|
|
|
|
|
2016-01-18 10:25:41 +01:00
|
|
|
void oopDesc::set_klass(Klass* k) {
|
2016-09-15 12:10:43 -04:00
|
|
|
CHECK_SET_KLASS(k);
|
2013-08-12 17:37:02 +02:00
|
|
|
if (UseCompressedClassPointers) {
|
2019-05-09 14:26:03 +02:00
|
|
|
*compressed_klass_addr() = CompressedKlassPointers::encode_not_null(k);
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
} else {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
*klass_addr() = k;
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2018-06-28 14:22:28 +02:00
|
|
|
void oopDesc::release_set_klass(HeapWord* mem, Klass* klass) {
|
|
|
|
CHECK_SET_KLASS(klass);
|
2016-09-15 12:10:43 -04:00
|
|
|
if (UseCompressedClassPointers) {
|
2019-11-25 12:22:13 +01:00
|
|
|
Atomic::release_store(compressed_klass_addr(mem),
|
|
|
|
CompressedKlassPointers::encode_not_null(klass));
|
2016-09-15 12:10:43 -04:00
|
|
|
} else {
|
2019-11-25 12:22:13 +01:00
|
|
|
Atomic::release_store(klass_addr(mem), klass);
|
2016-09-15 12:10:43 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef CHECK_SET_KLASS
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
int oopDesc::klass_gap() const {
|
2008-05-28 21:06:24 -07:00
|
|
|
return *(int*)(((intptr_t)this) + klass_gap_offset_in_bytes());
|
|
|
|
}
|
|
|
|
|
2018-06-28 14:22:28 +02:00
|
|
|
void oopDesc::set_klass_gap(HeapWord* mem, int v) {
|
2013-08-12 17:37:02 +02:00
|
|
|
if (UseCompressedClassPointers) {
|
2018-06-28 14:22:28 +02:00
|
|
|
*(int*)(((char*)mem) + klass_gap_offset_in_bytes()) = v;
|
2008-05-28 21:06:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-28 14:22:28 +02:00
|
|
|
void oopDesc::set_klass_gap(int v) {
|
|
|
|
set_klass_gap((HeapWord*)this, v);
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
bool oopDesc::is_a(Klass* k) const {
|
|
|
|
return klass()->is_subtype_of(k);
|
|
|
|
}
|
|
|
|
|
2016-01-18 10:25:41 +01:00
|
|
|
int oopDesc::size() {
|
2016-01-04 15:41:05 +01:00
|
|
|
return size_given_klass(klass());
|
|
|
|
}
|
|
|
|
|
|
|
|
int oopDesc::size_given_klass(Klass* klass) {
|
|
|
|
int lh = klass->layout_helper();
|
|
|
|
int s;
|
|
|
|
|
|
|
|
// lh is now a value computed at class initialization that may hint
|
|
|
|
// at the size. For instances, this is positive and equal to the
|
|
|
|
// size. For arrays, this is negative and provides log2 of the
|
|
|
|
// array element size. For other oops, it is zero and thus requires
|
|
|
|
// a virtual call.
|
|
|
|
//
|
|
|
|
// We go to all this trouble because the size computation is at the
|
|
|
|
// heart of phase 2 of mark-compaction, and called for every object,
|
|
|
|
// alive or dead. So the speed here is equal in importance to the
|
|
|
|
// speed of allocation.
|
|
|
|
|
|
|
|
if (lh > Klass::_lh_neutral_value) {
|
|
|
|
if (!Klass::layout_helper_needs_slow_path(lh)) {
|
|
|
|
s = lh >> LogHeapWordSize; // deliver size scaled by wordSize
|
|
|
|
} else {
|
|
|
|
s = klass->oop_size(this);
|
|
|
|
}
|
|
|
|
} else if (lh <= Klass::_lh_neutral_value) {
|
|
|
|
// The most common case is instances; fall through if so.
|
|
|
|
if (lh < Klass::_lh_neutral_value) {
|
|
|
|
// Second most common case is arrays. We have to fetch the
|
|
|
|
// length of the array, shift (multiply) it appropriately,
|
|
|
|
// up to wordSize, add the header, and align to object size.
|
|
|
|
size_t size_in_bytes;
|
|
|
|
size_t array_length = (size_t) ((arrayOop)this)->length();
|
|
|
|
size_in_bytes = array_length << Klass::layout_helper_log2_element_size(lh);
|
|
|
|
size_in_bytes += Klass::layout_helper_header_size(lh);
|
|
|
|
|
|
|
|
// This code could be simplified, but by keeping array_header_in_bytes
|
|
|
|
// in units of bytes and doing it this way we can round up just once,
|
2017-04-13 09:57:51 +02:00
|
|
|
// skipping the intermediate round to HeapWordSize.
|
|
|
|
s = (int)(align_up(size_in_bytes, MinObjAlignmentInBytes) / HeapWordSize);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2019-11-13 11:37:29 +01:00
|
|
|
// UseParallelGC and UseG1GC can change the length field
|
2016-01-04 15:41:05 +01:00
|
|
|
// of an "old copy" of an object array in the young gen so it indicates
|
|
|
|
// the grey portion of an already copied array. This will cause the first
|
|
|
|
// disjunct below to fail if the two comparands are computed across such
|
|
|
|
// a concurrent change.
|
|
|
|
assert((s == klass->oop_size(this)) ||
|
2019-11-13 11:37:29 +01:00
|
|
|
(Universe::heap()->is_gc_active() && is_objArray() && is_forwarded() && (UseParallelGC || UseG1GC)),
|
2016-01-04 15:41:05 +01:00
|
|
|
"wrong array object size");
|
|
|
|
} else {
|
|
|
|
// Must be zero, so bite the bullet and take the virtual call.
|
|
|
|
s = klass->oop_size(this);
|
|
|
|
}
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2016-07-05 15:34:06 -04:00
|
|
|
assert(s > 0, "Oop size must be greater than zero, not %d", s);
|
2017-07-18 10:20:52 +02:00
|
|
|
assert(is_object_aligned(s), "Oop size is not properly aligned: %d", s);
|
2016-01-04 15:41:05 +01:00
|
|
|
return s;
|
2015-10-09 14:08:15 -04:00
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
bool oopDesc::is_instance() const { return klass()->is_instance_klass(); }
|
2016-01-18 10:25:41 +01:00
|
|
|
bool oopDesc::is_array() const { return klass()->is_array_klass(); }
|
2016-01-04 15:41:05 +01:00
|
|
|
bool oopDesc::is_objArray() const { return klass()->is_objArray_klass(); }
|
|
|
|
bool oopDesc::is_typeArray() const { return klass()->is_typeArray_klass(); }
|
|
|
|
|
2018-02-22 10:39:42 +01:00
|
|
|
void* oopDesc::field_addr_raw(int offset) const { return reinterpret_cast<void*>(cast_from_oop<intptr_t>(as_oop()) + offset); }
|
|
|
|
void* oopDesc::field_addr(int offset) const { return Access<>::resolve(as_oop())->field_addr_raw(offset); }
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
|
2018-02-22 10:39:42 +01:00
|
|
|
template <class T>
|
|
|
|
T* oopDesc::obj_field_addr_raw(int offset) const { return (T*) field_addr_raw(offset); }
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
|
2018-05-20 22:08:25 +02:00
|
|
|
template <typename T>
|
|
|
|
size_t oopDesc::field_offset(T* p) const { return pointer_delta((void*)p, (void*)this, 1); }
|
|
|
|
|
2018-01-08 16:21:23 +01:00
|
|
|
template <DecoratorSet decorators>
|
|
|
|
inline oop oopDesc::obj_field_access(int offset) const { return HeapAccess<decorators>::oop_load_at(as_oop(), offset); }
|
2017-11-20 13:07:44 +01:00
|
|
|
inline oop oopDesc::obj_field(int offset) const { return HeapAccess<>::oop_load_at(as_oop(), offset); }
|
2018-01-08 16:21:23 +01:00
|
|
|
|
2017-11-20 13:07:44 +01:00
|
|
|
inline void oopDesc::obj_field_put(int offset, oop value) { HeapAccess<>::oop_store_at(as_oop(), offset, value); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-11-20 13:07:44 +01:00
|
|
|
inline jbyte oopDesc::byte_field(int offset) const { return HeapAccess<>::load_at(as_oop(), offset); }
|
|
|
|
inline void oopDesc::byte_field_put(int offset, jbyte value) { HeapAccess<>::store_at(as_oop(), offset, value); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-11-20 13:07:44 +01:00
|
|
|
inline jchar oopDesc::char_field(int offset) const { return HeapAccess<>::load_at(as_oop(), offset); }
|
|
|
|
inline void oopDesc::char_field_put(int offset, jchar value) { HeapAccess<>::store_at(as_oop(), offset, value); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2019-11-03 18:02:29 -05:00
|
|
|
inline jboolean oopDesc::bool_field(int offset) const { return HeapAccess<>::load_at(as_oop(), offset); }
|
2017-11-20 13:07:44 +01:00
|
|
|
inline void oopDesc::bool_field_put(int offset, jboolean value) { HeapAccess<>::store_at(as_oop(), offset, jboolean(value & 1)); }
|
2019-11-03 18:02:29 -05:00
|
|
|
inline jboolean oopDesc::bool_field_volatile(int offset) const { return HeapAccess<MO_SEQ_CST>::load_at(as_oop(), offset); }
|
|
|
|
inline void oopDesc::bool_field_put_volatile(int offset, jboolean value) { HeapAccess<MO_SEQ_CST>::store_at(as_oop(), offset, jboolean(value & 1)); }
|
2017-11-20 13:07:44 +01:00
|
|
|
inline jshort oopDesc::short_field(int offset) const { return HeapAccess<>::load_at(as_oop(), offset); }
|
|
|
|
inline void oopDesc::short_field_put(int offset, jshort value) { HeapAccess<>::store_at(as_oop(), offset, value); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-11-20 13:07:44 +01:00
|
|
|
inline jint oopDesc::int_field(int offset) const { return HeapAccess<>::load_at(as_oop(), offset); }
|
2018-07-06 16:04:19 +02:00
|
|
|
inline jint oopDesc::int_field_raw(int offset) const { return RawAccess<>::load_at(as_oop(), offset); }
|
2017-11-20 13:07:44 +01:00
|
|
|
inline void oopDesc::int_field_put(int offset, jint value) { HeapAccess<>::store_at(as_oop(), offset, value); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-11-20 13:07:44 +01:00
|
|
|
inline jlong oopDesc::long_field(int offset) const { return HeapAccess<>::load_at(as_oop(), offset); }
|
|
|
|
inline void oopDesc::long_field_put(int offset, jlong value) { HeapAccess<>::store_at(as_oop(), offset, value); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-11-20 13:07:44 +01:00
|
|
|
inline jfloat oopDesc::float_field(int offset) const { return HeapAccess<>::load_at(as_oop(), offset); }
|
|
|
|
inline void oopDesc::float_field_put(int offset, jfloat value) { HeapAccess<>::store_at(as_oop(), offset, value); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-11-20 13:07:44 +01:00
|
|
|
inline jdouble oopDesc::double_field(int offset) const { return HeapAccess<>::load_at(as_oop(), offset); }
|
|
|
|
inline void oopDesc::double_field_put(int offset, jdouble value) { HeapAccess<>::store_at(as_oop(), offset, value); }
|
2009-04-08 10:56:49 -07:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
bool oopDesc::is_locked() const {
|
2019-08-06 10:48:21 +02:00
|
|
|
return mark().is_locked();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
bool oopDesc::is_unlocked() const {
|
2019-08-06 10:48:21 +02:00
|
|
|
return mark().is_unlocked();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
bool oopDesc::has_bias_pattern() const {
|
2019-08-06 10:48:21 +02:00
|
|
|
return mark().has_bias_pattern();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2018-04-05 10:54:53 +02:00
|
|
|
bool oopDesc::has_bias_pattern_raw() const {
|
2019-08-06 10:48:21 +02:00
|
|
|
return mark_raw().has_bias_pattern();
|
2018-04-05 10:54:53 +02:00
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
// Used only for markSweep, scavenging
|
|
|
|
bool oopDesc::is_gc_marked() const {
|
2019-08-06 10:48:21 +02:00
|
|
|
return mark_raw().is_marked();
|
2016-01-04 15:41:05 +01:00
|
|
|
}
|
|
|
|
|
2015-02-13 14:37:35 +01:00
|
|
|
// Used by scavengers
|
2016-01-04 15:41:05 +01:00
|
|
|
bool oopDesc::is_forwarded() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
// The extra heap check is needed since the obj might be locked, in which case the
|
|
|
|
// mark would point to a stack location and have the sentinel bit cleared
|
2019-08-06 10:48:21 +02:00
|
|
|
return mark_raw().is_marked();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Used by scavengers
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::forward_to(oop p) {
|
2019-09-05 08:26:49 +02:00
|
|
|
verify_forwardee(p);
|
2019-08-06 10:48:21 +02:00
|
|
|
markWord m = markWord::encode_pointer_as_mark(p);
|
|
|
|
assert(m.decode_pointer() == p, "encoding must be reversable");
|
2018-04-05 10:54:53 +02:00
|
|
|
set_mark_raw(m);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Used by parallel scavengers
|
2019-08-06 10:48:21 +02:00
|
|
|
bool oopDesc::cas_forward_to(oop p, markWord compare, atomic_memory_order order) {
|
2019-09-05 08:26:49 +02:00
|
|
|
verify_forwardee(p);
|
2019-08-06 10:48:21 +02:00
|
|
|
markWord m = markWord::encode_pointer_as_mark(p);
|
|
|
|
assert(m.decode_pointer() == p, "encoding must be reversable");
|
2018-06-05 09:29:15 +02:00
|
|
|
return cas_set_mark_raw(m, compare, order) == compare;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2019-08-06 10:48:21 +02:00
|
|
|
oop oopDesc::forward_to_atomic(oop p, markWord compare, atomic_memory_order order) {
|
2019-09-05 08:26:49 +02:00
|
|
|
verify_forwardee(p);
|
2019-08-06 10:48:21 +02:00
|
|
|
markWord m = markWord::encode_pointer_as_mark(p);
|
|
|
|
assert(m.decode_pointer() == p, "encoding must be reversable");
|
|
|
|
markWord old_mark = cas_set_mark_raw(m, compare, order);
|
2018-10-24 16:22:34 +02:00
|
|
|
if (old_mark == compare) {
|
|
|
|
return NULL;
|
|
|
|
} else {
|
2019-08-06 10:48:21 +02:00
|
|
|
return (oop)old_mark.decode_pointer();
|
2015-03-17 15:53:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Note that the forwardee is not the same thing as the displaced_mark.
|
|
|
|
// The forwardee is used when copying during scavenge and mark-sweep.
|
|
|
|
// It does need to clear the low two locking- and GC-related bits.
|
2016-01-04 15:41:05 +01:00
|
|
|
oop oopDesc::forwardee() const {
|
2019-08-06 10:48:21 +02:00
|
|
|
return (oop) mark_raw().decode_pointer();
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-06-05 09:29:15 +02:00
|
|
|
// Note that the forwardee is not the same thing as the displaced_mark.
|
|
|
|
// The forwardee is used when copying during scavenge and mark-sweep.
|
|
|
|
// It does need to clear the low two locking- and GC-related bits.
|
|
|
|
oop oopDesc::forwardee_acquire() const {
|
2019-11-25 12:22:13 +01:00
|
|
|
return (oop) Atomic::load_acquire(&_mark).decode_pointer();
|
2018-06-05 09:29:15 +02:00
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// The following method needs to be MT safe.
|
2016-01-18 10:25:41 +01:00
|
|
|
uint oopDesc::age() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(!is_forwarded(), "Attempt to read age from forwarded mark");
|
2018-04-05 10:54:53 +02:00
|
|
|
if (has_displaced_mark_raw()) {
|
2019-08-06 10:48:21 +02:00
|
|
|
return displaced_mark_raw().age();
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2019-08-06 10:48:21 +02:00
|
|
|
return mark_raw().age();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::incr_age() {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(!is_forwarded(), "Attempt to increment age of forwarded mark");
|
2018-04-05 10:54:53 +02:00
|
|
|
if (has_displaced_mark_raw()) {
|
2019-08-06 10:48:21 +02:00
|
|
|
set_displaced_mark_raw(displaced_mark_raw().incr_age());
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2019-08-06 10:48:21 +02:00
|
|
|
set_mark_raw(mark_raw().incr_age());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
template <typename OopClosureType>
|
|
|
|
void oopDesc::oop_iterate(OopClosureType* cl) {
|
|
|
|
OopIteratorClosureDispatch::oop_oop_iterate(cl, this, klass());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename OopClosureType>
|
|
|
|
void oopDesc::oop_iterate(OopClosureType* cl, MemRegion mr) {
|
|
|
|
OopIteratorClosureDispatch::oop_oop_iterate(cl, this, klass(), mr);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename OopClosureType>
|
|
|
|
int oopDesc::oop_iterate_size(OopClosureType* cl) {
|
|
|
|
Klass* k = klass();
|
|
|
|
int size = size_given_klass(k);
|
|
|
|
OopIteratorClosureDispatch::oop_oop_iterate(cl, this, k);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename OopClosureType>
|
|
|
|
int oopDesc::oop_iterate_size(OopClosureType* cl, MemRegion mr) {
|
|
|
|
Klass* k = klass();
|
|
|
|
int size = size_given_klass(k);
|
|
|
|
OopIteratorClosureDispatch::oop_oop_iterate(cl, this, k, mr);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename OopClosureType>
|
|
|
|
void oopDesc::oop_iterate_backwards(OopClosureType* cl) {
|
|
|
|
OopIteratorClosureDispatch::oop_oop_iterate_backwards(cl, this, klass());
|
2016-01-04 15:41:05 +01:00
|
|
|
}
|
|
|
|
|
2018-03-15 21:24:10 +01:00
|
|
|
bool oopDesc::is_instanceof_or_null(oop obj, Klass* klass) {
|
|
|
|
return obj == NULL || obj->klass()->is_subtype_of(klass);
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
intptr_t oopDesc::identity_hash() {
|
|
|
|
// Fast case; if the object is unlocked and the hash value is set, no locking is needed
|
|
|
|
// Note: The mark must be read into local variable to avoid concurrent updates.
|
2019-08-06 10:48:21 +02:00
|
|
|
markWord mrk = mark();
|
|
|
|
if (mrk.is_unlocked() && !mrk.has_no_hash()) {
|
|
|
|
return mrk.hash();
|
|
|
|
} else if (mrk.is_marked()) {
|
|
|
|
return mrk.hash();
|
2016-01-04 15:41:05 +01:00
|
|
|
} else {
|
|
|
|
return slow_identity_hash();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-05 10:54:53 +02:00
|
|
|
bool oopDesc::has_displaced_mark_raw() const {
|
2019-08-06 10:48:21 +02:00
|
|
|
return mark_raw().has_displaced_mark_helper();
|
2016-01-04 15:41:05 +01:00
|
|
|
}
|
|
|
|
|
2019-08-06 10:48:21 +02:00
|
|
|
markWord oopDesc::displaced_mark_raw() const {
|
|
|
|
return mark_raw().displaced_mark_helper();
|
2016-01-04 15:41:05 +01:00
|
|
|
}
|
|
|
|
|
2019-08-06 10:48:21 +02:00
|
|
|
void oopDesc::set_displaced_mark_raw(markWord m) {
|
|
|
|
mark_raw().set_displaced_mark_helper(m);
|
2016-01-04 15:41:05 +01:00
|
|
|
}
|
|
|
|
|
2019-08-19 12:40:27 +02:00
|
|
|
// Supports deferred calling of obj->klass().
|
|
|
|
class DeferredObjectToKlass {
|
|
|
|
const oopDesc* _obj;
|
|
|
|
|
|
|
|
public:
|
|
|
|
DeferredObjectToKlass(const oopDesc* obj) : _obj(obj) {}
|
|
|
|
|
|
|
|
// Implicitly convertible to const Klass*.
|
|
|
|
operator const Klass*() const {
|
|
|
|
return _obj->klass();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
bool oopDesc::mark_must_be_preserved() const {
|
|
|
|
return mark_must_be_preserved(mark_raw());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool oopDesc::mark_must_be_preserved(markWord m) const {
|
|
|
|
// There's a circular dependency between oop.inline.hpp and
|
|
|
|
// markWord.inline.hpp because markWord::must_be_preserved wants to call
|
|
|
|
// oopDesc::klass(). This could be solved by calling klass() here. However,
|
|
|
|
// not all paths inside must_be_preserved calls klass(). Defer the call until
|
|
|
|
// the klass is actually needed.
|
|
|
|
return m.must_be_preserved(DeferredObjectToKlass(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool oopDesc::mark_must_be_preserved_for_promotion_failure(markWord m) const {
|
|
|
|
return m.must_be_preserved_for_promotion_failure(DeferredObjectToKlass(this));
|
|
|
|
}
|
|
|
|
|
2019-01-10 15:13:51 -05:00
|
|
|
#endif // SHARE_OOPS_OOP_INLINE_HPP
|