Module: wine Branch: master Commit: 9daafa87bc94364d9401b40286d2104c9b4ad29e URL: http://source.winehq.org/git/wine.git/?a=commit;h=9daafa87bc94364d9401b40286...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Aug 3 16:27:49 2016 +0200
jscript: Access arguments directly from stack in arguments object if possible.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/jscript/engine.c | 2 +- dlls/jscript/engine.h | 2 -- dlls/jscript/function.c | 33 ++++++++++++++++++++++----------- 3 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 187a8b7..2c6a9a3 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -545,7 +545,7 @@ static HRESULT equal2_values(jsval_t lval, jsval_t rval, BOOL *ret) * Transfers local variables from stack to variable object. * It's slow, so we want to avoid it as much as possible. */ -HRESULT detach_variable_object(script_ctx_t *ctx, call_frame_t *frame) +static HRESULT detach_variable_object(script_ctx_t *ctx, call_frame_t *frame) { unsigned i; HRESULT hres; diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index 1aebfd7..89a09fa 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -226,8 +226,6 @@ typedef struct _call_frame_t { struct _call_frame_t *prev_frame; } call_frame_t;
-HRESULT detach_variable_object(script_ctx_t*,call_frame_t*) DECLSPEC_HIDDEN; - #define EXEC_GLOBAL 0x0001 #define EXEC_CONSTRUCTOR 0x0002 #define EXEC_RETURN_TO_INTERP 0x0004 diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 006ec39..191976d 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -89,34 +89,45 @@ static unsigned Arguments_idx_length(jsdisp_t *jsdisp) return arguments->function->length; }
-static HRESULT Arguments_idx_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *res) +static jsval_t *get_argument_ref(ArgumentsInstance *arguments, unsigned idx) +{ + call_frame_t *frame = arguments->scope->frame; + return frame + ? arguments->jsdisp.ctx->stack + frame->arguments_off + idx + : NULL; +} + +static HRESULT Arguments_idx_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *r) { ArgumentsInstance *arguments = (ArgumentsInstance*)jsdisp; + jsval_t *ref;
TRACE("%p[%u]\n", arguments, idx);
- if(arguments->scope->frame) { - HRESULT hres; - hres = detach_variable_object(jsdisp->ctx, arguments->scope->frame); - if(FAILED(hres)) - return hres; - } + if((ref = get_argument_ref(arguments, idx))) + return jsval_copy(*ref, r);
/* FIXME: Accessing by name won't work for duplicated argument names */ - return jsdisp_propget_name(arguments->scope->jsobj, arguments->function->func_code->params[idx], res); + return jsdisp_propget_name(arguments->scope->jsobj, arguments->function->func_code->params[idx], r); }
static HRESULT Arguments_idx_put(jsdisp_t *jsdisp, unsigned idx, jsval_t val) { ArgumentsInstance *arguments = (ArgumentsInstance*)jsdisp; + jsval_t *ref; + HRESULT hres;
TRACE("%p[%u] = %s\n", arguments, idx, debugstr_jsval(val));
- if(arguments->scope->frame) { - HRESULT hres; - hres = detach_variable_object(jsdisp->ctx, arguments->scope->frame); + if((ref = get_argument_ref(arguments, idx))) { + jsval_t copy; + hres = jsval_copy(val, ©); if(FAILED(hres)) return hres; + + jsval_release(*ref); + *ref = copy; + return S_OK; }
/* FIXME: Accessing by name won't work for duplicated argument names */