From b33c0c564c51252ff241a2143e467dadfb8d8994 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 8 Nov 2023 15:31:44 -0500 Subject: fib.fth benchmark; some minor coreword optimizations --- libalee/state.hpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'libalee/state.hpp') 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(pop()); + return dcell; + } + + inline void pushd(DoubleCell d) { + push(static_cast(d)); + push(static_cast(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); -- cgit v1.2.3