Skip to content

Commit 87e1d17

Browse files
committed
feature.*: allow cop_feature to expand
The initial implementation of feature bits for faster access to feature flags used a single U32 member in COP to store the bits, but we're now up to 24 features, so rather than leaving this to the last minute I've re-worked regen/feature.pl to allow multiple U32 fields.
1 parent 7a6c52e commit 87e1d17

File tree

4 files changed

+283
-109
lines changed

4 files changed

+283
-109
lines changed

cop.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,15 @@ the octets.
434434

435435
#include "mydtrace.h"
436436

437+
/* keep in sync with feature.h (which will complain if this is out of sync)
438+
*/
439+
#define COP_FEATURE_SIZE 1
440+
441+
/* make this a struct so we can copy the feature bits with assignment */
442+
struct cop_feature_t {
443+
U32 bits[COP_FEATURE_SIZE];
444+
};
445+
437446
struct cop {
438447
BASEOP
439448
/* On LP64 putting this here takes advantage of the fact that BASEOP isn't
@@ -460,12 +469,11 @@ struct cop {
460469
/* compile time state of %^H. See the comment in op.c for how this is
461470
used to recreate a hash to return from caller. */
462471
COPHH * cop_hints_hash;
463-
/* for now just a bitmask stored here.
464-
If we get sufficient features this may become a pointer.
472+
/*
465473
How these flags are stored is subject to change without
466474
notice. Use the macros to test for features.
467475
*/
468-
U32 cop_features;
476+
struct cop_feature_t cop_features;
469477
};
470478

471479
/*

dump.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define PERL_IN_DUMP_C
2929
#include "perl.h"
3030
#include "regcomp.h"
31+
#include "feature.h"
3132

3233
static const char* const svtypenames[SVt_LAST] = {
3334
"NULL",
@@ -1414,8 +1415,11 @@ S_do_op_dump_bar(pTHX_ I32 level, UV bar, PerlIO *file, const OP *o)
14141415
/* add hints and features if set */
14151416
if (cCOPo->cop_hints)
14161417
S_opdump_indent(aTHX_ o, level, bar, file, "HINTS = %08x\n",cCOPo->cop_hints);
1417-
if (cCOPo->cop_features)
1418-
S_opdump_indent(aTHX_ o, level, bar, file, "FEATS = %08x\n",cCOPo->cop_features);
1418+
if (ANY_FEATURE_BITS_SET(cCOPo)) {
1419+
S_opdump_indent(aTHX_ o, level, bar, file, "FEATS = ");
1420+
DUMP_FEATURE_BITS(file, cCOPo);
1421+
PerlIO_puts(file, "\n");
1422+
}
14191423

14201424
S_opdump_indent(aTHX_ o, level, bar, file, "SEQ = %u\n",
14211425
(unsigned int)cCOPo->cop_seq);

0 commit comments

Comments
 (0)