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:
With the JIT and better tier 2 optimizations, effective specialization is becoming more important that plain speed in tier 1.
BEFORE_WITH
andBEFORE_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 aLOAD_SPECIAL
instruction for loading dunder methods and replaceBEFORE_WITH
as follows:Likewise for
BEFORE_ASYNC_WITH
.Even without any specialization of
LOAD_SPECIAL
, theCALL
will be specialized and the JIT can eliminate theCOPY
andSWAP
s.