-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Description
With the JIT and better tier 2 optimizations, effective specialization is becoming more important that plain speed in tier 1.
BEFORE_WITH and BEFORE_ASYNC_WITH could be specialized, but they are bulky and won't optimize well in tier 2.
Instead, we should lower them to attribute lookups and calls which can then be optimized.
We should add a LOAD_SPECIAL instruction for loading dunder methods and replace BEFORE_WITH as follows:
COPY 1
LOAD_SPECIAL __enter__ + NULL|self
SWAP 3
LOAD_SPECIAL __exit__
SWAP 3
CALL 0
Likewise for BEFORE_ASYNC_WITH.
Even without any specialization of LOAD_SPECIAL, the CALL will be specialized and the JIT can eliminate the COPY and SWAPs.
Linked PRs
Metadata
Metadata
Assignees
Labels
No labels