[class] implement static private methods

This patch refactors the declaration and allocation of the class variable, and
implements static private methods:


- The class variable is declared in the class scope with an explicit
  reference through class_scope->class_variable(). Anonymous classes
  whose class variable may be accessed transitively through static
  private method access use the dot string as the class name. Whether
  the class variable is allocated depending on whether it is used.
  Other references of the class variable in the ClassLiteral AST node
  and the ClassInfo structure are removed in favor of the reference
  through the class scope.
- Previously the class variable was always (stack- or context-)
  allocated if the class is named. Now if the class variable is only
  referenced by name, it's stack allocated. If it's used transitively
  by access to static private methods, or may be used through eval,
  it's context allocated. Therefore we now use 1 less context slots
  in the class context if it's a named class without anyone referencing
  it by name in inner scopes.
- Explicit access to static private methods or potential access to
  static private methods through eval results in forced context
  allocation of the class variables. In those cases, we save its index
  in context locals in the ScopeInfo and deserialize it later, so that
  we can check that the receiver of static private methods is the class
  constructor at run time. This flag is recorded as
  HasSavedClassVariableIndexField in the scope info.
- Classes that need the class variable to be saved due to
  access to static private methods now save a
  ShouldSaveClassVariableIndexField in the preparse data so that the
  bits on the variables can be updated during a reparse. In the case
  of anonymous classes that need the class variables to be saved,
  we also re-declare the class variable after the reparse since
  the inner functions are skipped and we need to rely on the preparse
  data flags to remember declaring it.

Design doc: https://docs.google.com/document/d/1rgGRw5RdzaRrM-GrIMhsn-DLULtADV2dmIdh_iIZxlc/edit

Bug: v8:8330
Change-Id: Idd07803f47614e97ad202de3b7faa9f71105eac5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1781011
Commit-Queue: Joyee Cheung <joyee@igalia.com>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64219}
27 files changed
tree: 453154ef5474ca7b115d015739dfa54c3947f4bd
  1. .clang-format
  2. .clang-tidy
  3. .editorconfig
  4. .flake8
  5. .git-blame-ignore-revs
  6. .gitattributes
  7. .gitignore
  8. .gn
  9. .vpython
  10. .ycm_extra_conf.py
  11. AUTHORS
  12. BUILD.gn
  13. CODE_OF_CONDUCT.md
  14. COMMON_OWNERS
  15. ChangeLog
  16. DEPS
  17. ENG_REVIEW_OWNERS
  18. INFRA_OWNERS
  19. INTL_OWNERS
  20. LICENSE
  21. LICENSE.fdlibm
  22. LICENSE.strongtalk
  23. LICENSE.v8
  24. LICENSE.valgrind
  25. MIPS_OWNERS
  26. OWNERS
  27. PPC_OWNERS
  28. PRESUBMIT.py
  29. README.md
  30. S390_OWNERS
  31. WATCHLISTS
  32. benchmarks/
  33. build_overrides/
  34. codereview.settings
  35. custom_deps/
  36. docs/
  37. gni/
  38. include/
  39. infra/
  40. samples/
  41. src/
  42. test/
  43. testing/
  44. third_party/
  45. tools/
README.md

V8 JavaScript Engine

V8 is Google's open source JavaScript engine.

V8 implements ECMAScript as specified in ECMA-262.

V8 is written in C++ and is used in Google Chrome, the open source browser from Google.

V8 can run standalone, or can be embedded into any C++ application.

V8 Project page: https://v8.dev/docs

Getting the Code

Checkout depot tools, and run

    fetch v8

This will checkout V8 into the directory v8 and fetch all of its dependencies. To stay up to date, run

    git pull origin
    gclient sync

For fetching all branches, add the following into your remote configuration in .git/config:

    fetch = +refs/branch-heads/*:refs/remotes/branch-heads/*
    fetch = +refs/tags/*:refs/tags/*

Contributing

Please follow the instructions mentioned at v8.dev/docs/contribute.