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

[GR-38700] Migrate to the Bytecode DSL #384

Open
wants to merge 39 commits into
base: master
Choose a base branch
from

Conversation

graalvmbot
Copy link

No description provided.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Feb 27, 2024
@DSouzaM
Copy link
Contributor

DSouzaM commented Feb 29, 2024

Copying description from the internal pull request, for usage information:

This PR defines an alternate bytecode interpreter implemented using the Bytecode DSL (PR).

The alternate interpreter is disabled by default, and can be switched on using the system property -Dpython.EnableBytecodeDSLInterpreter=true.

Some useful commands:

  • run on JVM: create the JVM standalone using mx python-jvm and then launch it with --vm.Dpython.EnableBytecodeDSLInterpreter=true.
  • run on NI: create a DSL-specific standalone using mx python-svm-dsl-interpreter.
  • run JUnit tests: mx punittest --no-leak-tests --use-bytecode-dsl-interpreter
  • run GraalPy tests: create a NI standalone (see above) and then mx graalpytest --python {standalone path} {file}
  • run CPython tests: mx python-run-cpython-unittest --use-bytecode-dsl-interpreter {pattern}
  • verify which interpreter is running: evaluate __graalpython__.is_bytecode_dsl_interpreter.

@graalvmbot graalvmbot force-pushed the mdsouza/GR-38700/operation-dsl branch from fb9f164 to 880e2cf Compare March 8, 2024 19:51
@graalvmbot graalvmbot force-pushed the mdsouza/GR-38700/operation-dsl branch from b2cff2d to 57e0d30 Compare March 20, 2024 19:44
profMagija and others added 15 commits April 10, 2024 09:43
Commits have been squashed to simplify rebase efforts. The original commit messages are:
    Get the DSL to generate code without errors
    Get the generated code to compile without errors
    re-add code to enable Operations interpreter
    Fix rebase issues + start factoring common validation out to AbstractCompiler.java
    Fix kwarg validation
    Fix implementation of Try
    Add named exception unbinding
    Fix implementation of With
    Minor fixes to f-strings and for-else blocks
    Refactor to support nested root node compilation without FunctionFinder
    Begin refactoring generators
    Partly fix generator implementation
    Support plain one-way generators
    Fix bug with empty generator expressions
    Support generator send (non-exceptional cases)
    Fully support enhanced generators
    Remove intermediate root node in generator implementation
    Add branch profile to generator resume code
    Fix prepareCall to handle generator calling convention
    merge generator logic back into a single PGenerator class
    Fix argument validation
    Fix unbound local checking and qualified names for functions
    Encapsulate compiler state in an OperationCompilerContext
    Support async def, async with, and await
    Get more JUnit tests running with the Operation interpreter
    Minor improvements to ResumeGenerator code
    Get JUnit tests using only the Operation interpreter
    Set catching frame reference for try-finally and with statements
    Fix stack walking to support continuation frames
    Minor location + integer constant fixes
    Convert FrameInfo to an interface and provide separate impls for bytecode and operation interpreters
    Make CodeUnit an abstract class with Bytecode and Operation implementations
    Allocate locals contiguously from slot 0 & avoid redundant allocations
    Misc. bug fixes (incl. name mangling and unbound local checking)
    Fix class cell reads and docstrings
    Fix bugs with keyword arguments + augmented assignments
    Remove AbstractCompiler abstraction, add more syntax checks
    Support type annotations
    Implement co_consts and other code fields
    Respect 'optimize' flag for compilations, constant fold unary negation
    Fix constants implementation + parser bugs
    Set exception __context__ when it is raised
    Properly handle __future__ imports
    Convert host StackOverflowError to RecursionError
    Use findBci to compute frame.f_lineno
    Use interceptTruffleException to set catchBci for exceptions
    fix Operation DSL API usage
    Move exception chaining to intercept hook
    Make future annotations inherited by exec
    Support interop method calls
    Fix finallyTry, local accesses, and continuation API usages after DSL updates
    Save + restore exception state on generator exit + entry
    Use getLocals/copyLocals APIs instead of hard-coded local offset
    Store bci into frame when potentially escaping root node
    use Proxyable for OperationProxy nodes
    Fix test setup after rebase
    Update with operation->bytecode package rename
    Rename POperationXYZ -> PBytecodeDSLXYZ
    Refactor compiler to return a CodeUnit and use a unique Builder for each root node
    Rework Marshal to use DataOutput and DataInput APIs
    Basic serialization implementation
    Avoid serialize+deserialize step for AST parsing
    Only build root node once for each MakeFunction/Generator/Coroutine operation
    Enable frozen modules, don't actually serialize Sources
    Cleanup style errors.
    Fix source creation, unintentional root node adoption, and parsing bugs
    Fix bciToLine
    Always use character-based sources
    Add separate DSL config for tests
    bump CI overlay
    bump overlay, dsl -> bytecode-dsl in gate tags
    peg imports to bytecode dsl branch
    Fix some compilation issues and undo temporary test hacks
    Break constant collection creation into separate operations
    Re-enable pattern matching tests and start a DSL implementation
    Add support for sequence pattern matching
    Move EnableBytecodeDSLInterpreter from an option to a system property; fix NI compilation
    bump overlay, add SVM DSL unittests config
    (wip) attempt to create separate native standalone for the DSL interpreter
    Pass bytecode DSL flag to builder when building standalone
    disable fail fast for DSL tests
    Fix inplace shifts; interactive string expressions
    Fix bug with empty module __init__ files
    Fix class decorators, disable pdb test on DSL interpreter, re-enable traceback test
    Fix super() implementation & fix bug with shadowed cell/free variables
    Update short-circuit ops, fix super() generator frame lookup
    Correctly mangle kwargs; implement co_lines; fix imod implementation
    Parse __future__ annotations before scope analysis to ensure bad annotations rejected
    Skip boolean coercion for boolean constants
    Use getLocal API for readClassCell/readSelf
    Clean up marshal code
    Use a PBytecodeDSLGeneratorFunctionRootNode instead of creating a bytecode node to instantiate generators
    Remove extra import
    Fix NI compilation by putting SourceSection method behind boundary; compute internal the same way as PBytecodeRootNode
    Fix rebase issue + manual bc frozen module issue
    bump ci overlay
    Fix another rebase issue with mx configuration
    bump overlay
    update to use new Bytecode DSL APIs (wip)
    remove bciToLine(int), set bytecode node when intercepting Truffle exceptions
    Replace instanceof checks with PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER checks
    getSourceLocation -> findSourceLocation
    Undo PythonTests.newBuilder now that DSL is enabled by a system property
    remove unreachable PKeyword marshalling logic
…meNode; fix runtime compilation of SyncFrameValuesNode
@graalvmbot graalvmbot force-pushed the mdsouza/GR-38700/operation-dsl branch from f7c84aa to 9cb5ef6 Compare April 10, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants