ecma262 icon indicating copy to clipboard operation
ecma262 copied to clipboard

Extra Execution Context of the module

Open dSalieri opened this issue 2 years ago • 6 comments

I am confused, I've checked a several editions on how ECMAScript operating with Execution Contexts.

In 9.0 / 10.0

  1. ModuleDeclarationEnvironmentSetup / InitializeEnvironment doesn't create Execution Context, also doesn't do it active execution context
  2. ModuleExecution / ExecuteModule creates Execution Context and does its active until ECMAScript code is evaluating

In 11.0

  1. InitializeEnvironment creates new ECMAScript Execution Context and makes its active until bindings writing into Environment Record.
  2. ExecuteModule pull from module.[[Context]] Execution Context and make its active until [[ECMAScriptCode]] of module evaluating.

In 14.0 / current draft

  1. InitializeEnvironment creates new ECMAScript Execution Context and makes its active until bindings writing into Environment Record.
  2. ExecutionModule creates new ECMAScript Execution Context and make its active until [[ECMAScriptCode]] of module evaluating

So I have several questions:

  1. In 11.0 of spec suddenly use Execution Context and moreover makes it active in InitializeEnvironment operation. But what is the reason for that?
  2. In 14 / draft - "jobs went weird", I mean [[Context]] of module isn't used as it was in 11.0 into ExecutionModule. Instead of that in ExecutionModule (draft) creates the brand new Execution Context and I definitely don't understand it, because I don't see tie between InitializeEnvironment and ExecutionModule how it was in 9.0 / 10.0. Any clarifications?

dSalieri avatar Aug 24 '23 22:08 dSalieri

It's very unclear what you're asking, but either way I think es.discourse.group might be the place you're looking for?

ljharb avatar Aug 24 '23 22:08 ljharb

@ljharb updated my issue

dSalieri avatar Aug 24 '23 23:08 dSalieri

If you want to know the history of changes to a repository, git blame is your friend (or for this repo you can use searchfox, linked from the readme). Have you tried that?

bakkot avatar Aug 24 '23 23:08 bakkot

@bakkot thanks, I've invesigated my questions owing to your tips ;)

Answer to my questions:

  1. If we don't create Execution Context, we will get null in [[ScriptOrModule]] of FunctionDeclaration (if we define FunctionDeclaration in module) https://github.com/tc39/ecma262/pull/1670
  2. Conflict of merging https://github.com/tc39/ecma262/issues/2660

Anyway, problem from point 2 is still opened and current draft has weird Execution Context instead of using [[Context]] field.

dSalieri avatar Aug 25 '23 10:08 dSalieri

PR #2886 fixes issue #2660.

jmdyck avatar Aug 25 '23 13:08 jmdyck

PR #2886 fixes issue #2660.

@jmdyck I see, but draft hasn't this fix yet.

dSalieri avatar Aug 25 '23 15:08 dSalieri