2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2017-04-26 10:26:39 +02:00
|
|
|
* Copyright (c) 1997, 2017, 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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#ifndef SHARE_VM_OOPS_OOP_INLINE_HPP
|
|
|
|
#define SHARE_VM_OOPS_OOP_INLINE_HPP
|
|
|
|
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/ageTable.hpp"
|
|
|
|
#include "gc/shared/barrierSet.inline.hpp"
|
|
|
|
#include "gc/shared/cardTableModRefBS.hpp"
|
|
|
|
#include "gc/shared/collectedHeap.inline.hpp"
|
|
|
|
#include "gc/shared/genCollectedHeap.hpp"
|
|
|
|
#include "gc/shared/generation.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/arrayKlass.hpp"
|
|
|
|
#include "oops/arrayOop.hpp"
|
2013-08-15 20:04:10 -04:00
|
|
|
#include "oops/klass.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/markOop.inline.hpp"
|
|
|
|
#include "oops/oop.hpp"
|
2016-08-21 20:56:37 -04:00
|
|
|
#include "runtime/atomic.hpp"
|
2014-04-29 15:17:27 +02:00
|
|
|
#include "runtime/orderAccess.inline.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
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
inline void update_barrier_set(void* p, oop v, bool release = false) {
|
|
|
|
assert(oopDesc::bs() != NULL, "Uninitialized bs in oop!");
|
|
|
|
oopDesc::bs()->write_ref_field(p, v, release);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T> inline void update_barrier_set_pre(T* p, oop v) {
|
|
|
|
oopDesc::bs()->write_ref_field_pre(p, v);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T> void oop_store(T* p, oop v) {
|
|
|
|
if (always_do_update_barrier) {
|
|
|
|
oop_store((volatile T*)p, v);
|
|
|
|
} else {
|
|
|
|
update_barrier_set_pre(p, v);
|
|
|
|
oopDesc::encode_store_heap_oop(p, v);
|
|
|
|
// always_do_update_barrier == false =>
|
|
|
|
// Either we are at a safepoint (in GC) or CMS is not used. In both
|
|
|
|
// cases it's unnecessary to mark the card as dirty with release sematics.
|
|
|
|
update_barrier_set((void*)p, v, false /* release */); // cast away type
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T> void oop_store(volatile T* p, oop v) {
|
|
|
|
update_barrier_set_pre((T*)p, v); // cast away volatile
|
|
|
|
// Used by release_obj_field_put, so use release_store_ptr.
|
|
|
|
oopDesc::release_encode_store_heap_oop(p, v);
|
|
|
|
// When using CMS we must mark the card corresponding to p as dirty
|
|
|
|
// with release sematics to prevent that CMS sees the dirty card but
|
|
|
|
// not the new value v at p due to reordering of the two
|
|
|
|
// stores. Note that CMS has a concurrent precleaning phase, where
|
|
|
|
// it reads the card table while the Java threads are running.
|
|
|
|
update_barrier_set((void*)p, v, true /* release */); // cast away type
|
|
|
|
}
|
|
|
|
|
|
|
|
// Should replace *addr = oop assignments where addr type depends on UseCompressedOops
|
|
|
|
// (without having to remember the function name this calls).
|
|
|
|
inline void oop_store_raw(HeapWord* addr, oop value) {
|
|
|
|
if (UseCompressedOops) {
|
|
|
|
oopDesc::encode_store_heap_oop((narrowOop*)addr, value);
|
|
|
|
} else {
|
|
|
|
oopDesc::encode_store_heap_oop((oop*)addr, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::release_set_mark(markOop m) {
|
2007-12-01 00:00:00 +00:00
|
|
|
OrderAccess::release_store_ptr(&_mark, m);
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
markOop oopDesc::cas_set_mark(markOop new_mark, markOop old_mark) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return (markOop) Atomic::cmpxchg_ptr(new_mark, &_mark, old_mark);
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::init_mark() {
|
|
|
|
set_mark(markOopDesc::prototype_for_object(this));
|
|
|
|
}
|
|
|
|
|
2016-01-18 10:25:41 +01:00
|
|
|
Klass* oopDesc::klass() const {
|
2013-08-12 17:37:02 +02:00
|
|
|
if (UseCompressedClassPointers) {
|
2013-08-15 20:04:10 -04:00
|
|
|
return Klass::decode_klass_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) {
|
2013-08-15 20:04:10 -04:00
|
|
|
return Klass::decode_klass(_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);
|
|
|
|
return Klass::decode_klass(OrderAccess::load_acquire(xaddr));
|
|
|
|
} else {
|
|
|
|
return (Klass*)OrderAccess::load_ptr_acquire(&_metadata._klass);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
Klass** oopDesc::klass_addr() {
|
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");
|
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
|
|
|
return (Klass**) &_metadata._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
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
narrowKlass* oopDesc::compressed_klass_addr() {
|
2013-08-12 17:37:02 +02:00
|
|
|
assert(UseCompressedClassPointers, "only called by compressed klass pointers");
|
2013-08-15 20:04:10 -04:00
|
|
|
return &_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
|
|
|
}
|
|
|
|
|
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) {
|
2013-08-15 20:04:10 -04:00
|
|
|
*compressed_klass_addr() = Klass::encode_klass_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
|
|
|
}
|
|
|
|
|
2016-09-15 12:10:43 -04:00
|
|
|
void oopDesc::release_set_klass(Klass* k) {
|
|
|
|
CHECK_SET_KLASS(k);
|
|
|
|
if (UseCompressedClassPointers) {
|
|
|
|
OrderAccess::release_store(compressed_klass_addr(),
|
|
|
|
Klass::encode_klass_not_null(k));
|
|
|
|
} else {
|
|
|
|
OrderAccess::release_store_ptr(klass_addr(), k);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#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());
|
|
|
|
}
|
|
|
|
|
2016-01-18 10:25:41 +01:00
|
|
|
void oopDesc::set_klass_gap(int v) {
|
2013-08-12 17:37:02 +02:00
|
|
|
if (UseCompressedClassPointers) {
|
2008-05-28 21:06:24 -07:00
|
|
|
*(int*)(((intptr_t)this) + klass_gap_offset_in_bytes()) = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::set_klass_to_list_ptr(oop k) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// This is only to be used during GC, for from-space objects, so no
|
|
|
|
// barrier is needed.
|
2013-08-12 17:37:02 +02:00
|
|
|
if (UseCompressedClassPointers) {
|
2013-08-15 20:04:10 -04:00
|
|
|
_metadata._compressed_klass = (narrowKlass)encode_heap_oop(k); // may be null (parnew overflow handling)
|
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
|
|
|
_metadata._klass = (Klass*)(address)k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
oop oopDesc::list_ptr_from_klass() {
|
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
|
|
|
// This is only to be used during GC, for from-space objects.
|
2013-08-12 17:37:02 +02:00
|
|
|
if (UseCompressedClassPointers) {
|
2013-08-15 20:04:10 -04:00
|
|
|
return decode_heap_oop((narrowOop)_metadata._compressed_klass);
|
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
|
|
|
} else {
|
|
|
|
// Special case for GC
|
|
|
|
return (oop)(address)_metadata._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
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
// ParNew (used by CMS), UseParallelGC and UseG1GC can change the length field
|
|
|
|
// 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.
|
|
|
|
// ParNew also runs with promotion labs (which look like int
|
|
|
|
// filler arrays) which are subject to changing their declared size
|
|
|
|
// when finally retiring a PLAB; this also can cause the first disjunct
|
|
|
|
// to fail for another worker thread that is concurrently walking the block
|
|
|
|
// offset table. Both these invariant failures are benign for their
|
|
|
|
// current uses; we relax the assertion checking to cover these two cases below:
|
|
|
|
// is_objArray() && is_forwarded() // covers first scenario above
|
|
|
|
// || is_typeArray() // covers second scenario above
|
|
|
|
// If and when UseParallelGC uses the same obj array oop stealing/chunking
|
|
|
|
// technique, we will need to suitably modify the assertion.
|
|
|
|
assert((s == klass->oop_size(this)) ||
|
|
|
|
(Universe::heap()->is_gc_active() &&
|
|
|
|
((is_typeArray() && UseConcMarkSweepGC) ||
|
|
|
|
(is_objArray() && is_forwarded() && (UseConcMarkSweepGC || UseParallelGC || UseG1GC)))),
|
|
|
|
"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(); }
|
|
|
|
|
|
|
|
void* oopDesc::field_base(int offset) const { return (void*)&((char*)this)[offset]; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jbyte* oopDesc::byte_field_addr(int offset) const { return (jbyte*) field_base(offset); }
|
|
|
|
jchar* oopDesc::char_field_addr(int offset) const { return (jchar*) field_base(offset); }
|
|
|
|
jboolean* oopDesc::bool_field_addr(int offset) const { return (jboolean*) field_base(offset); }
|
|
|
|
jint* oopDesc::int_field_addr(int offset) const { return (jint*) field_base(offset); }
|
|
|
|
jshort* oopDesc::short_field_addr(int offset) const { return (jshort*) field_base(offset); }
|
|
|
|
jlong* oopDesc::long_field_addr(int offset) const { return (jlong*) field_base(offset); }
|
|
|
|
jfloat* oopDesc::float_field_addr(int offset) const { return (jfloat*) field_base(offset); }
|
|
|
|
jdouble* oopDesc::double_field_addr(int offset) const { return (jdouble*) field_base(offset); }
|
|
|
|
Metadata** oopDesc::metadata_field_addr(int offset) const { return (Metadata**)field_base(offset); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
template <class T> T* oopDesc::obj_field_addr(int offset) const { return (T*) field_base(offset); }
|
|
|
|
address* oopDesc::address_field_addr(int offset) const { return (address*) field_base(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
|
|
|
|
|
|
|
|
|
|
|
// Functions for getting and setting oops within instance objects.
|
|
|
|
// If the oops are compressed, the type passed to these overloaded functions
|
|
|
|
// is narrowOop. All functions are overloaded so they can be called by
|
|
|
|
// template functions without conditionals (the compiler instantiates via
|
|
|
|
// the right type and inlines the appopriate code).
|
|
|
|
|
|
|
|
// Algorithm for encoding and decoding oops from 64 bit pointers to 32 bit
|
|
|
|
// offset from the heap base. Saving the check for null can save instructions
|
|
|
|
// in inner GC loops so these are separated.
|
|
|
|
|
2010-05-27 18:01:56 -07:00
|
|
|
inline bool check_obj_alignment(oop obj) {
|
2016-03-07 10:36:50 +03:00
|
|
|
return (cast_from_oop<intptr_t>(obj) & MinObjAlignmentInBytesMask) == 0;
|
2010-05-27 18:01:56 -07:00
|
|
|
}
|
|
|
|
|
2016-01-18 10:25:41 +01:00
|
|
|
oop oopDesc::decode_heap_oop_not_null(narrowOop v) {
|
2016-01-04 15:41:05 +01:00
|
|
|
assert(!is_null(v), "narrow oop value can never be zero");
|
|
|
|
address base = Universe::narrow_oop_base();
|
|
|
|
int shift = Universe::narrow_oop_shift();
|
|
|
|
oop result = (oop)(void*)((uintptr_t)base + ((uintptr_t)v << shift));
|
|
|
|
assert(check_obj_alignment(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-01-18 10:25:41 +01:00
|
|
|
oop oopDesc::decode_heap_oop(narrowOop v) {
|
2016-01-04 15:41:05 +01:00
|
|
|
return is_null(v) ? (oop)NULL : decode_heap_oop_not_null(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
narrowOop oopDesc::encode_heap_oop_not_null(oop v) {
|
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
|
|
|
assert(!is_null(v), "oop value can never be zero");
|
2010-05-27 18:01:56 -07:00
|
|
|
assert(check_obj_alignment(v), "Address not aligned");
|
2009-07-14 15:40:39 -07:00
|
|
|
assert(Universe::heap()->is_in_reserved(v), "Address not in heap");
|
2009-03-12 10:37:46 -07:00
|
|
|
address base = Universe::narrow_oop_base();
|
|
|
|
int shift = Universe::narrow_oop_shift();
|
|
|
|
uint64_t pd = (uint64_t)(pointer_delta((void*)v, (void*)base, 1));
|
2008-04-29 19:31:29 -04:00
|
|
|
assert(OopEncodingHeapMax > pd, "change encoding max if new encoding");
|
2009-03-12 10:37:46 -07:00
|
|
|
uint64_t result = pd >> shift;
|
2008-04-29 19:31:29 -04:00
|
|
|
assert((result & CONST64(0xffffffff00000000)) == 0, "narrow oop overflow");
|
2009-07-14 15:40:39 -07:00
|
|
|
assert(decode_heap_oop(result) == v, "reversibility");
|
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
|
|
|
return (narrowOop)result;
|
|
|
|
}
|
|
|
|
|
2016-01-18 10:25:41 +01:00
|
|
|
narrowOop oopDesc::encode_heap_oop(oop v) {
|
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
|
|
|
return (is_null(v)) ? (narrowOop)0 : encode_heap_oop_not_null(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load and decode an oop out of the Java heap into a wide oop.
|
2016-01-04 15:41:05 +01:00
|
|
|
oop oopDesc::load_decode_heap_oop_not_null(narrowOop* p) {
|
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
|
|
|
return decode_heap_oop_not_null(*p);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load and decode an oop out of the heap accepting null
|
2016-01-04 15:41:05 +01:00
|
|
|
oop oopDesc::load_decode_heap_oop(narrowOop* p) {
|
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
|
|
|
return decode_heap_oop(*p);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Encode and store a heap oop.
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::encode_store_heap_oop_not_null(narrowOop* p, oop v) {
|
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
|
|
|
*p = encode_heap_oop_not_null(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Encode and store a heap oop allowing for null.
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::encode_store_heap_oop(narrowOop* p, oop v) {
|
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
|
|
|
*p = encode_heap_oop(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store heap oop as is for volatile fields.
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::release_store_heap_oop(volatile oop* p, oop v) {
|
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
|
|
|
OrderAccess::release_store_ptr(p, v);
|
|
|
|
}
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::release_store_heap_oop(volatile narrowOop* p, narrowOop v) {
|
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
|
|
|
OrderAccess::release_store(p, v);
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::release_encode_store_heap_oop_not_null(volatile narrowOop* p, oop v) {
|
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
|
|
|
// heap oop is not pointer sized.
|
|
|
|
OrderAccess::release_store(p, encode_heap_oop_not_null(v));
|
|
|
|
}
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::release_encode_store_heap_oop_not_null(volatile oop* p, oop v) {
|
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
|
|
|
OrderAccess::release_store_ptr(p, v);
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::release_encode_store_heap_oop(volatile oop* p, oop v) {
|
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
|
|
|
OrderAccess::release_store_ptr(p, v);
|
|
|
|
}
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::release_encode_store_heap_oop(volatile narrowOop* p, oop v) {
|
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
|
|
|
OrderAccess::release_store(p, encode_heap_oop(v));
|
|
|
|
}
|
|
|
|
|
|
|
|
// These functions are only used to exchange oop fields in instances,
|
|
|
|
// not headers.
|
2016-01-04 15:41:05 +01:00
|
|
|
oop oopDesc::atomic_exchange_oop(oop exchange_value, volatile HeapWord *dest) {
|
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
|
|
|
if (UseCompressedOops) {
|
|
|
|
// encode exchange value from oop to T
|
|
|
|
narrowOop val = encode_heap_oop(exchange_value);
|
|
|
|
narrowOop old = (narrowOop)Atomic::xchg(val, (narrowOop*)dest);
|
|
|
|
// decode old from T to oop
|
|
|
|
return decode_heap_oop(old);
|
|
|
|
} else {
|
|
|
|
return (oop)Atomic::xchg_ptr(exchange_value, (oop*)dest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
oop oopDesc::atomic_compare_exchange_oop(oop exchange_value,
|
|
|
|
volatile HeapWord *dest,
|
|
|
|
oop compare_value,
|
|
|
|
bool prebarrier) {
|
|
|
|
if (UseCompressedOops) {
|
|
|
|
if (prebarrier) {
|
|
|
|
update_barrier_set_pre((narrowOop*)dest, exchange_value);
|
|
|
|
}
|
|
|
|
// encode exchange and compare value from oop to T
|
|
|
|
narrowOop val = encode_heap_oop(exchange_value);
|
|
|
|
narrowOop cmp = encode_heap_oop(compare_value);
|
|
|
|
|
|
|
|
narrowOop old = (narrowOop) Atomic::cmpxchg(val, (narrowOop*)dest, cmp);
|
|
|
|
// decode old from T to oop
|
|
|
|
return decode_heap_oop(old);
|
|
|
|
} else {
|
|
|
|
if (prebarrier) {
|
|
|
|
update_barrier_set_pre((oop*)dest, exchange_value);
|
|
|
|
}
|
|
|
|
return (oop)Atomic::cmpxchg_ptr(exchange_value, (oop*)dest, compare_value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// In order to put or get a field out of an instance, must first check
|
|
|
|
// if the field has been compressed and uncompress it.
|
2016-01-04 15:41:05 +01:00
|
|
|
oop oopDesc::obj_field(int offset) const {
|
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
|
|
|
return UseCompressedOops ?
|
|
|
|
load_decode_heap_oop(obj_field_addr<narrowOop>(offset)) :
|
|
|
|
load_decode_heap_oop(obj_field_addr<oop>(offset));
|
|
|
|
}
|
2015-07-22 16:25:06 +02:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::obj_field_put(int offset, oop value) {
|
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
|
|
|
UseCompressedOops ? oop_store(obj_field_addr<narrowOop>(offset), value) :
|
|
|
|
oop_store(obj_field_addr<oop>(offset), value);
|
|
|
|
}
|
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-01-04 15:41:05 +01:00
|
|
|
void oopDesc::obj_field_put_raw(int offset, oop value) {
|
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
|
|
|
UseCompressedOops ?
|
|
|
|
encode_store_heap_oop(obj_field_addr<narrowOop>(offset), value) :
|
|
|
|
encode_store_heap_oop(obj_field_addr<oop>(offset), value);
|
|
|
|
}
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::obj_field_put_volatile(int offset, oop value) {
|
2011-09-08 05:11:31 -07:00
|
|
|
OrderAccess::release();
|
|
|
|
obj_field_put(offset, value);
|
|
|
|
OrderAccess::fence();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
Metadata* oopDesc::metadata_field(int offset) const { return *metadata_field_addr(offset); }
|
|
|
|
void oopDesc::metadata_field_put(int offset, Metadata* value) { *metadata_field_addr(offset) = value; }
|
|
|
|
|
2017-07-26 10:41:07 -04:00
|
|
|
Metadata* oopDesc::metadata_field_acquire(int offset) const {
|
|
|
|
return (Metadata*)OrderAccess::load_ptr_acquire(metadata_field_addr(offset));
|
|
|
|
}
|
|
|
|
|
2017-07-24 17:46:06 -04:00
|
|
|
void oopDesc::release_metadata_field_put(int offset, Metadata* value) {
|
|
|
|
OrderAccess::release_store_ptr(metadata_field_addr(offset), value);
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jbyte oopDesc::byte_field(int offset) const { return (jbyte) *byte_field_addr(offset); }
|
|
|
|
void oopDesc::byte_field_put(int offset, jbyte contents) { *byte_field_addr(offset) = (jint) contents; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jchar oopDesc::char_field(int offset) const { return (jchar) *char_field_addr(offset); }
|
|
|
|
void oopDesc::char_field_put(int offset, jchar contents) { *char_field_addr(offset) = (jint) contents; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jboolean oopDesc::bool_field(int offset) const { return (jboolean) *bool_field_addr(offset); }
|
2015-10-13 18:13:34 -04:00
|
|
|
void oopDesc::bool_field_put(int offset, jboolean contents) { *bool_field_addr(offset) = (((jint) contents) & 1); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jint oopDesc::int_field(int offset) const { return *int_field_addr(offset); }
|
|
|
|
void oopDesc::int_field_put(int offset, jint contents) { *int_field_addr(offset) = contents; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jshort oopDesc::short_field(int offset) const { return (jshort) *short_field_addr(offset); }
|
|
|
|
void oopDesc::short_field_put(int offset, jshort contents) { *short_field_addr(offset) = (jint) contents;}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jlong oopDesc::long_field(int offset) const { return *long_field_addr(offset); }
|
|
|
|
void oopDesc::long_field_put(int offset, jlong contents) { *long_field_addr(offset) = contents; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jfloat oopDesc::float_field(int offset) const { return *float_field_addr(offset); }
|
|
|
|
void oopDesc::float_field_put(int offset, jfloat contents) { *float_field_addr(offset) = contents; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jdouble oopDesc::double_field(int offset) const { return *double_field_addr(offset); }
|
|
|
|
void oopDesc::double_field_put(int offset, jdouble contents) { *double_field_addr(offset) = contents; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
address oopDesc::address_field(int offset) const { return *address_field_addr(offset); }
|
|
|
|
void oopDesc::address_field_put(int offset, address contents) { *address_field_addr(offset) = contents; }
|
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-01-04 15:41:05 +01:00
|
|
|
oop oopDesc::obj_field_acquire(int offset) const {
|
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
|
|
|
return UseCompressedOops ?
|
|
|
|
decode_heap_oop((narrowOop)
|
|
|
|
OrderAccess::load_acquire(obj_field_addr<narrowOop>(offset)))
|
|
|
|
: decode_heap_oop((oop)
|
|
|
|
OrderAccess::load_ptr_acquire(obj_field_addr<oop>(offset)));
|
|
|
|
}
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::release_obj_field_put(int offset, oop value) {
|
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
|
|
|
UseCompressedOops ?
|
|
|
|
oop_store((volatile narrowOop*)obj_field_addr<narrowOop>(offset), value) :
|
|
|
|
oop_store((volatile oop*) obj_field_addr<oop>(offset), value);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jbyte oopDesc::byte_field_acquire(int offset) const { return OrderAccess::load_acquire(byte_field_addr(offset)); }
|
|
|
|
void oopDesc::release_byte_field_put(int offset, jbyte contents) { OrderAccess::release_store(byte_field_addr(offset), contents); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jchar oopDesc::char_field_acquire(int offset) const { return OrderAccess::load_acquire(char_field_addr(offset)); }
|
|
|
|
void oopDesc::release_char_field_put(int offset, jchar contents) { OrderAccess::release_store(char_field_addr(offset), contents); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jboolean oopDesc::bool_field_acquire(int offset) const { return OrderAccess::load_acquire(bool_field_addr(offset)); }
|
2015-10-13 18:13:34 -04:00
|
|
|
void oopDesc::release_bool_field_put(int offset, jboolean contents) { OrderAccess::release_store(bool_field_addr(offset), (contents & 1)); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jint oopDesc::int_field_acquire(int offset) const { return OrderAccess::load_acquire(int_field_addr(offset)); }
|
|
|
|
void oopDesc::release_int_field_put(int offset, jint contents) { OrderAccess::release_store(int_field_addr(offset), contents); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jshort oopDesc::short_field_acquire(int offset) const { return (jshort)OrderAccess::load_acquire(short_field_addr(offset)); }
|
|
|
|
void oopDesc::release_short_field_put(int offset, jshort contents) { OrderAccess::release_store(short_field_addr(offset), contents); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jlong oopDesc::long_field_acquire(int offset) const { return OrderAccess::load_acquire(long_field_addr(offset)); }
|
|
|
|
void oopDesc::release_long_field_put(int offset, jlong contents) { OrderAccess::release_store(long_field_addr(offset), contents); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jfloat oopDesc::float_field_acquire(int offset) const { return OrderAccess::load_acquire(float_field_addr(offset)); }
|
|
|
|
void oopDesc::release_float_field_put(int offset, jfloat contents) { OrderAccess::release_store(float_field_addr(offset), contents); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
jdouble oopDesc::double_field_acquire(int offset) const { return OrderAccess::load_acquire(double_field_addr(offset)); }
|
|
|
|
void oopDesc::release_double_field_put(int offset, jdouble contents) { OrderAccess::release_store(double_field_addr(offset), contents); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
address oopDesc::address_field_acquire(int offset) const { return (address) OrderAccess::load_ptr_acquire(address_field_addr(offset)); }
|
|
|
|
void oopDesc::release_address_field_put(int offset, address contents) { OrderAccess::release_store_ptr(address_field_addr(offset), contents); }
|
2009-04-08 10:56:49 -07:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
bool oopDesc::is_locked() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
return mark()->is_locked();
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
bool oopDesc::is_unlocked() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
return mark()->is_unlocked();
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
bool oopDesc::has_bias_pattern() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
return mark()->has_bias_pattern();
|
|
|
|
}
|
|
|
|
|
|
|
|
// used only for asserts
|
2016-01-18 10:25:41 +01:00
|
|
|
bool oopDesc::is_oop(bool ignore_mark_word) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
oop obj = (oop) this;
|
|
|
|
if (!check_obj_alignment(obj)) return false;
|
|
|
|
if (!Universe::heap()->is_in_reserved(obj)) return false;
|
|
|
|
// obj is aligned and accessible in heap
|
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
|
|
|
if (Universe::heap()->is_in_reserved(obj->klass_or_null())) return false;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Header verification: the mark is typically non-NULL. If we're
|
|
|
|
// at a safepoint, it must not be null.
|
|
|
|
// Outside of a safepoint, the header could be changing (for example,
|
|
|
|
// another thread could be inflating a lock on this object).
|
|
|
|
if (ignore_mark_word) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (mark() != NULL) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return !SafepointSynchronize::is_at_safepoint();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// used only for asserts
|
2016-01-18 10:25:41 +01:00
|
|
|
bool oopDesc::is_oop_or_null(bool ignore_mark_word) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
return this == NULL ? true : is_oop(ignore_mark_word);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
// used only for asserts
|
2016-01-04 15:41:05 +01:00
|
|
|
bool oopDesc::is_unlocked_oop() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (!Universe::heap()->is_in_reserved(this)) return false;
|
|
|
|
return mark()->is_unlocked();
|
|
|
|
}
|
|
|
|
#endif // PRODUCT
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
// Used only for markSweep, scavenging
|
|
|
|
bool oopDesc::is_gc_marked() const {
|
|
|
|
return mark()->is_marked();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool oopDesc::is_scavengable() const {
|
2015-02-13 14:37:35 +01:00
|
|
|
return Universe::heap()->is_scavengable(this);
|
|
|
|
}
|
2007-12-01 00:00:00 +00: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
|
|
|
|
return mark()->is_marked();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used by scavengers
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::forward_to(oop p) {
|
2010-05-27 18:01:56 -07:00
|
|
|
assert(check_obj_alignment(p),
|
|
|
|
"forwarding to something not aligned");
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(Universe::heap()->is_in_reserved(p),
|
|
|
|
"forwarding to something not in heap");
|
|
|
|
markOop m = markOopDesc::encode_pointer_as_mark(p);
|
|
|
|
assert(m->decode_pointer() == p, "encoding must be reversable");
|
|
|
|
set_mark(m);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used by parallel scavengers
|
2016-01-04 15:41:05 +01:00
|
|
|
bool oopDesc::cas_forward_to(oop p, markOop compare) {
|
2010-05-27 18:01:56 -07:00
|
|
|
assert(check_obj_alignment(p),
|
|
|
|
"forwarding to something not aligned");
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(Universe::heap()->is_in_reserved(p),
|
|
|
|
"forwarding to something not in heap");
|
|
|
|
markOop m = markOopDesc::encode_pointer_as_mark(p);
|
|
|
|
assert(m->decode_pointer() == p, "encoding must be reversable");
|
|
|
|
return cas_set_mark(m, compare) == compare;
|
|
|
|
}
|
|
|
|
|
2015-03-17 15:53:55 +01:00
|
|
|
#if INCLUDE_ALL_GCS
|
2016-01-04 15:41:05 +01:00
|
|
|
oop oopDesc::forward_to_atomic(oop p) {
|
2015-03-17 15:53:55 +01:00
|
|
|
markOop oldMark = mark();
|
|
|
|
markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p);
|
|
|
|
markOop curMark;
|
|
|
|
|
|
|
|
assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable");
|
|
|
|
assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this.");
|
|
|
|
|
|
|
|
while (!oldMark->is_marked()) {
|
|
|
|
curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark);
|
|
|
|
assert(is_forwarded(), "object should have been forwarded");
|
|
|
|
if (curMark == oldMark) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
// If the CAS was unsuccessful then curMark->is_marked()
|
|
|
|
// should return true as another thread has CAS'd in another
|
|
|
|
// forwarding pointer.
|
|
|
|
oldMark = curMark;
|
|
|
|
}
|
|
|
|
return forwardee();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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 {
|
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
|
|
|
return (oop) mark()->decode_pointer();
|
|
|
|
}
|
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");
|
|
|
|
if (has_displaced_mark()) {
|
|
|
|
return displaced_mark()->age();
|
|
|
|
} else {
|
|
|
|
return mark()->age();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
if (has_displaced_mark()) {
|
|
|
|
set_displaced_mark(displaced_mark()->incr_age());
|
|
|
|
} else {
|
|
|
|
set_mark(mark()->incr_age());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-02 10:04:27 +02:00
|
|
|
#if INCLUDE_ALL_GCS
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::pc_follow_contents(ParCompactionManager* cm) {
|
2015-04-02 10:04:27 +02:00
|
|
|
klass()->oop_pc_follow_contents(this, cm);
|
|
|
|
}
|
|
|
|
|
2016-01-28 13:30:12 +01:00
|
|
|
void oopDesc::pc_update_contents(ParCompactionManager* cm) {
|
2015-04-02 10:04:27 +02:00
|
|
|
Klass* k = klass();
|
2015-10-28 09:47:23 -04:00
|
|
|
if (!k->is_typeArray_klass()) {
|
2015-04-02 10:04:27 +02:00
|
|
|
// It might contain oops beyond the header, so take the virtual call.
|
2016-01-28 13:30:12 +01:00
|
|
|
k->oop_pc_update_pointers(this, cm);
|
2015-04-02 10:04:27 +02:00
|
|
|
}
|
|
|
|
// Else skip it. The TypeArrayKlass in the header never needs scavenging.
|
|
|
|
}
|
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
void oopDesc::ps_push_contents(PSPromotionManager* pm) {
|
2015-04-02 10:04:27 +02:00
|
|
|
Klass* k = klass();
|
2015-10-28 09:47:23 -04:00
|
|
|
if (!k->is_typeArray_klass()) {
|
2015-04-02 10:04:27 +02:00
|
|
|
// It might contain oops beyond the header, so take the virtual call.
|
|
|
|
k->oop_ps_push_contents(this, pm);
|
|
|
|
}
|
|
|
|
// Else skip it. The TypeArrayKlass in the header never needs scavenging.
|
|
|
|
}
|
2016-01-04 15:41:05 +01:00
|
|
|
#endif // INCLUDE_ALL_GCS
|
2015-04-02 10:04:27 +02:00
|
|
|
|
2016-01-04 15:41:05 +01:00
|
|
|
#define OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \
|
|
|
|
\
|
|
|
|
void oopDesc::oop_iterate(OopClosureType* blk) { \
|
|
|
|
klass()->oop_oop_iterate##nv_suffix(this, blk); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
void oopDesc::oop_iterate(OopClosureType* blk, MemRegion mr) { \
|
|
|
|
klass()->oop_oop_iterate_bounded##nv_suffix(this, blk, mr); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define OOP_ITERATE_SIZE_DEFN(OopClosureType, nv_suffix) \
|
|
|
|
\
|
|
|
|
int oopDesc::oop_iterate_size(OopClosureType* blk) { \
|
|
|
|
Klass* k = klass(); \
|
|
|
|
int size = size_given_klass(k); \
|
|
|
|
k->oop_oop_iterate##nv_suffix(this, blk); \
|
|
|
|
return size; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
int oopDesc::oop_iterate_size(OopClosureType* blk, MemRegion mr) { \
|
|
|
|
Klass* k = klass(); \
|
|
|
|
int size = size_given_klass(k); \
|
|
|
|
k->oop_oop_iterate_bounded##nv_suffix(this, blk, mr); \
|
|
|
|
return size; \
|
|
|
|
}
|
|
|
|
|
|
|
|
int oopDesc::oop_iterate_no_header(OopClosure* blk) {
|
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
|
|
|
// The NoHeaderExtendedOopClosure wraps the OopClosure and proxies all
|
|
|
|
// the do_oop calls, but turns off all other features in ExtendedOopClosure.
|
|
|
|
NoHeaderExtendedOopClosure cl(blk);
|
2015-09-02 09:14:04 +02:00
|
|
|
return oop_iterate_size(&cl);
|
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-01-04 15:41:05 +01:00
|
|
|
int oopDesc::oop_iterate_no_header(OopClosure* blk, MemRegion mr) {
|
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
|
|
|
NoHeaderExtendedOopClosure cl(blk);
|
2015-09-02 09:14:04 +02:00
|
|
|
return oop_iterate_size(&cl, mr);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2013-01-23 13:02:39 -05:00
|
|
|
#if INCLUDE_ALL_GCS
|
2015-04-02 10:04:27 +02:00
|
|
|
#define OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \
|
|
|
|
\
|
2015-09-02 09:14:04 +02:00
|
|
|
inline void oopDesc::oop_iterate_backwards(OopClosureType* blk) { \
|
|
|
|
klass()->oop_oop_iterate_backwards##nv_suffix(this, blk); \
|
2008-06-05 15:57:56 -07:00
|
|
|
}
|
2015-04-02 10:04:27 +02:00
|
|
|
#else
|
|
|
|
#define OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix)
|
2016-01-04 15:41:05 +01:00
|
|
|
#endif // INCLUDE_ALL_GCS
|
2015-04-02 10:04:27 +02:00
|
|
|
|
|
|
|
#define ALL_OOPDESC_OOP_ITERATE(OopClosureType, nv_suffix) \
|
|
|
|
OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \
|
2015-09-02 09:14:04 +02:00
|
|
|
OOP_ITERATE_SIZE_DEFN(OopClosureType, nv_suffix) \
|
2015-04-02 10:04:27 +02:00
|
|
|
OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix)
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-04-02 10:04:27 +02:00
|
|
|
ALL_OOP_OOP_ITERATE_CLOSURES_1(ALL_OOPDESC_OOP_ITERATE)
|
|
|
|
ALL_OOP_OOP_ITERATE_CLOSURES_2(ALL_OOPDESC_OOP_ITERATE)
|
2007-12-01 00:00:00 +00:00
|
|
|
|
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.
|
|
|
|
markOop mrk = mark();
|
|
|
|
if (mrk->is_unlocked() && !mrk->has_no_hash()) {
|
|
|
|
return mrk->hash();
|
|
|
|
} else if (mrk->is_marked()) {
|
|
|
|
return mrk->hash();
|
|
|
|
} else {
|
|
|
|
return slow_identity_hash();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool oopDesc::has_displaced_mark() const {
|
|
|
|
return mark()->has_displaced_mark_helper();
|
|
|
|
}
|
|
|
|
|
|
|
|
markOop oopDesc::displaced_mark() const {
|
|
|
|
return mark()->displaced_mark_helper();
|
|
|
|
}
|
|
|
|
|
|
|
|
void oopDesc::set_displaced_mark(markOop m) {
|
|
|
|
mark()->set_displaced_mark_helper(m);
|
|
|
|
}
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#endif // SHARE_VM_OOPS_OOP_INLINE_HPP
|