Commit 4bef35fd authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Clear stack outside OP_call* handlers.

parent 51f65ec9
...@@ -571,7 +571,7 @@ static HRESULT compile_new_expression(compiler_ctx_t *ctx, call_expression_t *ex ...@@ -571,7 +571,7 @@ static HRESULT compile_new_expression(compiler_ctx_t *ctx, call_expression_t *ex
static HRESULT compile_call_expression(compiler_ctx_t *ctx, call_expression_t *expr, BOOL emit_ret) static HRESULT compile_call_expression(compiler_ctx_t *ctx, call_expression_t *expr, BOOL emit_ret)
{ {
unsigned arg_cnt = 0; unsigned arg_cnt = 0, extra_args;
argument_t *arg; argument_t *arg;
unsigned instr; unsigned instr;
jsop_t op; jsop_t op;
...@@ -579,9 +579,11 @@ static HRESULT compile_call_expression(compiler_ctx_t *ctx, call_expression_t *e ...@@ -579,9 +579,11 @@ static HRESULT compile_call_expression(compiler_ctx_t *ctx, call_expression_t *e
if(is_memberid_expr(expr->expression->type)) { if(is_memberid_expr(expr->expression->type)) {
op = OP_call_member; op = OP_call_member;
extra_args = 2;
hres = compile_memberid_expression(ctx, expr->expression, 0); hres = compile_memberid_expression(ctx, expr->expression, 0);
}else { }else {
op = OP_call; op = OP_call;
extra_args = 1;
hres = compile_expression(ctx, expr->expression, TRUE); hres = compile_expression(ctx, expr->expression, TRUE);
} }
...@@ -601,7 +603,12 @@ static HRESULT compile_call_expression(compiler_ctx_t *ctx, call_expression_t *e ...@@ -601,7 +603,12 @@ static HRESULT compile_call_expression(compiler_ctx_t *ctx, call_expression_t *e
instr_ptr(ctx, instr)->u.arg[0].uint = arg_cnt; instr_ptr(ctx, instr)->u.arg[0].uint = arg_cnt;
instr_ptr(ctx, instr)->u.arg[1].lng = emit_ret; instr_ptr(ctx, instr)->u.arg[1].lng = emit_ret;
return S_OK;
hres = push_instr_uint(ctx, OP_pop, arg_cnt + extra_args);
if(FAILED(hres))
return hres;
return !emit_ret || push_instr(ctx, OP_push_ret) ? S_OK : E_OUTOFMEMORY;
} }
static HRESULT compile_delete_expression(compiler_ctx_t *ctx, unary_expression_t *expr) static HRESULT compile_delete_expression(compiler_ctx_t *ctx, unary_expression_t *expr)
......
...@@ -972,8 +972,8 @@ static HRESULT interp_call(script_ctx_t *ctx) ...@@ -972,8 +972,8 @@ static HRESULT interp_call(script_ctx_t *ctx)
{ {
const unsigned argn = get_op_uint(ctx, 0); const unsigned argn = get_op_uint(ctx, 0);
const int do_ret = get_op_int(ctx, 1); const int do_ret = get_op_int(ctx, 1);
jsval_t r, obj; call_frame_t *frame = ctx->call_ctx;
HRESULT hres; jsval_t obj;
TRACE("%d %d\n", argn, do_ret); TRACE("%d %d\n", argn, do_ret);
...@@ -981,13 +981,9 @@ static HRESULT interp_call(script_ctx_t *ctx) ...@@ -981,13 +981,9 @@ static HRESULT interp_call(script_ctx_t *ctx)
if(!is_object_instance(obj)) if(!is_object_instance(obj))
return throw_type_error(ctx, JS_E_INVALID_PROPERTY, NULL); return throw_type_error(ctx, JS_E_INVALID_PROPERTY, NULL);
hres = disp_call_value(ctx, get_object(obj), NULL, DISPATCH_METHOD, argn, stack_args(ctx, argn), clear_ret(frame);
do_ret ? &r : NULL); return disp_call_value(ctx, get_object(obj), NULL, DISPATCH_METHOD,
if(FAILED(hres)) argn, stack_args(ctx, argn), do_ret ? &frame->ret : NULL);
return hres;
stack_popn(ctx, argn+1);
return do_ret ? stack_push(ctx, r) : S_OK;
} }
/* ECMA-262 3rd Edition 11.2.3 */ /* ECMA-262 3rd Edition 11.2.3 */
...@@ -995,10 +991,9 @@ static HRESULT interp_call_member(script_ctx_t *ctx) ...@@ -995,10 +991,9 @@ static HRESULT interp_call_member(script_ctx_t *ctx)
{ {
const unsigned argn = get_op_uint(ctx, 0); const unsigned argn = get_op_uint(ctx, 0);
const int do_ret = get_op_int(ctx, 1); const int do_ret = get_op_int(ctx, 1);
call_frame_t *frame = ctx->call_ctx;
IDispatch *obj; IDispatch *obj;
jsval_t r;
DISPID id; DISPID id;
HRESULT hres;
TRACE("%d %d\n", argn, do_ret); TRACE("%d %d\n", argn, do_ret);
...@@ -1006,13 +1001,9 @@ static HRESULT interp_call_member(script_ctx_t *ctx) ...@@ -1006,13 +1001,9 @@ static HRESULT interp_call_member(script_ctx_t *ctx)
if(!obj) if(!obj)
return throw_type_error(ctx, id, NULL); return throw_type_error(ctx, id, NULL);
hres = disp_call(ctx, obj, id, DISPATCH_METHOD, argn, stack_args(ctx, argn), do_ret ? &r : NULL); clear_ret(frame);
if(FAILED(hres)) return disp_call(ctx, obj, id, DISPATCH_METHOD,
return hres; argn, stack_args(ctx, argn), do_ret ? &frame->ret : NULL);
stack_popn(ctx, argn+2);
return do_ret ? stack_push(ctx, r) : S_OK;
} }
/* ECMA-262 3rd Edition 11.1.1 */ /* ECMA-262 3rd Edition 11.1.1 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment