Feat: Implemented type propagation#24
Merged
Fidget-Spinner merged 21 commits intoFidget-Spinner:tier2_interpreter_no_separate_eval_no_tracer_contiguous_bbsfrom Mar 2, 2023
Conversation
…_bbs' into types_metainterpreter
…mplementing the types meta-interpreter
…_bbs' into types_metainterpreter # Conflicts: # Include/internal/pycore_opcode_macro_to_micro.h
Might require a refactor of the tier2 bytecode emitting code to progress. When emitting from a codeobject (with tier1 bytecode): 1. deop inst back to tier0 2. emit tier2 inst based on current type context 3. type propagate through emitted inst This allows the type propagator to work with tier2 bytecode (which contains more information) and can probably be generated from the DSL
…conditional stack effect
In preparation for type propagating within the tier2 branch handling code
Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Ken Jin <kenjin@python.org>
…python into types_metainterpreter
eeaa02f
into
Fidget-Spinner:tier2_interpreter_no_separate_eval_no_tracer_contiguous_bbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull requests contains:
bytecode.cfor the type propagationExample:
tier2_typepropagator.c.hwhich is inlined intotier2.c. This file deals with type propagation across all tier2 bytecode except forBB_TEST_IF_FALSE_OR_POPandBB_TEST_IF_TRUE_OR_POPbecause it's stack effect is dependent on branch takenDISPATCH()call in_PyTier2_Code_DetectAndEmitBB, which accounts for all tier2 bytecode except branch instructionsemit_logical_branch, which deals with type propagation except for the two above mentioned instructionsBB_BRANCH, where bothBB_TEST_IF_FALSE_OR_POPandBB_TEST_IF_TRUE_OR_POPsets a flaggen_bb_requires_popduring runtime which gets used inBB_BRANCHto perform the corresponding pop on the type context for the next BB.Other misc (but important) changes:
type_contextis now its own struct_PyTier2_Code_DetectAndEmitBBno longer makes a copy of thetype_contextand instead modifies the type context passed into it. Callers of this function should make a copy if needed.Future work:
type_contextfrom a BB who's target branches have all been generated can be reused without additional allocations, since said BB doesn't require atype_contextanymore.