Skip to content

Commit 84b6ffe

Browse files
committed
scope_types.h dont include a const static char arr [59]; in every TU
This array is 59 bytes long, and is rounded to 64 bytes of .rdata storage. While all commercial/big FOSS CCs will correctly discard this unreferenced array during link phase (.o/.obj -> .exe/.dll). There is no reason for every TU/.o file to have this 64 byte array sitting in it. This was caused by a mistake in the initial commit of scope_types.h, when this array was moved out of scope.c to a .h. commit 721bab5 - Yves Orton - 10/31/2022 6:37:27 AM scope_types.h - new header file for scope type data Next patch this data will be autogenerated. To fix this, I choose instead of feature switching it behind a very narrow and "not for CPAN" #ifdef PERL_IN_SCOPE_C I decided for flexibility if B::Foo or Devel::Foo on CPAN in the future wants this array they can ask for it with #define WANT_LEAVE_SCOPE_ARG_COUNTS also reduce white space for a tiny bit faster compile times (theoretical).
1 parent 69b5e8a commit 84b6ffe

File tree

3 files changed

+65
-60
lines changed

3 files changed

+65
-60
lines changed

regen/scope_types.pl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,21 @@ BEGIN
7272

7373
$c_code .= <<EOF_C;
7474
75+
#ifdef WANT_LEAVE_SCOPE_ARG_COUNTS
7576
static const U8 leave_scope_arg_counts[] = {
7677
EOF_C
7778

7879
foreach my $tuple (@arg_num) {
7980
my ($nargs, $type)= @$tuple;
80-
$c_code .= sprintf " %d%s /* %*s */\n",
81+
$c_code .= sprintf " %d%s /* %*s */\n",
8182
$nargs, $tuple == $arg_num[-1] ? " " : ",",
8283
-$tlen, $type;
8384
}
8485
my $max_savet= $#arg_num;
8586

8687
$c_code .= <<EOF_C;
8788
};
89+
#endif
8890
8991
#define MAX_SAVEt $max_savet
9092
EOF_C

scope.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "EXTERN.h"
2626
#define PERL_IN_SCOPE_C
27+
#define WANT_LEAVE_SCOPE_ARG_COUNTS
2728
#include "perl.h"
2829
#include "feature.h"
2930

scope_types.h

Lines changed: 61 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -84,67 +84,69 @@
8484
#define SAVEt_DELETE 57
8585
#define SAVEt_HINTS_HH 58
8686

