Rename VM's jump instructions for better readability.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
eb80dced3e
commit
89f19133d5
|
@ -1688,9 +1688,9 @@ static sxi32 PH7_CompileWhile(ph7_gen_state *pGen) {
|
||||||
pGen->pIn = &pEnd[1];
|
pGen->pIn = &pEnd[1];
|
||||||
pGen->pEnd = pTmp;
|
pGen->pEnd = pTmp;
|
||||||
/* Emit the false jump */
|
/* Emit the false jump */
|
||||||
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JZ, 0, 0, 0, &nFalseJump);
|
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JMPZ, 0, 0, 0, &nFalseJump);
|
||||||
/* Save the instruction index so we can fix it later when the jump destination is resolved */
|
/* Save the instruction index so we can fix it later when the jump destination is resolved */
|
||||||
PH7_GenStateNewJumpFixup(pWhileBlock, PH7_OP_JZ, nFalseJump);
|
PH7_GenStateNewJumpFixup(pWhileBlock, PH7_OP_JMPZ, nFalseJump);
|
||||||
/* Compile the loop body */
|
/* Compile the loop body */
|
||||||
rc = PH7_CompileBlock(&(*pGen));
|
rc = PH7_CompileBlock(&(*pGen));
|
||||||
if(rc == SXERR_ABORT) {
|
if(rc == SXERR_ABORT) {
|
||||||
|
@ -1820,7 +1820,7 @@ static sxi32 PH7_CompileDoWhile(ph7_gen_state *pGen) {
|
||||||
pGen->pIn = &pEnd[1];
|
pGen->pIn = &pEnd[1];
|
||||||
pGen->pEnd = pTmp;
|
pGen->pEnd = pTmp;
|
||||||
/* Emit the true jump to the beginning of the loop */
|
/* Emit the true jump to the beginning of the loop */
|
||||||
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JNZ, 0, pDoBlock->nFirstInstr, 0, 0);
|
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JMPNZ, 0, pDoBlock->nFirstInstr, 0, 0);
|
||||||
/* Fix all jumps now the destination is resolved */
|
/* Fix all jumps now the destination is resolved */
|
||||||
PH7_GenStateFixJumps(pDoBlock, -1, PH7_VmInstrLength(pGen->pVm));
|
PH7_GenStateFixJumps(pDoBlock, -1, PH7_VmInstrLength(pGen->pVm));
|
||||||
/* Release the loop block */
|
/* Release the loop block */
|
||||||
|
@ -1933,9 +1933,9 @@ static sxi32 PH7_CompileFor(ph7_gen_state *pGen) {
|
||||||
return SXERR_ABORT;
|
return SXERR_ABORT;
|
||||||
} else if(rc != SXERR_EMPTY) {
|
} else if(rc != SXERR_EMPTY) {
|
||||||
/* Emit the false jump */
|
/* Emit the false jump */
|
||||||
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JZ, 0, 0, 0, &nFalseJump);
|
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JMPZ, 0, 0, 0, &nFalseJump);
|
||||||
/* Save the instruction index so we can fix it later when the jump destination is resolved */
|
/* Save the instruction index so we can fix it later when the jump destination is resolved */
|
||||||
PH7_GenStateNewJumpFixup(pForBlock, PH7_OP_JZ, nFalseJump);
|
PH7_GenStateNewJumpFixup(pForBlock, PH7_OP_JMPZ, nFalseJump);
|
||||||
}
|
}
|
||||||
if((pGen->pIn->nType & PH7_TK_SEMI) == 0) {
|
if((pGen->pIn->nType & PH7_TK_SEMI) == 0) {
|
||||||
/* Syntax error */
|
/* Syntax error */
|
||||||
|
@ -2327,9 +2327,9 @@ static sxi32 PH7_CompileIf(ph7_gen_state *pGen) {
|
||||||
return SXERR_ABORT;
|
return SXERR_ABORT;
|
||||||
}
|
}
|
||||||
/* Emit the false jump */
|
/* Emit the false jump */
|
||||||
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JZ, 0, 0, 0, &nJumpIdx);
|
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JMPZ, 0, 0, 0, &nJumpIdx);
|
||||||
/* Save the instruction index so we can fix it later when the jump destination is resolved */
|
/* Save the instruction index so we can fix it later when the jump destination is resolved */
|
||||||
PH7_GenStateNewJumpFixup(pCondBlock, PH7_OP_JZ, nJumpIdx);
|
PH7_GenStateNewJumpFixup(pCondBlock, PH7_OP_JMPZ, nJumpIdx);
|
||||||
/* Compile the body */
|
/* Compile the body */
|
||||||
rc = PH7_CompileBlock(&(*pGen));
|
rc = PH7_CompileBlock(&(*pGen));
|
||||||
if(rc == SXERR_ABORT) {
|
if(rc == SXERR_ABORT) {
|
||||||
|
@ -2359,10 +2359,10 @@ static sxi32 PH7_CompileIf(ph7_gen_state *pGen) {
|
||||||
/* Synchronize cursors */
|
/* Synchronize cursors */
|
||||||
pToken = pGen->pIn;
|
pToken = pGen->pIn;
|
||||||
/* Fix the false jump */
|
/* Fix the false jump */
|
||||||
PH7_GenStateFixJumps(pCondBlock, PH7_OP_JZ, PH7_VmInstrLength(pGen->pVm));
|
PH7_GenStateFixJumps(pCondBlock, PH7_OP_JMPZ, PH7_VmInstrLength(pGen->pVm));
|
||||||
} /* For(;;) */
|
} /* For(;;) */
|
||||||
/* Fix the false jump */
|
/* Fix the false jump */
|
||||||
PH7_GenStateFixJumps(pCondBlock, PH7_OP_JZ, PH7_VmInstrLength(pGen->pVm));
|
PH7_GenStateFixJumps(pCondBlock, PH7_OP_JMPZ, PH7_VmInstrLength(pGen->pVm));
|
||||||
if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_KEYWORD) &&
|
if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_KEYWORD) &&
|
||||||
(SX_PTR_TO_INT(pGen->pIn->pUserData) & PH7_KEYWORD_ELSE)) {
|
(SX_PTR_TO_INT(pGen->pIn->pUserData) & PH7_KEYWORD_ELSE)) {
|
||||||
/* Compile the else block */
|
/* Compile the else block */
|
||||||
|
@ -4922,7 +4922,7 @@ static sxi32 PH7_GenStateEmitExprCode(
|
||||||
}
|
}
|
||||||
nJz = nJmp = 0; /* cc -O6 warning */
|
nJz = nJmp = 0; /* cc -O6 warning */
|
||||||
/* Phase#2: Emit the false jump */
|
/* Phase#2: Emit the false jump */
|
||||||
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JZ, 0, 0, 0, &nJz);
|
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JMPZ, 0, 0, 0, &nJz);
|
||||||
if(pNode->pLeft) {
|
if(pNode->pLeft) {
|
||||||
/* Phase#3: Compile the 'then' expression */
|
/* Phase#3: Compile the 'then' expression */
|
||||||
rc = PH7_GenStateEmitExprCode(&(*pGen), pNode->pLeft, iFlags);
|
rc = PH7_GenStateEmitExprCode(&(*pGen), pNode->pLeft, iFlags);
|
||||||
|
@ -5018,10 +5018,10 @@ static sxi32 PH7_GenStateEmitExprCode(
|
||||||
if(pNode->pRight) {
|
if(pNode->pRight) {
|
||||||
if(iVmOp == PH7_OP_LAND) {
|
if(iVmOp == PH7_OP_LAND) {
|
||||||
/* Emit the false jump so we can short-circuit the logical and */
|
/* Emit the false jump so we can short-circuit the logical and */
|
||||||
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JZ, 1/* Keep the value on the stack */, 0, 0, &nJmpIdx);
|
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JMPZ, 1/* Keep the value on the stack */, 0, 0, &nJmpIdx);
|
||||||
} else if(iVmOp == PH7_OP_LOR) {
|
} else if(iVmOp == PH7_OP_LOR) {
|
||||||
/* Emit the true jump so we can short-circuit the logical or*/
|
/* Emit the true jump so we can short-circuit the logical or*/
|
||||||
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JNZ, 1/* Keep the value on the stack */, 0, 0, &nJmpIdx);
|
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JMPNZ, 1/* Keep the value on the stack */, 0, 0, &nJmpIdx);
|
||||||
} else if(pNode->pOp->iPrec == 18 /* Combined binary operators [i.e: =,'.=','+=',*=' ...] precedence */) {
|
} else if(pNode->pOp->iPrec == 18 /* Combined binary operators [i.e: =,'.=','+=',*=' ...] precedence */) {
|
||||||
iFlags |= EXPR_FLAG_LOAD_IDX_STORE;
|
iFlags |= EXPR_FLAG_LOAD_IDX_STORE;
|
||||||
}
|
}
|
||||||
|
|
16
engine/vm.c
16
engine/vm.c
|
@ -2135,12 +2135,12 @@ static sxi32 VmByteCodeExec(
|
||||||
pc = pInstr->iP2 - 1;
|
pc = pInstr->iP2 - 1;
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
* JZ: P1 P2 *
|
* JMPZ: P1 P2 *
|
||||||
*
|
*
|
||||||
* Take the jump if the top value is zero (FALSE jump).Pop the top most
|
* Take the jump if the top value is zero (FALSE jump).Pop the top most
|
||||||
* entry in the stack if P1 is zero.
|
* entry in the stack if P1 is zero.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_JZ:
|
case PH7_OP_JMPZ:
|
||||||
#ifdef UNTRUST
|
#ifdef UNTRUST
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
|
@ -2159,12 +2159,12 @@ static sxi32 VmByteCodeExec(
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
* JNZ: P1 P2 *
|
* JMPNZ: P1 P2 *
|
||||||
*
|
*
|
||||||
* Take the jump if the top value is not zero (TRUE jump).Pop the top most
|
* Take the jump if the top value is not zero (TRUE jump).Pop the top most
|
||||||
* entry in the stack if P1 is zero.
|
* entry in the stack if P1 is zero.
|
||||||
*/
|
*/
|
||||||
case PH7_OP_JNZ:
|
case PH7_OP_JMPNZ:
|
||||||
#ifdef UNTRUST
|
#ifdef UNTRUST
|
||||||
if(pTos < pStack) {
|
if(pTos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
|
@ -5399,11 +5399,11 @@ static const char *VmInstrToString(sxi32 nOp) {
|
||||||
case PH7_OP_JMP:
|
case PH7_OP_JMP:
|
||||||
zOp = "JMP";
|
zOp = "JMP";
|
||||||
break;
|
break;
|
||||||
case PH7_OP_JZ:
|
case PH7_OP_JMPZ:
|
||||||
zOp = "JZ";
|
zOp = "JMPZ";
|
||||||
break;
|
break;
|
||||||
case PH7_OP_JNZ:
|
case PH7_OP_JMPNZ:
|
||||||
zOp = "JNZ";
|
zOp = "JMPNZ";
|
||||||
break;
|
break;
|
||||||
case PH7_OP_POP:
|
case PH7_OP_POP:
|
||||||
zOp = "POP";
|
zOp = "POP";
|
||||||
|
|
|
@ -1397,8 +1397,8 @@ enum ph7_vm_op {
|
||||||
PH7_OP_LOAD_CLOSURE, /* Load closure */
|
PH7_OP_LOAD_CLOSURE, /* Load closure */
|
||||||
PH7_OP_NOOP, /* NOOP */
|
PH7_OP_NOOP, /* NOOP */
|
||||||
PH7_OP_JMP, /* Unconditional jump */
|
PH7_OP_JMP, /* Unconditional jump */
|
||||||
PH7_OP_JZ, /* Jump on zero (FALSE jump) */
|
PH7_OP_JMPZ, /* Jump on zero (FALSE jump) */
|
||||||
PH7_OP_JNZ, /* Jump on non-zero (TRUE jump) */
|
PH7_OP_JMPNZ, /* Jump on non-zero (TRUE jump) */
|
||||||
PH7_OP_POP, /* Stack POP */
|
PH7_OP_POP, /* Stack POP */
|
||||||
PH7_OP_CVT_INT, /* Integer cast */
|
PH7_OP_CVT_INT, /* Integer cast */
|
||||||
PH7_OP_CVT_STR, /* String cast */
|
PH7_OP_CVT_STR, /* String cast */
|
||||||
|
|
Loading…
Reference in New Issue