8000 gh-114058: Foundations of the Tier2 redundancy eliminator by Fidget-Spinner · Pull Request #115085 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-114058: Foundations of the Tier2 redundancy eliminator #115085

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 54 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
169e08d
bring over changes from old branch
Fidget-Spinner Feb 6, 2024
e270364
Port over to Mark's DSL
Fidget-Spinner Feb 6, 2024
e8a8b78
reduce diff
Fidget-Spinner Feb 6, 2024
bb6137a
fix passthrough
Fidget-Spinner Feb 6, 2024
9b15f9e
fix tests
Fidget-Spinner Feb 6, 2024
66bfce5
fix mypy issues
Fidget-Spinner Feb 6, 2024
3789cd9
fix tests and address review
Fidget-Spinner Feb 6, 2024
20d087b
add tests for abstract cases generator
Fidget-Spinner Feb 6, 2024
0f58526
patchcheck
Fidget-Spinner Feb 6, 2024
c55ba14
Address review
Fidget-Spinner Feb 7, 2024
e34a0f5
reduce diff, add tests
Fidget-Spinner Feb 7, 2024
229aab0
fix compilation problems
Fidget-Spinner Feb 7, 2024
3c8def4
don't needlessly clear aliasing information
Fidget-Spinner Feb 7, 2024
649b0c7
remove is_const for now
Fidget-Spinner Feb 7, 2024 8000
2805755
remove type prop (address review)
Fidget-Spinner Feb 7, 2024
54e2f64
Add back SELF_OR_NULL :(
Fidget-Spinner Feb 7, 2024
dcddb2d
remove broken tests
Fidget-Spinner Feb 7, 2024
6e5ed12
address most reviews (except LOAD_ATTR todo)
Fidget-Spinner Feb 8, 2024
a8b27fc
implement NOT_NULL for attributes
Fidget-Spinner Feb 8, 2024
e00ec6f
revert function version cache size
Fidget-Spinner Feb 8, 2024
b8f0af1
remove unused stats
Fidget-Spinner Feb 8, 2024
9a9033f
remove unused macro
Fidget-Spinner Feb 8, 2024
710f609
remove unused types
Fidget-Spinner Feb 8, 2024
eaeb293
remove unused import
Fidget-Spinner Feb 8, 2024
0bb9539
rename file to tier2_redundancy_eliminator
Fidget-Spinner Feb 8, 2024
82405fa
fix the type system
Fidget-Spinner Feb 8, 2024
2e31906
fix cases generator
Fidget-Spinner Feb 8, 2024
ed25ce0
remove whitespace
Fidget-Spinner Feb 8, 2024
3bf3c7d
check all overridden uops are originally defined
Fidget-Spinner Feb 8, 2024
2af5b74
error -> out of space
Fidget-Spinner Feb 8, 2024
cb1d5fe
fix test cases
Fidget-Spinner Feb 8, 2024
5013027
remove extra lines
Fidget-Spinner Feb 8, 2024
1283660
fix out_of_space vs error
Fidget-Spinner Feb 8, 2024
d14dac6
fix CI
Fidget-Spinner Feb 8, 2024
5394cdd
move macros out, remove temp writebuffer
Fidget-Spinner Feb 9, 2024
0729778
update comment
Fidget-Spinner Feb 10, 2024
35227f8
Address review
Fidget-Spinner Feb 12, 2024
40a19f7
set IS_NULL as a flag
Fidget-Spinner Feb 12, 2024
0a4b6be
Merge remote-tracking branch 'upstream/main' into tier2_redundancy_el…
Fidget-Spinner Feb 12, 2024
aaeb4cd
Fix a bug
Fidget-Spinner Feb 12, 2024
6143256
fix a bug in frames
Fidget-Spinner Feb 12, 2024
35fff8f
address review
Fidget-Spinner Feb 12, 2024
2b6eff4
remove sym sharing
Fidget-Spinner Feb 12, 2024
3b5b498
Address changes
Fidget-Spinner Feb 12, 2024
702a6fc
Address review
Fidget-Spinner Feb 12, 2024
77e56ff
address review
Fidget-Spinner Feb 13, 2024
c457098
Merge remote-tracking branch 'upstream/main' into tier2_redundancy_el…
Fidget-Spinner Feb 13, 2024
fcd31af
rename inst -> this_instr
Fidget-Spinner Feb 13, 2024
92b211c
address review
Fidget-Spinner Feb 13, 2024
1bf6ef8
remove whitespace
Fidget-Spinner Feb 13, 2024
ea3755f
remove assert
Fidget-Spinner Feb 13, 2024
f09e3c3
remove enabled
Fidget-Spinner Feb 13, 2024
9670b23
fix up error codes
Fidget-Spinner Feb 13, 2024
38420c3
fix error code again
Fidget-Spinner Feb 13, 2024
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
set IS_NULL as a flag
  • Loading branch information
Fidget-Spinner committed Feb 12, 2024
commit 40a19f7305b3c0f026123290ae16ea94b35911ad
18 changes: 16 additions & 2 deletions Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
// Flags for below.
#define KNOWN_TYPE 1 << 0 // Just to differentiate NULL in typ
#define TRUE_CONST 1 << 1
#define NOT_NULL 1 << 2
#define IS_NULL 1 << 2
#define NOT_NULL 1 << 3

typedef struct {
int flags;
Expand Down Expand Up @@ -255,6 +256,12 @@ sym_set_flag(_Py_UOpsSymType *sym, int flag)
sym->flags |= flag;
}

static inline void
sym_clear_flag(_Py_UOpsSymType *sym, int flag)
{
sym->flags &= (~flag);
}

static inline bool
sym_has_flag(_Py_UOpsSymType *sym, int flag)
{
Expand All @@ -269,6 +276,13 @@ sym_set_type(_Py_UOpsSymType *sym, PyTypeObject *tp)
sym_set_flag(sym, KNOWN_TYPE);
}

static inline void
sym_set_null(_Py_UOpsSymType *sym)
{
sym_set_flag(sym, IS_NULL);
sym_clear_flag(sym, NOT_NULL);
}


static inline _Py_UOpsSymType*
sym_new_unknown(_Py_UOpsAbstractInterpContext *ctx)
Expand Down Expand Up @@ -326,7 +340,7 @@ sym_new_null(_Py_UOpsAbstractInterpContext *ctx)
if (null_sym == NULL) {
return NULL;
}
sym_set_type(null_sym, NULL);
sym_set_null(null_sym);
ctx->frequent_syms.push_nulL_sym = null_sym;
return null_sym;
}
Expand Down
4 changes: 2 additions & 2 deletions Python/tier2_redundancy_eliminator_bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dummy_func(void) {
op(_LOAD_FAST_CHECK, (-- value)) {
value = GETLOCAL(oparg);
// We guarantee this will error - just bail and don't optimize it.
if (sym_matches_type(value, NULL)) {
if (sym_has_flag(value, IS_NULL)) {
goto out_of_space;
}
}
Expand Down Expand Up @@ -179,7 +179,7 @@ dummy_func(void) {
}

op(_CHECK_CALL_BOUND_METHOD_EXACT_ARGS, (callable, null, unused[oparg] -- callable, null, unused[oparg])) {
sym_set_type(null, NULL);
sym_set_null(null);
sym_set_type(callable, &PyMethod_Type);
}

Expand Down
4 changes: 2 additions & 2 deletions Python/tier2_redundancy_eliminator_cases.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
_Py_UOpsSymType *value;
value = GETLOCAL(oparg);
// We guarantee this will error - just bail and don't optimize it.
if (sym_matches_type(value, NULL)) {
if (sym_has_flag(value, IS_NULL)) {
goto out_of_space;
}
stack_pointer[0] = value;
Expand Down Expand Up @@ -1243,7 +1243,7 @@
_Py_UOpsSymType *callable;
null = stack_pointer[-1 - oparg];
callable = stack_pointer[-2 - oparg];
sym_set_type(null, NULL);
sym_set_null(null);
sym_set_type(callable, &PyMethod_Type);
break;
}
Expand Down
0