tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
itm2stm::Scope Class Reference

#include <Scope.h>

Inheritance diagram for itm2stm::Scope:
Collaboration diagram for itm2stm::Scope:

Classes

struct  Callback
 
struct  LoggedWord
 
struct  ThrownObject
 

Public Member Functions

 Scope (_ITM_transaction &)
 
_ITM_transactionId_t getId () const
 
uint32_t getFlags () const
 
bool isExceptionBlock () const
 Used by the Transaction's rollback functionality. More...
 
void setAborted (bool val)
 
bool getAborted () const
 
_ITM_transactiongetOwner () const
 
void enter (_ITM_transactionId_t id, uint32_t flags)
 
std::pair< void **, size_t > & rollback (void **protected_stack)
 
void commit ()
 
void setThrownObject (void **addr, size_t length)
 Self explanatory, precondition thrown_.address == NULL. More...
 
void clearThrownObject ()
 
void log (void **addr, void *value, size_t bytes)
 
void registerOnCommit (_ITM_userCommitFunction f, void *arg)
 Registration handler is trivial so we inline it. More...
 
void registerOnAbort (_ITM_userUndoFunction f, void *arg)
 Registration handler is trivial so we inline it. More...
 
- Public Member Functions inherited from itm2stm::Checkpoint
void restore (uint32_t flags) asm("_stm_itm2stm_checkpoint_restore") NORETURN
 

Private Types

typedef std::vector< Callback
< _ITM_userUndoFunction > > 
RollbackList
 
typedef std::vector< Callback
< _ITM_userCommitFunction > > 
CommitList
 
typedef std::vector< LoggedWordUndoList
 

Static Private Member Functions

template<typename F >
static Callback< F > make_callback (F f, void *arg)
 

Private Attributes

bool aborted_
 
uint32_t flags_
 
_ITM_transactionId_t id_
 
ThrownObject thrown_
 
RollbackList do_on_rollback_
 
UndoList undo_on_rollback_
 
CommitList do_on_commit_
 
_ITM_transactionowner_
 

Additional Inherited Members

- Protected Attributes inherited from itm2stm::Checkpoint
void * checkpoint_ [CHECKPOINT_SIZE]
 

Detailed Description

A Scope maintains the data associated with a nested transaction. This includes the transaction's checkpoint, the flags that it began with, a flag that tells us if it has been aborted (an ABI-required behavior), an address range used to register a thrown exception, lists of user-registered onUndo and onCommit handlers, and a list of logged values.

The runtime can commit a scope, rollback a scope, and restore the scope's checkpoint (which performs a longjmp).

Member Typedef Documentation

We expect these features to be used uncommonly, thus we're happy just to store them as vectors. Should this become a bottleneck, particularly calls to "clear" them, we could go with something more optimized like an stm::MiniVector.

typedef std::vector<LoggedWord> itm2stm::Scope::UndoList
private

Constructor & Destructor Documentation

Scope::Scope ( _ITM_transaction owner)

Member Function Documentation

void Scope::clearThrownObject ( )

Here is the call graph for this function:

Here is the caller graph for this function:

void itm2stm::Scope::commit ( )
inline

Called to commit a scope. Inlined because we care about commit performance.

void itm2stm::Scope::enter ( _ITM_transactionId_t  id,
uint32_t  flags 
)
inline

Called every time that a transaction begins (includes outer transactions and nested transactions, on their first entry and on every restart). After this call the scope must be entirely clean and ready to go. We inline this because it is important for performance in a number of places.

Here is the call graph for this function:

bool itm2stm::Scope::getAborted ( ) const
inline
uint32_t itm2stm::Scope::getFlags ( ) const
inline

Used by the Transaction during a restart, to simplify re-calling Scope::enter during Transaction::restart.

_ITM_transactionId_t itm2stm::Scope::getId ( ) const
inline

Read access to the Scope's id. The id is set during the Scope::enter call from a parameter.

_ITM_transaction& itm2stm::Scope::getOwner ( ) const
inline

Used from the libstm conflict abort handler (itm2stm-5.7.cpp:stm::TxThread::tmabort).

Here is the caller graph for this function:

bool itm2stm::Scope::isExceptionBlock ( ) const
inline

Used by the Transaction's rollback functionality.

void itm2stm::Scope::log ( void **  addr,
void *  value,
size_t  bytes 
)
inline

This is called from the logging functions (_ITM_L*) which do all of the heavy lifting. All the scope has to do is save the data being passed.

Here is the caller graph for this function:

template<typename F >
static Callback<F> itm2stm::Scope::make_callback ( f,
void *  arg 
)
inlinestaticprivate

Standard metaprogramming type-dispatcher picks up the necessary type from the parameter (see std::make_pair);

Here is the caller graph for this function:

void itm2stm::Scope::registerOnAbort ( _ITM_userUndoFunction  f,
void *  arg 
)
inline

Registration handler is trivial so we inline it.

Here is the call graph for this function:

void itm2stm::Scope::registerOnCommit ( _ITM_userCommitFunction  f,
void *  arg 
)
inline

Registration handler is trivial so we inline it.

Here is the call graph for this function:

std::pair< void **, size_t > & Scope::rollback ( void **  protected_stack)

Called when a transaction is either aborted or restarted. From the scope's perspective there isn't any difference between these two operations. We don't really care about rollback performance so this is outlined. The return value is a pair indicating a range of addresses that should not be rolled back by the library—this corresponds with a registered thrown object, but there isn't any reason to expose the ThrownObject type externally. If there was no thrown object then the returned value will be the pair (NULL, 0).

The stack maintains an undo log in support of the _ITM_L* calls. We need to make sure not to clobber the protected stack during rollback, hence the protected_stack address parameter.

void itm2stm::Scope::setAborted ( bool  val)
inline

Read/write accessors for the aborted flag. The write accessor is only used by the Transaction during rollback when it finds that it must mark the "outermost" scope as aborted, before the outermost scope gets completely rolled back. This is an ITM-ABI required behavior.

void Scope::setThrownObject ( void **  addr,
size_t  length 
)

Self explanatory, precondition thrown_.address == NULL.

Member Data Documentation

bool itm2stm::Scope::aborted_
private
CommitList itm2stm::Scope::do_on_commit_
private
RollbackList itm2stm::Scope::do_on_rollback_
private
uint32_t itm2stm::Scope::flags_
private
_ITM_transactionId_t itm2stm::Scope::id_
private
_ITM_transaction& itm2stm::Scope::owner_
private
ThrownObject itm2stm::Scope::thrown_
private
UndoList itm2stm::Scope::undo_on_rollback_
private

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