mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
GH-94163: Add BINARY_SLICE and STORE_SLICE instructions. (GH-94168)
This commit is contained in:
parent
33fc3b5e42
commit
c0453a40fa
14 changed files with 339 additions and 161 deletions
|
@ -23,6 +23,7 @@
|
|||
#include "pycore_pymem.h" // _PyMem_IsPtrFreed()
|
||||
#include "pycore_pystate.h" // _PyInterpreterState_GET()
|
||||
#include "pycore_range.h" // _PyRangeIterObject
|
||||
#include "pycore_sliceobject.h" // _PyBuildSlice_ConsumeRefs
|
||||
#include "pycore_sysmodule.h" // _PySys_Audit()
|
||||
#include "pycore_tuple.h" // _PyTuple_ITEMS()
|
||||
#include "pycore_emscripten_signal.h" // _Py_CHECK_EMSCRIPTEN_SIGNALS
|
||||
|
@ -2139,6 +2140,46 @@ handle_eval_breaker:
|
|||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(BINARY_SLICE) {
|
||||
PyObject *stop = POP();
|
||||
PyObject *start = POP();
|
||||
PyObject *container = TOP();
|
||||
|
||||
PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop);
|
||||
if (slice == NULL) {
|
||||
goto error;
|
||||
}
|
||||
PyObject *res = PyObject_GetItem(container, slice);
|
||||
Py_DECREF(slice);
|
||||
if (res == NULL) {
|
||||
goto error;
|
||||
}
|
||||
SET_TOP(res);
|
||||
Py_DECREF(container);
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(STORE_SLICE) {
|
||||
PyObject *stop = POP();
|
||||
PyObject *start = POP();
|
||||
PyObject *container = TOP();
|
||||
PyObject *v = SECOND();
|
||||
|
||||
PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop);
|
||||
if (slice == NULL) {
|
||||
goto error;
|
||||
}
|
||||
int err = PyObject_SetItem(container, slice, v);
|
||||
Py_DECREF(slice);
|
||||
if (err) {
|
||||
goto error;
|
||||
}
|
||||
STACK_SHRINK(2);
|
||||
Py_DECREF(v);
|
||||
Py_DECREF(container);
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(BINARY_SUBSCR_ADAPTIVE) {
|
||||
_PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr;
|
||||
if (ADAPTIVE_COUNTER_IS_ZERO(cache)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue