Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-93678: refactor compiler so that optimizer does not need the assembler and compiler structs#93842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes from1 commit
Commits
Show all changes
16 commits
Select commitHold shift + click to select a range
6d38e85
optimize_cfg does not require a struct compiler*
iritkatrielJun 14, 2022
db0be36
optimize_cfg does not require a struct assembler*
iritkatrielJun 14, 2022
82be9a5
do not pass the whole assembler to functions that need only a_entry
iritkatrielJun 14, 2022
a2da370
Create struct assember just before assemble_emit. The other optimizer…
iritkatrielJun 14, 2022
c26a2bb
assemble_jump_offsets doesn't need the compiler
iritkatrielJun 14, 2022
36d2410
duplicate_exits_without_lineno can use b_next links to iterate
iritkatrielJun 14, 2022
7f06d70
stackdepth doesn't need the compiler
iritkatrielJun 14, 2022
5cd8fc9
push_cold_blocks_to_end and duplicate_exits_without_lineno do not nee…
iritkatrielJun 15, 2022
b1e9f7c
remove 3 unused fields from struct assembler
iritkatrielJun 15, 2022
b5f58d1
remove obsolete comment
iritkatrielJun 15, 2022
c4a125e
code review followup
iritkatrielJun 15, 2022
39f03c0
entry --> entryblock for consistency
iritkatrielJun 15, 2022
c233570
📜🤖 Added by blurb_it.
blurb-it[bot]Jun 15, 2022
482742a
Merge remote-tracking branch 'upstream/main' into reduce_dependencty_…
iritkatrielJun 17, 2022
28ba5d9
Merge remote-tracking branch 'upstream/main' into reduce_dependencty_…
iritkatrielJun 20, 2022
51b78f7
Merge branch 'main' into reduce_dependencty_on_compiler
iritkatrielJun 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
entry --> entryblock for consistency
  • Loading branch information
@iritkatriel
iritkatriel committedJun 15, 2022
commit39f03c09de82f288f8702a0c087901e85619e9b0
50 changes: 25 additions & 25 deletionsPython/compile.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7029,9 +7029,9 @@ struct assembler {
};

static basicblock**
make_cfg_traversal_stack(basicblock *entry) {
make_cfg_traversal_stack(basicblock *entryblock) {
int nblocks = 0;
for (basicblock *b =entry; b != NULL; b = b->b_next) {
for (basicblock *b =entryblock; b != NULL; b = b->b_next) {
b->b_visited = 0;
nblocks++;
}
Expand DownExpand Up@@ -7221,8 +7221,8 @@ copy_except_stack(ExceptStack *stack) {
}

static int
label_exception_targets(basicblock *entry) {
basicblock **todo_stack = make_cfg_traversal_stack(entry);
label_exception_targets(basicblock *entryblock) {
basicblock **todo_stack = make_cfg_traversal_stack(entryblock);
if (todo_stack == NULL) {
return -1;
}
Expand All@@ -7233,9 +7233,9 @@ label_exception_targets(basicblock *entry) {
return -1;
}
except_stack->depth = 0;
todo_stack[0] =entry;
entry->b_visited = 1;
entry->b_exceptstack = except_stack;
todo_stack[0] =entryblock;
entryblock->b_visited = 1;
entryblock->b_exceptstack = except_stack;
basicblock **todo = &todo_stack[1];
basicblock *handler = NULL;
while (todo > todo_stack) {
Expand DownExpand Up@@ -7300,7 +7300,7 @@ label_exception_targets(basicblock *entry) {
}
}
#ifdef Py_DEBUG
for (basicblock *b =entry; b != NULL; b = b->b_next) {
for (basicblock *b =entryblock; b != NULL; b = b->b_next) {
assert(b->b_exceptstack == NULL);
}
#endif
Expand All@@ -7313,15 +7313,15 @@ label_exception_targets(basicblock *entry) {
}

static int
mark_warm(basicblock *entry) {
basicblock **stack = make_cfg_traversal_stack(entry);
mark_warm(basicblock *entryblock) {
basicblock **stack = make_cfg_traversal_stack(entryblock);
if (stack == NULL) {
return -1;
}
basicblock **sp = stack;

*sp++ =entry;
entry->b_visited = 1;
*sp++ =entryblock;
entryblock->b_visited = 1;
while (sp > stack) {
basicblock *b = *(--sp);
assert(!b->b_except_predecessors);
Expand All@@ -7344,21 +7344,21 @@ mark_warm(basicblock *entry) {
}

static int
mark_cold(basicblock *entry) {
for (basicblock *b =entry; b != NULL; b = b->b_next) {
mark_cold(basicblock *entryblock) {
for (basicblock *b =entryblock; b != NULL; b = b->b_next) {
assert(!b->b_cold && !b->b_warm);
}
if (mark_warm(entry) < 0) {
if (mark_warm(entryblock) < 0) {
return -1;
}

basicblock **stack = make_cfg_traversal_stack(entry);
basicblock **stack = make_cfg_traversal_stack(entryblock);
if (stack == NULL) {
return -1;
}

basicblock **sp = stack;
for (basicblock *b =entry; b != NULL; b = b->b_next) {
for (basicblock *b =entryblock; b != NULL; b = b->b_next) {
if (b->b_except_predecessors) {
assert(b->b_except_predecessors == b->b_predecessors);
assert(!b->b_warm);
Expand DownExpand Up@@ -7394,18 +7394,18 @@ mark_cold(basicblock *entry) {
}

static int
push_cold_blocks_to_end(basicblock *entry, int code_flags) {
if (entry->b_next == NULL) {
push_cold_blocks_to_end(basicblock *entryblock, int code_flags) {
if (entryblock->b_next == NULL) {
/* single basicblock, no need to reorder */
return 0;
}
if (mark_cold(entry) < 0) {
if (mark_cold(entryblock) < 0) {
return -1;
}

/* If we have a cold block with fallthrough to a warm block, add */
/* an explicit jump instead of fallthrough */
for (basicblock *b =entry; b != NULL; b = b->b_next) {
for (basicblock *b =entryblock; b != NULL; b = b->b_next) {
if (b->b_cold && BB_HAS_FALLTHROUGH(b) && b->b_next && b->b_next->b_warm) {
basicblock *explicit_jump = basicblock_new_b_list_successor(b);
if (explicit_jump == NULL) {
Expand All@@ -7419,11 +7419,11 @@ push_cold_blocks_to_end(basicblock *entry, int code_flags) {
}
}

assert(!entry->b_cold); /* First block can't be cold */
assert(!entryblock->b_cold); /* First block can't be cold */
basicblock *cold_blocks = NULL;
basicblock *cold_blocks_tail = NULL;

basicblock *b =entry;
basicblock *b =entryblock;
while(b->b_next) {
assert(!b->b_cold);
while (b->b_next && !b->b_next->b_cold) {
Expand DownExpand Up@@ -7462,8 +7462,8 @@ push_cold_blocks_to_end(basicblock *entry, int code_flags) {
}

static void
convert_exception_handlers_to_nops(basicblock *entry) {
for (basicblock *b =entry; b != NULL; b = b->b_next) {
convert_exception_handlers_to_nops(basicblock *entryblock) {
for (basicblock *b =entryblock; b != NULL; b = b->b_next) {
for (int i = 0; i < b->b_iused; i++) {
struct instr *instr = &b->b_instr[i];
if (is_block_push(instr) || instr->i_opcode == POP_BLOCK) {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp