Commit 3f20b8aa authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

jscript: Convert unlink_props to a helper that unlinks the entire object.

It will be useful for other cases, and we don't need the gc_ctx for unlinking. Also set the PROP_PROTREFs to PROP_DELETED since we're unliking the prototype. Signed-off-by: 's avatarGabriel Ivăncescu <gabrielopcode@gmail.com>
parent f66c8972
...@@ -665,14 +665,13 @@ static HRESULT fill_protrefs(jsdisp_t *This) ...@@ -665,14 +665,13 @@ static HRESULT fill_protrefs(jsdisp_t *This)
return S_OK; return S_OK;
} }
static void unlink_props(jsdisp_t *jsdisp) static void unlink_jsdisp(jsdisp_t *jsdisp)
{ {
dispex_prop_t *prop = jsdisp->props, *end; dispex_prop_t *prop = jsdisp->props, *end;
for(end = prop + jsdisp->prop_cnt; prop < end; prop++) { for(end = prop + jsdisp->prop_cnt; prop < end; prop++) {
switch(prop->type) { switch(prop->type) {
case PROP_DELETED: case PROP_DELETED:
case PROP_PROTREF:
continue; continue;
case PROP_JSVAL: case PROP_JSVAL:
jsval_release(prop->u.val); jsval_release(prop->u.val);
...@@ -688,6 +687,14 @@ static void unlink_props(jsdisp_t *jsdisp) ...@@ -688,6 +687,14 @@ static void unlink_props(jsdisp_t *jsdisp)
} }
prop->type = PROP_DELETED; prop->type = PROP_DELETED;
} }
if(jsdisp->prototype) {
jsdisp_release(jsdisp->prototype);
jsdisp->prototype = NULL;
}
if(jsdisp->builtin_info->gc_traverse)
jsdisp->builtin_info->gc_traverse(NULL, GC_TRAVERSE_UNLINK, jsdisp);
} }
...@@ -927,15 +934,7 @@ HRESULT gc_run(script_ctx_t *ctx) ...@@ -927,15 +934,7 @@ HRESULT gc_run(script_ctx_t *ctx)
/* Grab it since it gets removed when unlinked */ /* Grab it since it gets removed when unlinked */
jsdisp_addref(obj); jsdisp_addref(obj);
unlink_props(obj); unlink_jsdisp(obj);
if(obj->prototype) {
jsdisp_release(obj->prototype);
obj->prototype = NULL;
}
if(obj->builtin_info->gc_traverse)
obj->builtin_info->gc_traverse(&gc_ctx, GC_TRAVERSE_UNLINK, obj);
/* Releasing unlinked object should not delete any other object, /* Releasing unlinked object should not delete any other object,
so we can safely obtain the next pointer now */ so we can safely obtain the next pointer now */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment