jscipt: Use passed copy of arguments if they are alread at the top of the stack.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5e4d3826ec
commit
b0dcbbdbee
|
@ -2591,19 +2591,25 @@ static HRESULT bind_event_target(script_ctx_t *ctx, function_code_t *func, jsdis
|
||||||
|
|
||||||
static HRESULT setup_scope(script_ctx_t *ctx, call_frame_t *frame, unsigned argc, jsval_t *argv)
|
static HRESULT setup_scope(script_ctx_t *ctx, call_frame_t *frame, unsigned argc, jsval_t *argv)
|
||||||
{
|
{
|
||||||
|
const unsigned orig_stack = ctx->stack_top;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
jsval_t v;
|
jsval_t v;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
frame->arguments_off = ctx->stack_top;
|
/* If arguments are already on the stack, we may use them. */
|
||||||
|
if(argv + argc == ctx->stack + ctx->stack_top) {
|
||||||
for(i = 0; i < argc; i++) {
|
frame->arguments_off = argv - ctx->stack;
|
||||||
hres = jsval_copy(argv[i], &v);
|
i = argc;
|
||||||
if(SUCCEEDED(hres))
|
}else {
|
||||||
hres = stack_push(ctx, v);
|
frame->arguments_off = ctx->stack_top;
|
||||||
if(FAILED(hres)) {
|
for(i = 0; i < argc; i++) {
|
||||||
stack_popn(ctx, i);
|
hres = jsval_copy(argv[i], &v);
|
||||||
return hres;
|
if(SUCCEEDED(hres))
|
||||||
|
hres = stack_push(ctx, v);
|
||||||
|
if(FAILED(hres)) {
|
||||||
|
stack_popn(ctx, i);
|
||||||
|
return hres;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2611,12 +2617,12 @@ static HRESULT setup_scope(script_ctx_t *ctx, call_frame_t *frame, unsigned argc
|
||||||
for(; i < frame->function->param_cnt; i++) {
|
for(; i < frame->function->param_cnt; i++) {
|
||||||
hres = stack_push(ctx, jsval_undefined());
|
hres = stack_push(ctx, jsval_undefined());
|
||||||
if(FAILED(hres)) {
|
if(FAILED(hres)) {
|
||||||
stack_popn(ctx, i);
|
stack_popn(ctx, ctx->stack_top - orig_stack);
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->pop_locals = i;
|
frame->pop_locals = ctx->stack_top - orig_stack;
|
||||||
frame->base_scope->frame = frame;
|
frame->base_scope->frame = frame;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue