optimize ip incrementation

llvm
Clyne 2 years ago
parent 739fce1848
commit 42d64c6da2

@ -60,8 +60,8 @@ execute:
default: default:
// must be calling a defined subroutine // must be calling a defined subroutine
state.pushr(state.ip); state.pushr(state.ip);
state.ip = index - sizeof(Cell); state.ip = index;
break; return;
case 0: // _lit case 0: // _lit
state.push(state.beyondip()); state.push(state.beyondip());
break; break;
@ -184,8 +184,8 @@ execute:
} }
[[fallthrough]]; [[fallthrough]];
case 28: // _jmp case 28: // _jmp
state.ip = state.beyondip() - sizeof(Cell); state.ip = state.beyondip();
break; return;
case 29: // depth case 29: // depth
state.push(state.size()); state.push(state.size());
break; break;
@ -207,6 +207,8 @@ execute:
Dictionary::InputCells - cell)); Dictionary::InputCells - cell));
break; break;
} }
state.ip += sizeof(Cell);
} }
int CoreWords::findi(const char *word) int CoreWords::findi(const char *word)

@ -37,12 +37,12 @@ State::Error State::execute(Addr addr)
if (!stat) { if (!stat) {
if (addr < CoreWords::WordCount) { if (addr < CoreWords::WordCount) {
CoreWords::run(addr, *this); CoreWords::run(addr, *this);
ip = 0;
} else { } else {
auto ins = addr; auto ins = addr;
for (;;) { for (;;) {
CoreWords::run(ins, *this); CoreWords::run(ins, *this);
ip += sizeof(Cell);
ins = dict.read(ip); ins = dict.read(ip);
} }
} }

Loading…
Cancel
Save