tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
library.hpp File Reference
#include <setjmp.h>
#include <stm/config.h>
#include <common/platform.hpp>
#include <stm/txthread.hpp>
#include "library_inst.hpp"
Include dependency graph for library.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  stm::Object
 

Namespaces

 stm
 

Macros

#define TM_BECOME_IRREVOC()   stm::become_irrevoc()
 
#define TM_READ(var)   stm::stm_read(&var, tx)
 
#define TM_WRITE(var, val)   stm::stm_write(&var, val, tx)
 
#define TM_BEGIN(TYPE)
 
#define TM_END
 
#define TM_GET_THREAD()   stm::TxThread* tx = (stm::TxThread*)stm::Self
 
#define TM_ARG_ALONE   stm::TxThread* tx
 
#define TM_ARG   , TM_ARG_ALONE
 
#define TM_PARAM   , tx
 
#define TM_PARAM_ALONE   tx
 
#define TM_WAIVER
 
#define TM_CALLABLE
 
#define TM_SYS_INIT()   stm::sys_init()
 
#define TM_THREAD_INIT   stm::thread_init
 
#define TM_THREAD_SHUTDOWN()   stm::thread_shutdown()
 
#define TM_SYS_SHUTDOWN   stm::sys_shutdown
 
#define TM_ALLOC   stm::tx_alloc
 
#define TM_FREE   stm::tx_free
 
#define TM_SET_POLICY(P)   stm::set_policy(P)
 
#define TM_GET_ALGNAME()   stm::get_algname()
 
#define TM_BEGIN_FAST_INITIALIZATION()
 
#define TM_END_FAST_INITIALIZATION()   TM_SET_POLICY(__config_string__)
 

Functions

TM_INLINE void stm::begin (TxThread *tx, scope_t *s, uint32_t)
 
TM_INLINE void stm::commit (TxThread *tx)
 
void NORETURN stm::UNRECOVERABLE (const char *)
 
void * stm::tx_alloc (size_t size)
 
void stm::tx_free (void *p)
 
void stm::sys_init (void(*abort_handler)(TxThread *)=NULL)
 
void stm::sys_shutdown ()
 
void stm::thread_init ()
 
void stm::thread_shutdown ()
 
void stm::set_policy (const char *)
 
const char * stm::get_algname ()
 
bool stm::become_irrevoc (STM_WHEN_PROTECT_STACK(void **top_of_stack))
 
void stm::restart ()
 
template<typename T >
stm::stm_read (T *addr, TxThread *thread)
 
template<typename T >
void stm::stm_write (T *addr, T val, TxThread *thread)
 

Macro Definition Documentation

#define TM_ALLOC   stm::tx_alloc
#define TM_ARG   , TM_ARG_ALONE
#define TM_ARG_ALONE   stm::TxThread* tx
#define TM_BECOME_IRREVOC ( )    stm::become_irrevoc()
#define TM_BEGIN (   TYPE)
Value:
{ \
stm::TxThread* tx = (stm::TxThread*)stm::Self; \
jmp_buf _jmpbuf; \
uint32_t abort_flags = setjmp(_jmpbuf); \
stm::begin(tx, &_jmpbuf, abort_flags); \
CFENCE; \
{
TM_INLINE void begin(TxThread *tx, scope_t *s, uint32_t)
Definition: library.hpp:71
stm_tx * tx
Definition: stmskip.cc:245
Definition: txthread.hpp:47

This is the way to start a transaction

#define TM_BEGIN_FAST_INITIALIZATION ( )
Value:
const char* __config_string__ = TM_GET_ALGNAME(); \
#define TM_GET_ALGNAME()
Definition: library.hpp:298
#define TM_SET_POLICY(P)
Definition: library.hpp:296
#define TM_GET_THREAD()
Definition: library.hpp:281

This is gross. ITM, like any good compiler, will make nontransactional versions of code so that we can cleanly do initialization from outside of a transaction. The library can do this, but only via some cumbersome template games that we really don't want to keep playing (see the previous release for examples).

Since we don't want to have transactional configuration (it is slow, and it messes up some accounting of commits and transaction sizes), we use the following trick: if we aren't using a compiler for instrumentation, then BEGIN_FAST_INITIALIZATION will copy the current STM configuration (envar STM_CONFIG) to a local, then switch the mode to CGL, then call the instrumented functions using CGL instrumentation (e.g., the lightest possible, and correct without a 'commit'). Likewise, if we aren't using a compiler for instrumentation, then END_FAST_INITIALIZATION will restore the original configuration, so that the app will use the STM as expected.

#define TM_CALLABLE
#define TM_END
Value:
} \
}
TM_INLINE void commit(TxThread *tx)
Definition: library.hpp:104
stm_tx * tx
Definition: stmskip.cc:245

This is the way to commit a transaction. Note that these macros weakly enforce lexical scoping

#define TM_END_FAST_INITIALIZATION ( )    TM_SET_POLICY(__config_string__)
#define TM_FREE   stm::tx_free
#define TM_GET_ALGNAME ( )    stm::get_algname()
#define TM_GET_THREAD ( )    stm::TxThread* tx = (stm::TxThread*)stm::Self

Macro to get STM context. This currently produces a pointer to a TxThread

#define TM_PARAM   , tx
#define TM_PARAM_ALONE   tx
#define TM_READ (   var)    stm::stm_read(&var, tx)

Code should only use these calls, not the template stuff declared above

#define TM_SET_POLICY (   P)    stm::set_policy(P)
#define TM_SYS_INIT ( )    stm::sys_init()
#define TM_SYS_SHUTDOWN   stm::sys_shutdown
#define TM_THREAD_INIT   stm::thread_init
#define TM_THREAD_SHUTDOWN ( )    stm::thread_shutdown()
#define TM_WAIVER
#define TM_WRITE (   var,
  val 
)    stm::stm_write(&var, val, tx)