From 97ec04789d795ed589a324aaf7dd9eb79ec4f7d9 Mon Sep 17 00:00:00 2001 From: Sahil Jain Date: Mon, 30 Jun 2025 22:57:49 +0530 Subject: [PATCH] Add JUMP_BACKWARD + CACHE comments --- ASTree.cpp | 11 ++++++++--- bytecode.cpp | 4 ++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ASTree.cpp b/ASTree.cpp index 5f5603a..99f95cb 100644 --- a/ASTree.cpp +++ b/ASTree.cpp @@ -1164,10 +1164,13 @@ PycRef BuildFromCode(PycRef code, PycModule* mod) } break; case Pyc::JUMP_ABSOLUTE_A: + // bpo-47120: Replaced JUMP_ABSOLUTE by the relative jump JUMP_BACKWARD. + case Pyc::JUMP_BACKWARD_A: + case Pyc::JUMP_BACKWARD_NO_INTERRUPT_A: { int offs = operand; if (mod->verCompare(3, 10) >= 0) - offs *= sizeof(uint16_t); // // BPO-27129 + offs *= sizeof(uint16_t); // // BPO-27129 if (offs < pos) { if (curblock->blktype() == ASTBlock::BLK_FOR) { @@ -1689,8 +1692,10 @@ PycRef BuildFromCode(PycRef code, PycModule* mod) } // end for loop here - // TODO : Ensure that FOR loop ends here. - // Due to CACHE instructions at play, this can change. + /* TODO : Ensure that FOR loop ends here. + Due to CACHE instructions at play, the end indicated in + the for loop by pycdas is not correct, it is off by + some small amount. */ if (curblock->blktype() == ASTBlock::BLK_FOR) { PycRef prev = blocks.top(); blocks.pop(); diff --git a/bytecode.cpp b/bytecode.cpp index 7821459..c6b7cba 100644 --- a/bytecode.cpp +++ b/bytecode.cpp @@ -472,6 +472,10 @@ void bc_disasm(std::ostream& pyc_output, PycRef code, PycModule* mod, case Pyc::INSTRUMENTED_POP_JUMP_IF_FALSE_A: case Pyc::INSTRUMENTED_POP_JUMP_IF_TRUE_A: { + /* TODO: Fix offset based on CACHE instructions. + Offset is relative to next non-CACHE instruction + and thus will be printed lower than actual value. + See TODO @ END_FOR ASTree.cpp */ int offs = operand; if (mod->verCompare(3, 10) >= 0) offs *= sizeof(uint16_t); // BPO-27129