diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2023-11-08 15:31:44 -0500 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2023-11-08 15:31:44 -0500 |
commit | b33c0c564c51252ff241a2143e467dadfb8d8994 (patch) | |
tree | 1e090f690843d9daf9c3fda7e08187bc7ea9fadb /libalee/state.hpp | |
parent | 8e7cb05cfb2903e3c6a3e0bf713282cf50563590 (diff) |
fib.fth benchmark; some minor coreword optimizations
Diffstat (limited to 'libalee/state.hpp')
-rw-r--r-- | libalee/state.hpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/libalee/state.hpp b/libalee/state.hpp index e77a223..2e69463 100644 --- a/libalee/state.hpp +++ b/libalee/state.hpp @@ -87,31 +87,42 @@ public: *dsp++ = value; } - inline Cell pop() { + inline const Cell& pop() { verify(dsp > dstack, Error::pop); return *--dsp; } + inline DoubleCell popd() { + DoubleCell dcell = pop(); + dcell <<= sizeof(Cell) * 8; + dcell |= static_cast<Addr>(pop()); + return dcell; + } + + inline void pushd(DoubleCell d) { + push(static_cast<Cell>(d)); + push(static_cast<Cell>(d >> (sizeof(Cell) * 8))); + } + inline void pushr(Cell value) { verify(rsp < rstack + ReturnStackSize, Error::pushr); *rsp++ = value; } - inline Cell popr() { + inline const Cell& popr() { verify(rsp > rstack, Error::popr); return *--rsp; } - inline Cell& top() { - verify(dsp > dstack, Error::top); - return *(dsp - 1); - } - inline Cell& pick(std::size_t i) { verify(dsp - i > dstack, Error::pick); return *(dsp - i - 1); } + inline Cell& top() { + return pick(0); + } + // Advances the instruction pointer and returns that cell's contents. inline Cell beyondip() { context.ip += sizeof(Cell); |