87+
#ifdef WANT_LEAVE_SCOPE_ARG_COUNTS
8788
static const U8 leave_scope_arg_counts[] = {
88-
0, /* SAVEt_ALLOC */
89-
0, /* SAVEt_CLEARPADRANGE */
90-
0, /* SAVEt_CLEARSV */
91-
0, /* SAVEt_REGCONTEXT */
92-
1, /* SAVEt_TMPSFLOOR */
93-
1, /* SAVEt_BOOL */
94-
1, /* SAVEt_COMPILE_WARNINGS */
95-
1, /* SAVEt_CURCOP_WARNINGS */
96-
1, /* SAVEt_COMPPAD */
97-
1, /* SAVEt_FREECOPHH */
98-
1, /* SAVEt_FREEOP */
99-
1, /* SAVEt_FREEPV */
100-
1, /* SAVEt_FREESV */
101-
1, /* SAVEt_I16 */
102-
1, /* SAVEt_I32_SMALL */
103-
1, /* SAVEt_I8 */
104-
1, /* SAVEt_INT_SMALL */
105-
1, /* SAVEt_MORTALIZESV */
106-
1, /* SAVEt_NSTAB */
107-
1, /* SAVEt_OP */
108-
1, /* SAVEt_PARSER */
109-
1, /* SAVEt_STACK_POS */
110-
1, /* SAVEt_READONLY_OFF */
111-
1, /* SAVEt_FREEPADNAME */
112-
1, /* SAVEt_STRLEN_SMALL */
113-
1, /* SAVEt_FREERCPV */
114-
1, /* SAVEt_FREE_REXC_STATE */
115-
2, /* SAVEt_AV */
116-
2, /* SAVEt_DESTRUCTOR */
117-
2, /* SAVEt_DESTRUCTOR_X */
118-
2, /* SAVEt_GENERIC_PVREF */
119-
2, /* SAVEt_GENERIC_SVREF */
120-
2, /* SAVEt_GP */
121-
2, /* SAVEt_GVSV */
122-
2, /* SAVEt_HINTS */
123-
2, /* SAVEt_HPTR */
124-
2, /* SAVEt_HV */
125-
2, /* SAVEt_I32 */
126-
2, /* SAVEt_INT */
127-
2, /* SAVEt_ITEM */
128-
2, /* SAVEt_IV */
129-
2, /* SAVEt_PPTR */
130-
2, /* SAVEt_SAVESWITCHSTACK */
131-
2, /* SAVEt_SHARED_PVREF */
132-
2, /* SAVEt_SPTR */
133-
2, /* SAVEt_STRLEN */
134-
2, /* SAVEt_SV */
135-
2, /* SAVEt_SVREF */
136-
2, /* SAVEt_VPTR */
137-
2, /* SAVEt_ADELETE */
138-
2, /* SAVEt_APTR */
139-
2, /* SAVEt_RCPV */
140-
3, /* SAVEt_HELEM */
141-
3, /* SAVEt_PADSV_AND_MORTALIZE */
142-
3, /* SAVEt_SET_SVFLAGS */
143-
3, /* SAVEt_GVSLOT */
144-
3, /* SAVEt_AELEM */
145-
3, /* SAVEt_DELETE */
146-
3 /* SAVEt_HINTS_HH */
89+
0, /* SAVEt_ALLOC */
90+
0, /* SAVEt_CLEARPADRANGE */
91+
0, /* SAVEt_CLEARSV */
92+
0, /* SAVEt_REGCONTEXT */
93+
1, /* SAVEt_TMPSFLOOR */
94+
1, /* SAVEt_BOOL */
95+
1, /* SAVEt_COMPILE_WARNINGS */
96+
1, /* SAVEt_CURCOP_WARNINGS */
97+
1, /* SAVEt_COMPPAD */
98+
1, /* SAVEt_FREECOPHH */
99+
1, /* SAVEt_FREEOP */
100+
1, /* SAVEt_FREEPV */
101+
1, /* SAVEt_FREESV */
102+
1, /* SAVEt_I16 */
103+
1, /* SAVEt_I32_SMALL */
104+
1, /* SAVEt_I8 */
105+
1, /* SAVEt_INT_SMALL */
106+
1, /* SAVEt_MORTALIZESV */
107+
1, /* SAVEt_NSTAB */
108+
1, /* SAVEt_OP */
109+
1, /* SAVEt_PARSER */
110+
1, /* SAVEt_STACK_POS */
111+
1, /* SAVEt_READONLY_OFF */
112+
1, /* SAVEt_FREEPADNAME */
113+
1, /* SAVEt_STRLEN_SMALL */
114+
1, /* SAVEt_FREERCPV */
115+
1, /* SAVEt_FREE_REXC_STATE */
116+
2, /* SAVEt_AV */
117+
2, /* SAVEt_DESTRUCTOR */
118+
2, /* SAVEt_DESTRUCTOR_X */
119+
2, /* SAVEt_GENERIC_PVREF */
120+
2, /* SAVEt_GENERIC_SVREF */
121+
2, /* SAVEt_GP */
122+
2, /* SAVEt_GVSV */
123+
2, /* SAVEt_HINTS */
124+
2, /* SAVEt_HPTR */
125+
2, /* SAVEt_HV */
126+
2, /* SAVEt_I32 */
127+
2, /* SAVEt_INT */
128+
2, /* SAVEt_ITEM */
129+
2, /* SAVEt_IV */
130+
2, /* SAVEt_PPTR */
131+
2, /* SAVEt_SAVESWITCHSTACK */
132+
2, /* SAVEt_SHARED_PVREF */
133+
2, /* SAVEt_SPTR */
134+
2, /* SAVEt_STRLEN */
135+
2, /* SAVEt_SV */
136+
2, /* SAVEt_SVREF */
137+
2, /* SAVEt_VPTR */
138+
2, /* SAVEt_ADELETE */
139+
2, /* SAVEt_APTR */
140+
2, /* SAVEt_RCPV */
141+
3, /* SAVEt_HELEM */
142+
3, /* SAVEt_PADSV_AND_MORTALIZE */
143+
3, /* SAVEt_SET_SVFLAGS */
144+
3, /* SAVEt_GVSLOT */
145+
3, /* SAVEt_AELEM */
146+
3, /* SAVEt_DELETE */
147+
3 /* SAVEt_HINTS_HH */
147148
};
149+
#endif
148150

149151
#define MAX_SAVEt 58
150152

0 commit comments

Comments
 (0)