Skip to content

Commit a745bbd

Browse files
correct version
1 parent c868172 commit a745bbd

File tree

9 files changed

+33
-52
lines changed

9 files changed

+33
-52
lines changed

Include/internal/pycore_opcode_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_testinternalcapi/test_cases.c.h

Lines changed: 5 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,15 +2945,15 @@ dummy_func(
29452945
_SAVE_RETURN_OFFSET +
29462946
_PUSH_FRAME;
29472947

2948-
op(_LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN_FRAME, (getattribute/4, owner -- new_frame)) {
2948+
op(_LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN_FRAME, (func_version/2, getattribute/4, owner -- new_frame)) {
29492949
assert((oparg & 1) == 0);
29502950
assert(Py_IS_TYPE(getattribute, &PyFunction_Type));
29512951
PyFunctionObject *f = (PyFunctionObject *)getattribute;
2952+
assert(func_version != 0);
2953+
EXIT_IF(f->func_version != func_version);
29522954
PyCodeObject *code = (PyCodeObject *)f->func_code;
2953-
DEOPT_IF((code->co_flags & (CO_VARKEYWORDS | CO_VARARGS | CO_OPTIMIZED)) != CO_OPTIMIZED);
2954-
DEOPT_IF(code->co_kwonlyargcount);
2955-
DEOPT_IF(code->co_argcount != 2);
2956-
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize));
2955+
assert(code->co_argcount == 2);
2956+
EXIT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize));
29572957
STAT_INC(LOAD_ATTR, hit);
29582958
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 1);
29592959
_PyInterpreterFrame *pushed_frame = _PyFrame_PushUnchecked(
@@ -2969,7 +2969,6 @@ dummy_func(
29692969
_RECORD_TOS_TYPE +
29702970
_GUARD_TYPE_VERSION +
29712971
_CHECK_PEP_523 +
2972-
unused/2 +
29732972
_LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN_FRAME +
29742973
_SAVE_RETURN_OFFSET +
29752974
_PUSH_FRAME;

Python/executor_cases.c.h

Lines changed: 6 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 5 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer_bytecodes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,8 @@ dummy_func(void) {
995995
new_frame = PyJitRef_WrapInvalid(f);
996996
}
997997

998-
op(_LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN_FRAME, (getattribute/4, owner -- new_frame)) {
998+
op(_LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN_FRAME, (func_version/2, getattribute/4, owner -- new_frame)) {
999+
(void)func_version;
9991000
PyCodeObject *co = (PyCodeObject *)((PyFunctionObject *)getattribute)->func_code;
10001001
_Py_UOpsAbstractFrame *f = frame_new(ctx, co, NULL, 0);
10011002
if (f == NULL) {

Python/optimizer_cases.c.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/specialize.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,10 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
910910
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_METHOD);
911911
return -1;
912912
}
913+
uint32_t version = function_get_version(descr, LOAD_ATTR);
914+
if (version == 0) {
915+
return -1;
916+
}
913917
/* Don't specialize if PEP 523 is active */
914918
if (_PyInterpreterState_GET()->eval_frame) {
915919
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_OTHER);
@@ -921,10 +925,10 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
921925
return -1;
922926
}
923927
#endif
924-
assert(tp_version != 0);
925-
write_u32(lm_cache->type_version, tp_version);
928+
write_u32(lm_cache->keys_version, version);
926929
/* borrowed */
927930
write_ptr(lm_cache->descr, descr);
931+
write_u32(lm_cache->type_version, tp_version);
928932
specialize(instr, LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN);
929933
return 0;
930934
}

0 commit comments

Comments
 (0)