diff --git a/include/pocketpy/frame.h b/include/pocketpy/frame.h index 12e51651..77b01bb2 100644 --- a/include/pocketpy/frame.h +++ b/include/pocketpy/frame.h @@ -94,10 +94,10 @@ struct Frame { Frame(PyVar* p0, const CodeObject_& co, PyVar _module) : _ip(-1), _next_ip(0), _sp_base(p0), co(co.get()), _module(_module), _callable(nullptr), _locals(co.get(), p0) {} - Bytecode next_bytecode() { + int next_bytecode() { _ip = _next_ip++; PK_DEBUG_ASSERT(_ip >= 0 && _ip < co->codes.size()); - return co->codes[_ip]; + return _ip; } PyVar* actual_sp_base() const { return _locals.a; } diff --git a/src/ceval.cpp b/src/ceval.cpp index fd8fc2ba..a76f97cd 100644 --- a/src/ceval.cpp +++ b/src/ceval.cpp @@ -111,10 +111,11 @@ PyVar VM::__run_top_frame(){ __NEXT_FRAME: const CodeObject* co = frame->co; + const Bytecode* co_codes = co->codes.data(); Bytecode byte; __NEXT_STEP:; - byte = frame->next_bytecode(); + byte = co_codes[frame->next_bytecode()]; CEVAL_STEP_CALLBACK(); #if PK_DEBUG_CEVAL_STEP