Bug 151586 - [ES6] Propagate `this` usage from Generator's scope to GeneratorFunction's scope to avoid unnecessary `to_this` call.
Summary: [ES6] Propagate `this` usage from Generator's scope to GeneratorFunction's sc...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-11-24 02:00 PST by Yusuke Suzuki
Modified: 2023-08-14 18:40 PDT (History)
4 users (show)

See Also:


Attachments
Patch (22.48 KB, patch)
2017-06-25 08:36 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2015-11-24 02:00:45 PST
...
Comment 1 Caitlin Potter (:caitp) 2016-10-28 09:37:05 PDT
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
Comment 2 Yusuke Suzuki 2017-06-22 09:38:31 PDT
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.
Comment 3 Yusuke Suzuki 2017-06-25 08:36:46 PDT
Created attachment 313804 [details]
Patch
Comment 4 Yusuke Suzuki 2017-06-25 08:40:09 PDT
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.
Comment 5 Radar WebKit Bug Importer 2023-08-14 18:40:46 PDT
<rdar://problem/113883697>