tlds
Transactional Operations for Linked Data Structures
|
#include <Scope.h>
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_transaction & | getOwner () 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< LoggedWord > | UndoList |
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_transaction & | owner_ |
Additional Inherited Members | |
Protected Attributes inherited from itm2stm::Checkpoint | |
void * | checkpoint_ [CHECKPOINT_SIZE] |
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).
|
private |
|
private |
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.
|
private |
Scope::Scope | ( | _ITM_transaction & | owner | ) |
void Scope::clearThrownObject | ( | ) |
|
inline |
Called to commit a scope. Inlined because we care about commit performance.
|
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.
|
inline |
|
inline |
Used by the Transaction during a restart, to simplify re-calling Scope::enter during Transaction::restart.
|
inline |
Read access to the Scope's id. The id is set during the Scope::enter call from a parameter.
|
inline |
Used from the libstm conflict abort handler (itm2stm-5.7.cpp:stm::TxThread::tmabort).
|
inline |
Used by the Transaction's rollback functionality.
|
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.
|
inlinestaticprivate |
Standard metaprogramming type-dispatcher picks up the necessary type from the parameter (see std::make_pair);
|
inline |
Registration handler is trivial so we inline it.
|
inline |
Registration handler is trivial so we inline it.
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.
|
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.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |