Closed Bug 1636800 Opened 4 years ago Closed 4 years ago

Snapshot incoming scope information for Stencil

Categories

(Core :: JavaScript Engine, task, P1)

task

Tracking

()

RESOLVED FIXED
mozilla78
Tracking Status
firefox78 --- fixed

People

(Reporter: tcampbell, Assigned: tcampbell)

References

Details

Attachments

(7 files, 8 obsolete files)

47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review

Things like FunctionBox::initWithEnclosingScope read VM Scopes directly to initialize. We should avoid the parser needing to access the VM for better isolation. It is also useful to document exactly what state is an input to parsing.

Generally this comes up for delazification and evals.

Examples:

  • SharedContext::computeAllowSyntax
  • SharedContext::computeThisBinding
  • SharedContext::computeInWith
  • BytecodeEmitter::findFieldInitializersForCall

Use initWithEnclosingScope instead. This also mirrors standAloneLazyFunction better.

Depends on D74908

This also reorganizes the ownership of ExternalContext, putting it into CompilationInfo.

A small exception being BinAST delazification, which is a bit weird.

Depends on D74912

Attachment #9147712 - Attachment description: Bug 1636800 - Snapshot inWith scope status outside of parser r?tcampbell → Bug 1636800 - Snapshot enclosing scope derived information before starting parse r?tcampbell
Attachment #9147713 - Attachment is obsolete: true
Attachment #9147714 - Attachment is obsolete: true
Attachment #9147715 - Attachment is obsolete: true
Depends on: 1638083
Depends on: 1638140
Assignee: mgaudet → tcampbell
Attachment #9149127 - Attachment is obsolete: true

I've made a mess of this, but I'm going to include an alternative stack inspired heavily by what is here.

Introduce a FunctionSyntaxKind for FieldInitializer since special rules
(around arguments) apply. At the same time we can move the flag from the
scope to the BaseScript::ImmutableFlags. This is similar to how derived
constructors are handled and makes the initWithEnclosingScope code closer to
initWithEnclosingContext.

Remove the separate needsThisTDZChecks flag and instead encode this into the
ThisBinding enum. This makes it inheritance less error-prone.

We use the (dynamic) environment chain for setting up context and for
execution, but we do not need for the compilation itself. Instead, the static
scope-chain is used as needed.

Depends on D75421

This does not change behaviour, but prepares for all of this logic to be
moved outside the parser itself.

Depends on D75454

Add FunctionFlags/FunctionSyntaxKind arguments for symmetry with
initWithEnclosingContext. Use the method in more places.

Also cleanup similar allow-syntax computation functions. We add checks for
field-initializers for consistency even though we currently don't use syntax
parsing on them.

Depends on D75455

This is used to compute a new ScopeContext struct that captures information
about the scope/environment chain. This reduces the need for parser to access
the VM directly.

Depends on D75456

The CompilationInfo now shapshots the required information so that the BCE
does not need to read scope chains from the VM. This is used by the unusual
edge cases such as:

  class C {}
  class D extends C {
    field1 = 1;

    constructor() {
      eval("super()");
    }
  }

This also cleans up the traversal to stop at any non-arrow non-constructor
function on the chain since they would not have been allowed to make a
super() call and require field info.

Depends on D75457

Blocks: 1638309
Pushed by tcampbell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/decc13d5e097 Track isFieldInitializer on BaseScript instead of Scope. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/4d2ccab906d1 Add ThisBinding::DerivedConstructor. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/b4268209648b Remove unused env argument from CompileEvalScript. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/5d4168c00031 Move debugger-eval special case into SharedContext::computeThisBinding. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/5dd4887b25a7 Generalize FunctionBox::initWithEnclosingScope. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/a16d2c3fe7e5 Pass enclosing scope/environment to CompilationInfo. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/0514a40bd588 Locate field-initializer information before parse starts. r=mgaudet
Attachment #9147709 - Attachment is obsolete: true
Attachment #9147710 - Attachment is obsolete: true
Attachment #9147711 - Attachment is obsolete: true
Attachment #9147712 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: