Module: wine Branch: master Commit: 0f0f76ce6badf9ab0d952b78fa846c05e2b81a44 URL: http://source.winehq.org/git/wine.git/?a=commit;h=0f0f76ce6badf9ab0d952b78fa...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Dec 14 11:06:43 2012 +0100
jscript: Allow poping multiple stack values at the time.
---
dlls/jscript/compile.c | 24 ++++++++++++------------ dlls/jscript/engine.c | 6 ++++-- dlls/jscript/engine.h | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index a3dab82..c37ec31 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -530,8 +530,9 @@ static HRESULT compile_conditional_expression(compiler_ctx_t *ctx, conditional_e return E_OUTOFMEMORY;
set_arg_uint(ctx, jmp_false, ctx->code_off); - if(!push_instr(ctx, OP_pop)) - return E_OUTOFMEMORY; + hres = push_instr_uint(ctx, OP_pop, 1); + if(FAILED(hres)) + return hres;
hres = compile_expression(ctx, expr->false_expression, TRUE); if(FAILED(hres)) @@ -1053,7 +1054,7 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr, BOOL if(FAILED(hres)) return hres;
- return emit_ret || push_instr(ctx, OP_pop) ? S_OK : E_OUTOFMEMORY; + return emit_ret ? S_OK : push_instr_uint(ctx, OP_pop, 1); }
static inline BOOL is_loop_statement(statement_type_t type) @@ -1353,12 +1354,12 @@ static HRESULT pop_to_stat(compiler_ctx_t *ctx, BOOL var_stack, BOOL scope_stack stack_pop += iter->stack_use; }
- if(var_stack) { - /* FIXME: optimize */ - while(stack_pop--) { - if(!push_instr(ctx, OP_pop)) - return E_OUTOFMEMORY; - } + if(var_stack && stack_pop) { + HRESULT hres; + + hres = push_instr_uint(ctx, OP_pop, stack_pop); + if(FAILED(hres)) + return hres; }
return S_OK; @@ -1579,12 +1580,11 @@ static HRESULT compile_switch_statement(compiler_ctx_t *ctx, switch_statement_t }
if(SUCCEEDED(hres)) { - if(push_instr(ctx, OP_pop)) { + hres = push_instr_uint(ctx, OP_pop, 1); + if(SUCCEEDED(hres)) { default_jmp = push_instr(ctx, OP_jmp); if(!default_jmp) hres = E_OUTOFMEMORY; - }else { - hres = E_OUTOFMEMORY; } }
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index a7934fc..fbfa460 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -2339,9 +2339,11 @@ static HRESULT interp_jmp_z(exec_ctx_t *ctx)
static HRESULT interp_pop(exec_ctx_t *ctx) { - TRACE("\n"); + const unsigned arg = get_op_uint(ctx, 0);
- stack_popn(ctx, 1); + TRACE("%u\n", arg); + + stack_popn(ctx, arg); return S_OK; }
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index 3407c06..0e9ed3b 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -84,7 +84,7 @@ typedef struct { X(null, 1, 0,0) \ X(obj_prop, 1, ARG_BSTR, 0) \ X(or, 1, 0,0) \ - X(pop, 1, 0,0) \ + X(pop, 1, ARG_UINT, 0) \ X(pop_except, 1, 0,0) \ X(pop_scope, 1, 0,0) \ X(postinc, 1, ARG_INT, 0) \