Bug 237841 - [JSC] Eliminate dead bytecode locals
Summary: [JSC] Eliminate dead bytecode locals
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-03-14 10:42 PDT by Robin Morisset
Modified: 2022-03-21 10:43 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Morisset 2022-03-14 10:42:09 PDT
The bytecode generator tends to allocate more locals than strictly necessary. I saw quite a few examples, e.g. allocating two locals for the scope even when the function is simple enough to only need one:
[   0] enter              
[   1] get_scope          dst:loc4
[   3] mov                dst:loc5, src:loc4
[   6] check_traps  
Where loc5 is completely unused afterwards

I can think of two ways to solve this:
- either going carefully through a bunch of examples and for each one finding all dead locals, tracking where it came from and fixing this particular part of the bytecode generator
- or just adding a generic dead local elimination phase to the bytecode generator.

The latter seems easier, but the former is less likely to cause a perf regression.

The memory benefit here should be tiny, but I would expect some significant win in DFG compilation time, considering that most DFG phases constantly manipulate mappings from Local -> some kind of data, and materialize these mappings at each BasicBlock boundary.
Comment 1 Radar WebKit Bug Importer 2022-03-21 10:43:16 PDT
<rdar://problem/90576249>