Jacek Caban : jscipt: Use passed copy of arguments if they are alread at the top of the stack.
Alexandre Julliard
julliard at winehq.org
Fri Jul 29 10:17:08 CDT 2016
Module: wine
Branch: master
Commit: b0dcbbdbee2bfa0d4d0fab1d6ff21cb04e5eb596
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b0dcbbdbee2bfa0d4d0fab1d6ff21cb04e5eb596
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Jul 28 18:44:57 2016 +0200
jscipt: Use passed copy of arguments if they are alread at the top of the stack.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/jscript/engine.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index acdeb85..2c44112 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -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)
{
+ const unsigned orig_stack = ctx->stack_top;
unsigned i;
jsval_t v;
HRESULT hres;
- frame->arguments_off = ctx->stack_top;
-
- for(i = 0; i < argc; i++) {
- hres = jsval_copy(argv[i], &v);
- if(SUCCEEDED(hres))
- hres = stack_push(ctx, v);
- if(FAILED(hres)) {
- stack_popn(ctx, i);
- return hres;
+ /* If arguments are already on the stack, we may use them. */
+ if(argv + argc == ctx->stack + ctx->stack_top) {
+ frame->arguments_off = argv - ctx->stack;
+ i = argc;
+ }else {
+ frame->arguments_off = ctx->stack_top;
+ for(i = 0; i < argc; i++) {
+ hres = jsval_copy(argv[i], &v);
+ 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++) {
hres = stack_push(ctx, jsval_undefined());
if(FAILED(hres)) {
- stack_popn(ctx, i);
+ stack_popn(ctx, ctx->stack_top - orig_stack);
return hres;
}
}
- frame->pop_locals = i;
+ frame->pop_locals = ctx->stack_top - orig_stack;
frame->base_scope->frame = frame;
return S_OK;
}
More information about the wine-cvs
mailing list