8000 gh-104584: Baby steps towards generating and executing traces by gvanrossum · Pull Request #105924 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
8000

gh-104584: Baby steps towards generating and executing traces #105924

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

Merged
merged 68 commits into from
Jun 27, 2023
Merged
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
3008fc7
Boilerplate for new uop optimizer+executor
gvanrossum Jun 17, 2023
512b764
Make uop optimizer execute a LOAD_FAST
gvanrossum Jun 17, 2023
52742c8
Generalize uop optimizer infrastructure
gvanrossum Jun 18, 2023
4de0468
Give uop_execute an instruction decoding loop
gvanrossum Jun 19, 2023
5ded690
Make the translator use a switch
gvanrossum Jun 19, 2023
e41acc0
Support LOAD_FAST_LOAD_FAST
gvanrossum Jun 19, 2023
76ccf2d
Support LOAD_CONST
gvanrossum Jun 19, 2023
3001dde
Fix edge case for LOAD_FAST_LOAD_FAST
gvanrossum Jun 19, 2023
a7d2cba
Generate SET_IP after each instr
gvanrossum Jun 19, 2023
e00703c
Turn stats into properties (tp_members)
gvanrossum Jun 19, 2023
3d41ffe
Comment out fprintfs
gvanrossum Jun 19, 2023
7db1d12
Enable UOp optimizer by default in main interpreter
gvanrossum Jun 19, 2023
17bcc61
The world isn't ready for 'const int X = 1;'
gvanrossum Jun 19, 2023
e07bc4c
Avoid MSC warning about implicit cast
gvanrossum Jun 19, 2023
02b0624
Add missing cast in pylifecycle.c
gvanrossum Jun 19, 2023
b5feec7
Use write_provenance_header() more
gvanrossum Jun 20, 2023
775df6e
Generate (some) cases for the executor
gvanrossum Jun 20, 2023
e2855ca
Recompile flowgraph.c when opcodse_metadata.h changes
gvanrossum Jun 20, 2023
0ad18cf
Add uop status to opcode metadata
gvanrossum Jun 20, 2023
f5c8316
Use macros from ceval_macros.h
gvanrossum Jun 20, 2023
13c6bd2 8000
Interim -- opcode without oparg using cache entry
gvanrossum Jun 20, 2023
1b1584c
ERROR_IF is no longer a dirty word (but errors crash)
gvanrossum Jun 20, 2023
c2c1868
Regenerate generated_cases.c.h
gvanrossum Jun 20, 2023
340570f
Hacky way to avoid flagging macros as uops
gvanrossum Jun 20, 2023
96fa5ef
Support DEOPT_IF
gvanrossum Jun 21, 2023
f2d71f5
Support ERROR_IF (had to forbid unbound_local_error)
gvanrossum Jun 21, 2023
be5dcb2
Attempt to fix check-c-globals
gvanrossum Jun 21, 2023
6ba3557
Add exceptions for static UOp*_Type to c-analyzer
gvanrossum Jun 21, 2023
792f45f
Add c-analyzer exceptions for real
gvanrossum Jun 21, 2023
71ff09c
More sophisticated uop tracing
gvanrossum Jun 21, 2023
6d532c7
gh-105481: refactor instr flag related code into a new InstructionFla…
iritkatriel Jun 21, 2023
bf7abc2
Restore IS_UOP flag generation
gvanrossum Jun 21, 2023
121fbad
Trace uop optimizations if PYTHON_UOP_DEBUG is set
gvanrossum Jun 22, 2023
4dc0019
Merge remote-tracking branch 'origin/main' into optim-exec
gvanrossum Jun 22, 2023
a5880da
Move check for oparg-or-one-short-cache into is_viable_uop()
gvanrossum Jun 22, 2023
59c84a3
Support SET_FUNCTION_CLOSURE
gvanrossum Jun 22, 2023
8fd4a71
Move uop optimizer to ceval.c so it can use static functions defined …
gvanrossum Jun 22, 2023
f0ec658
Support tstate
gvanrossum Jun 22, 2023
65a3c80
Rename 'adjust_cache[s]' to 'tier'
gvanrossum Jun 22, 2023
decfe4a
Reformat Analyzer.__init__ header
gvanrossum Jun 22, 2023
f9db482
Merge remote-tracking branch 'origin/main' into optim-exec
gvanrossum Jun 22, 2023
94441b6
Auto-generate uop values
gvanrossum Jun 23, 2023
8a6bc14
Switch to using macro expansion
gvanrossum Jun 23, 2023
88fbe66
Remove IS_UOP flag
gvanrossum Jun 23, 2023
7f9349e
Allow pointer-sized ints for Tier-2 oparg
gvanrossum Jun 23, 2023
97aab6e
Rename FORBIDDEN_INSTRUCTIONS
gvanrossum Jun 23, 2023
67f7798
Remove separate UOpOptimizerObject type
gvanrossum Jun 23, 2023
2848c3d
Try to use pystats
gvanrossum Jun 23, 2023
5b018c2
Rationalize errors
gvanrossum Jun 24, 2023
a228b5d
Fix typo in pystats output
gvanrossum Jun 24, 2023
2695bb7
Move uop_optimizer back to optimizer.c
gvanrossum Jun 24, 2023
91dd86c
Fix 4/6 failing tests
gvanrossum Jun 25, 2023
7d1750e
Receiving end of macro expansion
gvanrossum Jun 25, 2023
c1bcd0f
Avoid warnings; subtler debug output levels
gvanrossum Jun 25, 2023
9df20bb
Add eval breaker check to _PyUopExecute; fixes test_threading
gvanrossum Jun 25, 2023
b0f6d18
Merge remote-tracking branch 'origin/main' into optim-exec
gvanrossum Jun 25, 2023
acfd143
Add opcode name to ADD_TO_TRACE debug output
gvanrossum Jun 26, 2023
e3471da
Fix test_memoryview by excluding BEFORE_WITH
gvanrossum Jun 26, 2023
44a1ffc
Fix Windows test_mmap -- by removing BUILD_SLICE/STORE_SLICE
gvanrossum Jun 26, 2023
2254f83
Fix bug in ENTER_EXECUTOR - on error go to resume_with_error
gvanrossum Jun 26, 2023
2f6603e
Silence warnings on Windows
gvanrossum Jun 26, 2023
00f8f2c
Replace oparg with operand in more debug output
gvanrossum Jun 26, 2023
4 8000 bd7bb6
Fix test_memoryview again by excluding BEFORE_WITH
gvanrossum Jun 26, 2023
9646b4e
Add -Xuops flag and debug tweaks
gvanrossum Jun 26, 2023
9c04e40
Revert "Fix 4/6 failing tests"
gvanrossum Jun 26, 2023
39bc8fe
Use PRIu64 instead of %lld/%llu formats
gvanrossum Jun 26, 2023
6606c5d
Remove superfluous INCREF -- hope it fixes the refleaks
gvanrossum Jun 26, 2023
c14e104
📜🤖 Added by blurb_it.
blurb-it[bot] Jun 27, 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
Prev Previous commit
Next Next commit
Use macros from ceval_macros.h
  • Loading branch information
