Revert context frame implementation
All checks were successful
Build / AerScript (push) Successful in 32s

This commit is contained in:
2025-08-30 18:27:59 +02:00
parent 566997d080
commit cd924eb066
5 changed files with 12 additions and 52 deletions

View File

@@ -1879,8 +1879,6 @@ static sxi32 PH7_CompileFor(ph7_gen_state *pGen) {
pTmp = pGen->pEnd;
pGen->pEnd = pEnd;
sxu32 nKey = (sxu32)(SX_PTR_TO_INT(pGen->pIn->pUserData));
/* Emit the OP_CF_START instruction to enter a context frame */
PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_CF_START, 0, 0, 0, 0);
if(nKey & (PH7_KEYWORD_AUTO | PH7_KEYWORD_TYPEDEF)) {
/* Compile variable */
PH7_CompileVar(&(*pGen));
@@ -1982,8 +1980,6 @@ static sxi32 PH7_CompileFor(ph7_gen_state *pGen) {
PH7_GenStateFixJumps(pForBlock, -1, PH7_VmInstrLength(pGen->pVm));
/* Release the loop block */
PH7_GenStateLeaveBlock(pGen, 0);
/* Emit the OP_CF_STOP instruction to leave the context frame */
PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_CF_STOP, 0, 0, 0, 0);
/* Statement successfully compiled */
return SXRET_OK;
}

View File

@@ -19,7 +19,7 @@ PH7_PRIVATE sxi32 VmExtractDebugTrace(ph7_vm *pVm, SySet *pDebugTrace) {
/* Backup current frame */
VmFrame *oFrame = pVm->pFrame;
while(pVm->pFrame) {
if(pVm->pFrame->iFlags & (VM_FRAME_ACTIVE | VM_FRAME_CONTEXT)) {
if(pVm->pFrame->iFlags & VM_FRAME_ACTIVE) {
/* Iterate through all frames */
ph7_vm_func *pFunc;
pFunc = (ph7_vm_func *)pVm->pFrame->pUserData;
@@ -116,12 +116,6 @@ static const char *VmInstrToString(sxi32 nOp) {
case PH7_OP_JMPNZ:
zOp = "JMPNZ";
break;
case PH7_OP_CF_START:
zOp = "CF_START";
break;
case PH7_OP_CF_STOP:
zOp = "CF_STOP";
break;
case PH7_OP_LF_START:
zOp = "LF_START";
break;

View File

@@ -1394,7 +1394,7 @@ static ph7_value *VmExtractMemObj(
}
break;
}
if(pFrame->pParent && pFrame->iFlags & (VM_FRAME_CONTEXT | VM_FRAME_LOOP | VM_FRAME_EXCEPTION | VM_FRAME_CATCH | VM_FRAME_FINALLY)) {
if(pFrame->pParent && pFrame->iFlags & (VM_FRAME_LOOP | VM_FRAME_EXCEPTION | VM_FRAME_CATCH | VM_FRAME_FINALLY)) {
pFrame = pFrame->pParent;
} else {
break;
@@ -1908,14 +1908,14 @@ static sxi32 VmByteCodeExec(
VmLeaveFrame(&(*pVm));
}
} else if(pVm->pFrame->iFlags & VM_FRAME_LOOP) {
while(pVm->pFrame->pParent && (pVm->pFrame->iFlags & (VM_FRAME_ACTIVE | VM_FRAME_CONTEXT)) == 0) {
while(pVm->pFrame->pParent && (pVm->pFrame->iFlags & VM_FRAME_ACTIVE) == 0) {
VmLeaveFrame(&(*pVm));
}
}
if(pResult) {
/* Execution result */
PH7_MemObjStore(pTos, pResult);
if(!pInstr->iP2 && pVm->pFrame->iFlags & (VM_FRAME_ACTIVE | VM_FRAME_CONTEXT)) {
if(!pInstr->iP2 && pVm->pFrame->iFlags & VM_FRAME_ACTIVE) {
ph7_vm_func *pFunc = (ph7_vm_func *)pVm->pFrame->pUserData;
if(pFunc->nType) {
if((pFunc->nType & MEMOBJ_MIXED) == 0) {
@@ -2027,33 +2027,6 @@ static sxi32 VmByteCodeExec(
VmPopOperand(&pTos, 1);
}
break;
/*
* CF_START: * * *
*
* Creates and enters the active context frame.
*/
case PH7_OP_CF_START: {
VmFrame *pFrame = 0;
/* Enter the context frame */
rc = VmEnterFrame(&(*pVm), pVm->pFrame->pUserData, pVm->pFrame->pThis, &pFrame);
if(rc != SXRET_OK) {
PH7_VmMemoryError(&(*pVm));
}
pFrame->iFlags = VM_FRAME_CONTEXT;
break;
}
/*
* CF_STOP: * * *
*
* Leaves and destroys the active context frame.
*/
case PH7_OP_CF_STOP: {
/* Leave the context frame */
if(pVm->pFrame->iFlags & VM_FRAME_CONTEXT) {
VmLeaveFrame(&(*pVm));
}
break;
}
/*
* LF_START: * * *
*
@@ -2347,7 +2320,7 @@ static sxi32 VmByteCodeExec(
/* Candidate for expansion via user defined callbacks */
for(;;) {
pEntry = SyHashGet(&pFrame->hConst, SyBlobData(&pObj->sBlob), SyBlobLength(&pObj->sBlob));
if(pEntry == 0 && pFrame->iFlags & (VM_FRAME_CONTEXT | VM_FRAME_LOOP) && pFrame->pParent) {
if(pEntry == 0 && pFrame->iFlags & VM_FRAME_LOOP && pFrame->pParent) {
pFrame = pFrame->pParent;
} else {
break;