While running in XCode's profiler, I noticed two memory leaks in `interp_redim_preserve`.
After looking at `interp_redim`, the `bounds` structure is freed.
I've updated `interp_redim_preserve` to free `bounds` when the array is NULL and not NULL.
--
v3: vbscript: Fix memory leak in interp_redim_preserve
https://gitlab.winehq.org/wine/wine/-/merge_requests/2132
Jinoh Kang (@iamahuman) commented about dlls/ntdll/rtl.c:
> + * the 32-bit addition above to handle.
> + *
> + * This produces an integer in the range [0x7fffffe2, 0xfffffffe].
> + */
> + result = 0x7fffffffu * 2 - result;
> +
> + /* Perform the 2nd round of the modulus calculation.
> + * This produces an integer in the range [0, 0x7fffffff].
> + */
> + result = (result & 0x7fffffffu) + (result >> 31);
> +
> + /* If result is 0x7fffffff, set it to 0. We avoid branching here so that
> + * RtlUniform runs in near-constant time. This also avoids unexpected
> + * performance hit due to polluted branch target buffer.
> + */
> + result &= -((0x7fffffffu * 2 - result) >> 31);
If we assume that the right shift operator is always defined as arithmetic shift, we can optimize it further:
```suggestion:-0+0
result &= (LONG)(0x7fffffffu * 2 - result) >> 31;
```
That said, GCC (https://godbolt.org/z/65od5ErMo) does this optimization already. Meanwhile clang (https://godbolt.org/z/46x8a8r9v) seems to recognize the trick and replace it with `inc + cmovns` (since `0x7fffffff + 1` is `0x80000000` which sets SF).
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/821#note_23433
QueryInterface should set *out to NULL on failure, as it seems to do in many different places.
This seems to be a regression from !888.
One old game started to crash on startup with this merge request.
I bisected it and it pointed to the commit 131ada052a2dbec66df695ce536ca048a2bd9174.
--
v2: wmvcore/tests: check out value in check_interface
https://gitlab.winehq.org/wine/wine/-/merge_requests/2130
While running in XCode's profiler, I noticed two memory leaks in `interp_redim_preserve`.
After looking at `interp_redim`, the `bounds` structure is freed.
I've updated `interp_redim_preserve` to free `bounds` when the array is NULL and not NULL.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/2132
QueryInterface should set *out to NULL on failure, as it seems to do in many different places.
This seems to be a regression from !888.
One old game started to crash on startup with this merge request.
I bisected it and it pointed to the commit 131ada052a2dbec66df695ce536ca048a2bd9174.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/2130
On Wed Feb 8 01:17:39 2023 +0000, Torge Matthies wrote:
> I can remove the second commit if desired, the first commit is enough to
> make performance acceptable again.
Also note that there are some more details about the commits in the commit message bodies.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/2114#note_23391