< prev index next > src/hotspot/share/oops/markWord.hpp
Print this page
#ifndef SHARE_OOPS_MARKWORD_HPP
#define SHARE_OOPS_MARKWORD_HPP
#include "metaprogramming/integralConstant.hpp"
#include "metaprogramming/primitiveConversions.hpp"
! #include "oops/oopsHierarchy.hpp"
#include "runtime/globals.hpp"
// The markWord describes the header of an object.
//
// Bit-format of an object header (most significant first, big endian layout below):
#ifndef SHARE_OOPS_MARKWORD_HPP
#define SHARE_OOPS_MARKWORD_HPP
#include "metaprogramming/integralConstant.hpp"
#include "metaprogramming/primitiveConversions.hpp"
! #include "oops/compressedKlass.hpp"
#include "runtime/globals.hpp"
// The markWord describes the header of an object.
//
// Bit-format of an object header (most significant first, big endian layout below):
// --------
// hash:25 ------------>| age:4 unused_gap:1 lock:2 (normal object)
//
// 64 bits:
// --------
! // unused:25 hash:31 -->| unused_gap:1 age:4 unused_gap:1 lock:2 (normal object)
//
// - hash contains the identity hash value: largest value is
// 31 bits, see os::random(). Also, 64-bit vm's require
// a hash value no bigger than 32 bits because they will not
// properly generate a mask larger than that: see library_call.cpp
// --------
// hash:25 ------------>| age:4 unused_gap:1 lock:2 (normal object)
//
// 64 bits:
// --------
! // nklass:32 hash:25 -->| unused_gap:1 age:4 unused_gap:1 lock:2 (normal object)
//
// - hash contains the identity hash value: largest value is
// 31 bits, see os::random(). Also, 64-bit vm's require
// a hash value no bigger than 32 bits because they will not
// properly generate a mask larger than that: see library_call.cpp
uintptr_t value() const { return _value; }
// Constants
static const int age_bits = 4;
static const int lock_bits = 2;
! static const int first_unused_gap_bits = 1;
! static const int max_hash_bits = BitsPerWord - age_bits - lock_bits - first_unused_gap_bits;
! static const int hash_bits = max_hash_bits > 31 ? 31 : max_hash_bits;
! static const int second_unused_gap_bits = LP64_ONLY(1) NOT_LP64(0);
static const int lock_shift = 0;
! static const int age_shift = lock_bits + first_unused_gap_bits;
! static const int hash_shift = age_shift + age_bits + second_unused_gap_bits;
static const uintptr_t lock_mask = right_n_bits(lock_bits);
static const uintptr_t lock_mask_in_place = lock_mask << lock_shift;
static const uintptr_t age_mask = right_n_bits(age_bits);
static const uintptr_t age_mask_in_place = age_mask << age_shift;
static const uintptr_t hash_mask = right_n_bits(hash_bits);
static const uintptr_t hash_mask_in_place = hash_mask << hash_shift;
static const uintptr_t locked_value = 0;
static const uintptr_t unlocked_value = 1;
static const uintptr_t monitor_value = 2;
static const uintptr_t marked_value = 3;
uintptr_t value() const { return _value; }
// Constants
static const int age_bits = 4;
static const int lock_bits = 2;
! static const int self_forwarded_bits = 1;
! static const int max_hash_bits = BitsPerWord - age_bits - lock_bits - self_forwarded_bits;
! static const int hash_bits = max_hash_bits > 25 ? 25 : max_hash_bits;
! #ifdef _LP64
+ static const int klass_bits = 32;
+ #endif
static const int lock_shift = 0;
! static const int self_forwarded_shift = lock_shift + lock_bits;
! static const int age_shift = self_forwarded_shift + self_forwarded_bits;
+ static const int hash_shift = age_shift + age_bits;
+ #ifdef _LP64
+ static const int klass_shift = hash_shift + hash_bits;
+ #endif
static const uintptr_t lock_mask = right_n_bits(lock_bits);
static const uintptr_t lock_mask_in_place = lock_mask << lock_shift;
+ static const uintptr_t self_forwarded_mask = right_n_bits(self_forwarded_bits);
+ static const uintptr_t self_forwarded_mask_in_place = self_forwarded_mask << self_forwarded_shift;
static const uintptr_t age_mask = right_n_bits(age_bits);
static const uintptr_t age_mask_in_place = age_mask << age_shift;
static const uintptr_t hash_mask = right_n_bits(hash_bits);
static const uintptr_t hash_mask_in_place = hash_mask << hash_shift;
+ #ifdef _LP64
+ static const uintptr_t klass_mask = right_n_bits(klass_bits);
+ static const uintptr_t klass_mask_in_place = klass_mask << klass_shift;
+ #endif
+
static const uintptr_t locked_value = 0;
static const uintptr_t unlocked_value = 1;
static const uintptr_t monitor_value = 2;
static const uintptr_t marked_value = 3;
bool has_no_hash() const {
return hash() == no_hash;
}
+ #ifdef _LP64
+ inline Klass* klass() const;
+ inline Klass* klass_or_null() const;
+ inline Klass* safe_klass() const;
+ inline markWord set_klass(const Klass* klass) const;
+ inline narrowKlass narrow_klass() const;
+ inline markWord set_narrow_klass(const narrowKlass klass) const;
+ #endif
+
// Prototype mark for initialization
static markWord prototype() {
return markWord( no_hash_in_place | no_lock_in_place );
}
// Prepare address of oop for placement into mark
inline static markWord encode_pointer_as_mark(void* p) { return from_pointer(p).set_marked(); }
// Recover address of oop from encoded form used in mark
inline void* decode_pointer() { return (void*)clear_lock_bits().value(); }
+
+ inline bool self_forwarded() const {
+ return mask_bits(value(), self_forwarded_mask_in_place) != 0;
+ }
+
+ inline markWord set_self_forwarded() const {
+ return markWord(value() | self_forwarded_mask_in_place | marked_value);
+ }
};
// Support atomic operations.
template<>
struct PrimitiveConversions::Translate<markWord> : public TrueType {
< prev index next >