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

bpo-46841: Use inline caching for calls#31709

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

Merged
brandtbucher merged 9 commits intopython:mainfrombrandtbucher:inline-call
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
NextNext commit
Use inline caching for PRECALL
  • Loading branch information
@brandtbucher
brandtbucher committedMar 4, 2022
commitca72a99b6b460b4cb717cbf498060ba29c37236f
39 changes: 11 additions & 28 deletionsInclude/internal/pycore_code.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,24 +13,6 @@ typedef struct {
int32_t _; /* Force 8 byte size */
} _PyEntryZero;

typedef struct {
uint8_t original_oparg;
uint8_t counter;
uint16_t index;
uint32_t version;
} _PyAdaptiveEntry;

typedef struct {
/* Borrowed ref */
PyObject *obj;
} _PyObjectCache;

typedef struct {
uint32_t func_version;
uint16_t min_args;
uint16_t defaults_len;
} _PyPrecallCache;


/* Add specialized versions of entries to this union.
*
Expand All@@ -44,9 +26,6 @@ typedef struct {
*/
typedef union {
_PyEntryZero zero;
_PyAdaptiveEntry adaptive;
_PyObjectCache obj;
_PyPrecallCache call;
} SpecializedCacheEntry;

#define INSTRUCTIONS_PER_ENTRY (sizeof(SpecializedCacheEntry)/sizeof(_Py_CODEUNIT))
Expand DownExpand Up@@ -122,6 +101,14 @@ typedef struct {

#define INLINE_CACHE_ENTRIES_CALL CACHE_ENTRIES(_PyCallCache)

// XXX: Combine with _PyCallCache?
typedef struct {
_Py_CODEUNIT counter;
_Py_CODEUNIT callable[4];
} _PyPrecallCache;

#define INLINE_CACHE_ENTRIES_PRECALL CACHE_ENTRIES(_PyPrecallCache)

/* Maximum size of code to quicken, in code units. */
#define MAX_SIZE_TO_QUICKEN 5000

Expand DownExpand Up@@ -342,11 +329,6 @@ extern int _PyLineTable_PreviousAddressRange(PyCodeAddressRange *range);

#define ADAPTIVE_CACHE_BACKOFF 64

static inline void
cache_backoff(_PyAdaptiveEntry *entry) {
entry->counter = ADAPTIVE_CACHE_BACKOFF;
}

/* Specialization functions */

extern int _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr,
Expand All@@ -360,8 +342,9 @@ extern int _Py_Specialize_BinarySubscr(PyObject *sub, PyObject *container, _Py_C
extern int _Py_Specialize_StoreSubscr(PyObject *container, PyObject *sub, _Py_CODEUNIT *instr);
extern int _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr,
int nargs, PyObject *kwnames);
extern int _Py_Specialize_Precall(PyObject *callable, _Py_CODEUNIT *instr, int nargs,
PyObject *kwnames, SpecializedCacheEntry *cache, PyObject *builtins);
extern int _Py_Specialize_Precall(PyObject *callable, _Py_CODEUNIT *instr,
int nargs, PyObject *kwnames,
PyObject *builtins, int oparg);
extern void _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
int oparg);
extern void _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs,
Expand Down
1 change: 1 addition & 0 deletionsInclude/opcode.h
View file
Open in desktop

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

2 changes: 1 addition & 1 deletionLib/opcode.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -191,7 +191,7 @@ def jabs_op(name, op, entries=0):
def_op('SET_UPDATE', 163)
def_op('DICT_MERGE', 164)
def_op('DICT_UPDATE', 165)
def_op('PRECALL', 166)
def_op('PRECALL', 166, 5)

def_op('CALL', 171, 5)
def_op('KW_NAMES', 172)
Expand Down
294 changes: 147 additions & 147 deletionsLib/test/test_dis.py
View file
Open in desktop

Large diffs are not rendered by default.

81 changes: 43 additions & 38 deletionsPrograms/test_frozenmain.h
View file
Open in desktop

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

Loading

[8]ページ先頭

©2009-2025 Movatter.jp