extern void _PyCode_Clear_Executors(PyCodeObject *code);
-#ifdef Py_GIL_DISABLED
-// gh-115999 tracks progress on addressing this.
-#define ENABLE_SPECIALIZATION 0
-// Use this to enable specialization families once they are thread-safe. All
-// uses will be replaced with ENABLE_SPECIALIZATION once all families are
-// thread-safe.
-#define ENABLE_SPECIALIZATION_FT 1
-#else
#define ENABLE_SPECIALIZATION 1
-#define ENABLE_SPECIALIZATION_FT ENABLE_SPECIALIZATION
-#endif
/* Specialization functions, these are exported only for other re-generated
* interpreters to call */
_opcode.ENABLE_SPECIALIZATION, "requires specialization")(test)
-def requires_specialization_ft(test):
- return unittest.skipUnless(
- _opcode.ENABLE_SPECIALIZATION_FT, "requires specialization")(test)
-
-
def reset_code(f: types.FunctionType) -> types.FunctionType:
"""Clear all specializations, local instrumentation, and JIT code for the given function."""
f.__code__ = f.__code__.replace()
import unittest
import test.support
-from test.support import import_helper, requires_specialization_ft, script_helper
+from test.support import import_helper, requires_specialization, script_helper
_testcapi = import_helper.import_module("_testcapi")
_testinternalcapi = import_helper.import_module("_testinternalcapi")
)
self.assertEqual(events[0], ("throw", IndexError))
- @requires_specialization_ft
+ @requires_specialization
def test_no_unwind_for_shim_frame(self):
class ValueErrorRaiser:
def __init__(self):
import types
import unittest
from test.support import (threading_helper, check_impl_detail,
- requires_specialization, requires_specialization_ft,
+ requires_specialization,
cpython_only, requires_jit_disabled, reset_code)
from test.support.import_helper import import_module
f()
@requires_jit_disabled
- @requires_specialization_ft
+ @requires_specialization
def test_assign_init_code(self):
class MyClass:
def __init__(self):
instantiate()
@requires_jit_disabled
- @requires_specialization_ft
+ @requires_specialization
def test_push_init_frame_fails(self):
def instantiate():
return InitTakesArg()
f()
@requires_jit_disabled
- @requires_specialization_ft
+ @requires_specialization
def test_specialize_call_function_ex_py(self):
def ex_py(*args, **kwargs):
return 1
self.assert_specialized(instantiate, "CALL_EX_PY")
@requires_jit_disabled
- @requires_specialization_ft
+ @requires_specialization
def test_specialize_call_function_ex_py_fail(self):
def ex_py(*args, **kwargs):
return 1
for writer in writers:
writer.join()
- @requires_specialization_ft
+ @requires_specialization
def test_binary_subscr_getitem(self):
def get_items():
class C:
opname = "BINARY_OP_SUBSCR_GETITEM"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_binary_subscr_list_int(self):
def get_items():
items = []
opname = "FOR_ITER_LIST"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_load_attr_class(self):
def get_items():
class C:
opname = "LOAD_ATTR_CLASS"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_load_attr_class_with_metaclass_check(self):
def get_items():
class Meta(type):
opname = "LOAD_ATTR_CLASS_WITH_METACLASS_CHECK"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_load_attr_getattribute_overridden(self):
def get_items():
class C:
opname = "LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_load_attr_instance_value(self):
def get_items():
class C:
opname = "LOAD_ATTR_INSTANCE_VALUE"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_load_attr_method_lazy_dict(self):
def get_items():
class C(Exception):
opname = "LOAD_ATTR_METHOD_LAZY_DICT"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_load_attr_method_no_dict(self):
def get_items():
class C:
opname = "LOAD_ATTR_METHOD_NO_DICT"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_load_attr_method_with_values(self):
def get_items():
class C:
opname = "LOAD_ATTR_METHOD_WITH_VALUES"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_load_attr_module(self):
def get_items():
items = []
opname = "LOAD_ATTR_MODULE"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_load_attr_property(self):
def get_items():
class C:
opname = "LOAD_ATTR_PROPERTY"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_load_attr_slot(self):
def get_items():
class C:
opname = "LOAD_ATTR_SLOT"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_load_attr_with_hint(self):
def get_items():
class C:
opname = "LOAD_ATTR_WITH_HINT"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_load_global_module(self):
if not have_dict_key_versions():
raise unittest.SkipTest("Low on dict key versions")
opname = "STORE_ATTR_WITH_HINT"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_store_subscr_list_int(self):
def get_items():
items = []
opname = "STORE_SUBSCR_LIST_INT"
self.assert_races_do_not_crash(opname, get_items, read, write)
- @requires_specialization_ft
+ @requires_specialization
def test_unpack_sequence_list(self):
def get_items():
items = []
class TestSpecializer(TestBase):
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_binary_op(self):
def binary_op_add_int():
for _ in range(_testinternalcapi.SPECIALIZATION_THRESHOLD):
self.assert_no_opcode(binary_op_bitwise_extend, "BINARY_OP")
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_load_super_attr(self):
"""Ensure that LOAD_SUPER_ATTR is specialized as expected."""
self.assert_no_opcode(A.__init__, "LOAD_SUPER_ATTR_METHOD")
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_contain_op(self):
def contains_op_dict():
for _ in range(_testinternalcapi.SPECIALIZATION_THRESHOLD):
self.assert_no_opcode(contains_op_set, "CONTAINS_OP")
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_send_with(self):
def run_async(coro):
while True:
self.assert_specialized(send_with, "SEND_GEN")
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_send_yield_from(self):
def g():
yield None
self.assert_no_opcode(send_yield_from, "SEND")
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_store_attr_slot(self):
class C:
__slots__ = ['x']
self.assert_no_opcode(set_slot, "STORE_ATTR_SLOT")
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_store_attr_instance_value(self):
class C:
pass
self.assert_no_opcode(set_value, "STORE_ATTR_INSTANCE_VALUE")
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_store_attr_with_hint(self):
class C:
pass
self.assert_no_opcode(set_value, "STORE_ATTR_WITH_HINT")
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_to_bool(self):
def to_bool_bool():
true_cnt, false_cnt = 0, 0
self.assert_no_opcode(to_bool_str, "TO_BOOL")
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_unpack_sequence(self):
def unpack_sequence_two_tuple():
for _ in range(_testinternalcapi.SPECIALIZATION_THRESHOLD):
self.assert_no_opcode(unpack_sequence_list, "UNPACK_SEQUENCE")
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_binary_subscr(self):
def binary_subscr_list_int():
for _ in range(_testinternalcapi.SPECIALIZATION_THRESHOLD):
self.assert_no_opcode(binary_subscr_getitems, "BINARY_OP")
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_compare_op(self):
def compare_op_int():
for _ in range(_testinternalcapi.SPECIALIZATION_THRESHOLD):
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_for_iter(self):
L = list(range(10))
def for_iter_list():
self.assert_no_opcode(for_iter_generator, "FOR_ITER")
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_call_list_append(self):
# gh-141367: only exact lists should use
# CALL_LIST_APPEND instruction after specialization.
self.assert_no_opcode(my_list_append, "CALL")
@cpython_only
- @requires_specialization_ft
+ @requires_specialization
def test_load_attr_module_with_getattr(self):
module = types.ModuleType("test_module_with_getattr")
module.__dict__["some_attr"] = "foo"
import unittest
from test import support
-from test.support import cpython_only, import_helper, requires_specialization_ft
+from test.support import cpython_only, import_helper, requires_specialization
from test.support.script_helper import assert_python_ok
from test.support.threading_helper import requires_working_threading
@requires_working_threading()
@unittest.skipUnless(support.Py_GIL_DISABLED, "only in free-threaded builds")
class TLBCTests(unittest.TestCase):
- @requires_specialization_ft
+ @requires_specialization
def test_new_threads_start_with_unspecialized_code(self):
code = textwrap.dedent("""
import dis
""")
assert_python_ok("-X", "tlbc=1", "-c", code)
- @requires_specialization_ft
+ @requires_specialization
def test_threads_specialize_independently(self):
code = textwrap.dedent("""
import dis
import unittest
import warnings
from test import support
-from test.support import import_helper, requires_specialization, requires_specialization_ft
+from test.support import import_helper, requires_specialization
try:
from sys import _clear_type_cache
except ImportError:
self._check_specialization(store_bar_2, B(), "STORE_ATTR", should_specialize=False)
- @requires_specialization_ft
+ @requires_specialization
def test_class_call_specialization_user_type(self):
class F:
def __init__(self):
if (PyModule_AddIntMacro(m, ENABLE_SPECIALIZATION) < 0) {
return -1;
}
- if (PyModule_AddIntMacro(m, ENABLE_SPECIALIZATION_FT) < 0) {
- return -1;
- }
return 0;
}
lhs = stack_pointer[-2];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(BINARY_OP);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
assert(NB_ADD <= oparg);
assert(oparg <= NB_OPARG_LAST);
}
callable = stack_pointer[-2 - oparg];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(CALL);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
/* Skip 2 cache entries */
// _MAYBE_EXPAND_METHOD
func = stack_pointer[-4];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(CALL_FUNCTION_EX);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _MAKE_CALLARGS_A_TUPLE
{
callable = stack_pointer[-3 - oparg];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(CALL_KW);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
/* Skip 2 cache entries */
// _MAYBE_EXPAND_METHOD_KW
left = stack_pointer[-2];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(COMPARE_OP);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _COMPARE_OP
{
right = stack_pointer[-1];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(CONTAINS_OP);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _CONTAINS_OP
{
iter = stack_pointer[-2];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(FOR_ITER);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _FOR_ITER
{
owner = stack_pointer[-1];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
next_instr = this_instr;
}
OPCODE_DEFERRED_INC(LOAD_ATTR);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
/* Skip 8 cache entries */
// _LOAD_ATTR
{
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
next_instr = this_instr;
}
OPCODE_DEFERRED_INC(LOAD_GLOBAL);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
/* Skip 1 cache entry */
/* Skip 1 cache entry */
global_super_st = stack_pointer[-3];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
int load_method = oparg & 1;
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
}
OPCODE_DEFERRED_INC(LOAD_SUPER_ATTR);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _LOAD_SUPER_ATTR
{
}
// _QUICKEN_RESUME
{
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (tstate->tracing == 0 && this_instr->op.code == RESUME) {
FT_ATOMIC_STORE_UINT8_RELAXED(this_instr->op.code, RESUME_CHECK);
}
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _CHECK_PERIODIC_IF_NOT_YIELD_FROM
{
receiver = stack_pointer[-2];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(SEND);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _SEND
{
owner = stack_pointer[-1];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
next_instr = this_instr;
}
OPCODE_DEFERRED_INC(STORE_ATTR);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
/* Skip 3 cache entries */
// _STORE_ATTR
container = stack_pointer[-2];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(STORE_SUBSCR);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _STORE_SUBSCR
{
value = stack_pointer[-1];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(TO_BOOL);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
/* Skip 2 cache entries */
// _TO_BOOL
seq = stack_pointer[-1];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(UNPACK_SEQUENCE);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
(void)seq;
(void)counter;
}
}
op(_QUICKEN_RESUME, (--)) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (tstate->tracing == 0 && this_instr->op.code == RESUME) {
FT_ATOMIC_STORE_UINT8_RELAXED(this_instr->op.code, RESUME_CHECK);
}
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
tier1 op(_MAYBE_INSTRUMENT, (--)) {
};
specializing op(_SPECIALIZE_TO_BOOL, (counter/1, value -- value)) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_Py_Specialize_ToBool(value, next_instr);
}
OPCODE_DEFERRED_INC(TO_BOOL);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
op(_TO_BOOL, (value -- res)) {
};
specializing op(_SPECIALIZE_STORE_SUBSCR, (counter/1, container, sub -- container, sub)) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_Py_Specialize_StoreSubscr(container, sub, next_instr);
}
OPCODE_DEFERRED_INC(STORE_SUBSCR);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
op(_STORE_SUBSCR, (v, container, sub -- )) {
};
specializing op(_SPECIALIZE_SEND, (counter/1, receiver, unused -- receiver, unused)) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_Py_Specialize_Send(receiver, next_instr);
}
OPCODE_DEFERRED_INC(SEND);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
op(_SEND, (receiver, v -- receiver, retval)) {
};
specializing op(_SPECIALIZE_UNPACK_SEQUENCE, (counter/1, seq -- seq)) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_Py_Specialize_UnpackSequence(seq, next_instr, oparg);
}
OPCODE_DEFERRED_INC(UNPACK_SEQUENCE);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
(void)seq;
(void)counter;
}
};
specializing op(_SPECIALIZE_STORE_ATTR, (counter/1, owner -- owner)) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
next_instr = this_instr;
}
OPCODE_DEFERRED_INC(STORE_ATTR);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
op(_STORE_ATTR, (v, owner --)) {
};
specializing op(_SPECIALIZE_LOAD_GLOBAL, (counter/1 -- )) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
next_instr = this_instr;
}
OPCODE_DEFERRED_INC(LOAD_GLOBAL);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// res[1] because we need a pointer to res to pass it to _PyEval_LoadGlobalStackRef
};
specializing op(_SPECIALIZE_LOAD_SUPER_ATTR, (counter/1, global_super_st, class_st, unused -- global_super_st, class_st, unused)) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
int load_method = oparg & 1;
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
}
OPCODE_DEFERRED_INC(LOAD_SUPER_ATTR);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
tier1 op(_LOAD_SUPER_ATTR, (global_super_st, class_st, self_st -- attr)) {
};
specializing op(_SPECIALIZE_LOAD_ATTR, (counter/1, owner -- owner)) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
next_instr = this_instr;
}
OPCODE_DEFERRED_INC(LOAD_ATTR);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
op(_LOAD_ATTR, (owner -- attr, self_or_null[oparg&1])) {
};
specializing op(_SPECIALIZE_COMPARE_OP, (counter/1, left, right -- left, right)) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_Py_Specialize_CompareOp(left, right, next_instr, oparg);
}
OPCODE_DEFERRED_INC(COMPARE_OP);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
op(_COMPARE_OP, (left, right -- res)) {
}
specializing op(_SPECIALIZE_CONTAINS_OP, (counter/1, left, right -- left, right)) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_Py_Specialize_ContainsOp(right, next_instr);
}
OPCODE_DEFERRED_INC(CONTAINS_OP);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
macro(CONTAINS_OP) = _SPECIALIZE_CONTAINS_OP + _CONTAINS_OP + POP_TOP + POP_TOP;
};
specializing op(_SPECIALIZE_FOR_ITER, (counter/1, iter, null_or_index -- iter, null_or_index)) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_Py_Specialize_ForIter(iter, null_or_index, next_instr, oparg);
}
OPCODE_DEFERRED_INC(FOR_ITER);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
replaced op(_FOR_ITER, (iter, null_or_index -- iter, null_or_index, next)) {
};
specializing op(_SPECIALIZE_CALL, (counter/1, callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_Py_Specialize_Call(callable, self_or_null, next_instr, oparg + !PyStackRef_IsNull(self_or_null));
}
OPCODE_DEFERRED_INC(CALL);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
op(_MAYBE_EXPAND_METHOD, (callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) {
_PUSH_FRAME;
specializing op(_SPECIALIZE_CALL_KW, (counter/1, callable, self_or_null, unused[oparg], unused -- callable, self_or_null, unused[oparg], unused)) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_Py_Specialize_CallKw(callable, next_instr, oparg + !PyStackRef_IsNull(self_or_null));
}
OPCODE_DEFERRED_INC(CALL_KW);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
macro(CALL_KW) =
}
specializing op(_SPECIALIZE_CALL_FUNCTION_EX, (counter/1, func, unused, unused, unused -- func, unused, unused, unused)) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_Py_Specialize_CallFunctionEx(func, next_instr);
}
OPCODE_DEFERRED_INC(CALL_FUNCTION_EX);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
macro(CALL_FUNCTION_EX) =
}
specializing op(_SPECIALIZE_BINARY_OP, (counter/1, lhs, rhs -- lhs, rhs)) {
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, LOCALS_ARRAY);
}
OPCODE_DEFERRED_INC(BINARY_OP);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
assert(NB_ADD <= oparg);
assert(oparg <= NB_OPARG_LAST);
}
#undef ENABLE_SPECIALIZATION
#define ENABLE_SPECIALIZATION 0
-#undef ENABLE_SPECIALIZATION_FT
-#define ENABLE_SPECIALIZATION_FT 0
uint16_t uopcode;
#ifdef Py_STATS
(COUNTER) = pause_backoff_counter((COUNTER)); \
} while (0);
-#ifdef ENABLE_SPECIALIZATION_FT
+#ifdef ENABLE_SPECIALIZATION
/* Multiple threads may execute these concurrently if thread-local bytecode is
* disabled and they all execute the main copy of the bytecode. Specialization
* is disabled in that case so the value is unused, but the RMW cycle should be
lhs = stack_pointer[-2];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(BINARY_OP);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
assert(NB_ADD <= oparg);
assert(oparg <= NB_OPARG_LAST);
}
callable = stack_pointer[-2 - oparg];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(CALL);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
/* Skip 2 cache entries */
// _MAYBE_EXPAND_METHOD
func = stack_pointer[-4];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(CALL_FUNCTION_EX);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _MAKE_CALLARGS_A_TUPLE
{
callable = stack_pointer[-3 - oparg];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(CALL_KW);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
/* Skip 2 cache entries */
// _MAYBE_EXPAND_METHOD_KW
left = stack_pointer[-2];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(COMPARE_OP);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _COMPARE_OP
{
right = stack_pointer[-1];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(CONTAINS_OP);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _CONTAINS_OP
{
iter = stack_pointer[-2];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(FOR_ITER);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _FOR_ITER
{
owner = stack_pointer[-1];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
next_instr = this_instr;
}
OPCODE_DEFERRED_INC(LOAD_ATTR);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
/* Skip 8 cache entries */
// _LOAD_ATTR
{
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
next_instr = this_instr;
}
OPCODE_DEFERRED_INC(LOAD_GLOBAL);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
/* Skip 1 cache entry */
/* Skip 1 cache entry */
global_super_st = stack_pointer[-3];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
int load_method = oparg & 1;
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
}
OPCODE_DEFERRED_INC(LOAD_SUPER_ATTR);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _LOAD_SUPER_ATTR
{
}
// _QUICKEN_RESUME
{
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (tstate->tracing == 0 && this_instr->op.code == RESUME) {
FT_ATOMIC_STORE_UINT8_RELAXED(this_instr->op.code, RESUME_CHECK);
}
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _CHECK_PERIODIC_IF_NOT_YIELD_FROM
{
receiver = stack_pointer[-2];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(SEND);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _SEND
{
owner = stack_pointer[-1];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
next_instr = this_instr;
}
OPCODE_DEFERRED_INC(STORE_ATTR);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
/* Skip 3 cache entries */
// _STORE_ATTR
container = stack_pointer[-2];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(STORE_SUBSCR);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
// _STORE_SUBSCR
{
value = stack_pointer[-1];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(TO_BOOL);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
/* Skip 2 cache entries */
// _TO_BOOL
seq = stack_pointer[-1];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
}
OPCODE_DEFERRED_INC(UNPACK_SEQUENCE);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
(void)seq;
(void)counter;
}
void
_PyCode_Quicken(_Py_CODEUNIT *instructions, Py_ssize_t size, int enable_counters)
{
- #if ENABLE_SPECIALIZATION_FT
+ #if ENABLE_SPECIALIZATION
_Py_BackoffCounter jump_counter, adaptive_counter;
if (enable_counters) {
PyThreadState *tstate = _PyThreadState_GET();
oparg = 0;
}
}
- #endif /* ENABLE_SPECIALIZATION_FT */
+ #endif /* ENABLE_SPECIALIZATION */
}
#define SIMPLE_FUNCTION 0
PyObject *global_super = PyStackRef_AsPyObjectBorrow(global_super_st);
PyObject *cls = PyStackRef_AsPyObjectBorrow(cls_st);
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[LOAD_SUPER_ATTR] == INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR);
if (global_super != (PyObject *)&PySuper_Type) {
SPECIALIZATION_FAIL(LOAD_SUPER_ATTR, SPEC_FAIL_SUPER_SHADOWED);
{
PyObject *owner = PyStackRef_AsPyObjectBorrow(owner_st);
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[LOAD_ATTR] == INLINE_CACHE_ENTRIES_LOAD_ATTR);
PyTypeObject *type = Py_TYPE(owner);
bool fail;
{
PyObject *owner = PyStackRef_AsPyObjectBorrow(owner_st);
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[STORE_ATTR] == INLINE_CACHE_ENTRIES_STORE_ATTR);
PyObject *descr = NULL;
_PyAttrCache *cache = (_PyAttrCache *)(instr + 1);
PyObject *globals, PyObject *builtins,
_Py_CODEUNIT *instr, PyObject *name)
{
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[LOAD_GLOBAL] == INLINE_CACHE_ENTRIES_LOAD_GLOBAL);
/* Use inline cache */
_PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)(instr + 1);
PyObject *container = PyStackRef_AsPyObjectBorrow(container_st);
PyObject *sub = PyStackRef_AsPyObjectBorrow(sub_st);
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
PyTypeObject *container_type = Py_TYPE(container);
if (container_type == &PyList_Type) {
if (PyLong_CheckExact(sub)) {
{
PyObject *callable = PyStackRef_AsPyObjectBorrow(callable_st);
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[CALL] == INLINE_CACHE_ENTRIES_CALL);
assert(_Py_OPCODE(*instr) != INSTRUMENTED_CALL);
int fail;
{
PyObject *callable = PyStackRef_AsPyObjectBorrow(callable_st);
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[CALL_KW] == INLINE_CACHE_ENTRIES_CALL_KW);
assert(_Py_OPCODE(*instr) != INSTRUMENTED_CALL_KW);
int fail;
{
PyObject *lhs = PyStackRef_AsPyObjectBorrow(lhs_st);
PyObject *rhs = PyStackRef_AsPyObjectBorrow(rhs_st);
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[BINARY_OP] == INLINE_CACHE_ENTRIES_BINARY_OP);
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)(instr + 1);
PyObject *rhs = PyStackRef_AsPyObjectBorrow(rhs_st);
uint8_t specialized_op;
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[COMPARE_OP] == INLINE_CACHE_ENTRIES_COMPARE_OP);
// All of these specializations compute boolean values, so they're all valid
// regardless of the fifth-lowest oparg bit.
{
PyObject *seq = PyStackRef_AsPyObjectBorrow(seq_st);
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[UNPACK_SEQUENCE] ==
INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE);
if (PyTuple_CheckExact(seq)) {
Py_NO_INLINE void
_Py_Specialize_ForIter(_PyStackRef iter, _PyStackRef null_or_index, _Py_CODEUNIT *instr, int oparg)
{
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[FOR_ITER] == INLINE_CACHE_ENTRIES_FOR_ITER);
PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter);
PyTypeObject *tp = Py_TYPE(iter_o);
if (PyStackRef_IsNull(null_or_index)) {
+ if (tp == &PyRangeIter_Type) {
#ifdef Py_GIL_DISABLED
- // Only specialize for uniquely referenced iterators, so that we know
- // they're only referenced by this one thread. This is more limiting
- // than we need (even `it = iter(mylist); for item in it:` won't get
- // specialized) but we don't have a way to check whether we're the only
- // _thread_ who has access to the object.
- if (!_PyObject_IsUniquelyReferenced(iter_o)) {
- goto failure;
- }
+ // Only specialize for uniquely referenced iterators, so that we know
+ // they're only referenced by this one thread. This is more limiting
+ // than we need (even `it = iter(mylist); for item in it:` won't get
+ // specialized) but we don't have a way to check whether we're the only
+ // _thread_ who has access to the object.
+ if (!_PyObject_IsUniquelyReferenced(iter_o)) {
+ goto failure;
+ }
#endif
- if (tp == &PyRangeIter_Type) {
specialize(instr, FOR_ITER_RANGE);
return;
}
else if (tp == &PyGen_Type && oparg <= SHRT_MAX) {
- // Generators are very much not thread-safe, so don't worry about
- // the specialization not being thread-safe.
assert(instr[oparg + INLINE_CACHE_ENTRIES_FOR_ITER + 1].op.code == END_FOR ||
instr[oparg + INLINE_CACHE_ENTRIES_FOR_ITER + 1].op.code == INSTRUMENTED_END_FOR
);
{
PyObject *receiver = PyStackRef_AsPyObjectBorrow(receiver_st);
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[SEND] == INLINE_CACHE_ENTRIES_SEND);
PyTypeObject *tp = Py_TYPE(receiver);
if (tp == &PyGen_Type || tp == &PyCoro_Type) {
{
PyObject *func = PyStackRef_AsPyObjectBorrow(func_st);
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[CALL_FUNCTION_EX] == INLINE_CACHE_ENTRIES_CALL_FUNCTION_EX);
if (Py_TYPE(func) == &PyFunction_Type &&
Py_NO_INLINE void
_Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
{
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[TO_BOOL] == INLINE_CACHE_ENTRIES_TO_BOOL);
_PyToBoolCache *cache = (_PyToBoolCache *)(instr + 1);
PyObject *value = PyStackRef_AsPyObjectBorrow(value_o);
{
PyObject *value = PyStackRef_AsPyObjectBorrow(value_st);
- assert(ENABLE_SPECIALIZATION_FT);
+ assert(ENABLE_SPECIALIZATION);
assert(_PyOpcode_Caches[CONTAINS_OP] == INLINE_CACHE_ENTRIES_COMPARE_OP);
if (PyDict_CheckExact(value)) {
specialize(instr, CONTAINS_OP_DICT);