Closed Bug 1683746 Opened 4 years ago Closed 4 years ago

Minor bytecode optimizations for private fields

Categories

(Core :: JavaScript Engine, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
87 Branch
Tracking Status
firefox87 --- fixed

People

(Reporter: jorendorff, Assigned: jorendorff)

Details

Attachments

(3 files)

A few things could be improved at the margin:

  • We do a private brand check twice in the bytecode for obj.#priv++. Also affects compound assignment. But if the first brand check passes, the second will too.

  • We emit ToPropertyKey in the bytecode for obj.#m(), but it's a no-op since #m is always a Symbol (the private name).

  • We emit a CheckAliasedLexical each time we look up a private symbol, like the #m in obj.#m(), because it's implemented as a bogus lexical binding. But the binding can't be uninitialized; we initialize it as part of setting up the class, long before any code using the private name can actually run.

Assignee: nobody → jorendorff
Status: NEW → ASSIGNED

Private fields are implemented, in part, with bogus bindings like #f or
#m.method, stored in the class Environment, which contain the private
symbols, methods, getters, and setters for the class. Since these are not real
bindings, the spec never says to check that they are initialized. They're
always initialized as part of class setup, before they could possibly be used.
The CheckAliasedLexical instruction is, therefore, a no-op. This patch
eliminates it.

Depends on D100285

There are some r+ patches which didn't land and no activity in this bug for 2 weeks.
:jorendorff, could you have a look please?
For more information, please visit auto_nag documentation.

Flags: needinfo?(jorendorff)
Attachment #9194314 - Attachment description: Bug 1683746 - Part 1: Eliminate redundant brand check in inc/dec/compound assignment to private field. r?mgaudet → Bug 1683746 - Part 1: Eliminate redundant brand check in compound assignment to private field. r?mgaudet
Pushed by jorendorff@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/063b2af126f1 Part 1: Eliminate redundant brand check in compound assignment to private field. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/e80fe7b8b46b Part 2: Don't emit ToPropertyKey if the key is a private name. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/a64719684a50 Part 3: Don't emit CheckAliasedLexical when fetch a private name or method. r=mgaudet
Pushed by jorendorff@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0920a2ae2126 Part 1: Eliminate redundant brand check in compound assignment to private field. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/529954587d3f Part 2: Don't emit ToPropertyKey if the key is a private name. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/26fa34063dec Part 3: Don't emit CheckAliasedLexical when fetch a private name or method. r=mgaudet
Flags: needinfo?(jorendorff)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: