Open Bug 1653267 Opened 4 years ago Updated 4 years ago

Unnecessary CheckAliasedLexical instruction when accessing a private field

Categories

(Core :: JavaScript Engine, enhancement, P2)

enhancement

Tracking

()

People

(Reporter: jorendorff, Unassigned)

Details

The CheckAliasedLexical instruction below is checking that the private field key, the symbol that's the name of #f, has been created and stored in the environment.

I don't think there's any way that could possibly not be true, though, so I think the check is superfluous. Special cases to look out for include static field initializers and computed property names, but I think even those run after the private field keys are set up.

js> class C { #f = 0; m() { this.#f; } }
js> dis(C.prototype.m)
flags:
loc     op
-----   --
00000:  FunctionThis                    # THIS
00001:  SetLocal 0                      # THIS
00005:  Pop                             # 
main:
00006:  GetLocal 0                      # this
00010:  GetAliasedVar "#f" (hops = 0, slot = 2) # this #f
00015:  CheckAliasedLexical "#f" (hops = 0, slot = 2) # this #f
00020:  GetPrivateElem                  # <unknown>
00021:  Pop                             # 
00022:  RetRval                         # 
Severity: -- → S4
Type: task → enhancement
Priority: -- → P2
You need to log in before you can comment on or make changes to this bug.