...
This issue also applies to async functions (https://bugs.webkit.org/show_bug.cgi?id=163760), which are implemented using the same "body as a separate function" approach. This is also really the same issue which affects always storing the home object on async arrow function bodies, fixing this bug should solve both problems. I'll point those issues to this
We should follow arrow function design... Set |this| in generator function's environment and load it from the environment. Basically, using |this| inside the generator is very rare... We can avoid loading/storing it in most cases.
Created attachment 313804 [details] Patch
This is WIP patch. We still need to change async functions part. While it improves generator performance in SixSpeed, it a bit causes regression in ARES-6 Basic. This is because ARES-6 Basic's generator touches |this|. And in this case, it allocates one more JS heap environment. So, to adopt this change, we should change the current generator implementation to the more efficient one. My idea is allocating one JS environment for storing |this|, arguments and yield storing values. This fixes above regression.
<rdar://problem/113883697>