Skip to content

Commit

Permalink
feature.*: allow cop_feature to expand
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tonycoz committed Jan 9, 2025
1 parent 7a6c52e commit 87e1d17
Show file tree
Hide file tree
Showing 4 changed files with 283 additions and 109 deletions.
14 changes: 11 additions & 3 deletions cop.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,15 @@ the octets.

#include "mydtrace.h"

/* keep in sync with feature.h (which will complain if this is out of sync)
*/
#define COP_FEATURE_SIZE 1

/* make this a struct so we can copy the feature bits with assignment */
struct cop_feature_t {
U32 bits[COP_FEATURE_SIZE];
};

struct cop {
BASEOP
/* On LP64 putting this here takes advantage of the fact that BASEOP isn't
Expand All @@ -460,12 +469,11 @@ struct cop {
/* compile time state of %^H. See the comment in op.c for how this is
used to recreate a hash to return from caller. */
COPHH * cop_hints_hash;
/* for now just a bitmask stored here.
If we get sufficient features this may become a pointer.
/*
How these flags are stored is subject to change without
notice. Use the macros to test for features.
*/
U32 cop_features;
struct cop_feature_t cop_features;
};

/*
Expand Down
8 changes: 6 additions & 2 deletions dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define PERL_IN_DUMP_C
#include "perl.h"
#include "regcomp.h"
#include "feature.h"

static const char* const svtypenames[SVt_LAST] = {
"NULL",
Expand Down Expand Up @@ -1414,8 +1415,11 @@ S_do_op_dump_bar(pTHX_ I32 level, UV bar, PerlIO *file, const OP *o)
/* add hints and features if set */
if (cCOPo->cop_hints)
S_opdump_indent(aTHX_ o, level, bar, file, "HINTS = %08x\n",cCOPo->cop_hints);
if (cCOPo->cop_features)
S_opdump_indent(aTHX_ o, level, bar, file, "FEATS = %08x\n",cCOPo->cop_features);
if (ANY_FEATURE_BITS_SET(cCOPo)) {
S_opdump_indent(aTHX_ o, level, bar, file, "FEATS = ");
DUMP_FEATURE_BITS(file, cCOPo);
PerlIO_puts(file, "\n");
}

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

0 comments on commit 87e1d17

Please sign in to comment.