summaryrefslogtreecommitdiff
path: root/src/interpreter.h
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2017-09-20 09:49:58 -0700
committerGitHub <noreply@github.com>2017-09-20 09:49:58 -0700
commit447e6f752b157d0a9951525a045d862e62d9b88c (patch)
tree2484ab5841f35fa50127f6dd83460f943a202fb6 /src/interpreter.h
parentc71918746e06d2afffc46b3da5e3f2c024cc4b92 (diff)
downloadwabt-447e6f752b157d0a9951525a045d862e62d9b88c.tar.gz
wabt-447e6f752b157d0a9951525a045d862e62d9b88c.tar.bz2
wabt-447e6f752b157d0a9951525a045d862e62d9b88c.zip
Add Atomic instructions (#633)
This adds support for all atomic instructions, enabled via the `--enable-threads` flag. It supports all tools: parsing text, decoding binary, validation, and interpreting. It does not currently ensure that the memory is marked as shared; that flag is not supported in wabt yet.
Diffstat (limited to 'src/interpreter.h')
-rw-r--r--src/interpreter.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/interpreter.h b/src/interpreter.h
index 178fad19..cccf5897 100644
--- a/src/interpreter.h
+++ b/src/interpreter.h
@@ -38,6 +38,8 @@ namespace interpreter {
V(Returned, "returned") \
/* memory access is out of bounds */ \
V(TrapMemoryAccessOutOfBounds, "out of bounds memory access") \
+ /* atomic memory access is unaligned */ \
+ V(TrapAtomicMemoryAccessUnaligned, "atomic memory access is unaligned") \
/* converting from float -> int would overflow int */ \
V(TrapIntegerOverflow, "integer overflow") \
/* dividend is zero in integer divide */ \
@@ -495,6 +497,10 @@ class Thread {
void Trace(Stream*);
Memory* ReadMemory(const uint8_t** pc);
+ template <typename MemType>
+ Result GetAccessAddress(const uint8_t** pc, void** out_address);
+ template <typename MemType>
+ Result GetAtomicAccessAddress(const uint8_t** pc, void** out_address);
Value& Top();
Value& Pick(Index depth);
@@ -523,16 +529,25 @@ class Thread {
Result PushCall(const uint8_t* pc) WABT_WARN_UNUSED;
IstreamOffset PopCall();
- template <typename MemType, typename ResultType = MemType>
- Result Load(const uint8_t** pc) WABT_WARN_UNUSED;
- template <typename MemType, typename ResultType = MemType>
- Result Store(const uint8_t** pc) WABT_WARN_UNUSED;
-
template <typename R, typename T> using UnopFunc = R(T);
template <typename R, typename T> using UnopTrapFunc = Result(T, R*);
template <typename R, typename T> using BinopFunc = R(T, T);
template <typename R, typename T> using BinopTrapFunc = Result(T, T, R*);
+ template <typename MemType, typename ResultType = MemType>
+ Result Load(const uint8_t** pc) WABT_WARN_UNUSED;
+ template <typename MemType, typename ResultType = MemType>
+ Result Store(const uint8_t** pc) WABT_WARN_UNUSED;
+ template <typename MemType, typename ResultType = MemType>
+ Result AtomicLoad(const uint8_t** pc) WABT_WARN_UNUSED;
+ template <typename MemType, typename ResultType = MemType>
+ Result AtomicStore(const uint8_t** pc) WABT_WARN_UNUSED;
+ template <typename MemType, typename ResultType = MemType>
+ Result AtomicRmw(BinopFunc<ResultType, ResultType>,
+ const uint8_t** pc) WABT_WARN_UNUSED;
+ template <typename MemType, typename ResultType = MemType>
+ Result AtomicRmwCmpxchg(const uint8_t** pc) WABT_WARN_UNUSED;
+
template <typename R, typename T = R>
Result Unop(UnopFunc<R, T> func) WABT_WARN_UNUSED;
template <typename R, typename T = R>