Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
79a30a4e
Commit
79a30a4e
authored
Oct 26, 2012
by
Jacek Caban
Committed by
Alexandre Julliard
Oct 26, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Optimize object refcount handling.
parent
90c6f57f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
31 deletions
+68
-31
dispex.c
dlls/jscript/dispex.c
+49
-29
jscript.h
dlls/jscript/jscript.h
+19
-2
No files found.
dlls/jscript/dispex.c
View file @
79a30a4e
...
...
@@ -543,46 +543,23 @@ static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid,
return
E_NOINTERFACE
;
}
IUnknown_AddRef
((
IUnknown
*
)
*
ppv
);
jsdisp_addref
(
This
);
return
S_OK
;
}
static
ULONG
WINAPI
DispatchEx_AddRef
(
IDispatchEx
*
iface
)
{
jsdisp_t
*
This
=
impl_from_IDispatchEx
(
iface
);
LONG
ref
=
InterlockedIncrement
(
&
This
->
ref
);
TRACE
(
"(%p) ref=%d
\n
"
,
This
,
ref
);
return
ref
;
jsdisp_addref
(
This
);
return
This
->
ref
;
}
static
ULONG
WINAPI
DispatchEx_Release
(
IDispatchEx
*
iface
)
{
jsdisp_t
*
This
=
impl_from_IDispatchEx
(
iface
);
LONG
ref
=
InterlockedDecrement
(
&
This
->
ref
);
TRACE
(
"(%p) ref=%d
\n
"
,
This
,
ref
);
if
(
!
ref
)
{
dispex_prop_t
*
prop
;
for
(
prop
=
This
->
props
;
prop
<
This
->
props
+
This
->
prop_cnt
;
prop
++
)
{
if
(
prop
->
type
==
PROP_JSVAL
)
jsval_release
(
prop
->
u
.
val
);
heap_free
(
prop
->
name
);
}
heap_free
(
This
->
props
);
script_release
(
This
->
ctx
);
if
(
This
->
prototype
)
jsdisp_release
(
This
->
prototype
);
if
(
This
->
builtin_info
->
destructor
)
This
->
builtin_info
->
destructor
(
This
);
else
heap_free
(
This
);
}
ULONG
ref
=
--
This
->
ref
;
if
(
!
ref
)
jsdisp_free
(
This
);
return
ref
;
}
...
...
@@ -931,6 +908,49 @@ HRESULT create_dispex(script_ctx_t *ctx, const builtin_info_t *builtin_info, jsd
return
S_OK
;
}
void
jsdisp_free
(
jsdisp_t
*
obj
)
{
dispex_prop_t
*
prop
;
TRACE
(
"(%p)
\n
"
,
obj
);
for
(
prop
=
obj
->
props
;
prop
<
obj
->
props
+
obj
->
prop_cnt
;
prop
++
)
{
if
(
prop
->
type
==
PROP_JSVAL
)
jsval_release
(
prop
->
u
.
val
);
heap_free
(
prop
->
name
);
}
heap_free
(
obj
->
props
);
script_release
(
obj
->
ctx
);
if
(
obj
->
prototype
)
jsdisp_release
(
obj
->
prototype
);
if
(
obj
->
builtin_info
->
destructor
)
obj
->
builtin_info
->
destructor
(
obj
);
else
heap_free
(
obj
);
}
#ifdef TRACE_REFCNT
jsdisp_t
*
jsdisp_addref
(
jsdisp_t
*
jsdisp
)
{
ULONG
ref
=
++
jsdisp
->
ref
;
TRACE
(
"(%p) ref=%d
\n
"
,
jsdisp
,
ref
);
return
jsdisp
;
}
void
jsdisp_release
(
jsdisp_t
*
jsdisp
)
{
ULONG
ref
=
--
jsdisp
->
ref
;
TRACE
(
"(%p) ref=%d
\n
"
,
jsdisp
,
ref
);
if
(
!
ref
)
jsdisp_free
(
jsdisp
);
}
#endif
HRESULT
init_dispex_from_constr
(
jsdisp_t
*
dispex
,
script_ctx_t
*
ctx
,
const
builtin_info_t
*
builtin_info
,
jsdisp_t
*
constr
)
{
jsdisp_t
*
prot
=
NULL
;
...
...
dlls/jscript/jscript.h
View file @
79a30a4e
...
...
@@ -223,18 +223,35 @@ static inline IDispatch *to_disp(jsdisp_t *jsdisp)
jsdisp_t
*
as_jsdisp
(
IDispatch
*
)
DECLSPEC_HIDDEN
;
jsdisp_t
*
to_jsdisp
(
IDispatch
*
)
DECLSPEC_HIDDEN
;
void
jsdisp_free
(
jsdisp_t
*
)
DECLSPEC_HIDDEN
;
#ifndef TRACE_REFCNT
/*
* We do a lot of refcount calls during script execution, so having an inline
* version is a nice perf win. Define TRACE_REFCNT macro when debugging
* refcount bugs to have traces. Also, since jsdisp_t is not thread safe anyways,
* there is no point in using atomic operations.
*/
static
inline
jsdisp_t
*
jsdisp_addref
(
jsdisp_t
*
jsdisp
)
{
IDispatchEx_AddRef
(
&
jsdisp
->
IDispatchEx_iface
)
;
jsdisp
->
ref
++
;
return
jsdisp
;
}
static
inline
void
jsdisp_release
(
jsdisp_t
*
jsdisp
)
{
IDispatchEx_Release
(
&
jsdisp
->
IDispatchEx_iface
);
if
(
!--
jsdisp
->
ref
)
jsdisp_free
(
jsdisp
);
}
#else
jsdisp_t
*
jsdisp_addref
(
jsdisp_t
*
)
DECLSPEC_HIDDEN
;
void
jsdisp_release
(
jsdisp_t
*
)
DECLSPEC_HIDDEN
;
#endif
HRESULT
create_dispex
(
script_ctx_t
*
,
const
builtin_info_t
*
,
jsdisp_t
*
,
jsdisp_t
**
)
DECLSPEC_HIDDEN
;
HRESULT
init_dispex
(
jsdisp_t
*
,
script_ctx_t
*
,
const
builtin_info_t
*
,
jsdisp_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
init_dispex_from_constr
(
jsdisp_t
*
,
script_ctx_t
*
,
const
builtin_info_t
*
,
jsdisp_t
*
)
DECLSPEC_HIDDEN
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment