Skip to content

Commit e354246

Browse files
authored
gh-160132: Reduce padding in _PyCfgBasicblock (#160149)
1 parent 75d96f8 commit e354246

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Reduce memory usage during compilation by reordering the fields of the
2+
internal basic block structure to reduce padding.
3+
Patch by Shamil Abdulaev.

‎Python/flowgraph.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ typedef struct _PyCfgBasicblock {
4747
struct _PyCfgBasicblock *b_list;
4848
/* The label of this block if it is a jump target, -1 otherwise */
4949
_PyJumpTargetLabel b_label;
50+
/* Basic block is an exception handler that preserves lasti */
51+
unsigned b_preserve_lasti : 1;
52+
/* Used by compiler passes to mark whether they have visited a basic block. */
53+
unsigned b_visited : 1;
54+
/* b_except_handler is used by the cold-detection algorithm to mark exception targets */
55+
unsigned b_except_handler : 1;
56+
/* b_cold is true if this block is not perf critical (like an exception handler) */
57+
unsigned b_cold : 1;
58+
/* b_warm is used by the cold-detection algorithm to mark blocks which are definitely not cold */
59+
unsigned b_warm : 1;
5060
/* Exception stack at start of block, used by assembler to create the exception handling table */
5161
struct _PyCfgExceptStack *b_exceptstack;
5262
/* pointer to an array of instructions, initially NULL */
@@ -64,16 +74,6 @@ typedef struct _PyCfgBasicblock {
6474
int b_predecessors;
6575
/* depth of stack upon entry of block, computed by stackdepth() */
6676
int b_startdepth;
67-
/* Basic block is an exception handler that preserves lasti */
68-
unsigned b_preserve_lasti : 1;
69-
/* Used by compiler passes to mark whether they have visited a basic block. */
70-
unsigned b_visited : 1;
71-
/* b_except_handler is used by the cold-detection algorithm to mark exception targets */
72-
unsigned b_except_handler : 1;
73-
/* b_cold is true if this block is not perf critical (like an exception handler) */
74-
unsigned b_cold : 1;
75-
/* b_warm is used by the cold-detection algorithm to mark blocks which are definitely not cold */
76-
unsigned b_warm : 1;
7777
} basicblock;
7878

7979

0 commit comments

Comments
 (0)