Jacek Caban : jscript: Get rid of no longer needed exec_ctx_t.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Mar 28 09:12:35 CDT 2016


Module: wine
Branch: master
Commit: 32d9c59868423570a2b0d2aaef31fb6e6ba30fc6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=32d9c59868423570a2b0d2aaef31fb6e6ba30fc6

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Mar 25 17:50:16 2016 +0100

jscript: Get rid of no longer needed exec_ctx_t.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/jscript/engine.c   | 53 +++++++++++--------------------------------------
 dlls/jscript/engine.h   | 16 +--------------
 dlls/jscript/function.c | 16 +++++----------
 dlls/jscript/global.c   |  2 +-
 dlls/jscript/jscript.c  | 33 ++++++++++--------------------
 dlls/jscript/jscript.h  |  1 -
 6 files changed, 29 insertions(+), 92 deletions(-)

diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 27c8ad7..f6ade36 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -295,33 +295,6 @@ void scope_release(scope_chain_t *scope)
     heap_free(scope);
 }
 
-HRESULT create_exec_ctx(script_ctx_t *script_ctx, exec_ctx_t **ret)
-{
-    exec_ctx_t *ctx;
-
-    ctx = heap_alloc_zero(sizeof(exec_ctx_t));
-    if(!ctx)
-        return E_OUTOFMEMORY;
-
-    ctx->ref = 1;
-
-    script_addref(script_ctx);
-    ctx->script = script_ctx;
-
-    *ret = ctx;
-    return S_OK;
-}
-
-void exec_release(exec_ctx_t *ctx)
-{
-    if(--ctx->ref)
-        return;
-
-    if(ctx->script)
-        script_release(ctx->script);
-    heap_free(ctx);
-}
-
 static HRESULT disp_get_id(script_ctx_t *ctx, IDispatch *disp, const WCHAR *name, BSTR name_bstr, DWORD flags, DISPID *id)
 {
     IDispatchEx *dispex;
@@ -2530,7 +2503,7 @@ static HRESULT bind_event_target(script_ctx_t *ctx, function_code_t *func, jsdis
     return hres;
 }
 
-static HRESULT setup_call_frame(exec_ctx_t *ctx, bytecode_t *bytecode, function_code_t *function, scope_chain_t *scope,
+static HRESULT setup_call_frame(script_ctx_t *ctx, bytecode_t *bytecode, function_code_t *function, scope_chain_t *scope,
         IDispatch *this_obj, BOOL is_global, jsdisp_t *variable_obj)
 {
     call_frame_t *frame;
@@ -2554,7 +2527,7 @@ static HRESULT setup_call_frame(exec_ctx_t *ctx, bytecode_t *bytecode, function_
     frame->bytecode = bytecode;
     frame->function = function;
     frame->ip = function->instr_off;
-    frame->stack_base = ctx->script->stack_top;
+    frame->stack_base = ctx->stack_top;
     frame->ret = jsval_undefined();
 
     if(scope)
@@ -2562,23 +2535,21 @@ static HRESULT setup_call_frame(exec_ctx_t *ctx, bytecode_t *bytecode, function_
 
     if(this_obj)
         frame->this_obj = this_obj;
-    else if(ctx->script->host_global)
-        frame->this_obj = ctx->script->host_global;
+    else if(ctx->host_global)
+        frame->this_obj = ctx->host_global;
     else
-        frame->this_obj = to_disp(ctx->script->global);
+        frame->this_obj = to_disp(ctx->global);
     IDispatch_AddRef(frame->this_obj);
 
     frame->is_global = is_global;
     frame->variable_obj = jsdisp_addref(variable_obj);
 
-    frame->exec_ctx = ctx;
-
-    frame->prev_frame = ctx->script->call_ctx;
-    ctx->script->call_ctx = frame;
+    frame->prev_frame = ctx->call_ctx;
+    ctx->call_ctx = frame;
     return S_OK;
 }
 
-HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, scope_chain_t *scope,
+HRESULT exec_source(script_ctx_t *ctx, bytecode_t *code, function_code_t *func, scope_chain_t *scope,
         IDispatch *this_obj, BOOL is_global, jsdisp_t *variable_obj, jsval_t *ret)
 {
     jsval_t val;
@@ -2591,12 +2562,12 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, sc
         if(!func->funcs[i].name)
             continue;
 
-        hres = create_source_function(ctx->script, code, func->funcs+i, scope, &func_obj);
+        hres = create_source_function(ctx, code, func->funcs+i, scope, &func_obj);
         if(FAILED(hres))
             return hres;
 
         if(func->funcs[i].event_target)
-            hres = bind_event_target(ctx->script, func->funcs+i, func_obj);
+            hres = bind_event_target(ctx, func->funcs+i, func_obj);
         else
             hres = jsdisp_propput_name(variable_obj, func->funcs[i].name, jsval_obj(func_obj));
         jsdisp_release(func_obj);
@@ -2605,7 +2576,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, sc
     }
 
     for(i=0; i < func->var_cnt; i++) {
-        if(!is_global || !lookup_global_members(ctx->script, func->variables[i], NULL)) {
+        if(!is_global || !lookup_global_members(ctx, func->variables[i], NULL)) {
             DISPID id = 0;
 
             hres = jsdisp_get_id(variable_obj, func->variables[i], fdexNameEnsure, &id);
@@ -2618,7 +2589,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, sc
     if(FAILED(hres))
         return hres;
 
-    hres = enter_bytecode(ctx->script, func, &val);
+    hres = enter_bytecode(ctx, func, &val);
     if(FAILED(hres))
         return hres;
 
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index b7bb1d2..3af3eac 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -208,21 +208,7 @@ typedef struct _call_frame_t {
     function_code_t *function;
 
     struct _call_frame_t *prev_frame;
-    exec_ctx_t *exec_ctx;
 } call_frame_t;
 
-struct _exec_ctx_t {
-    LONG ref;
-
-    script_ctx_t *script;
-};
-
-static inline void exec_addref(exec_ctx_t *ctx)
-{
-    ctx->ref++;
-}
-
-void exec_release(exec_ctx_t*) DECLSPEC_HIDDEN;
-HRESULT create_exec_ctx(script_ctx_t*,exec_ctx_t**) DECLSPEC_HIDDEN;
-HRESULT exec_source(exec_ctx_t*,bytecode_t*,function_code_t*,scope_chain_t*,IDispatch*,BOOL,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
+HRESULT exec_source(script_ctx_t*,bytecode_t*,function_code_t*,scope_chain_t*,IDispatch*,BOOL,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 84ef469..0a531a5 100644
--- a/dlls/jscript/function.c
+++ b/dlls/jscript/function.c
@@ -206,7 +206,6 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis
         jsval_t *r)
 {
     jsdisp_t *var_disp, *arg_disp;
-    exec_ctx_t *exec_ctx;
     scope_chain_t *scope;
     HRESULT hres;
 
@@ -239,17 +238,12 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis
 
     hres = scope_push(function->scope_chain, var_disp, to_disp(var_disp), &scope);
     if(SUCCEEDED(hres)) {
-        hres = create_exec_ctx(ctx, &exec_ctx);
-        if(SUCCEEDED(hres)) {
-            jsdisp_t *prev_args;
+        jsdisp_t *prev_args;
 
-            prev_args = function->arguments;
-            function->arguments = arg_disp;
-            hres = exec_source(exec_ctx, function->code, function->func_code, scope, this_obj, FALSE, var_disp, r);
-            function->arguments = prev_args;
-
-            exec_release(exec_ctx);
-        }
+        prev_args = function->arguments;
+        function->arguments = arg_disp;
+        hres = exec_source(ctx, function->code, function->func_code, scope, this_obj, FALSE, var_disp, r);
+        function->arguments = prev_args;
 
         scope_release(scope);
     }
diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c
index 3249a02..60a7332 100644
--- a/dlls/jscript/global.c
+++ b/dlls/jscript/global.c
@@ -223,7 +223,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
         return throw_syntax_error(ctx, hres, NULL);
     }
 
-    hres = exec_source(ctx->call_ctx->exec_ctx, code, &code->global_code, frame->scope,
+    hres = exec_source(ctx, code, &code->global_code, frame->scope,
             frame->this_obj, frame->is_global, frame->variable_obj, r);
     release_bytecode(code);
     return hres;
diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c
index 2a85dd4..ef176db 100644
--- a/dlls/jscript/jscript.c
+++ b/dlls/jscript/jscript.c
@@ -102,18 +102,12 @@ static inline BOOL is_started(script_ctx_t *ctx)
 
 static HRESULT exec_global_code(JScript *This, bytecode_t *code)
 {
-    exec_ctx_t *exec_ctx;
     HRESULT hres;
 
-    hres = create_exec_ctx(This->ctx, &exec_ctx);
-    if(FAILED(hres))
-        return hres;
-
     IActiveScriptSite_OnEnterScript(This->site);
 
     clear_ei(This->ctx);
-    hres = exec_source(exec_ctx, code, &code->global_code, NULL, NULL, TRUE, This->ctx->global, NULL);
-    exec_release(exec_ctx);
+    hres = exec_source(This->ctx, code, &code->global_code, NULL, NULL, TRUE, This->ctx->global, NULL);
 
     IActiveScriptSite_OnLeaveScript(This->site);
     return hres;
@@ -774,26 +768,19 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
         return hres;
 
     if(dwFlags & SCRIPTTEXT_ISEXPRESSION) {
-        exec_ctx_t *exec_ctx;
-
-        hres = create_exec_ctx(This->ctx, &exec_ctx);
-        if(SUCCEEDED(hres)) {
-            jsval_t r;
-
-            IActiveScriptSite_OnEnterScript(This->site);
+        jsval_t r;
 
-            clear_ei(This->ctx);
-            hres = exec_source(exec_ctx, code, &code->global_code, NULL, NULL, TRUE, This->ctx->global, &r);
-            if(SUCCEEDED(hres)) {
-                if(pvarResult)
-                    hres = jsval_to_variant(r, pvarResult);
-                jsval_release(r);
-            }
-            exec_release(exec_ctx);
+        IActiveScriptSite_OnEnterScript(This->site);
 
-            IActiveScriptSite_OnLeaveScript(This->site);
+        clear_ei(This->ctx);
+        hres = exec_source(This->ctx, code, &code->global_code, NULL, NULL, TRUE, This->ctx->global, &r);
+        if(SUCCEEDED(hres)) {
+            if(pvarResult)
+                hres = jsval_to_variant(r, pvarResult);
+            jsval_release(r);
         }
 
+        IActiveScriptSite_OnLeaveScript(This->site);
         return hres;
     }
 
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h
index 1c7303e..53272c9 100644
--- a/dlls/jscript/jscript.h
+++ b/dlls/jscript/jscript.h
@@ -36,7 +36,6 @@
 typedef struct _jsval_t jsval_t;
 typedef struct _jsstr_t jsstr_t;
 typedef struct _script_ctx_t script_ctx_t;
-typedef struct _exec_ctx_t exec_ctx_t;
 typedef struct _dispex_prop_t dispex_prop_t;
 
 typedef struct {




More information about the wine-cvs mailing list