Module: wine Branch: master Commit: 42e90ca5925324815958a430324faa2d47eb2f4e URL: http://source.winehq.org/git/wine.git/?a=commit;h=42e90ca5925324815958a43032...
Author: Jacek Caban jacek@codeweavers.com Date: Mon Mar 28 17:50:59 2016 +0200
jscript: Moved arguments object destuction to interpreter.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/jscript/engine.c | 12 +++++++++++- dlls/jscript/engine.h | 4 +++- dlls/jscript/function.c | 6 +----- dlls/jscript/global.c | 2 +- dlls/jscript/jscript.c | 4 ++-- 5 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 4616853..5a4d76f 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -2381,6 +2381,13 @@ OP_LIST
static void release_call_frame(call_frame_t *frame) { + if(frame->arguments_obj) { + /* Reset arguments value to cut the reference cycle. Note that since all activation contexts have + * their own arguments property, it's impossible to use prototype's one during name lookup */ + static const WCHAR argumentsW[] = {'a','r','g','u','m','e','n','t','s',0}; + jsdisp_propput_name(frame->variable_obj, argumentsW, jsval_undefined()); + jsdisp_release(frame->arguments_obj); + } if(frame->variable_obj) jsdisp_release(frame->variable_obj); if(frame->this_obj) @@ -2529,7 +2536,7 @@ static HRESULT bind_event_target(script_ctx_t *ctx, function_code_t *func, jsdis }
HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, function_code_t *function, scope_chain_t *scope, - IDispatch *this_obj, jsdisp_t *variable_obj, jsval_t *r) + IDispatch *this_obj, jsdisp_t *variable_obj, jsdisp_t *arguments_obj, jsval_t *r) { call_frame_t *frame; unsigned i; @@ -2597,6 +2604,9 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi frame->this_obj = to_disp(ctx->global); IDispatch_AddRef(frame->this_obj);
+ if(arguments_obj) + frame->arguments_obj = jsdisp_addref(arguments_obj); + frame->flags = flags; frame->variable_obj = jsdisp_addref(variable_obj);
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index 4b3bba2..e500ba4 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -204,6 +204,7 @@ typedef struct _call_frame_t {
IDispatch *this_obj; jsdisp_t *variable_obj; + jsdisp_t *arguments_obj; DWORD flags;
bytecode_t *bytecode; @@ -215,5 +216,6 @@ typedef struct _call_frame_t { #define EXEC_GLOBAL 0x0001 #define EXEC_CONSTRUCTOR 0x0002
-HRESULT exec_source(script_ctx_t*,DWORD,bytecode_t*,function_code_t*,scope_chain_t*,IDispatch*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN; +HRESULT exec_source(script_ctx_t*,DWORD,bytecode_t*,function_code_t*,scope_chain_t*,IDispatch*, + jsdisp_t*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN; HRESULT create_source_function(script_ctx_t*,bytecode_t*,function_code_t*,scope_chain_t*,jsdisp_t**) DECLSPEC_HIDDEN; diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index bd85fda..be1f29c 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -245,16 +245,12 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis exec_flags |= EXEC_CONSTRUCTOR; prev_args = function->arguments; function->arguments = arg_disp; - hres = exec_source(ctx, exec_flags, function->code, function->func_code, scope, this_obj, var_disp, r); + hres = exec_source(ctx, exec_flags, function->code, function->func_code, scope, this_obj, var_disp, arg_disp, r); function->arguments = prev_args;
scope_release(scope); }
- /* Reset arguments value to cut the reference cycle. Note that since all activation contexts have - * their own arguments property, it's impossible to use prototype's one during name lookup */ - jsdisp_propput_name(var_disp, argumentsW, jsval_undefined()); - jsdisp_release(arg_disp); jsdisp_release(var_disp); return hres; diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c index 33d1f3c..24ec358 100644 --- a/dlls/jscript/global.c +++ b/dlls/jscript/global.c @@ -227,7 +227,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns if(frame->flags & EXEC_GLOBAL) exec_flags |= EXEC_GLOBAL; hres = exec_source(ctx, exec_flags, code, &code->global_code, frame->scope, - frame->this_obj, frame->variable_obj, r); + frame->this_obj, frame->variable_obj, NULL, r); release_bytecode(code); return hres; } diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c index eb336fc..61fa400 100644 --- a/dlls/jscript/jscript.c +++ b/dlls/jscript/jscript.c @@ -107,7 +107,7 @@ static HRESULT exec_global_code(JScript *This, bytecode_t *code) IActiveScriptSite_OnEnterScript(This->site);
clear_ei(This->ctx); - hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, This->ctx->global, NULL); + hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, This->ctx->global, NULL, NULL);
IActiveScriptSite_OnLeaveScript(This->site); return hres; @@ -773,7 +773,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface, IActiveScriptSite_OnEnterScript(This->site);
clear_ei(This->ctx); - hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, This->ctx->global, &r); + hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, This->ctx->global, NULL, &r); if(SUCCEEDED(hres)) { if(pvarResult) hres = jsval_to_variant(r, pvarResult);