GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-114058: Foundations of the Tier2 redundancy eliminator by Fidget-Spinner · Pull Request #115085 · python/cpython Conversation
|
| _Py_UOpsSymType **stack_pointer; | ||
| _Py_UOpsSymType **stack; | ||
| _Py_UOpsSymType **locals; | ||
| } _Py_UOpsAbstractFrame; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You can use much the same layout as an actual frame and put the locals and stack at the end:
...
_Py_UOpsSymType **stack_pointer;
_Py_UOpsSymType *localsplus[1];
}
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I initially did that, but this new layout is easier for inlining, because it actually models the state if all frames were to be inlined. So it makes things like calculating the new locals offset easier.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
But we aren't inlining yet, and we might choose a different approach. Making it a single struct would make memory management simpler.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Right now making it a single struct would make memory management a little more complex, because my "frames" are just an array of static sized structs. Their localsplus is just accessing a giant pool. frame->prev is just index--. It's all rather clean. And I just need to manage memory once instead of for 7 giant frames.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we won't be doing any allocations, just reusing a buffer on the thread-state. But's that future PR.
But we still need to manage the memory within that buffer, and monolithic frames will make that simpler.
This should be fine for now, though.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
How hard would it be to change the API to take |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Quite possible. I can just convert to the internal representation internally. (The representation is just to save space, and support unions in the future). The only thing is there are some "types" that cant be represented using pytype object. In that case I will special case them. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
It is probably best to add those cases to the API. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
|
||
| #define GETLOCAL(idx) ((ctx->frame->locals[idx])) | ||
|
|
||
| #define REPLACE_OP(op, arg, oper) \ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't like macros that assume context, and we rarely (maybe never) want to set the oparg or operand.
| #define REPLACE_OP(op, arg, oper) \ | |
| #define REPLACE_OP(INST, OP) (INST)->opcode = (OP) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We will need operand once we start burning in _LOAD_CONST_INLINE and friends.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
|
||
|
|
||
| static void | ||
| remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Has this changed, or has it just moved?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I did not change it. It just moved.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // The only valid error we can raise is MemoryError. | ||
| // Other times it's not really errors but things like not being able | ||
| // to fetch a function version because the function got deleted. | ||
| return PyErr_Occurred() ? -1 : 0; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to check PyErr_Occurred()? uop_redundancy_eliminator should not be returning -1 unless an error has occurred.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In the old code, constant propagation could raise MemoryError.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Looks good now.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…onGH-115085) --------- Co-authored-by: Mark Shannon <[email protected]> Co-authored-by: Jules <[email protected]> Co-authored-by: Guido van Rossum <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.