jscript: Added new jmp_z opcode, more appropriate for branches.
This commit is contained in:
parent
e5d7d50faa
commit
95677c5099
|
@ -915,7 +915,7 @@ static HRESULT compile_if_statement(compiler_ctx_t *ctx, if_statement_t *stat)
|
|||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
jmp_else = push_instr(ctx, OP_cnd_z);
|
||||
jmp_else = push_instr(ctx, OP_jmp_z);
|
||||
if(jmp_else == -1)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
|
@ -929,9 +929,6 @@ static HRESULT compile_if_statement(compiler_ctx_t *ctx, if_statement_t *stat)
|
|||
|
||||
instr_ptr(ctx, jmp_else)->arg1.uint = ctx->code_off;
|
||||
|
||||
if(push_instr(ctx, OP_pop) == -1)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if(stat->else_stat) {
|
||||
hres = compile_statement(ctx, stat->else_stat);
|
||||
if(FAILED(hres))
|
||||
|
|
|
@ -2884,6 +2884,28 @@ static HRESULT interp_jmp(exec_ctx_t *ctx)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT interp_jmp_z(exec_ctx_t *ctx)
|
||||
{
|
||||
const unsigned arg = ctx->parser->code->instrs[ctx->ip].arg1.uint;
|
||||
VARIANT_BOOL b;
|
||||
VARIANT *v;
|
||||
HRESULT hres;
|
||||
|
||||
TRACE("\n");
|
||||
|
||||
v = stack_pop(ctx);
|
||||
hres = to_boolean(v, &b);
|
||||
VariantClear(v);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
if(b)
|
||||
ctx->ip++;
|
||||
else
|
||||
ctx->ip = arg;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT interp_pop(exec_ctx_t *ctx)
|
||||
{
|
||||
TRACE("\n");
|
||||
|
|
|
@ -69,6 +69,7 @@ typedef struct _func_stack {
|
|||
X(instanceof, 1, 0,0) \
|
||||
X(int, 1, ARG_INT, 0) \
|
||||
X(jmp, 0, ARG_ADDR, 0) \
|
||||
X(jmp_z, 0, ARG_ADDR, 0) \
|
||||
X(lshift, 1, 0,0) \
|
||||
X(lt, 1, 0,0) \
|
||||
X(lteq, 1, 0,0) \
|
||||
|
|
Loading…
Reference in New Issue