[PATCH v2 1/8] vbscript: Unlink the code list from the script dispatch when it's released.

Gabriel Ivăncescu gabrielopcode at gmail.com
Wed Oct 30 07:57:19 CDT 2019


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---

v2: Unlink persistent code from the list when it is released and only
re-execute after the script dispatch is released, not every time after the
script is paused.

This is mostly needed for the next patch to work properly, since some of
the code lists will have more limited lifespans (code that is not persistent).

These patches correct the implementation so that it passes the tests at
the end of the series.

Note that I haven't sent the linked list->array conversion yet, because
that is not a functional change, just an optimization, so it will come after
this behavior is corrected first (so some of it is just moved temporarily).

 dlls/vbscript/compile.c  | 3 +++
 dlls/vbscript/vbscript.c | 8 ++++++++
 dlls/vbscript/vbscript.h | 4 ++++
 3 files changed, 15 insertions(+)

diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index 0727979..417faf4 100644
--- a/dlls/vbscript/compile.c
+++ b/dlls/vbscript/compile.c
@@ -1960,6 +1960,7 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli
 
         var->next = script->global_vars;
         script->global_vars = ctx.global_vars;
+        code->last_global_var = var;
     }
 
     if(ctx.funcs) {
@@ -1967,6 +1968,7 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli
 
         new_func->next = script->global_funcs;
         script->global_funcs = ctx.funcs;
+        code->last_func = new_func;
     }
 
     if(ctx.classes) {
@@ -1981,6 +1983,7 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli
 
         class->next = script->classes;
         script->classes = ctx.classes;
+        code->last_class = class;
     }
 
     if(TRACE_ON(vbscript_disas))
diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c
index 56c53b4..cff2ef5 100644
--- a/dlls/vbscript/vbscript.c
+++ b/dlls/vbscript/vbscript.c
@@ -131,6 +131,7 @@ IDispatch *lookup_named_item(script_ctx_t *ctx, const WCHAR *name, unsigned flag
 static void release_script(script_ctx_t *ctx)
 {
     class_desc_t *class_desc;
+    vbscode_t *code;
 
     collect_objects(ctx);
     clear_ei(&ctx->ei);
@@ -178,6 +179,13 @@ static void release_script(script_ctx_t *ctx)
         IDispatchEx_Release(&script_obj->IDispatchEx_iface);
     }
 
+    LIST_FOR_EACH_ENTRY(code, &ctx->code_list, vbscode_t, entry)
+    {
+        if (code->last_global_var) code->last_global_var->next = NULL;
+        if (code->last_func) code->last_func->next = NULL;
+        if (code->last_class) code->last_class->next = NULL;
+    }
+
     detach_global_objects(ctx);
     heap_pool_free(&ctx->heap);
     heap_pool_init(&ctx->heap);
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index fefed63..cfc9f65 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -347,6 +347,10 @@ struct _vbscode_t {
     unsigned bstr_cnt;
     heap_pool_t heap;
 
+    dynamic_var_t *last_global_var;
+    function_t *last_func;
+    class_desc_t *last_class;
+
     struct list entry;
 };
 
-- 
2.21.0




More information about the wine-devel mailing list