Skip to content
Merged
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
1 change: 1 addition & 0 deletions Doc/library/socket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ The AF_* and SOCK_* constants are now :class:`AddressFamily` and

.. versionchanged:: 3.15
``IPV6_HDRINCL`` was added.
Added support for ``SO_PASSRIGHTS`` on Linux platforms when available.


.. data:: AF_CAN
Expand Down
1 change: 1 addition & 0 deletions Include/internal/pycore_uop.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typedef struct _PyUOpInstruction{
uint64_t operand0; // A cache entry
uint64_t operand1;
#ifdef Py_STATS
int32_t fitness;
uint64_t execution_count;
#endif
} _PyUOpInstruction;
Expand Down
6 changes: 1 addition & 5 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import re
import sys
import warnings
from unittest import TestCase, main, skip
from unittest import TestCase, main
from unittest.mock import patch
from copy import copy, deepcopy

Expand Down Expand Up @@ -6796,11 +6796,7 @@ def test_get_type_hints_modules(self):
self.assertEqual(gth(ann_module2), {})
self.assertEqual(gth(ann_module3), {})

@skip("known bug")
def test_get_type_hints_modules_forwardref(self):
# FIXME: This currently exposes a bug in typing. Cached forward references
# don't account for the case where there are multiple types of the same
# name coming from different modules in the same program.
mgc_hints = {'default_a': Optional[mod_generics_cache.A],
'default_b': Optional[mod_generics_cache.B]}
self.assertEqual(gth(mod_generics_cache), mgc_hints)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for :data:`!socket.SO_PASSRIGHTS` on Linux.
3 changes: 3 additions & 0 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -8276,6 +8276,9 @@ socket_exec(PyObject *m)
#ifdef SO_BINDTODEVICE
ADD_INT_MACRO(m, SO_BINDTODEVICE);
#endif
#ifdef SO_PASSRIGHTS
ADD_INT_MACRO(m, SO_PASSRIGHTS);
#endif
#ifdef SO_BINDTOIFINDEX
ADD_INT_MACRO(m, SO_BINDTOIFINDEX);
#endif
Expand Down
20 changes: 11 additions & 9 deletions Python/optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,12 +562,13 @@ dynamic_exit_uop[MAX_UOP_ID + 1] = {

static inline void
add_to_trace(
_PyJitUopBuffer *trace,
_PyJitTracerState *tracer,
uint16_t opcode,
uint16_t oparg,
uint64_t operand,
uint32_t target)
{
_PyJitUopBuffer *trace = &tracer->code_buffer;
_PyUOpInstruction *inst = trace->next;
inst->opcode = opcode;
inst->format = UOP_FORMAT_TARGET;
Expand All @@ -576,22 +577,23 @@ add_to_trace(
inst->operand0 = operand;
#ifdef Py_STATS
inst->execution_count = 0;
inst->fitness = tracer->translator_state.fitness;
#endif
trace->next++;
}


#ifdef Py_DEBUG
#define ADD_TO_TRACE(OPCODE, OPARG, OPERAND, TARGET) \
add_to_trace(trace, (OPCODE), (OPARG), (OPERAND), (TARGET)); \
add_to_trace(tracer, (OPCODE), (OPARG), (OPERAND), (TARGET)); \
if (lltrace >= 2) { \
printf("%4d ADD_TO_TRACE: ", uop_buffer_length(trace)); \
_PyUOpPrint(uop_buffer_last(trace)); \
printf("\n"); \
}
#else
#define ADD_TO_TRACE(OPCODE, OPARG, OPERAND, TARGET) \
add_to_trace(trace, (OPCODE), (OPARG), (OPERAND), (TARGET))
add_to_trace(tracer, (OPCODE), (OPARG), (OPERAND), (TARGET))
#endif

#define INSTR_IP(INSTR, CODE) \
Expand Down Expand Up @@ -1133,6 +1135,9 @@ _PyJit_TryInitializeTracing(
/* Set up tracing buffer*/
_PyJitUopBuffer *trace = &tracer->code_buffer;
uop_buffer_init(trace, &tracer->uop_array[0], UOP_MAX_TRACE_LENGTH);
_PyJitTracerTranslatorState *ts = &tracer->translator_state;
ts->fitness = tstate->interp->opt_config.fitness_initial;
ts->frame_depth = 0;
ADD_TO_TRACE(_START_EXECUTOR, 0, (uintptr_t)start_instr, INSTR_IP(start_instr, code));
ADD_TO_TRACE(_MAKE_WARM, 0, 0, 0);

Expand Down Expand Up @@ -1162,10 +1167,6 @@ _PyJit_TryInitializeTracing(
assert(curr_instr->op.code == JUMP_BACKWARD_JIT || curr_instr->op.code == RESUME_CHECK_JIT || (exit != NULL));
tracer->initial_state.jump_backward_instr = curr_instr;

const _PyOptimizationConfig *cfg = &tstate->interp->opt_config;
_PyJitTracerTranslatorState *ts = &tracer->translator_state;
ts->fitness = cfg->fitness_initial;
ts->frame_depth = 0;
DPRINTF(3, "Fitness init: chain_depth=%d, fitness=%d\n",
chain_depth, ts->fitness);

Expand Down Expand Up @@ -1300,6 +1301,7 @@ static void make_exit(_PyUOpInstruction *inst, int opcode, int target, bool is_c
inst->target = target;
inst->operand1 = is_control_flow;
#ifdef Py_STATS
inst->fitness = 0;
inst->execution_count = 0;
#endif
}
Expand Down Expand Up @@ -2100,8 +2102,8 @@ write_row_for_uop(_PyExecutorObject *executor, uint32_t i, FILE *out)
#ifdef Py_STATS
const char *bg_color = get_background_color(inst, executor->trace[0].execution_count);
const char *color = get_foreground_color(inst, executor->trace[0].execution_count);
fprintf(out, " <tr><td port=\"i%d\" border=\"1\" color=\"%s\" bgcolor=\"%s\" ><font color=\"%s\"> %s &nbsp;--&nbsp; %" PRIu64 "</font></td></tr>\n",
i, color, bg_color, color, opname, inst->execution_count);
fprintf(out, " <tr><td port=\"i%d\" border=\"1\" color=\"%s\" bgcolor=\"%s\" ><font color=\"%s\"> %s [%d]&nbsp;--&nbsp; %" PRIu64 "</font></td></tr>\n",
i, color, bg_color, color, opname, inst->fitness, inst->execution_count);
#else
const char *color = (_PyUop_Uncached[inst->opcode] == _DEOPT) ? RED : BLACK;
fprintf(out, " <tr><td port=\"i%d\" border=\"1\" color=\"%s\" >%s op0=%" PRIu64 "</td></tr>\n", i, color, opname, inst->operand0);
Expand Down
3 changes: 3 additions & 0 deletions Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ add_op(JitOptContext *ctx, _PyUOpInstruction *this_instr,
out->target = this_instr->target;
out->operand0 = (operand0);
out->operand1 = this_instr->operand1;
#ifdef Py_STATS
out->fitness = this_instr->fitness;
#endif
ctx->out_buffer.next++;
}

Expand Down
Loading