mirror of
https://github.com/python/cpython.git
synced 2026-04-20 10:51:00 +00:00
gh-148211: refactor bool to explicit uops in JIT (GH-148258)
This commit is contained in:
parent
efde4333bf
commit
b5ccf00bd6
3 changed files with 64 additions and 57 deletions
|
|
@ -536,21 +536,24 @@ dummy_func(void) {
|
|||
}
|
||||
|
||||
op(_TO_BOOL, (value -- res)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res, false);
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res,
|
||||
_POP_TOP, _LOAD_CONST_INLINE_BORROW);
|
||||
if (!already_bool) {
|
||||
res = sym_new_truthiness(ctx, value, true);
|
||||
}
|
||||
}
|
||||
|
||||
op(_TO_BOOL_BOOL, (value -- value)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &value, false);
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &value,
|
||||
_POP_TOP, _LOAD_CONST_INLINE_BORROW);
|
||||
if (!already_bool) {
|
||||
sym_set_type(value, &PyBool_Type);
|
||||
}
|
||||
}
|
||||
|
||||
op(_TO_BOOL_INT, (value -- res, v)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res, true);
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res,
|
||||
_NOP, _INSERT_1_LOAD_CONST_INLINE_BORROW);
|
||||
if (!already_bool) {
|
||||
sym_set_type(value, &PyLong_Type);
|
||||
res = sym_new_truthiness(ctx, value, true);
|
||||
|
|
@ -559,7 +562,8 @@ dummy_func(void) {
|
|||
}
|
||||
|
||||
op(_TO_BOOL_LIST, (value -- res, v)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res, true);
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res,
|
||||
_NOP, _INSERT_1_LOAD_CONST_INLINE_BORROW);
|
||||
if (!already_bool) {
|
||||
res = sym_new_type(ctx, &PyBool_Type);
|
||||
}
|
||||
|
|
@ -567,7 +571,8 @@ dummy_func(void) {
|
|||
}
|
||||
|
||||
op(_TO_BOOL_NONE, (value -- res)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res, false);
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res,
|
||||
_POP_TOP, _LOAD_CONST_INLINE_BORROW);
|
||||
if (!already_bool) {
|
||||
sym_set_const(value, Py_None);
|
||||
res = sym_new_const(ctx, Py_False);
|
||||
|
|
@ -593,7 +598,8 @@ dummy_func(void) {
|
|||
}
|
||||
|
||||
op(_TO_BOOL_STR, (value -- res, v)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res, true);
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res,
|
||||
_NOP, _INSERT_1_LOAD_CONST_INLINE_BORROW);
|
||||
v = value;
|
||||
if (!already_bool) {
|
||||
res = sym_new_truthiness(ctx, value, true);
|
||||
|
|
@ -837,7 +843,8 @@ dummy_func(void) {
|
|||
if (watched_mutations < _Py_MAX_ALLOWED_GLOBALS_MODIFICATIONS) {
|
||||
PyDict_Watch(GLOBALS_WATCHER_ID, dict);
|
||||
_Py_BloomFilter_Add(dependencies, dict);
|
||||
PyObject *res = convert_global_to_const(this_instr, dict, true);
|
||||
PyObject *res = convert_global_to_const(this_instr, dict,
|
||||
_INSERT_1_LOAD_CONST_INLINE_BORROW, _INSERT_1_LOAD_CONST_INLINE);
|
||||
if (res == NULL) {
|
||||
attr = sym_new_not_null(ctx);
|
||||
}
|
||||
|
|
@ -890,7 +897,7 @@ dummy_func(void) {
|
|||
PyTypeObject *type = (PyTypeObject *)sym_get_const(ctx, owner);
|
||||
PyObject *name = get_co_name(ctx, oparg >> 1);
|
||||
attr = lookup_attr(ctx, dependencies, this_instr, type, name,
|
||||
true);
|
||||
_POP_TOP, _LOAD_CONST_INLINE_BORROW, _LOAD_CONST_INLINE);
|
||||
}
|
||||
|
||||
op(_LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES, (descr/4, owner -- attr)) {
|
||||
|
|
@ -898,7 +905,7 @@ dummy_func(void) {
|
|||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = get_co_name(ctx, oparg >> 1);
|
||||
attr = lookup_attr(ctx, dependencies, this_instr, type, name,
|
||||
true);
|
||||
_POP_TOP, _LOAD_CONST_INLINE_BORROW, _LOAD_CONST_INLINE);
|
||||
}
|
||||
|
||||
op(_LOAD_ATTR_NONDESCRIPTOR_NO_DICT, (descr/4, owner -- attr)) {
|
||||
|
|
@ -906,7 +913,7 @@ dummy_func(void) {
|
|||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = get_co_name(ctx, oparg >> 1);
|
||||
attr = lookup_attr(ctx, dependencies, this_instr, type, name,
|
||||
true);
|
||||
_POP_TOP, _LOAD_CONST_INLINE_BORROW, _LOAD_CONST_INLINE);
|
||||
}
|
||||
|
||||
op(_LOAD_ATTR_METHOD_WITH_VALUES, (descr/4, owner -- attr, self)) {
|
||||
|
|
@ -914,7 +921,7 @@ dummy_func(void) {
|
|||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = get_co_name(ctx, oparg >> 1);
|
||||
attr = lookup_attr(ctx, dependencies, this_instr, type, name,
|
||||
false);
|
||||
_NOP, _INSERT_1_LOAD_CONST_INLINE_BORROW, _INSERT_1_LOAD_CONST_INLINE);
|
||||
self = owner;
|
||||
}
|
||||
|
||||
|
|
@ -923,7 +930,7 @@ dummy_func(void) {
|
|||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = get_co_name(ctx, oparg >> 1);
|
||||
attr = lookup_attr(ctx, dependencies, this_instr, type, name,
|
||||
false);
|
||||
_NOP, _INSERT_1_LOAD_CONST_INLINE_BORROW, _INSERT_1_LOAD_CONST_INLINE);
|
||||
self = owner;
|
||||
}
|
||||
|
||||
|
|
@ -932,7 +939,7 @@ dummy_func(void) {
|
|||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = get_co_name(ctx, oparg >> 1);
|
||||
attr = lookup_attr(ctx, dependencies, this_instr, type, name,
|
||||
false);
|
||||
_NOP, _INSERT_1_LOAD_CONST_INLINE_BORROW, _INSERT_1_LOAD_CONST_INLINE);
|
||||
self = owner;
|
||||
}
|
||||
|
||||
|
|
@ -2007,7 +2014,8 @@ dummy_func(void) {
|
|||
ctx->builtins_watched = true;
|
||||
}
|
||||
if (ctx->frame->globals_checked_version != 0 && ctx->frame->globals_watched) {
|
||||
cnst = convert_global_to_const(this_instr, builtins, false);
|
||||
cnst = convert_global_to_const(this_instr, builtins,
|
||||
_LOAD_CONST_INLINE_BORROW, _LOAD_CONST_INLINE);
|
||||
}
|
||||
}
|
||||
if (cnst == NULL) {
|
||||
|
|
@ -2046,7 +2054,8 @@ dummy_func(void) {
|
|||
ctx->frame->globals_checked_version = version;
|
||||
}
|
||||
if (ctx->frame->globals_checked_version == version) {
|
||||
cnst = convert_global_to_const(this_instr, globals, false);
|
||||
cnst = convert_global_to_const(this_instr, globals,
|
||||
_LOAD_CONST_INLINE_BORROW, _LOAD_CONST_INLINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue