Skip to content

gh-106603: Make uop struct a triple (opcode, oparg, operand) - #106794

Merged
gvanrossum merged 6 commits into
python:mainfrom
gvanrossum:add-oparg
Jul 17, 2023
Merged

gh-106603: Make uop struct a triple (opcode, oparg, operand)#106794
gvanrossum merged 6 commits into
python:mainfrom
gvanrossum:add-oparg

Conversation

@gvanrossum

@gvanrossumgvanrossum commented Jul 15, 2023

Copy link
Copy Markdown
Member

Almost everything that used to go in operand now goes in oparg, except cache entries, which go into operand. This way a uop can have an oparg and a cache entry, which is much more convenient for splitting the more complex CALL specializations into uops. Most of the complexity (and debugging :-( ) went into optimizer.c.

As a side effect, without any extra work, we have four new viable uops:

  • STORE_ATTR (unspecialized, but still)
  • _LOAD_GLOBAL_MODULE
  • _LOAD_GLOBAL_BUILTINS
  • _LOAD_ATTR_INSTANCE_VALUE

The Python API (iterating over a uop executor) now returns triples (opname, oparg, operand).

Comment threadPython/bytecodes.c
Comment on lines -652 to +655
inst(STORE_SUBSCR, (counter/1, v, container, sub -- )) {
inst(STORE_SUBSCR, (unused/1, v, container, sub -- )) {
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
_PyStoreSubscrCache *cache = (_PyStoreSubscrCache *)next_instr;
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

This change simply follows the vast majority of other unspecialized opcodes.

@gvanrossum

Copy link
Copy Markdown
MemberAuthor

@markshannon Can you review this?

@gvanrossum
gvanrossum merged commit 8e9a1a0 into python:mainJul 17, 2023
@gvanrossum
gvanrossum deleted the add-oparg branch July 17, 2023 19:12
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@gvanrossum@bedevere-bot