gvanrossum committed Jun 20, 2023
commit f5c83167fb869b36cf085f13ef41dc7263a8d6a2
25 changes: 6 additions & 19 deletions Python/optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
#include "Python.h"
#include "opcode.h"
#include "pycore_interp.h"
#include "pycore_object.h"
#include "pycore_opcode.h"
#include "pycore_pystate.h"
#include "cpython/optimizer.h"
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "opcode_metadata.h"
#include "ceval_macros.h"

static bool
has_space_for_executor(PyCodeObject *code, _Py_CODEUNIT *instr)
Expand Down Expand Up @@ -327,25 +329,6 @@ static PyTypeObject UOpExecu A0EC tor_Type = {
static _PyInterpreterFrame *
uop_execute(_PyExecutorObject *executor, _PyInterpreterFrame *frame, PyObject **stack_pointer)
{
// TODO: These macros should be imported from ceval_macros.h or similar
#define GETLOCAL(i) (frame->localsplus[i])
#define SETLOCAL(i, v) do { \
PyObject *tmp = GETLOCAL(i); \
GETLOCAL(i) = (v); \
Py_XDECREF(tmp); \
} while (0)
#define GETITEM(v, i) PyTuple_GET_ITEM((v), (i))
#define STACK_GROW(n) (stack_pointer += (n))
#define STACK_SHRINK(n) (stack_pointer -= (n))
#define FRAME_CO_CONSTS (_PyFrame_GetCode(frame)->co_consts)
#define FRAME_CO_NAMES (_PyFrame_GetCode(frame)->co_names)
#define DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dval, result) do {\
result = PyFloat_FromDouble(dval); \
/* if ((result) == NULL) goto error; */ \
Py_DECREF(left); \
Py_DECREF(right); \
} while (0)

UOpExecutorObject *self = (UOpExecutorObject *)executor;
self->optimizer->traces_executed++;
_Py_CODEUNIT *ip_offset = (_Py_CODEUNIT *)_PyFrame_GetCode(frame)->co_code_adaptive - 1;
Expand Down Expand Up @@ -385,6 +368,10 @@ uop_execute(_PyExecutorObject *executor, _PyInterpreterFrame *frame, PyObject **
}

}
continue;
error:
fprintf(stderr, "[Opcode %d, oparg %d]\n", opcode, oparg);
Py_FatalError("Errors not yet supported");
}
}

Expand Down
0