Module: wine Branch: master Commit: 685cd437c9818b03e17393178f4beb7b0be61e52 URL: http://source.winehq.org/git/wine.git/?a=commit;h=685cd437c9818b03e17393178f...
Author: Jacek Caban jacek@codeweavers.com Date: Mon May 1 18:30:44 2017 +0200
jscript: Pass finally offset instead of catch ident to OP_push_except.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/jscript/compile.c | 7 +++++-- dlls/jscript/engine.c | 22 +++++++++++----------- dlls/jscript/engine.h | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 6a818ac..f9f70f0 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -1690,7 +1690,7 @@ static HRESULT compile_try_statement(compiler_ctx_t *ctx, try_statement_t *stat) { statement_ctx_t try_ctx = {0, FALSE, TRUE}, catch_ctx = {0, TRUE, FALSE}; statement_ctx_t finally_ctx = {2, FALSE, FALSE}; - unsigned push_except; + unsigned push_except, finally_off = 0, catch_off = 0; BSTR ident; HRESULT hres;
@@ -1725,7 +1725,7 @@ static HRESULT compile_try_statement(compiler_ctx_t *ctx, try_statement_t *stat) if(!jmp_finally) return E_OUTOFMEMORY;
- instr_ptr(ctx, push_except)->u.arg[0].uint = ctx->code_off; + catch_off = ctx->code_off;
hres = push_instr_bstr(ctx, OP_enter_catch, ident); if(FAILED(hres)) @@ -1744,6 +1744,7 @@ static HRESULT compile_try_statement(compiler_ctx_t *ctx, try_statement_t *stat) }
if(stat->finally_statement) { + finally_off = ctx->code_off; hres = compile_statement(ctx, stat->catch_block ? NULL : &finally_ctx, stat->finally_statement); if(FAILED(hres)) return hres; @@ -1752,6 +1753,8 @@ static HRESULT compile_try_statement(compiler_ctx_t *ctx, try_statement_t *stat) return E_OUTOFMEMORY; }
+ instr_ptr(ctx, push_except)->u.arg[0].uint = catch_off; + instr_ptr(ctx, push_except)->u.arg[1].uint = finally_off; return S_OK; }
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 4aee171..d012d7c 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -41,7 +41,7 @@ struct _except_frame_t { unsigned stack_top; scope_chain_t *scope; unsigned catch_off; - BSTR ident; + unsigned finally_off;
except_frame_t *next; }; @@ -897,8 +897,8 @@ static HRESULT interp_throw_type(script_ctx_t *ctx) /* ECMA-262 3rd Edition 12.14 */ static HRESULT interp_push_except(script_ctx_t *ctx) { - const unsigned arg1 = get_op_uint(ctx, 0); - const BSTR arg2 = get_op_bstr(ctx, 1); + const unsigned catch_off = get_op_uint(ctx, 0); + const unsigned finally_off = get_op_uint(ctx, 1); call_frame_t *frame = ctx->call_ctx; except_frame_t *except; unsigned stack_top; @@ -907,7 +907,7 @@ static HRESULT interp_push_except(script_ctx_t *ctx)
stack_top = ctx->stack_top;
- if(!arg2) { + if(!catch_off) { HRESULT hres;
hres = stack_push(ctx, jsval_bool(TRUE)); @@ -924,8 +924,8 @@ static HRESULT interp_push_except(script_ctx_t *ctx)
except->stack_top = stack_top; except->scope = frame->scope; - except->catch_off = arg1; - except->ident = arg2; + except->catch_off = catch_off; + except->finally_off = finally_off; except->next = frame->except_frame; frame->except_frame = except; return S_OK; @@ -2657,7 +2657,7 @@ static HRESULT unwind_exception(script_ctx_t *ctx, HRESULT exception_hres) except_frame_t *except_frame; call_frame_t *frame; jsval_t except_val; - BSTR ident; + unsigned catch_off; HRESULT hres;
for(frame = ctx->call_ctx; !frame->except_frame; frame = ctx->call_ctx) { @@ -2675,7 +2675,7 @@ static HRESULT unwind_exception(script_ctx_t *ctx, HRESULT exception_hres) }
except_frame = frame->except_frame; - ident = except_frame->ident; + catch_off = except_frame->catch_off; frame->except_frame = except_frame->next;
assert(except_frame->stack_top <= ctx->stack_top); @@ -2684,8 +2684,8 @@ static HRESULT unwind_exception(script_ctx_t *ctx, HRESULT exception_hres) while(except_frame->scope != frame->scope) scope_pop(&frame->scope);
- frame->ip = except_frame->catch_off; - if(ident) assert(frame->bytecode->instrs[frame->ip].op == OP_enter_catch); + frame->ip = catch_off ? catch_off : except_frame->finally_off; + if(catch_off) assert(frame->bytecode->instrs[frame->ip].op == OP_enter_catch);
except_val = ctx->ei.val; ctx->ei.val = jsval_undefined(); @@ -2697,7 +2697,7 @@ static HRESULT unwind_exception(script_ctx_t *ctx, HRESULT exception_hres) if(FAILED(hres)) return hres;
- if(!ident) + if(!catch_off) hres = stack_push(ctx, jsval_bool(FALSE)); return hres; } diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index bf74576..4992061 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -72,7 +72,7 @@ X(pop_scope, 1, 0,0) \ X(postinc, 1, ARG_INT, 0) \ X(preinc, 1, ARG_INT, 0) \ - X(push_except,1, ARG_ADDR, ARG_BSTR) \ + X(push_except,1, ARG_ADDR, ARG_UINT) \ X(push_ret, 1, 0,0) \ X(push_scope, 1, 0,0) \ X(regexp, 1, ARG_STR, ARG_UINT) \