Skip to content

Commit

Permalink
Define agents and agent clusters
Browse files Browse the repository at this point in the history
This puts the infrastructure in place to define SharedArrayBuffer in
detail. See also #2260.
  • Loading branch information
annevk committed Apr 11, 2017
1 parent 34b40e4 commit 5b4c97e
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2853,6 +2853,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

<ul class="brief">
<li><dfn data-x-href="https://tc39.github.io/ecma262/#active-function-object">active function object</dfn></li>
<li><dfn data-x-href="https://tc39.github.io/ecma262/#sec-agents">agent</dfn> and
<dfn data-x-href="https://tc39.github.io/ecma262/#sec-agent-clusters">agent cluster</dfn></li>
<li><dfn data-x-href="https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion">automatic semicolon insertion</dfn></li>
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#current-realm">current Realm Record</dfn></li>
<li><dfn data-x-href="https://tc39.github.io/ecma262/#early-error-rule">early error</dfn></li>
Expand Down Expand Up @@ -2934,6 +2936,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x="js-abstract-equality" data-x-href="https://tc39.github.io/ecma262/#sec-abstract-equality-comparison">Abstract Equality Comparison</dfn> algorithm</li>
<li>The <dfn data-x="js-strict-equality" data-x-href="https://tc39.github.io/ecma262/#sec-strict-equality-comparison">Strict Equality Comparison</dfn> algorithm</li>
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-date-objects"><code>Date</code></dfn> class</li>
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-sharedarraybuffer-objects"><code>SharedArrayBuffer</code></dfn> class</li>
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror"><code>TypeError</code></dfn> class</li>
<li>The <dfn data-x="js-RangeError" data-x-href="https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror"><code>RangeError</code></dfn> class</li>
<li>The <dfn data-x="js-typeof" data-x-href="https://tc39.github.io/ecma262/#sec-typeof-operator"><code>typeof</code></dfn> operator</li>
Expand Down Expand Up @@ -88403,6 +88406,101 @@ import "https://example.com/foo/../module2.js";</pre>
data-x="concept-module-script-module-record">module record</span>.</p></li>
</ol>

<h5>Integration with the JavaScript agent formalism</h5>

<p>JavaScript defines the concept of an <span>agent</span>. This corresponds, in a 1-to-1 manner,
with this specification's concept of an <span>environment settings object</span>.</p>

<p class="warning">See also <a href="https://github.com/tc39/ecma262/issues/882">tc39/ecma262
issue #882</a>.</p>

<p>To determine the manifestation of JavaScript's <span>agent cluster</span> concept in user
agents, we first define the set of <dfn>directly-shared environment settings objects</dfn> for a
given <span>environment settings object</span> <var>settingsObject</var>:</p>

<dl class="switch">
<dt>For a <var>settingsObject</var> with a <span>responsible document</span></dt>
<dd>
<p>The set containing:</p>

<ul>
<li><var>settingsObject</var>,</li>
<li>any <span>environment settings object</span> whose <span>responsible browsing
context</span> is in the same <span>unit of related similar-origin browsing contexts</span> as
<var>settingsObject</var>'s <span>responsible browsing context</span>,</li>
<li>and any <span>environment settings object</span> whose <span
data-x="concept-settings-object-global">global object</span> is a
<code>DedicatedWorkerGlobalScope</code> object of which <span>the worker's owners</span>
contains <var>settingsObject</var>'s <span>responsible document</span>.</li>
</ul>
</dd>

<dt>For a <var>settingsObject</var> whose <span data-x="concept-settings-object-global">global
object</span> is a <code>DedicatedWorkerGlobalScope</code> object</dt>
<dd>
<p>The set containing:

<ul>
<li><var>settingsObject</var>,</li>
<li>the <span>relevant settings object</span> of <var>settingsObject</var>'s
<span data-x="concept-settings-object-global">global object</span>'s single <span data-x="the
worker's owners">the worker's owner</span>,</li>
<li>any <span>relevant settings object</span> of <var>settingsObject</var>'s
<span data-x="concept-settings-object-global">global object</span>'s <span>the worker's
workers</span> that are not <code>SharedWorkerGlobalScope</code> objects.</li>
</ul>
</dd>

<dt>Otherwise (a shared or service worker)</dt>
<dd><p>The set containing <var>settingsObject</var> and any <span>relevant settings object</span>
of <var>settingsObject</var>'s <span data-x="concept-settings-object-global">global
object</span>'s <span>the worker's workers</span> that are not
<code>SharedWorkerGlobalScope</code> objects.</p>
</dl>

<p class="warning">What to do with worklets?</p>

<p>Then, the transitive closure of all <span data-x="environment settings object">environment
settings objects</span> that are <span>directly-shared environment settings objects</span> are the
<dfn>shared environment settings objects</dfn>, and a JavaScript <span>agent cluster</span>
consists of all the corresponding <span data-x="agent">agents</span>.</p>

<p class="note">The <span>agent cluster</span> concept is crucial for defining the JavaScript
memory model, and in particular among which <span data-x="agent">agents</span> the backing data of
<code>SharedArrayBuffer</code> objects can be shared.</p>

<div class="example">
<p>The following pairs of global objects are each within the same <span>shared environment
settings objects</span>, and thus can use <code>SharedArrayBuffer</code> instances to share
memory with each other:</p>

<ul class="brief">
<li>A <code>Window</code> and a dedicated worker that it created</li>

<li>A worker (of any type) and a dedicated worker it creates</li>

<li>A <code>Window</code> and the <code>Window</code> of an <code>iframe</code> element that
could be <span>same origin-domain</span></li>

<li>A <code>Window</code> and the <code>Window</code> that opened it</li>
</ul>

<p>The following pairs of global objects are <em>not</em> within the same <span>shared
environment settings objects</span>, and thus cannot share memory:</p>

<ul class="brief">
<li>A <code>Window</code> and a shared worker it creates</li>

<li>A worker (of any type) and a shared worker it creates</li>

<li>A <code>Window</code> and a service worker it creates</li>

<li>A <code>Window</code> and the <code>Window</code> of an <code>iframe</code> element that
cannot be <span>same origin-domain</span></li>
</ul>

</div>

</div>


Expand Down

0 comments on commit 5b4c97e

Please sign in to comment.