Skip to content

Conversation

@richardleach
Copy link
Contributor

This PR includes 2 commits:

  • Removal of a branch that appears to be a no-op.
  • Changing xpvav & xpvhv initialization from Zero() followed by struct member overwrites, to using compound literals.

xav_alloc is a member of the xpvav struct. The instance modified
here would have been Zero()ed several lines previously, so both
sides of this if() branch should be no-ops.

With gcc 8.3.0 the compiled function is about 6 instructions smaller.
@richardleach
Copy link
Contributor Author

The one concern I have is whether or not it's really portable & safe to initialize the xmg_u union like this?

@richardleach richardleach requested a review from tonycoz December 10, 2021 00:49
@tonycoz
Copy link
Contributor

tonycoz commented Dec 12, 2021

The one concern I have is whether or not it's really portable & safe to initialize the xmg_u union like this?

It does seem a bit strange to mix designated and non-designated initialization, but it is well defined in C99 and C11.

Designating xmg_u might be clearer though:

-                .xmg_stash = NULL, {.xmg_magic = NULL}, .xav_fill = -1,
+                .xmg_stash = NULL, .xmg_u = {.xmg_magic = NULL}, .xav_fill = -1,

and works for me.

For both the AV and HV cases, the new body is Zero()ed but then various
struct members are set to non-zero values. Now that we support parts of
c99, it seems more efficient to use compound literals to initailize the
struct members.

With gcc v8.3.0, the compiled function is smaller by 25 instructions.
sv.o is slightly smaller, but the final perl binary size is unchanged.
@richardleach richardleach force-pushed the hydahy/sv_upgrade-compoundliteral branch from d5cf193 to 35ed640 Compare December 13, 2021 20:14
@richardleach
Copy link
Contributor Author

Thanks, I've done that, rebased and pushed.

@khwilliamson khwilliamson merged commit 0d63558 into Perl:blead Dec 24, 2021
@richardleach richardleach deleted the hydahy/sv_upgrade-compoundliteral branch December 24, 2021 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants