Skip to content
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

Tier 2 interpreter experiment (diff only for viewing, DO NOT MERGE) #38

Draft
wants to merge 300 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
1e0116d
Feat: Added more type annotations and localarr effect to DSL and upda…
JuliaPoo Feb 27, 2023
4f4a3fd
feat: Implemented type propagation except for jump instructions with …
JuliaPoo Feb 28, 2023
19b80a8
Refactor: Moved type_propagate to be with the _PyTier2TypeContext code
JuliaPoo Mar 1, 2023
a349f16
Refactor: Added tier2_typepropagator.c.h as generated in .gitattributes
JuliaPoo Mar 1, 2023
1b2d4a4
Feat: Handled type propagation across the tier2 branching logic
JuliaPoo Mar 1, 2023
337720b
Fix: Wrong behaviour of gen_bb_requires_pop
JuliaPoo Mar 2, 2023
17b09ca
Style: Reformatted to follow CPython's style guide
JuliaPoo Mar 2, 2023
579c2d6
Update Tools/cases_generator/parser.py
JuliaPoo Mar 2, 2023
80b9cbe
Update Tools/cases_generator/parser.py
JuliaPoo Mar 2, 2023
5c5db52
Update Tools/cases_generator/parser.py
JuliaPoo Mar 2, 2023
f17dd5f
Refactor: Change shadowed builtins `type` in parser.py
JuliaPoo Mar 2, 2023
699a6a3
Refactor: Renamed functions
JuliaPoo Mar 2, 2023
808c9eb
Merge branch 'types_metainterpreter' of https://github.com/JuliaPoo/c…
JuliaPoo Mar 2, 2023
eeaa02f
Merge pull request #24 from JuliaPoo/types_metainterpreter
Fidget-Spinner Mar 2, 2023
cd32a5a
Merge remote-tracking branch 'upstream/main' into tier2_interpreter_n…
Fidget-Spinner Mar 2, 2023
99a4ade
Feat: More type prop rules in the DSL and bytecodes.c
JuliaPoo Mar 2, 2023
d8c6edc
Perf: Removed unneccessary declarations in type propagator
JuliaPoo Mar 3, 2023
24ded88
Perf: Removed unneccessary type annotations in MATCH bytecode
JuliaPoo Mar 3, 2023
deec638
Merge pull request #25 from JuliaPoo/types_metainterpreter
Fidget-Spinner Mar 3, 2023
2771f89
Merge remote-tracking branch 'upstream/main' into tier2_interpreter_n…
Fidget-Spinner Mar 4, 2023
2238944
Support multi-file inputs
Fidget-Spinner Mar 4, 2023
ed37138
Refactor: Setup parser.py and generate_cases.py in preparation for th…
JuliaPoo Mar 9, 2023
8f81c3e
Merge remote-tracking branch 'upstream/main' into tier2_interpreter_n…
Fidget-Spinner Mar 12, 2023
066df40
Add dis support for tier 2 code objects
Fidget-Spinner Mar 12, 2023
abb9548
Add Jump offsets to dis
Fidget-Spinner Mar 12, 2023
52994f1
Use type propagation to generate branchless ops
Fidget-Spinner Mar 13, 2023
1351aef
Copy specialised ops, ladder the type guards
Fidget-Spinner Mar 13, 2023
4315bca
Merge remote-tracking branch 'upstream/main' into tier2_interpreter_n…
Fidget-Spinner Mar 13, 2023
eccd7e1
Add float support
Fidget-Spinner Mar 13, 2023
448f82f
Fix a bunch of compiler warnings
Fidget-Spinner Mar 16, 2023
417b725
Refactor: Again
JuliaPoo Mar 17, 2023
52513f9
Style: parser.py
JuliaPoo Mar 17, 2023
5d1a01e
Feat: Improved referenced-based type propagator
JuliaPoo Mar 18, 2023
49b09eb
Fix+Debug: Fixed bugs and print type context
JuliaPoo Mar 18, 2023
2f4e231
Merge branch 'tier2_interpreter_no_separate_eval_no_tracer_contiguous…
JuliaPoo Mar 20, 2023
f0ed274
Fix: Bug fixes to the new type prop
JuliaPoo Mar 20, 2023
63fa5bb
Refactor: rename _typenode_get_type to typenode_get_type
JuliaPoo Mar 20, 2023
e7e69be
Refactor: Simplify __type_stack_shrink
JuliaPoo Mar 20, 2023
bed5b8a
fix allocation issues
Fidget-Spinner Mar 20, 2023
d144e35
temp commit
Fidget-Spinner Mar 20, 2023
183d009
Support unboxed floats
Fidget-Spinner Mar 20, 2023
34cca1e
Feat: Allow multiple type operations per annotation
JuliaPoo Mar 20, 2023
702ee98
Merge branch 'tier2_interpreter_no_separate_eval_no_tracer_contiguous…
Fidget-Spinner Mar 20, 2023
01721eb
Merge pull request #26 from JuliaPoo/type_propagator_improved
Fidget-Spinner Mar 20, 2023
79a204c
unbox when loading from fastlocals
Fidget-Spinner Mar 20, 2023
0eacc5e
Fix up merge problems
Fidget-Spinner Mar 20, 2023
438873e
Fix more segfaults, write back on LOAD_FAST unboxed
Fidget-Spinner Mar 20, 2023
07a8d61
Fix up some type annotations in DSL
Fidget-Spinner Mar 21, 2023
3143a10
fix refleak in UNBOX_FLOAT
Fidget-Spinner Mar 22, 2023
1359271
Fix: Buggy pointer magic in copying type context (#27)
JuliaPoo Mar 23, 2023
80fa4ed
gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternat…
iritkatriel Mar 13, 2023
aaca52a
gh-87092: refactor assemble() to a number of separate functions, whic…
iritkatriel Mar 13, 2023
3985abd
GH-100987: Don't cache references to the names and consts array in `_…
markshannon Mar 13, 2023
5814088
gh-102650: Remove duplicate include directives from multiple source f…
chgnrdv Mar 13, 2023
c54eeaf
gh-98169 dataclasses.astuple support DefaultDict (#98170)
kwsp Mar 13, 2023
98b34ba
gh-102069: Fix `__weakref__` descriptor generation for custom datacla…
sobolevn Mar 13, 2023
762e024
gh-101524: Fix the ChannelID tp_name (gh-102655)
ericsnowcurrently Mar 13, 2023
75153c1
gh-101659: Avoid Allocation for Shared Exceptions in the _xxsubinterp…
ericsnowcurrently Mar 13, 2023
b99132d
gh-98831: Use DECREF_INPUTS() more (#102409)
gvanrossum Mar 13, 2023
e2be4e4
gh-102627: Replace address pointing toward malicious web page (#102630)
Blind4Basics Mar 13, 2023
5b8c3cb
GH-102670: Use sumprod() to simplify, speed up, and improve accuracy …
rhettinger Mar 14, 2023
91a5bd4
gh-102013: Add PyUnstable_GC_VisitObjects (#102014)
jbower-fb Mar 14, 2023
e65b6b8
doc: Remove a duplicate 'versionchanged' in library/asyncio-task (gh-…
achimnol Mar 14, 2023
4d7f5d0
GH-100227: cleanup initialization of global interned dict (#102682)
kumaraditya303 Mar 14, 2023
9c61718
gh-100315: clarification to `__slots__` docs. (#102621)
kwsp Mar 14, 2023
c92b445
GH-94851: check unicode consistency of static strings in debug mode (…
kumaraditya303 Mar 14, 2023
038b67c
gh-81057: Add a CI Check for New Unsupported C Global Variables (gh-1…
ericsnowcurrently Mar 14, 2023
41426fe
gh-102354: change python3 to python in docs examples (#102696)
Liturgist Mar 14, 2023
f4367d5
gh-102660: Handle m_copy Specially for the sys and builtins Modules (…
ericsnowcurrently Mar 14, 2023
b608a19
gh-102674: Remove _specialization_stats from Lib/opcode.py (#102685)
corona10 Mar 14, 2023
a504830
Rename redundant enum tests so that they run (#102535)
JosephSBoyle Mar 14, 2023
fedee27
gh-101578: mention in what's new in 3.12 that exceptions are now norm…
iritkatriel Mar 14, 2023
2d5a20c
gh-102703: Fix typo in modules tutorial documentation (GH-102707)
rprater Mar 15, 2023
9e47401
gh-102519: Avoid failing tests due to inaccessible volumes (GH-102706)
zooba Mar 15, 2023
b78ead8
gh-102560 Add docstrings to asyncio.TaskGroup (#102565)
JosephSBoyle Mar 15, 2023
669c82a
gh-101377: improving test_locale_calendar_formatweekday of calendar (…
andrehora Mar 15, 2023
ff52779
Remove misformatted exclamation marks in docs (#102694)
tom93 Mar 15, 2023
4de1e65
gh-102615: Use `list` instead of `tuple` in `repr` of paramspec (#102…
sobolevn Mar 15, 2023
06915ed
gh-102281: Fix potential nullptr dereference + use of uninitialized m…
maxbachmann Mar 15, 2023
939f5a6
gh-101100: Documenting --prefix and --exec-prefix. (GH-102695)
JulienPalard Mar 15, 2023
71190ac
gh-102654: Insert #line directives in generated_cases.c.h (#102669)
gvanrossum Mar 15, 2023
7204c41
Exclude `ceval.c` from the C-analyzer tool (#102735)
AlexWaygood Mar 15, 2023
b537248
Fix typo in code comment (#102726)
martin-martin Mar 15, 2023
824309e
Simplify and speed-up math.hypot() and math.dist() (GH-102734)
rhettinger Mar 15, 2023
bc1ff3a
gh-102738: remove from cases generator the code related to register i…
iritkatriel Mar 15, 2023
9368557
gh-102660: Fix Refleaks in import.c (#102744)
ericsnowcurrently Mar 16, 2023
b05f294
gh-102690: Use Edge as fallback in webbrowser instead of IE (#102691)
DBJim Mar 16, 2023
edd10d0
GH-100112: avoid using iterable coroutines in asyncio internally (#1…
kumaraditya303 Mar 16, 2023
f9f542d
gh-94440: Fix issue of ProcessPoolExecutor shutdown hanging (#94468)
yonatanp Mar 16, 2023
a965c5e
gh-102594: PyErr_SetObject adds note to exception raised on normaliza…
iritkatriel Mar 16, 2023
e3461ea
Add comments to `{typing,_collections_abc}._type_repr` about each oth…
sobolevn Mar 16, 2023
9730682
GH-102653: Make recipe docstring show the correct distribution (#102742)
rhettinger Mar 16, 2023
dd97b75
gh-102721: Improve coverage of `_collections_abc._CallableGenericAlia…
sobolevn Mar 16, 2023
a123f26
GH-102748: remove legacy support for generator based coroutines from …
kumaraditya303 Mar 16, 2023
df9a322
gh-102737: Un-ignore ceval.c in the CI globals check (gh-102745)
ericsnowcurrently Mar 16, 2023
6b9d4cb
gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternat…
iritkatriel Mar 16, 2023
ba65c48
gh-102192: remove redundant exception fields from ssl module socket (…
iritkatriel Mar 16, 2023
a10c1f2
gh-99726: Improves correctness of stat results for Windows, and uses …
zooba Mar 16, 2023
93e32d6
gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternat…
iritkatriel Mar 16, 2023
2c96fc0
Fix outdated note about 'int' rounding or truncating (#102736)
mdickinson Mar 16, 2023
dd639e7
gh-102755: Add PyErr_DisplayException(exc) (#102756)
iritkatriel Mar 16, 2023
0405b45
Increase stack reserve size for Windows debug builds to avoid test cr…
zooba Mar 17, 2023
8d2b6b5
GH-78530: add support for generators in `asyncio.wait` (#102761)
kumaraditya303 Mar 17, 2023
b538145
gh-102701: Fix overflow in dictobject.c (GH-102750)
methane Mar 17, 2023
f9d4acc
gh-102781: fix cwd dependence in cases generator (#102782)
carljm Mar 17, 2023
d451dd0
Simplify and improve accuracy for subnormals in hypot() (GH-102785)
rhettinger Mar 17, 2023
e2e5fa6
gh-102799: remove unnecessary calls to sys.exc_info() in tests (#102800)
iritkatriel Mar 18, 2023
b019008
gh-101975: Fixed a potential SegFault on garbage collection (GH-102803)
gaogaotiantian Mar 18, 2023
0d85488
gh-102778: Add sys.last_exc, deprecate sys.last_type, sys.last_value,…
iritkatriel Mar 18, 2023
863f705
gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternat…
iritkatriel Mar 18, 2023
1820891
Add more comments to hypot() (GH-102817)
rhettinger Mar 18, 2023
ba86d35
gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternat…
iritkatriel Mar 19, 2023
2cfaac1
gh-102755: fix refleak (#102826)
iritkatriel Mar 19, 2023
4746094
gh-102778: revert changes to idlelib (#102825)
iritkatriel Mar 19, 2023
c8e62e7
gh-102828: add onexc arg to shutil.rmtree. Deprecate onerror. (#102829)
iritkatriel Mar 19, 2023
d66b16b
gh-102810: Add docstrings to the public-facing methods of `asyncio.Ti…
JosephSBoyle Mar 19, 2023
49de99b
gh-102491: Remove IronPython version check in sys_version (#102492)
eendebakpt Mar 19, 2023
5699276
gh-102828: fix test failure (add missing skip instructions) (#102835)
iritkatriel Mar 20, 2023
7dab359
gh-72346: Added isdst deprecation warning to email.utils.localtime (G…
alanfwilliams Mar 20, 2023
6e01113
gh-102255: Use GetVersionEx instead of GetVersionExW to match argumen…
maxbachmann Mar 20, 2023
2b10a8d
gh-102304: Move _Py_RefTotal to _PyRuntimeState (gh-102543)
ericsnowcurrently Mar 20, 2023
457391d
gh-102304: Add a What's New Entry About _Py_RefTotal (gh-102845)
ericsnowcurrently Mar 20, 2023
76fb37b
gh-102304: Fix Non-Debug Builds (gh-102846)
ericsnowcurrently Mar 20, 2023
a003e0f
Add itertool recipe for polynomial evaluation. (GH-102852)
rhettinger Mar 20, 2023
1886084
gh-102809: Remove `Misc/gdbinit` (#102854)
sobolevn Mar 20, 2023
5226688
Remove itermediate list. Expand docstring. (GH-102862)
rhettinger Mar 21, 2023
f357fc7
The pow() variant further improves accuracy (GH-102866)
rhettinger Mar 21, 2023
af512cc
gh-102598: Remove obsolete optimization from `FORMAT_VALUE` opcode (#…
sobolevn Mar 21, 2023
45e8c3e
gh-102755: PyErr_DisplayException only in ABI >= 3.12. Tests cover Py…
iritkatriel Mar 21, 2023
52172d3
gh-102799: Let pydoc use the exception instead of sys.exc_info (#102830)
iritkatriel Mar 21, 2023
6776fb1
gh-102828: emit deprecation warning for onerror arg to shutil.rmtree …
iritkatriel Mar 21, 2023
05078fd
gh-102595: Document `PyObject_Format` c-api function (GH-102596)
sobolevn Mar 21, 2023
8eb9d2f
gh-98608: Stop Treating All Errors from _Py_NewInterpreterFromConfig(…
ericsnowcurrently Mar 21, 2023
70e542b
gh-102876: remove superfluous parens from itertools.batched recipe (G…
wimglenn Mar 21, 2023
4ae6f69
gh-102304: Move the Total Refcount to PyInterpreterState (gh-102545)
ericsnowcurrently Mar 21, 2023
711256c
Tweak polynomial itertool recipes (GH-102880)
rhettinger Mar 21, 2023
ac24ffa
gh-98608: Fix Failure-handling in new_interpreter() (gh-102658)
ericsnowcurrently Mar 21, 2023
6739463
gh-102860: improve performance of compiler's instr_sequence_to_cfg (#…
iritkatriel Mar 21, 2023
7de1d79
gh-94673: Isolate the _io module to Each Interpreter (gh-102663)
ericsnowcurrently Mar 21, 2023
43f13b9
gh-102406: replace exception chaining by PEP-678 notes in codecs (#10…
iritkatriel Mar 21, 2023
7174c0c
Add link to `sys.exit` function documentation (#102805)
david-poirier Mar 21, 2023
4dc1709
gh-102839: remove AC for math.log (GH-102863)
skirpichev Mar 21, 2023
e030c18
Docs: improve accuracy of pdb alias example (#102892)
gaogaotiantian Mar 22, 2023
e139442
GH-94808: Cover `PyOS_mystrnicmp` and `PyOS_mystricmp` (gh-102469)
artemmukhin Mar 22, 2023
563cf60
Docs: improve the accuracy of the sqlite3.connect() timeout param (#1…
erlend-aasland Mar 22, 2023
3e09860
gh-100989: Improve the accuracy of collections.deque docstrings (#100…
timobrembeck Mar 22, 2023
f59f943
Docs: improve accuracy of sqlite3.Connection.interrupt() (#102904)
erlend-aasland Mar 22, 2023
6a95610
GH-95494: Fix transport EOF handling in OpenSSL 3.0 (GH-95495)
davidben Mar 22, 2023
f0e9319
gh-101313: Add -h and --help arguments to the webbrowser module (gh-1…
Icelain Mar 22, 2023
b6098c5
gh-101947: Remove size check from sqlite3 serialize test (#102914)
erlend-aasland Mar 22, 2023
f30f362
gh-102027: Fix macro name (#102124)
maxbachmann Mar 22, 2023
233ef6d
gh-96931: Fix incorrect results in ssl.SSLSocket.shared_ciphers (#96932)
benfogle Mar 22, 2023
b645f1b
GH-89727: Fix pathlib.Path.walk RecursionError on deep trees (GH-100282)
zmievsa Mar 22, 2023
32f8276
GH-101291: Rearrange the size bits in PyLongObject (GH-102464)
markshannon Mar 22, 2023
ae4c54b
gh-102033: Fix syntax error in `Tools/c-analyzer` (GH-102066)
sobolevn Mar 22, 2023
4080fb7
gh-102780: Fix uncancel() call in asyncio timeouts (#102815)
kristjanvalur Mar 22, 2023
27f390b
gh-102859: Remove JUMP_IF_FALSE_OR_POP and JUMP_IF_TRUE_OR_POP (#102870)
iritkatriel Mar 22, 2023
404a6c5
gh-102921: [doc] Clarify `exc` argument name in `BaseExceptionGroup` …
kkirsche Mar 22, 2023
f8f08c2
[doc] Fix error in tutorial example: type(exc) is the type rather tha…
jenshb Mar 22, 2023
828e887
gh-100227: Make the Global Interned Dict Safe for Isolated Interprete…
ericsnowcurrently Mar 23, 2023
c95d83c
gh-102939: Fix "conversion from Py_ssize_t to long" warning in builti…
sobolevn Mar 23, 2023
24016a8
Docs: fixup incorrect escape char in sqlite3 docs (#102945)
erlend-aasland Mar 23, 2023
4ef8efa
gh-102947: Improve traceback when calling `fields()` on a non-datacla…
AlexWaygood Mar 23, 2023
67a48e5
gh-88965: typing: fix type substitution of a list of types after ini…
sobolevn Mar 23, 2023
49e03ce
gh-102943: Stop checking localized error text in socket tests on Wind…
aisk Mar 23, 2023
47e12e5
gh-102810 Improve the sphinx docs for `asyncio.Timeout` (#102934)
JosephSBoyle Mar 23, 2023
1999027
Move binomialvariate() to a section for discrete distributions (GH-10…
rhettinger Mar 23, 2023
10b47a8
gh-102936: typing: document performance pitfalls of protocols decorat…
AlexWaygood Mar 23, 2023
c25402d
gh-98239: Document that `inspect.getsource()` can raise `TypeError` (…
sobolevn Mar 23, 2023
110c3dd
Minor readability improvement to the factor() recipe (GH-102971)
rhettinger Mar 23, 2023
9227b98
gh-102558: [Enum] fix AttributeError during member repr() (GH-102601)
corona10 Mar 23, 2023
6183cbd
GH-100982: Break up COMPARE_AND_BRANCH (GH-102801)
brandtbucher Mar 23, 2023
6f57d0a
gh-99726: Fix order of recently added fields for FILE_STAT_BASIC_INFO…
zooba Mar 23, 2023
a67d94a
gh-94684: uuid: support bytes in the name argument to uuid3/5 (#94709)
MonadChains Mar 23, 2023
c945040
GH-100989: Revert Improve the accuracy of collections.deque docstring…
rhettinger Mar 24, 2023
de24df7
GH-100989: remove annotation from docstring (GH-102991)
rhettinger Mar 24, 2023
bf3bfdb
gh-101100: Test docs in nit-picky mode (#102513)
hugovk Mar 24, 2023
387cc11
gh-100372: Use BIO_eof to detect EOF for SSL_FILETYPE_ASN1 (GH-100373)
davidben Mar 24, 2023
a11fcbb
gh-102873: logging.LogRecord docs: improve description of `msg` param…
aminalaee Mar 24, 2023
6b4ce01
gh-102980: Add tests for pdf's display, alias and where commands (#10…
gaogaotiantian Mar 24, 2023
2812212
gh-100131: Add optional delete parameter to tempfile.TemporaryDirecto…
JakobDev Mar 24, 2023
6f2c3f0
gh-101100: Test only Doc/ files in nit-picky mode (#103019)
hugovk Mar 25, 2023
faaaabd
GH-102833: Mention the key function in the docstrings (GH-103009)
rhettinger Mar 25, 2023
537a413
gh-103025: fix two ctypes doc issues (#103026)
peterjpxie Mar 25, 2023
a61efbe
gh-103027: Update `dataclass.make_dataclass` docstring (gh-103028)
sobolevn Mar 25, 2023
86bc734
Fix typos in faulthandler, testcapi error messages (#103020)
sudoliyang Mar 25, 2023
6f15ebd
Update pdb docs for arguments (#102965)
gaogaotiantian Mar 25, 2023
8e4f648
gh-98886: Fix issues with dataclass fields with special underscore na…
hauntsaninja Mar 25, 2023
0831f21
Fix typo in _swappedbytes_ in ctypes comment (#102773)
matthiasgoergens Mar 25, 2023
0f312ec
gh-102941: Fix "‘subobj’ may be used uninitialized in this function" …
sobolevn Mar 27, 2023
c4306ba
Finish merge
Fidget-Spinner Mar 27, 2023
950cf29
fix a bug
Fidget-Spinner Mar 27, 2023
5227258
Fix: Improper handling of conditional stack effect for BB_TEST_ITER
JuliaPoo Mar 27, 2023
11609bf
Fix: Buggy macros
JuliaPoo Mar 27, 2023
20f919f
Fix: Added missing opcode
JuliaPoo Mar 27, 2023
b57665e
Fix: Bug in EXTENDED_ARG handling for _PyTier2_RewriteForwardJump
JuliaPoo Mar 27, 2023
88c27eb
Apply review comments
Fidget-Spinner Mar 28, 2023
d6a7b97
Some cleanup
Fidget-Spinner Mar 28, 2023
fae3104
Merge remote-tracking branch 'upstream/main' into tier2_interpreter_n…
Fidget-Spinner Mar 28, 2023
4b7137c
Revert "Merge remote-tracking branch 'upstream/main' into tier2_inter…
Fidget-Spinner Mar 28, 2023
4d19b71
Merge remote-tracking branch 'upstream/main' into tier2_interpreter_n…
Fidget-Spinner Mar 28, 2023
632305b
Fix bad merge
Fidget-Spinner Mar 28, 2023
98e96af
remove extraneous print
Fidget-Spinner Mar 28, 2023
6a8e230
Fix bug in forward jump rewrites
Fidget-Spinner Mar 28, 2023
590e99a
Added EXTENDED_ARG to type prop (#29)
JuliaPoo Mar 28, 2023
47d1029
Revert "Added EXTENDED_ARG to type prop (#29)"
Fidget-Spinner Mar 28, 2023
1b8fb91
Handle EXTENDED_ARG in tier 1
Fidget-Spinner Mar 28, 2023
e8f9f98
Diff function for backwards jump
Fidget-Spinner Mar 29, 2023
d95cdb6
Fix backwards jump generation (again)
Fidget-Spinner Mar 29, 2023
3c2ac64
Fix: Buggy type propagation across SWAP (#30)
JuliaPoo Mar 29, 2023
6bade7b
More support for EXTENDED_ARGS
Fidget-Spinner Mar 29, 2023
10fd8ec
fix a small memory leak
Fidget-Spinner Mar 29, 2023
c9d3b49
Add assert for type stacksize
Fidget-Spinner Mar 29, 2023
a77cf56
Fix an EXTENDED_ARG bug
Fidget-Spinner Mar 29, 2023
66143f9
Fix: BB_TEST_ITER wrong type propagation (#31)
JuliaPoo Mar 30, 2023
f36e9d7
Fix more EXTENDED_ARG issues
Fidget-Spinner Mar 30, 2023
941fea0
Add BB_TEST_ITER specialisations
Fidget-Spinner Mar 30, 2023
3608d6b
Add unboxed float ops for multiply and subtract
Fidget-Spinner Mar 30, 2023
cfe1e1a
fix up type check ladder generation
Fidget-Spinner Mar 30, 2023
15aa9c1
Fix: Bug in typeprop handling UNPACK_*, and bug in COPY_NO_INCREF (#32)
JuliaPoo Mar 31, 2023
4821284
Add guardless container ops
Fidget-Spinner Mar 31, 2023
7ec2dc0
Fix: Ref leak in unboxing checks (#33)
JuliaPoo Mar 31, 2023
0a14be3
Add our own nbody benchmark
Fidget-Spinner Mar 31, 2023
be8fbf9
change iterations
Fidget-Spinner Mar 31, 2023
2f12aad
Remove BB_TEST_ITER_GEN
Fidget-Spinner Mar 31, 2023
74b20cb
make work on gcc
Fidget-Spinner Mar 31, 2023
309715c
regen opcode targets
Fidget-Spinner Mar 31, 2023
1ed4c15
fix for makefile
Fidget-Spinner Mar 31, 2023
5529495
Update bm_nbody.py
Fidget-Spinner Mar 31, 2023
b758a31
Add documentation
Fidget-Spinner Apr 7, 2023
ab2145e
Add instructions
Fidget-Spinner Apr 7, 2023
59f885d
Docs: Added typeprop documentation (#36)
JuliaPoo Apr 8, 2023
badce84
Fix type guard emitting
Fidget-Spinner Apr 11, 2023
69dee64
Merge branch 'tier2_interpreter_no_separate_eval_no_tracer_contiguous…
Fidget-Spinner Apr 11, 2023
fd338df
Tests: Modified dis.py and added primitive tests (#37)
JuliaPoo Apr 13, 2023
d1f3a74
Test: Added test for container specialisation (#39)
JuliaPoo Apr 14, 2023
3366eca
modify test
Fidget-Spinner Apr 15, 2023
223949a
update build info
Fidget-Spinner Apr 15, 2023
ce3724f
Create bm_float_unboxed.py
Fidget-Spinner Apr 15, 2023
aef3516
Commit pylbbv results
Fidget-Spinner Apr 15, 2023
6ee3fdb
Update bm_float_unboxed.py
Fidget-Spinner Apr 15, 2023
19e6fe2
Remove old benchmarks
Fidget-Spinner Apr 15, 2023
d5f2da4
Add benchmark results for cpython and pylbbv
Fidget-Spinner Apr 15, 2023
3d44cb4
Test literally only float ops in bm_float_unboxed
Fidget-Spinner Apr 16, 2023
0e81dc4
New bm_nbody_float results
Fidget-Spinner Apr 16, 2023
3a4c75d
Add tests for BB_TEST_ITER specialisation
Fidget-Spinner Apr 16, 2023
c728f31
Merge branch 'tier2_interpreter_no_separate_eval_no_tracer_contiguous…
Fidget-Spinner Apr 16, 2023
ea992b3
Create CPython_Tier_2_LBBV_Report_For_Repo.pdf
Fidget-Spinner Apr 16, 2023
2b84a6b
Update CPython_Tier_2_LBBV_Report_For_Repo.pdf
Fidget-Spinner Apr 16, 2023
f430545
Add reference to Mark's tiers of execution, and whatsnew on PEP 659
Fidget-Spinner May 20, 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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Parser/token.c generated
Programs/test_frozenmain.h generated
Python/Python-ast.c generated
Python/generated_cases.c.h generated
Python/tier2_typepropagator.c.h generated
Python/opcode_targets.h generated
Python/stdlib_module_names.h generated
Tools/peg_generator/pegen/grammar_parser.py generated
Expand Down
40 changes: 40 additions & 0 deletions CS4215.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# A Lazy Basic Block Versioning Interpreter for CPython.

# Build instructions

You should follow the official CPython build instructions for your platform.
https://devguide.python.org/getting-started/setup-building/

We have one major difference - you must have a pre-existing Python installation.
Preferrably Python 3.9 or higher. On MacOS/Unix systems, that Python installation
*must* be located at `python3`.

The main reason for this limitation is that Python is used to bootstrap the compilation
of Python. However, since our interpreter is unable to run a large part of the Python
language, our interpreter cannot be used as a bootstrap Python.

During the build process, errors may be printed, and the build process may error. However,
the final Python executable should still be generated.

# Where are files located?

The majority of the changes and functionality are in `Python/tier2.c` where Doxygen documentation
is written alongside the code, and in `Tools/cases_generator/` which contains the DSL implementation.

# Running tests

We've written simple tests of the main functionalities.
Unfortunately we did not have time to write comprehensive tests, and it doesn't seem worth it eitherways given the experimental nature of this project.

After building, run `python tier2_test.py` in the repository's root folder.

# Debugging output

In `tier2.c`, two flags can be set to print debug messages:
```c
// Prints codegen debug messages
#define BB_DEBUG 0

// Prints typeprop debug messages
#define TYPEPROP_DEBUG 0
```
91 changes: 91 additions & 0 deletions Include/cpython/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,95 @@ typedef struct {
PyObject *_co_freevars;
} _PyCoCached;

// TYPENODE is a tagged pointer that uses the last 2 LSB as the tag
#define _Py_TYPENODE_t uintptr_t

// TYPENODE Tags
typedef enum _Py_TypeNodeTags {
// Node is unused
TYPE_NULL = 0,
// TYPE_ROOT can point to a PyTypeObject or be a NULL
TYPE_ROOT = 1,
// TYPE_REF points to a TYPE_ROOT or a TYPE_REF
TYPE_REF = 2
} _Py_TypeNodeTags;

#define _Py_TYPENODE_GET_TAG(typenode) ((typenode) & (0b11))
#define _Py_TYPENODE_CLEAR_TAG(typenode) ((typenode) & (~(uintptr_t)(0b11)))

#define _Py_TYPENODE_MAKE_ROOT(ptr) (_Py_TYPENODE_CLEAR_TAG(ptr) | TYPE_ROOT)
#define _Py_TYPENODE_MAKE_REF(ptr) (_Py_TYPENODE_CLEAR_TAG(ptr) | TYPE_REF)

#define _Py_TYPENODE_NULL 0
#define _Py_TYPENODE_NULLROOT _Py_TYPENODE_MAKE_ROOT(_Py_TYPENODE_NULL)

// Tier 2 types meta interpreter
typedef struct _PyTier2TypeContext {
// points into type_stack, points to one element after the stack
_Py_TYPENODE_t *type_stack_ptr;
int type_locals_len;
int type_stack_len;
_Py_TYPENODE_t *type_stack;
_Py_TYPENODE_t *type_locals;
} _PyTier2TypeContext;

// Tier 2 interpreter information
typedef struct _PyTier2BBMetadata {
// Index into _PyTier2Info->bb_data
int id;
_PyTier2TypeContext *type_context;
_Py_CODEUNIT *tier2_start;
// Note, this is the first tier 1 instruction to execute AFTER the BB ends.
_Py_CODEUNIT *tier1_end;
} _PyTier2BBMetadata;

// Bump allocator for basic blocks (overallocated)
typedef struct _PyTier2BBSpace {
// (in bytes)
Py_ssize_t max_capacity;
// How much space has been consumed in bbs. (in bytes)
Py_ssize_t water_level;
// There's extra memory at the end of this.
_Py_CODEUNIT u_code[1];
} _PyTier2BBSpace;

typedef struct _PyTier2BBStartTypeContextTriplet {
int id;
_Py_CODEUNIT *tier1_start;
// This is a strong reference. So during cleanup we need to free this.
_PyTier2TypeContext *start_type_context;
} _PyTier2BBStartTypeContextTriplet;

// Tier 2 info stored in the code object. Lazily allocated.
typedef struct _PyTier2Info {
/* the tier 2 basic block to execute (if any) */
_PyTier2BBMetadata *_entry_bb;
_PyTier2BBSpace *_bb_space;
// Keeps track of offset of jump targets (in number of codeunits)
// from co_code_adaptive.
int backward_jump_count;
int *backward_jump_offsets;
// Each backward jump offset will have a corresponding array of _PyTier2BBMetadata *
// This allows us to find a suitable BB on a backward jump.
// So backward jump offset [1, 2, 3 ,4]
// will have [[BB_ID1, BB_ID2], [BB_ID3,], [], []]
// etc.
_PyTier2BBStartTypeContextTriplet **backward_jump_target_bb_pairs;
// Max len of bb_data
int bb_data_len;
// Current index to write into in bb_data. Incremented after each write.
// This also assigns the BB ID.
int bb_data_curr;
_PyTier2BBMetadata **bb_data;

// @TODO:
// Potentially optimise _PyTier2TypeContext by allocating the stacksize
// to the size needed for the snapshot, and the type propagation is performed
// on type_metainterpreter_stack_scratch which is allocated only once per
// code object.
// PyTypeObject** type_metainterpreter_stack_scratch;
} _PyTier2Info;

// To avoid repeating ourselves in deepfreeze.py, all PyCodeObject members are
// defined in this macro:
#define _PyCode_DEF(SIZE) { \
Expand Down Expand Up @@ -116,6 +205,8 @@ typedef struct {
_PyCoCached *_co_cached; /* cached co_* attributes */ \
int _co_firsttraceable; /* index of first traceable instruction */ \
char *_co_linearray; /* array of line offsets */ \
int _tier2_warmup; /* warmup counter for tier 2 */ \
_PyTier2Info *_tier2_info; /* info required for tier 2, lazily alloc */ \
/* Scratch space for extra data relating to the code object. \
Type is a void* to keep the format private in codeobject.c to force \
people to go through the proper APIs. */ \
Expand Down
43 changes: 41 additions & 2 deletions Include/internal/pycore_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ extern "C" {

#define CODE_MAX_WATCHERS 8

typedef struct {
// Unique ID (for this code object) for this basic block. This indexes into
// the PyTier2Info bb_data field.
// The LSB indicates whether the bb branch is a type guard or not.
// To get the actual BB ID, do a right bit shift by one.
uint16_t bb_id_tagged;
} _PyBBBranchCache;

#define INLINE_CACHE_ENTRIES_BB_BRANCH CACHE_ENTRIES(_PyBBBranchCache)

/* PEP 659
* Specialization and quickening structs and helper functions
*/
Expand Down Expand Up @@ -238,14 +248,44 @@ extern void _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs,
_Py_CODEUNIT *instr, int oparg);
extern void _Py_Specialize_UnpackSequence(PyObject *seq, _Py_CODEUNIT *instr,
int oparg);
extern void _Py_Specialize_ForIter(PyObject *iter, _Py_CODEUNIT *instr, int oparg);
extern void _Py_Specialize_ForIter(PyObject *iter, _Py_CODEUNIT *instr, int oparg, char is_bb);
extern void _Py_Specialize_Send(PyObject *receiver, _Py_CODEUNIT *instr);

/* Finalizer function for static codeobjects used in deepfreeze.py */
extern void _PyStaticCode_Fini(PyCodeObject *co);
/* Function to intern strings of codeobjects and quicken the bytecode */
extern int _PyStaticCode_Init(PyCodeObject *co);

/* Tier 2 interpreter */

// gen_bb_is_successor:
// true = successor
// false = alternate
// gen_bb_requires_pop (maximum 7):
// For tier2 type propagation, handling of jump instructions with
// runtime-dependent stack effect.
// This flag is used to determine if the type context of a new bb
// requires a stack element to be popped.
#define BB_TEST(gen_bb_is_successor, gen_bb_requires_pop) \
(((gen_bb_is_successor) << 4) | (gen_bb_requires_pop))
#define BB_TEST_IS_SUCCESSOR(bb_test) ((bb_test) >> 4)
#define BB_TEST_GET_N_REQUIRES_POP(bb_test) ((bb_test) & 0b1111)

extern _Py_CODEUNIT *_PyCode_Tier2Warmup(struct _PyInterpreterFrame *,
_Py_CODEUNIT *);
extern _Py_CODEUNIT *_PyTier2_GenerateNextBB(
struct _PyInterpreterFrame *frame,
uint16_t bb_id_tagged,
_Py_CODEUNIT *curr_executing_instr,
int jumpby,
_Py_CODEUNIT **tier1_fallback,
char bb_flag);
extern _Py_CODEUNIT *_PyTier2_LocateJumpBackwardsBB(
struct _PyInterpreterFrame *frame, uint16_t bb_id, int jumpby,
_Py_CODEUNIT **tier1_fallback, _Py_CODEUNIT *curr, int stacksize);
extern void _PyTier2_RewriteForwardJump(_Py_CODEUNIT *bb_branch, _Py_CODEUNIT *target);
extern void _PyTier2_RewriteBackwardJump(_Py_CODEUNIT *jump_backward_lazy, _Py_CODEUNIT *target);
void _PyTier2TypeContext_Free(_PyTier2TypeContext *type_context);
#ifdef Py_STATS


Expand Down Expand Up @@ -503,7 +543,6 @@ extern uint32_t _Py_next_func_version;

#define COMPARISON_NOT_EQUALS (COMPARISON_UNORDERED | COMPARISON_LESS_THAN | COMPARISON_GREATER_THAN)


#ifdef __cplusplus
}
#endif
Expand Down
34 changes: 29 additions & 5 deletions Include/internal/pycore_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,19 @@ typedef struct _PyInterpreterFrame {
int stacktop; /* Offset of TOS from localsplus */
uint16_t yield_offset;
char owner;
/* Locals and stack */
/* Locals and stack and unboxed bit mask */
PyObject *localsplus[1];
} _PyInterpreterFrame;

#define _PyInterpreterFrame_LASTI(IF) \
((int)((IF)->prev_instr - _PyCode_CODE((IF)->f_code)))
static inline int
_PyInterpreterFrame_LASTI(_PyInterpreterFrame *f) {
if (f->f_code->_tier2_info != NULL) {
return ((int)((f)->prev_instr - f->f_code->_tier2_info->_bb_space->u_code));
}
return ((int)((f)->prev_instr - _PyCode_CODE((f)->f_code)));
}
//#define _PyInterpreterFrame_LASTI(IF) \
// ((int)((IF)->prev_instr - _PyCode_CODE((IF)->f_code)))

static inline PyObject **_PyFrame_Stackbase(_PyInterpreterFrame *f) {
return f->localsplus + f->f_code->co_nlocalsplus;
Expand Down Expand Up @@ -98,7 +105,10 @@ _PyFrame_NumSlotsForCodeObject(PyCodeObject *code)
/* This function needs to remain in sync with the calculation of
* co_framesize in Tools/build/deepfreeze.py */
assert(code->co_framesize >= FRAME_SPECIALS_SIZE);
return code->co_framesize - FRAME_SPECIALS_SIZE;
int res = code->co_framesize - FRAME_SPECIALS_SIZE -
(code->co_nlocalsplus * sizeof(char) / sizeof(PyObject *) + 1);
assert(res > 0);
return res;
}

void _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest);
Expand All @@ -119,7 +129,12 @@ _PyFrame_Initialize(
frame->f_locals = locals;
frame->stacktop = code->co_nlocalsplus;
frame->frame_obj = NULL;
frame->prev_instr = _PyCode_CODE(code) - 1;
if (code->_tier2_info != NULL) {
frame->prev_instr = code->_tier2_info->_entry_bb->tier2_start - 1;
}
else {
frame->prev_instr = _PyCode_CODE(code) - 1;
}
frame->yield_offset = 0;
frame->owner = FRAME_OWNED_BY_THREAD;

Expand All @@ -128,6 +143,15 @@ _PyFrame_Initialize(
}
}

// The unboxed bitmask. true indicates an unboxed value. false indicates a normal PyObject.
static inline char*
_PyFrame_GetUnboxedBitMask(_PyInterpreterFrame *frame)
{
PyCodeObject *co = frame->f_code;
return (char *)(frame + co->co_framesize -
(co->co_nlocalsplus * sizeof(char) / sizeof(PyObject *) + 1));
}

/* Gets the pointer to the locals array
* that precedes this frame.
*/
Expand Down
Loading