Skip to content

Commit eacbc9d

Browse files
committed
Layering: straighten out initialization
The previous "ECMAScript Initialization()" abstract operation was intended for use in initializing the entire ECMAScript implementation. (This corresponds to an event loop, in browsers.) However, it was ill-suited for its purpose, as each "implementation" does not need a realm implicitly created, and in fact most implementations will have more than one realm. As such, we leave implementation creation up to the host environment, and merge "ECMAScript Initialization()" with InitializeHostDefinedRealm(). Host environments are now able to call InitializeHostDefinedRealm() to create new realms within their own implementations. In the future, we hope to introduce a new concept that formalizes "ECMAScript implementation", per e.g. e.g. https://esdiscuss.org/topic/event-loops-in-navigated-away-from-windows and https://esdiscuss.org/topic/holy-mixed-metaphors-batman-was-event-loops-in-navigated-away-from-windows.
1 parent 9474c58 commit eacbc9d

1 file changed

Lines changed: 9 additions & 22 deletions

File tree

spec.html

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6251,41 +6251,28 @@ <h1>NextJob result</h1>
62516251
</emu-clause>
62526252
</emu-clause>
62536253

6254-
<!-- es6num="8.5" -->
6255-
<emu-clause id="sec-ecmascript-initialization" aoid="Initialization">
6256-
<h1>ECMAScript Initialization()</h1>
6257-
<p>An ECMAScript implementation performs the following steps prior to the execution of any Jobs or the evaluation of any ECMAScript code:</p>
6254+
<emu-clause id="sec-initializehostdefinedrealm" aoid="InitializeHostDefinedRealm">
6255+
<h1>InitializeHostDefinedRealm( )</h1>
6256+
<p>The abstract operation InitializeHostDefinedRealm performs the following steps:</p>
6257+
62586258
<emu-alg>
62596259
1. Let _realm_ be CreateRealm().
62606260
1. Let _newContext_ be a new execution context.
62616261
1. Set the Function of _newContext_ to *null*.
62626262
1. Set the Realm of _newContext_ to _realm_.
62636263
1. Push _newContext_ onto the execution context stack; _newContext_ is now the running execution context.
6264-
1. Let _status_ be InitializeHostDefinedRealm(_realm_).
6265-
1. If _status_ is an abrupt completion, then
6266-
1. Assert: The first realm could not be created.
6267-
1. Terminate ECMAScript execution.
6264+
1. If the host requires use of an exotic object to serve as _realm_'s global object, let _global_ be such an object created in an implementation defined manner. Otherwise, let _global_ be *undefined*, indicating that an ordinary object should be created as the global object.
6265+
1. If the host requires that the `this` binding in _realm_'s global scope return an object other than the global object, let _thisValue_ be such an object created in an implementation defined manner. Otherwise, let _thisValue_ be *undefined*, indicating that _realm_'s global `this` binding should be the global object.
6266+
1. Perform SetRealmGlobalObject(_realm_, _global_, _thisValue_).
6267+
1. Let _globalObj_ be ? SetDefaultGlobalBindings(_realm_).
6268+
1. Create any implementation defined global object properties on _globalObj_.
62686269
1. In an implementation dependent manner, obtain the ECMAScript source texts (see clause <emu-xref href="#sec-ecmascript-language-source-code"></emu-xref>) for zero or more ECMAScript scripts and/or ECMAScript modules. For each such _sourceText_ do,
62696270
1. If _sourceText_ is the source code of a script, then
62706271
1. Perform EnqueueJob(`"ScriptJobs"`, ScriptEvaluationJob, &laquo; _sourceText_ &raquo;).
62716272
1. Else _sourceText_ is the source code of a module,
62726273
1. Perform EnqueueJob(`"ScriptJobs"`, TopLevelModuleEvaluationJob, &laquo; _sourceText_ &raquo;).
62736274
1. NextJob NormalCompletion(*undefined*).
62746275
</emu-alg>
6275-
6276-
<!-- es6num="8.5.1" -->
6277-
<emu-clause id="sec-initializehostdefinedrealm" aoid="InitializeHostDefinedRealm">
6278-
<h1>InitializeHostDefinedRealm ( _realm_ )</h1>
6279-
<p>The abstract operation InitializeHostDefinedRealm with parameter _realm_ performs the following steps:</p>
6280-
<emu-alg>
6281-
1. If this implementation requires use of an exotic object to serve as _realm_'s global object, let _global_ be such an object created in an implementation defined manner. Otherwise, let _global_ be *undefined* indicating that an ordinary object should be created as the global object.
6282-
1. If this implementation requires a specific value for the _realm_'s global `this` binding, let _thisValue_ be that value. Otherwise, let _thisValue_ be *undefined* indicating that the global object should be used.
6283-
1. Perform SetRealmGlobalObject(_realm_, _global_, _thisValue_).
6284-
1. Let _globalObj_ be ? SetDefaultGlobalBindings(_realm_).
6285-
1. Create any implementation defined global object properties on _globalObj_.
6286-
1. Return NormalCompletion(*undefined*).
6287-
</emu-alg>
6288-
</emu-clause>
62896276
</emu-clause>
62906277
</emu-clause>
62916278

0 commit comments

Comments
 (0)