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

Target Python 3.11 in byte code interpreter #252

Merged
merged 4 commits into from
Jul 13, 2023

Conversation

jeff5
Copy link
Member

@jeff5 jeff5 commented Jun 7, 2023

We've been targeting 3.8 and that looks a bit old now. Work on the PEG parser will be easier with 3.11. Some CPython internals are better thought out, providing a clearer pattern to copy. On the down-side, parts of the CPython interpreter are significantly more complicated, but these are internal optimisations we need not emulate.

In particular, we will not attempt to emulate CPython's byte code "quickening" since we intend to generate JVM code most of the time and interpret CPython byte code only where there's no alternative. However, it is also a good place to develop from.

In the first step we simply rename classes without changing them and also compile the examples with Python 3.11. As the changes to the interpreter so far are simply name changes we disable the CPython interpreter tests. Something more interesting will follow.

We also compile the examples with Python 3.11. As the changes to the
interpreter so far are simply name changes we disable the CPython
interpreter tests.
@jeff5 jeff5 marked this pull request as draft June 7, 2023 06:37
jeff5 added 3 commits June 8, 2023 13:19
We update framework and implementation classes that we need for
execution of 3.11 byte code. The main affected classes are PyCode,
PyFrame and PyFunction, and their implementations for CPython byte code.

PyFunction is added because in 3.11 all frames have a function object,
even a top level module. Other changes are just supporting methods and
tweaks.

Opcodes are not implemented yet, so we can't run code, but we can load
it.
We re-enable a batch of tests in CPython311CodeTest and implement the
opcodes they need in eval(). A number of object and utility classes have
to up their game in support.
@jeff5
Copy link
Member Author

jeff5 commented Jun 8, 2023

At this point, the set of tests that ran before the change of target to 3.11, now runs again.

I'll leave this to simmer for a few weeks before merging.

@jeff5 jeff5 marked this pull request as ready for review June 8, 2023 15:56
@jeff5 jeff5 merged commit e9eeb64 into jython:main Jul 13, 2023
1 check passed
@jeff5 jeff5 deleted the target-python-3.11 branch July 13, 2023 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant