Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Compress location entries more effectively
  • Loading branch information
brandtbucher committed Nov 15, 2022
commit 6d96e8c02c2a0879b829d95e2936497dba175cea
19 changes: 8 additions & 11 deletions Programs/test_frozenmain.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 24 additions & 6 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ location_is_after(location loc1, location loc2) {
(loc1.col_offset > loc2.end_col_offset));
}

static inline bool
same_location(location a, location b)
{
return (a.lineno < 0 && b.lineno < 0) ||(a.lineno == b.lineno &&
a.end_lineno == b.end_lineno &&
a.col_offset == b.col_offset &&
a.end_col_offset == b.end_col_offset);
}

#define LOC(x) SRC_LOCATION_FROM_AST(x)

typedef struct jump_target_label_ {
Expand Down Expand Up @@ -7830,6 +7839,9 @@ write_location_info_entry(struct assembler* a, location loc, int isize)
static int
assemble_emit_location(struct assembler* a, location loc, int isize)
{
if (isize == 0) {
return 1;
}
while (isize > 8) {
if (!write_location_info_entry(a, loc, 8)) {
return 0;
Expand Down Expand Up @@ -8859,17 +8871,23 @@ assemble(struct compiler *c, int addNone)

/* Emit location info */
a.a_lineno = c->u->u_firstlineno;
location loc;
int size;
location loc = NO_LOCATION;
int size = 0;
for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) {
for (int j = 0; j < b->b_iused; j++) {
loc = b->b_instr[j].i_loc;
size = instr_size(&b->b_instr[j]);
if (!assemble_emit_location(&a, loc, size)) {
goto error;
if (!same_location(loc, b->b_instr[j].i_loc)) {
if (!assemble_emit_location(&a, loc, size)) {
goto error;
}
loc = b->b_instr[j].i_loc;
size = 0;
}
size += instr_size(&b->b_instr[j]);
}
}
if (!assemble_emit_location(&a, loc, size)) {
goto error;
}

if (!assemble_exception_table(&a, g->g_entryblock)) {
goto error;
Expand Down