CACAO
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes
Lockword Class Reference

Lockword. More...

Public Member Functions

 Lockword (uintptr_t &lockword)
 
void init ()
 
bool is_thin_lock () const
 
bool is_fat_lock () const
 
bool is_unlocked () const
 Check if the lockword is an unlocked thin-lock. More...
 
bool lock (uintptr_t thinlock)
 Try to lock the lockword with the given thin-lock value. More...
 
void unlock ()
 Set the lockword to THIN_UNLOCKED. More...
 
uintptr_t get_thin_lock () const
 
uintptr_t get_thin_lock_without_count () const
 
int32_t get_thin_lock_count () const
 
int32_t get_thin_lock_thread_index () const
 
struct lock_record_tget_fat_lock () const
 
void set (uintptr_t lockword)
 
void set (struct lock_record_t *lr)
 
bool is_max_thin_lock_count () const
 
void increase_thin_lock_count ()
 
void decrease_thin_lock_count ()
 
void inflate (struct lock_record_t *lr)
 Inflate the lock of the given object. More...
 

Static Public Member Functions

static uintptr_t pre_compute_thinlock (int32_t index)
 Pre-compute the thin lock value for a thread index. More...
 

Private Attributes

uintptr_t & _lockword
 

Static Private Attributes

static const int THIN_LOCK_WORD_SIZE = SIZEOF_VOID_P * 8
 
static const int THIN_LOCK_SHAPE_BIT = 0x01
 
static const uintptr_t THIN_UNLOCKED = 0
 
static const int THIN_LOCK_COUNT_SHIFT = 1
 
static const int THIN_LOCK_COUNT_SIZE = 8
 
static const int THIN_LOCK_COUNT_INCR = (1 << THIN_LOCK_COUNT_SHIFT)
 
static const int THIN_LOCK_COUNT_MAX = ((1 << THIN_LOCK_COUNT_SIZE) - 1)
 
static const int THIN_LOCK_COUNT_MASK = (THIN_LOCK_COUNT_MAX << THIN_LOCK_COUNT_SHIFT)
 
static const int THIN_LOCK_TID_SHIFT = (THIN_LOCK_COUNT_SIZE + THIN_LOCK_COUNT_SHIFT)
 
static const int THIN_LOCK_TID_SIZE = (THIN_LOCK_WORD_SIZE - THIN_LOCK_TID_SHIFT)
 

Detailed Description

Lockword.

Definition at line 37 of file lockword.hpp.

Constructor & Destructor Documentation

Lockword::Lockword ( uintptr_t &  lockword)
inline

Definition at line 59 of file lockword.hpp.

Member Function Documentation

void Lockword::decrease_thin_lock_count ( )
inline

Definition at line 207 of file lockword.hpp.

struct lock_record_t * Lockword::get_fat_lock ( ) const

Definition at line 174 of file lockword.hpp.

uintptr_t Lockword::get_thin_lock ( ) const
inline

Definition at line 150 of file lockword.hpp.

int32_t Lockword::get_thin_lock_count ( ) const
inline

Definition at line 162 of file lockword.hpp.

int32_t Lockword::get_thin_lock_thread_index ( ) const
inline

Definition at line 168 of file lockword.hpp.

uintptr_t Lockword::get_thin_lock_without_count ( ) const
inline

Definition at line 156 of file lockword.hpp.

void Lockword::increase_thin_lock_count ( )
inline

Definition at line 198 of file lockword.hpp.

void Lockword::inflate ( struct lock_record_t lr)

Inflate the lock of the given object.

This may only be called by the owner of the monitor of the object.

PRE-CONDITION: The current thread must be the owner of this object's monitor AND of the lock record's lock!

Parameters
lrThe lock-record to install. The current thread must own the lock of this lock record!

Definition at line 44 of file lockword.cpp.

void Lockword::init ( )
inline

Definition at line 61 of file lockword.hpp.

bool Lockword::is_fat_lock ( ) const
inline

Definition at line 108 of file lockword.hpp.

bool Lockword::is_max_thin_lock_count ( ) const
inline

Definition at line 192 of file lockword.hpp.

bool Lockword::is_thin_lock ( ) const
inline

Definition at line 102 of file lockword.hpp.

bool Lockword::is_unlocked ( ) const
inline

Check if the lockword is an unlocked thin-lock.

Returns
true if unlocked, false otherwise.

Definition at line 119 of file lockword.hpp.

bool Lockword::lock ( uintptr_t  thinlock)
inline

Try to lock the lockword with the given thin-lock value.

Parameters
thinlockThin-lock value to store in the Lockword.
Returns
true if lock was successful, false otherwise.

Definition at line 132 of file lockword.hpp.

uintptr_t Lockword::pre_compute_thinlock ( int32_t  index)
inlinestatic

Pre-compute the thin lock value for a thread index.

Parameters
indexThe thead index (>= 1).
Returns
The thin lock value for this thread index.

Definition at line 96 of file lockword.hpp.

void Lockword::set ( uintptr_t  lockword)
inline

Definition at line 180 of file lockword.hpp.

void Lockword::set ( struct lock_record_t lr)
inline

Definition at line 186 of file lockword.hpp.

void Lockword::unlock ( )
inline

Set the lockword to THIN_UNLOCKED.

Definition at line 144 of file lockword.hpp.

Field Documentation

uintptr_t& Lockword::_lockword
private

Definition at line 56 of file lockword.hpp.

const int Lockword::THIN_LOCK_COUNT_INCR = (1 << THIN_LOCK_COUNT_SHIFT)
staticprivate

Definition at line 46 of file lockword.hpp.

const int Lockword::THIN_LOCK_COUNT_MASK = (THIN_LOCK_COUNT_MAX << THIN_LOCK_COUNT_SHIFT)
staticprivate

Definition at line 49 of file lockword.hpp.

const int Lockword::THIN_LOCK_COUNT_MAX = ((1 << THIN_LOCK_COUNT_SIZE) - 1)
staticprivate

Definition at line 47 of file lockword.hpp.

const int Lockword::THIN_LOCK_COUNT_SHIFT = 1
staticprivate

Definition at line 44 of file lockword.hpp.

const int Lockword::THIN_LOCK_COUNT_SIZE = 8
staticprivate

Definition at line 45 of file lockword.hpp.

const int Lockword::THIN_LOCK_SHAPE_BIT = 0x01
staticprivate

Definition at line 40 of file lockword.hpp.

const int Lockword::THIN_LOCK_TID_SHIFT = (THIN_LOCK_COUNT_SIZE + THIN_LOCK_COUNT_SHIFT)
staticprivate

Definition at line 51 of file lockword.hpp.

const int Lockword::THIN_LOCK_TID_SIZE = (THIN_LOCK_WORD_SIZE - THIN_LOCK_TID_SHIFT)
staticprivate

Definition at line 52 of file lockword.hpp.

const int Lockword::THIN_LOCK_WORD_SIZE = SIZEOF_VOID_P * 8
staticprivate

Definition at line 39 of file lockword.hpp.

const uintptr_t Lockword::THIN_UNLOCKED = 0
staticprivate

Definition at line 42 of file lockword.hpp.


The documentation for this class was generated from the following files: