17 #ifndef WRITESET_HPP__
18 #define WRITESET_HPP__
20 #include <stm/config.h>
68 bool filter(
void** lower,
void** upper)
70 return !(
addr + 1 < lower ||
addr >= upper);
92 assert((uint8_t*)upper - (uint8_t*)lower >= (
int)
sizeof(
void*));
93 assert((uintptr_t)upper %
sizeof(
void*) == 0);
94 if (
addr >= lower && (
addr + 1) <= upper)
148 if (__builtin_expect(rhs.
mask == (uintptr_t)~0x0,
true)) {
154 uintptr_t new_val = (uintptr_t)rhs.
val;
156 new_val |= (uintptr_t)
val & ~rhs.
mask;
157 val = (
void*)new_val;
177 return !(
addr + 1 < lower ||
addr >= upper);
191 if (__builtin_expect(
mask == (uintptr_t)~0x0,
true)) {
201 for (
unsigned i = 0; i <
sizeof(
val); ++i)
215 if (
addr + 1 < lower ||
addr >= upper)
218 if (
addr >= lower &&
addr + 1 <= upper) {
224 for (
unsigned i = 0; i <
sizeof(
void*); ++i) {
236 #if defined(STM_WS_WORDLOG)
237 typedef WordLoggingWriteSetEntry WriteSetEntry;
238 # define STM_WRITE_SET_ENTRY(addr, val, mask) addr, val
239 #elif defined(STM_WS_BYTELOG)
240 typedef ByteLoggingWriteSetEntry WriteSetEntry;
241 # define STM_WRITE_SET_ENTRY(addr, val, mask) addr, val, mask
243 # error WriteSet logging granularity configuration error.
277 size_t hash(
void*
const key)
const
279 static const unsigned long long s = 2654435769ull;
280 const unsigned long long r = ((
unsigned long long)key) * s;
281 return (
size_t)((r & 0xFFFFFFFF) >>
shift);
301 WriteSet(
const size_t initial_capacity);
310 bool find(WriteSetEntry& log)
const
312 size_t h =
hash(log.addr);
315 if (
index[h].address != log.addr) {
320 #if defined(STM_WS_WORDLOG)
323 #elif defined(STM_WS_BYTELOG)
333 if (__builtin_expect((log.mask & entry.mask) == 0,
false)) {
342 log.mask = entry.mask;
345 #error "Preprocessor configuration error."
349 #if defined(STM_WS_BYTELOG)
363 #if !defined (STM_ABORT_ON_THROW)
365 # define STM_ROLLBACK(log, stack, exception, len) log.rollback()
367 # if !defined(STM_PROTECT_STACK)
369 # define STM_ROLLBACK(log, stack, exception, len) log.rollback(exception, len)
371 void rollback(
void**,
void**,
size_t);
372 # define STM_ROLLBACK(log, stack, exception, len) log.rollback(stack, exception, len)
381 #if !defined(STM_PROTECT_STACK)
390 #ifdef STM_PROTECT_STACK
396 if (i->filter(&top_of_stack, upper_stack_bound))
409 size_t h =
hash(log.addr);
415 if (
index[h].address != log.addr) {
472 #endif // WRITESET_HPP__
void * val
Definition: WriteSet.hpp:120
void * address
Definition: WriteSet.hpp:257
~WriteSet()
Definition: types.cpp:92
uint8_t byte_val[sizeof(void *)]
Definition: WriteSet.hpp:121
void * val
Definition: WriteSet.hpp:47
void writeback() const
Definition: WriteSet.hpp:189
Definition: stm_fraser.c:61
WordLoggingWriteSetEntry(void **paddr, void *pval)
Definition: WriteSet.hpp:49
index_t()
Definition: WriteSet.hpp:260
void update(const WordLoggingWriteSetEntry &rhs)
Definition: WriteSet.hpp:58
void reset_internal()
Definition: types.cpp:132
uint8_t * byte_addr
Definition: WriteSet.hpp:116
void rebuild()
Definition: types.cpp:99
ByteLoggingWriteSetEntry(void **paddr, void *pval, uintptr_t pmask)
Definition: WriteSet.hpp:129
void resize()
Definition: types.cpp:122
void insert(const WriteSetEntry &log)
Definition: WriteSet.hpp:407
size_t version
Definition: WriteSet.hpp:256
WriteSetEntry * list
Definition: WriteSet.hpp:268
size_t version
Definition: WriteSet.hpp:266
uintptr_t mask
Definition: WriteSet.hpp:125
Definition: WriteSet.hpp:44
bool filter(void **lower, void **upper)
Definition: WriteSet.hpp:175
Definition: WriteSet.hpp:112
void ** addr
Definition: WriteSet.hpp:115
void rollback(void **lower, void **upper)
Definition: WriteSet.hpp:90
Definition: WriteSet.hpp:251
bool filter(void **lower, void **upper)
Definition: WriteSet.hpp:68
size_t ilength
Definition: WriteSet.hpp:265
size_t capacity
Definition: WriteSet.hpp:269
void update(const ByteLoggingWriteSetEntry &rhs)
Definition: WriteSet.hpp:145
size_t shift
Definition: WriteSet.hpp:264
void ** addr
Definition: WriteSet.hpp:46
size_t hash(void *const key) const
Definition: WriteSet.hpp:277
index_t * index
Definition: WriteSet.hpp:263
void rollback()
Definition: WriteSet.hpp:364
void reset()
Definition: WriteSet.hpp:454
bool find(WriteSetEntry &log) const
Definition: WriteSet.hpp:310
void writeback() const
Definition: WriteSet.hpp:78
WriteSet(const size_t initial_capacity)
Definition: types.cpp:79
WriteSetEntry * iterator
Definition: WriteSet.hpp:466
size_t doubleIndexLength()
Definition: types.cpp:69
TM_INLINE void writeback()
Definition: WriteSet.hpp:382
Definition: WriteSet.hpp:254
uint8_t byte_mask[sizeof(void *)]
Definition: WriteSet.hpp:126
size_t lsize
Definition: WriteSet.hpp:270
iterator begin() const
Definition: WriteSet.hpp:467
iterator end() const
Definition: WriteSet.hpp:468
size_t size() const
Definition: WriteSet.hpp:449
size_t index
Definition: WriteSet.hpp:258
void rollback(void **lower, void **upper)
Definition: WriteSet.hpp:212