Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-131798: JIT: SplitCALL_ISINSTANCE into several uops#133339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
brandtbucher merged 9 commits intopython:mainfromtomasr8:jit-split-isinstance
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
NextNext commit
Unpack args array into separate stack variables
  • Loading branch information
@tomasr8
tomasr8 committedMay 3, 2025
commit8ba53c3db69cf9a640500ab6f2d53d0cd8dc1ace
4 changes: 2 additions & 2 deletionsInclude/internal/pycore_opcode_metadata.h
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

6 changes: 3 additions & 3 deletionsInclude/internal/pycore_uop_metadata.h
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

15 changes: 7 additions & 8 deletionsPython/bytecodes.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4353,26 +4353,25 @@ dummy_func(
res = PyStackRef_FromPyObjectSteal(res_o);
}

op(_GUARD_CALLABLE_ISINSTANCE, (callable, unused, unused[oparg]-- callable, unused, unused[oparg])) {
op(_GUARD_CALLABLE_ISINSTANCE, (callable, unused, unused, unused-- callable, unused, unused, unused)) {
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
PyInterpreterState *interp = tstate->interp;
DEOPT_IF(callable_o != interp->callable_cache.isinstance);
}

op(_CALL_ISINSTANCE, (callable, null,args[oparg] -- res)) {
op(_CALL_ISINSTANCE, (callable, null,inst_, cls -- res)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't love the trailing underscore. Not a huge deal, but maybe just rename toinstance orobj or something ?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I renamed it toinstance inbe50e24

/* isinstance(o, o2) */
assert(oparg == 2);
STAT_INC(CALL, hit);
PyObject *inst = PyStackRef_AsPyObjectBorrow(args[0]);
PyObject *cls = PyStackRef_AsPyObjectBorrow(args[1]);
int retval = PyObject_IsInstance(inst, cls);
PyObject *inst_o = PyStackRef_AsPyObjectBorrow(inst_);
PyObject *cls_o = PyStackRef_AsPyObjectBorrow(cls);
int retval = PyObject_IsInstance(inst_o, cls_o);
if (retval < 0) {
ERROR_NO_POP();
}
(void)null; // Silence compiler warnings about unused variables
PyStackRef_CLOSE(cls);
PyStackRef_CLOSE(inst_);
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Interesting that with named stackrefs it won't let me do this:

DEAD(null);PyStackRef_CLOSE(cls);PyStackRef_CLOSE(inst_);

(the error isSyntaxError: Input 'null' is not live, but 'inst_' is)
While with the previousargs version this was fine:

DEAD(null);PyStackRef_CLOSE(args[0]);PyStackRef_CLOSE(args[1]);

I guess the cases generator can't reason about arrays? Another reason to use named stackrefs instead :)

brandtbucher reacted with thumbs up emoji
DEAD(null);
PyStackRef_CLOSE(args[0]);
PyStackRef_CLOSE(args[1]);
PyStackRef_CLOSE(callable);
res = retval ? PyStackRef_True : PyStackRef_False;
assert((!PyStackRef_IsNull(res)) ^ (_PyErr_Occurred(tstate) != NULL));
Expand Down
31 changes: 17 additions & 14 deletionsPython/executor_cases.c.h
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

26 changes: 15 additions & 11 deletionsPython/generated_cases.c.h
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

2 changes: 1 addition & 1 deletionPython/optimizer_bytecodes.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1095,7 +1095,7 @@ dummy_func(void) {
res = sym_new_type(ctx, &PyLong_Type);
}

op(_GUARD_CALLABLE_ISINSTANCE, (callable, unused, unused[oparg]-- callable, unused, unused[oparg])) {
op(_GUARD_CALLABLE_ISINSTANCE, (callable, unused, unused, unused-- callable, unused, unused, unused)) {
PyObject *isinstance = _PyInterpreterState_GET()->callable_cache.isinstance;
if (sym_get_const(ctx, callable) == isinstance) {
REPLACE_OP(this_instr, _NOP, 0, 0);
Expand Down
6 changes: 3 additions & 3 deletionsPython/optimizer_cases.c.h
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp