Jacek Caban : jscript: Added new jmp_z opcode, more appropriate for branches.
Alexandre Julliard
julliard at winehq.org
Tue Dec 20 13:43:26 CST 2011
Module: wine
Branch: master
Commit: 95677c5099c35c94a5346dcdd53f753fcacd7fac
URL: http://source.winehq.org/git/wine.git/?a=commit;h=95677c5099c35c94a5346dcdd53f753fcacd7fac
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Dec 20 11:47:37 2011 +0100
jscript: Added new jmp_z opcode, more appropriate for branches.
---
dlls/jscript/compile.c | 5 +----
dlls/jscript/engine.c | 22 ++++++++++++++++++++++
dlls/jscript/engine.h | 1 +
3 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 3633493..ceed228 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -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))
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 80486b8..9f4a5a7 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -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");
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index 3e58db2..2f0ba53 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -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) \
More information about the wine-cvs
mailing list