Skip to content

gh-107557: Setup abstract interpretation #107847

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
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
d20fbb8
gh-107557: Tier 2 abstract interpreter barebones
Fidget-Spinner Aug 2, 2023
2aeea51
📜🤖 Added by blurb_it.
blurb-it[bot] Aug 2, 2023
1a728ab
Copy Guido's input and output code, and fix build
Fidget-Spinner Aug 2, 2023
17fccbc
fix separator
Fidget-Spinner Aug 2, 2023
a1da69d
credit Jules
Fidget-Spinner Aug 2, 2023
b458e17
add jules to co-authors
Fidget-Spinner Aug 2, 2023
f81f888
add pycore_optimizer.h to headers in makefile
Fidget-Spinner Aug 2, 2023
0020320
fix: remove whitespace
Fidget-Spinner Aug 2, 2023
1f93072
fix make smelly
Fidget-Spinner Aug 2, 2023
dac63e3
fix: build
Fidget-Spinner Aug 2, 2023
e62e015
fix wrong symbol
Fidget-Spinner Aug 2, 2023
a7f654c
ignore static globals check for abstract interpreter
Fidget-Spinner Aug 2, 2023
f4040b8
Merge remote-tracking branch 'upstream/main' into abstract_interpreter
Fidget-Spinner Aug 4, 2023
ec58145
merge Guido's changes
Fidget-Spinner Aug 4, 2023
4292767
remove unused stuff
Fidget-Spinner Aug 4, 2023
fdcca90
Turn on the abstract interpreter
Fidget-Spinner Aug 4, 2023
5110fb9
Merge remote-tracking branch 'upstream/main' into abstract_interpreter
Fidget-Spinner Aug 5, 2023
9f443a2
Merge remote-tracking branch 'origin/abstract_interpreter' into parti…
Fidget-Spinner Aug 5, 2023
7632ed1
(leaky) data structures for constant propagation
Fidget-Spinner Aug 5, 2023
0d0c4c4
(with cycles) try to fix the type prop
Fidget-Spinner Aug 6, 2023
4c8953e
fix: cycles
Fidget-Spinner Aug 6, 2023
3bd36fa
cleanup
Fidget-Spinner Aug 6, 2023
229097f
Fix+Refactor: Handling of root nodes in special-cased type prop (#40)
JuliaPoo Aug 7, 2023
ca0fab7
partially partially evaluate
Fidget-Spinner Aug 8, 2023
68c684f
rename vars
Fidget-Spinner Aug 8, 2023
46c5777
fixx off by one
Fidget-Spinner Aug 8, 2023
b839ee4
partial eval working for real this time
Fidget-Spinner Aug 9, 2023
6ecf3d2
Fix: Inconsistent `AbstractInterpContext` used in `PARTITIONNODE_OVER…
JuliaPoo Aug 9, 2023
b6eeb25
fix test, refactor, bugfix
Fidget-Spinner Aug 9, 2023
d5cceb9
re-compute jump offsets and targets
Fidget-Spinner Aug 10, 2023
8c0d65f
Fix+Refactor: Extra EXIT_TRACE emitted (#42)
JuliaPoo Aug 10, 2023
95db909
fix: overallocate buffer and virtual/real stack offset calculation
Fidget-Spinner Aug 10, 2023
1e05ef8
more bugfix
Fidget-Spinner Aug 10, 2023
d7d8b52
Merge remote-tracking branch 'upstream/main' into partition_algo
Fidget-Spinner Aug 10, 2023
4d7abc7
Perf+Cleanup: Removed temporary allocation in `remove_duplicate_save_…
JuliaPoo Aug 11, 2023
3d76f9a
clean up code
Fidget-Spinner Aug 11, 2023
e81def2
Merge branch 'partition_algo' of https://github.com/Fidget-Spinner/cp…
Fidget-Spinner Aug 11, 2023
9a5a3f7
make static
Fidget-Spinner Aug 11, 2023
df490d0
make types static
Fidget-Spinner Aug 11, 2023
1e4fc94
make const and ignore in c analyzer
Fidget-Spinner Aug 11, 2023
6de77a7
fix c-analyzer ignored list
Fidget-Spinner Aug 11, 2023
a11fc80
more cleanup
Fidget-Spinner Aug 13, 2023
c61015b
Merge remote-tracking branch 'upstream/main' into partition_algo
Fidget-Spinner Aug 13, 2023
56c62eb
regen files
Fidget-Spinner Aug 13, 2023
3c08ebe
address review
Fidget-Spinner Aug 14, 2023
d5f16be
regen
Fidget-Spinner Aug 14, 2023
1e61c49
and env var to block tests
Fidget-Spinner Aug 14, 2023
6c24b49
regen again
Fidget-Spinner Aug 14, 2023
2be404d
fix generated files
Fidget-Spinner Aug 14, 2023
29e255d
Address review
Fidget-Spinner Aug 15, 2023
3c44117
fix up INSERT
Fidget-Spinner Aug 15, 2023
b758b47
remove experimental parts
Fidget-Spinner Aug 15, 2023
80c7f18
revert more changes
Fidget-Spinner Aug 15, 2023
6a2b204
use memmove
Fidget-Spinner Aug 15, 2023
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
4 changes: 2 additions & 2 deletions Include/internal/pycore_uops.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ extern "C" {
#define _Py_UOP_MAX_TRACE_LENGTH 64

typedef struct {
int32_t opcode;
int32_t oparg;
uint32_t opcode;
uint32_t oparg;
uint64_t operand; // A cache entry
} _PyUOpInstruction;

Expand Down
25 changes: 0 additions & 25 deletions Lib/test/test_capi/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2618,31 +2618,6 @@ def testfunc(it):
with self.assertRaises(StopIteration):
next(it)

@unittest.skipIf(os.getenv("PYTHONUOPSOPTIMIZE") is None, "UOps optimization isn't enabled")
class TestUopsOptimization(unittest.TestCase):

def test_int_constant_propagation(self):
def testfunc(loops):
num = 0
while num < loops:
x = 0
y = 1
z = 2
a = x + y + z + x + y + z + x + y + z
num += 1
return a

opt = _testinternalcapi.get_uop_optimizer()
res = None
with temporary_optimizer(opt):
res = testfunc(3)

ex = get_first_executor(testfunc)
self.assertIsNotNone(ex)
self.assertEqual(res, 9)
binop_count = [opname for opname, _, _ in ex if opname == "_BINARY_OP_ADD_INT"]
self.assertEqual(len(binop_count), 1)


if __name__ == "__main__":
unittest.main()
7 changes: 3 additions & 4 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3743,11 +3743,10 @@ dummy_func(
return frame;
}

op(INSERT, (stuff[oparg], top -- top, stuff[oparg])) {
// Inserts TOS at position specified by oparg
PyObject *tos = TOP();
op(INSERT, (unused[oparg], top -- top, unused[oparg])) {
// Inserts TOS at position specified by oparg;
for (int i = 1; i < oparg + 1; i++) {
stack_pointer[i] = stack_pointer[i - 1];
stack_pointer[-i] = stack_pointer[-(i - 1)];
}
}

Expand Down
4 changes: 0 additions & 4 deletions Python/executor_cases.c.h

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

Loading