jscript: Clear stack outside OP_new handler.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2016-03-28 17:49:10 +02:00 committed by Alexandre Julliard
parent d08036120a
commit 51f65ec974
3 changed files with 33 additions and 9 deletions

View File

@ -558,7 +558,15 @@ static HRESULT compile_new_expression(compiler_ctx_t *ctx, call_expression_t *ex
arg_cnt++;
}
return push_instr_uint(ctx, OP_new, arg_cnt);
hres = push_instr_uint(ctx, OP_new, arg_cnt);
if(FAILED(hres))
return hres;
hres = push_instr_uint(ctx, OP_pop, arg_cnt+1);
if(FAILED(hres))
return hres;
return push_instr(ctx, OP_push_ret) ? S_OK : E_OUTOFMEMORY;
}
static HRESULT compile_call_expression(compiler_ctx_t *ctx, call_expression_t *expr, BOOL emit_ret)

View File

@ -201,6 +201,11 @@ static inline jsval_t steal_ret(call_frame_t *frame)
return r;
}
static inline void clear_ret(call_frame_t *frame)
{
jsval_release(steal_ret(frame));
}
static void exprval_release(exprval_t *val)
{
switch(val->type) {
@ -941,8 +946,8 @@ static HRESULT interp_refval(script_ctx_t *ctx)
static HRESULT interp_new(script_ctx_t *ctx)
{
const unsigned argc = get_op_uint(ctx, 0);
jsval_t r, constr;
HRESULT hres;
call_frame_t *frame = ctx->call_ctx;
jsval_t constr;
TRACE("%d\n", argc);
@ -957,12 +962,9 @@ static HRESULT interp_new(script_ctx_t *ctx)
else if(!get_object(constr))
return throw_type_error(ctx, JS_E_INVALID_PROPERTY, NULL);
hres = disp_call_value(ctx, get_object(constr), NULL, DISPATCH_CONSTRUCT, argc, stack_args(ctx, argc), &r);
if(FAILED(hres))
return hres;
stack_popn(ctx, argc+1);
return stack_push(ctx, r);
clear_ret(frame);
return disp_call_value(ctx, get_object(constr), NULL, DISPATCH_CONSTRUCT,
argc, stack_args(ctx, argc), &frame->ret);
}
/* ECMA-262 3rd Edition 11.2.3 */
@ -2353,6 +2355,19 @@ static HRESULT interp_setret(script_ctx_t *ctx)
return S_OK;
}
static HRESULT interp_push_ret(script_ctx_t *ctx)
{
call_frame_t *frame = ctx->call_ctx;
HRESULT hres;
TRACE("\n");
hres = stack_push(ctx, frame->ret);
if(SUCCEEDED(hres))
frame->ret = jsval_undefined();
return hres;
}
typedef HRESULT (*op_func_t)(script_ctx_t*);
static const op_func_t op_funcs[] = {

View File

@ -70,6 +70,7 @@
X(postinc, 1, ARG_INT, 0) \
X(preinc, 1, ARG_INT, 0) \
X(push_except,1, ARG_ADDR, ARG_BSTR) \
X(push_ret, 1, 0,0) \
X(push_scope, 1, 0,0) \
X(regexp, 1, ARG_STR, ARG_UINT) \
X(rshift, 1, 0,0) \