Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
opline: move cop_line to BASEOP
Browse files Browse the repository at this point in the history
Looking up COP's to find the error lines is inexact, slow and esp.
8% heavier than using less COP's and moving the opline to each op.

On an average of 4 ops per line, and the reduced need for
runtime nextstates of 90% - only lexstate changes and file beginning
and the overhead of 5 ptrs per COP, we will win 4ptrs per reduced COP.
On typical 10k src with 40k ops it will be a 4 ptrs(5-1)*10k memory win: 40kb
(4 ops per line on average), plus the runtime win of ~about 4k ops, 8%.

See [cperl #333]
  • Loading branch information
rurban committed Nov 2, 2018
1 parent 963ae96 commit 5f6bf9c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 1 addition & 4 deletions cop.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,6 @@ string/length pair.

struct cop {
BASEOP
/* On LP64 putting this here takes advantage of the fact that BASEOP isn't
an exact multiple of 8 bytes to save structure padding. */
line_t cop_line; /* line # of this command */
/* label for this construct is now stored in cop_hints_hash */
#ifdef USE_ITHREADS
PADOFFSET cop_stashoff; /* offset into PL_stashpad, for the
Expand Down Expand Up @@ -547,7 +544,7 @@ be zero.
#define CopLABEL_alloc(pv) ((pv)?savepv(pv):NULL)

#define CopSTASH_ne(c,hv) (!CopSTASH_eq(c,hv))
#define CopLINE(c) ((c)->cop_line)
#define CopLINE(c) ((c)->op_line)
#define CopLINE_inc(c) (++CopLINE(c))
#define CopLINE_dec(c) (--CopLINE(c))
#define CopLINE_set(c,l) (CopLINE(c) = (l))
Expand Down
3 changes: 2 additions & 1 deletion op.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ typedef PERL_BITFIELD16 Optype;
PERL_BITFIELD16 op_typechecked:1; \
U8 op_flags; \
U8 op_private; \
U8 op_rettype;
U8 op_rettype; \
line_t op_line; /* line # of this command */
#endif

/* Class::XSAccessor abuses this */
Expand Down

0 comments on commit 5f6bf9c

Please sign in to comment.