Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
11 changes: 10 additions & 1 deletion Include/internal/pycore_dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,15 @@ get_insertion_order_array(PyDictValues *values)
return (uint8_t *)&values->values[values->capacity];
}

/* The insertion order array stores deltas (ix - position) instead of
absolute indices.

A sequential store (ix == values->size) has delta 0. The slots of the
array beyond values->size are kept zero (zeroed when the inline values
are allocated, and zeroed again in delete_index_from_values when an
entry is removed), so callers handling that common case can skip this
function entirely and just bump values->size -- see
_STORE_ATTR_INSTANCE_VALUE. */
static inline void
_PyDictValues_AddToInsertionOrder(PyDictValues *values, Py_ssize_t ix)
{
Expand All @@ -337,7 +346,7 @@ _PyDictValues_AddToInsertionOrder(PyDictValues *values, Py_ssize_t ix)
uint8_t *array = get_insertion_order_array(values);
assert(size < values->capacity);
assert(((uint8_t)ix) == ix);
array[size] = (uint8_t)ix;
array[size] = (uint8_t)(ix - size);
values->size = size+1;
}

Expand Down
12 changes: 12 additions & 0 deletions Include/internal/pycore_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ typedef struct _JitOptContext {
JitOptRef stack_array[ABSTRACT_INTERP_STACK_SIZE];
_PyJitUopBuffer out_buffer;
_PyBloomFilter *dependencies;

/* gh-138453: static tracking of a freshly allocated object's inline
* values->size, used to specialise _STORE_ATTR_INSTANCE_VALUE.
* fresh_alloc_pending_type is set by _CHECK_OBJECT and consumed by the
* immediately following _ALLOCATE_OBJECT. fresh_alloc_sym is the symbol
* of the object being tracked (NULL when not tracking); fresh_alloc_count
* is the number of sequential stores proven so far; fresh_alloc_next_offset
* is the byte offset of the next expected inline value slot. */
PyTypeObject *fresh_alloc_pending_type;
JitOptSymbol *fresh_alloc_sym;
int fresh_alloc_count;
uint32_t fresh_alloc_next_offset;
} JitOptContext;


Expand Down
Loading
Loading