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>
This commit is contained in:
Jacek Caban 2016-08-03 16:27:49 +02:00 committed by Alexandre Julliard
parent b652a9787c
commit 9daafa87bc
3 changed files with 23 additions and 14 deletions

View file

@ -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;

View file

@ -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

View file

@ -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, &copy);
if(FAILED(hres))
return hres;
jsval_release(*ref);
*ref = copy;
return S_OK;
}
/* FIXME: Accessing by name won't work for duplicated argument names */