Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-144179: Use recorded values to make optimizer more robust#144437

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
markshannon wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
frommarkshannon:optimize-using-recorded-values-2
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
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
22 changes: 11 additions & 11 deletionsInclude/internal/pycore_opcode_metadata.h
View file
Open in desktop

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

14 changes: 14 additions & 0 deletionsInclude/internal/pycore_optimizer.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -298,6 +298,11 @@ extern JitOptRef _Py_uop_sym_new_compact_int(JitOptContext *ctx);
extern void _Py_uop_sym_set_compact_int(JitOptContext *ctx, JitOptRef sym);
extern JitOptRef _Py_uop_sym_new_predicate(JitOptContext *ctx, JitOptRef lhs_ref, JitOptRef rhs_ref, JitOptPredicateKind kind);
extern void _Py_uop_sym_apply_predicate_narrowing(JitOptContext *ctx, JitOptRef sym, bool branch_is_true);
extern void _Py_uop_sym_set_recorded_value(JitOptContext *ctx, JitOptRef sym, PyObject *value);
extern void _Py_uop_sym_set_recorded_type(JitOptContext *ctx, JitOptRef sym, PyTypeObject *type);
extern void _Py_uop_sym_set_recorded_gen_func(JitOptContext *ctx, JitOptRef ref, PyFunctionObject *value);
extern PyCodeObject *_Py_uop_sym_get_probable_func_code(JitOptRef sym);
extern PyObject *_Py_uop_sym_get_probable_value(JitOptRef sym);

extern void _Py_uop_abstractcontext_init(JitOptContext *ctx);
extern void _Py_uop_abstractcontext_fini(JitOptContext *ctx);
Expand All@@ -308,6 +313,14 @@ extern _Py_UOpsAbstractFrame *_Py_uop_frame_new(
int curr_stackentries,
JitOptRef *args,
int arg_len);

extern _Py_UOpsAbstractFrame *_Py_uop_frame_new_from_symbol(
JitOptContext *ctx,
JitOptRef callable,
int curr_stackentries,
JitOptRef *args,
int arg_len);

extern int _Py_uop_frame_pop(JitOptContext *ctx, PyCodeObject *co, int curr_stackentries);

PyAPI_FUNC(PyObject *) _Py_uop_symbols_test(PyObject *self, PyObject *ignored);
Expand DownExpand Up@@ -341,6 +354,7 @@ _PyJit_TryInitializeTracing(PyThreadState *tstate, _PyInterpreterFrame *frame,
int oparg, _PyExecutorObject *current_executor);

PyAPI_FUNC(void) _PyJit_FinalizeTracing(PyThreadState *tstate, int err);
void _PyPrintExecutor(_PyExecutorObject *executor, const _PyUOpInstruction *marker);
void _PyJit_TracerFree(_PyThreadStateImpl *_tstate);

void _PyJit_Tracer_InvalidateDependency(PyThreadState *old_tstate, void *obj);
Expand Down
24 changes: 24 additions & 0 deletionsInclude/internal/pycore_optimizer_types.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,6 +41,9 @@ typedef enum _JitSymType {
JIT_SYM_TRUTHINESS_TAG = 9,
JIT_SYM_COMPACT_INT = 10,
JIT_SYM_PREDICATE_TAG = 11,
JIT_SYM_RECORDED_VALUE_TAG = 12,
JIT_SYM_RECORDED_TYPE_TAG = 13,
JIT_SYM_RECORDED_GEN_FUNC_TAG = 14,
} JitSymType;

typedef struct _jit_opt_known_class {
Expand DownExpand Up@@ -87,6 +90,24 @@ typedef struct {
uint16_t rhs;
} JitOptPredicate;

typedef struct _jit_opt_recorded_value {
uint8_t tag;
bool known_type;
PyObject *value;
} JitOptRecordedValue;

typedef struct _jit_opt_recorded_type {
uint8_t tag;
PyTypeObject *type;
} JitOptRecordedType;

/* Represents a generator, but we record the
* function as the generator is emphemeral */
typedef struct _jit_opt_recorded_gen_func {
uint8_t tag;
PyFunctionObject *func;
} JitOptRecordedGenFunc;

typedef struct {
uint8_t tag;
} JitOptCompactInt;
Expand All@@ -100,6 +121,9 @@ typedef union _jit_opt_symbol {
JitOptTruthiness truthiness;
JitOptCompactInt compact;
JitOptPredicate predicate;
JitOptRecordedValue recorded_value;
JitOptRecordedType recorded_type;
JitOptRecordedGenFunc recorded_gen_func;
} JitOptSymbol;

// This mimics the _PyStackRef API
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2026 Movatter.jp