From 514b0b45384d38b9e9aea99c7b4aec8d43658052 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Mon, 21 Nov 2022 22:50:15 -0500 Subject: [PATCH] Execution Context section: Make the EC Stack subsection Collect stuff about the execution context stack, move it to a new subsection, and then rework it. Note that there a couple of problems in the status quo: "A new execution context is created whenever control is transferred from the executable code associated with the currently running execution context to executable code that is not associated with that execution context." That became false when generators were added. "Transition of the running execution context status among execution contexts usually occurs in stack-like last-in/first-out manner. However, some ECMAScript features require non-LIFO transitions of the running execution context." No, it's always stack-like. --- spec.html | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spec.html b/spec.html index ad30c054f12..42ed91d457c 100644 --- a/spec.html +++ b/spec.html @@ -11561,7 +11561,6 @@

Execution Contexts

An execution context is a specification device that is used to track the runtime evaluation of code by an ECMAScript implementation. At any point in time, there is at most one execution context per agent that is actually executing code. This is known as the agent's running execution context. All references to the running execution context in this specification denote the running execution context of the surrounding agent.

-

The execution context stack is used to track execution contexts. The running execution context is always the top element of this stack. A new execution context is created whenever control is transferred from the executable code associated with the currently running execution context to executable code that is not associated with that execution context. The newly created execution context is pushed onto the stack and becomes the running execution context.

An execution context contains whatever implementation specific state is necessary to track the execution progress of its associated code. Each execution context has at least the state components listed in .

@@ -11607,7 +11606,6 @@

Execution Contexts

-

Evaluation of code by the running execution context may be suspended at various points defined within this specification. Once the running execution context has been suspended a different execution context may become the running execution context and commence evaluating its code. At some later time a suspended execution context may again become the running execution context and continue evaluating its code at the point where it had previously been suspended. Transition of the running execution context status among execution contexts usually occurs in stack-like last-in/first-out manner. However, some ECMAScript features require non-LIFO transitions of the running execution context.

The value of the Realm component of the running execution context is also called the current Realm Record. The value of the Function component of the running execution context is also called the active function object.

ECMAScript code execution contexts have the additional state components listed in .

@@ -11647,7 +11645,7 @@

Execution Contexts

The LexicalEnvironment and VariableEnvironment components of an execution context are always Environment Records.

-

In most situations only the running execution context (the top of the execution context stack) is directly manipulated by algorithms within this specification. Hence when the terms “LexicalEnvironment”, and “VariableEnvironment” are used without qualification they are in reference to those components of the running execution context.

+

In most situations only the running execution context is directly manipulated by algorithms within this specification. Hence when the terms “LexicalEnvironment”, and “VariableEnvironment” are used without qualification they are in reference to those components of the running execution context.

Execution contexts representing the evaluation of Generators have the additional state components listed in .

@@ -11681,6 +11679,13 @@

Execution Contexts

An execution context is purely a specification mechanism and need not correspond to any particular artefact of an ECMAScript implementation. It is impossible for ECMAScript code to directly access or observe an execution context.

+ +

Execution Context Stack

+

An agent's execution context stack is used to organize some or all of the agent's execution contexts. The running execution context is always the top element of this stack.

+

Adding and removing always happens at the “top” of the execution context stack. When an execution context is added, it becomes the topmost (i.e., the running execution context), and when it is later removed, the execution context “below” it becomes topmost again.

+ In the absense of generators, every execution context that is pushed onto the stack is new, and when it's removed from the stack it can be discarded. With generators, some execution contexts outlive their time on the stack, exist for a while outside the stack, and then later are pushed onto the stack again. +
+

GetActiveScriptOrModule ( ): a Script Record, a Module Record, or *null*