Skip to content

Commit

Permalink
new approach, taking into account CanBlock, but not redefining event …
Browse files Browse the repository at this point in the history
…loop or === event loop and agents
  • Loading branch information
annevk committed Apr 12, 2017
1 parent 5b4c97e commit ba41268
Showing 1 changed file with 82 additions and 46 deletions.
128 changes: 82 additions & 46 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3781,6 +3781,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://w3c.github.io/ServiceWorker/#dfn-serviceworker-link">serviceworker link</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/ServiceWorker/#serviceworker"><code>ServiceWorker</code></dfn> interface</li>
<li><dfn data-x-href="https://w3c.github.io/ServiceWorker/#serviceworkercontainer"><code>ServiceWorkerContainer</code></dfn> interface</li>
<li><dfn data-x-href="https://w3c.github.io/ServiceWorker/#serviceworkerglobalscope"><code>ServiceWorkerGlobalScope</code></dfn> interface</li>
<li><dfn data-x-href="https://w3c.github.io/ServiceWorker/#dfn-use-cache">use cache</dfn></li>
</ul>

Expand Down Expand Up @@ -3906,6 +3907,17 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
</ul>
</dd>

<dt>Worklets</dt>

<dd>
<p>The following feature is defined in the <cite>Worklets</cite> specification: <ref
spec=WORKLETS></p>

<ul class="brief">
<li><dfn data-x-href="https://drafts.css-houdini.org/worklets/#workletglobalscope"><code>WorkletGlobalScope</code></dfn></li>
</ul>
</dd>

</dl>

<hr>
Expand Down Expand Up @@ -88408,71 +88420,92 @@ import "https://example.com/foo/../module2.js";</pre>

<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>JavaScript defines the concept of an <span>agent</span>. Until such a time that this standard
has a better handle on lifetimes, we define an <span>agent</span> from the perspective of a
<span>global object</span>:

<p class="warning">See also <a href="https://github.com/tc39/ecma262/issues/882">tc39/ecma262
issue #882</a>.</p>
<dl class="switch">
<dt><code>Window</code></dt>
<dd><p>The <span>agent</span>'s [[CanBlock]] is false, and its set of <span data-x="JavaScript
realm">JavaScript realms</span> consists of this <code>Window</code> object's <span
data-x="concept-global-object-realm">Realm</span>, and any other <span
data-x="concept-global-object-realm">Realm</span> of <code>Window</code> objects whose
<span>relevant settings object</span>'s <span>responsible browsing context</span> is in the same
<span>unit of related similar-origin browsing contexts</span> as this <code>Window</code>
object's <span>relevant settings object</span>'s <span>responsible browsing
context</span>.</p></dd>

<dt><code>DedicatedWorkerGlobalScope</code></dt>
<dd><p>The <span>agent</span>'s [[CanBlock]] is true, and its set of <span data-x="JavaScript
realm">JavaScript realms</span> consists of this <code>DedicatedWorkerGlobalScope</code>
object's <span data-x="concept-global-object-realm">Realm</span>.</p></dd>

<dt><code>SharedWorkerGlobalScope</code></dt>
<dd><p>The <span>agent</span>'s [[CanBlock]] is true, and its set of <span data-x="JavaScript
realm">JavaScript realms</span> consists of this <code>SharedWorkerGlobalScope</code>
object's <span data-x="concept-global-object-realm">Realm</span>.</p></dd>

<dt><code>ServiceWorkerGlobalScope</code></dt>
<dd><p>The <span>agent</span>'s [[CanBlock]] is ?????, and its set of <span data-x="JavaScript
realm">JavaScript realms</span> consists of this <code>ServiceWorkerGlobalScope</code>
object's <span data-x="concept-global-object-realm">Realm</span>.</p></dd>

<dt><code>WorkletGlobalScope</code></dt>
<dd><p>The <span>agent</span>'s [[CanBlock]] is false, and its set of <span data-x="JavaScript
realm">JavaScript realms</span> consists of this <code>WorkletGlobalScope</code> object's
<span data-x="concept-global-object-realm">Realm</span>.</p></dd>
</dl>

<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>
agents, we first define the set of <dfn>nearby-can-share-with global objects</dfn> for a given
<span>global object</span> <var>globalObject</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><code>Window</code></dt>
<dd><p>The set containing <var>globalObject</var>'s <span>agent</span>'s set of realms's
<span data-x="concept-realm-global">global objects</span> and any
<code>DedicatedWorkerGlobalScope</code> object whose <span>the worker's owners</span> contains
<var>globalObject</var>'s <var>relevant settings object</var>'s <span>responsible
document</span>.</p></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>
<dt><code>DedicatedWorkerGlobalScope</code></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>
<li><var>globalObject</var>,</li>
<li>the <span data-x="concept-relevant-global">relevant global object</span> of
<var>globalObject</var>'s single <span data-x="the worker's owners">the worker's
owner</span>,</li>
<li>any <span data-x="concept-relevant-global">relevant global object</span> of
<var>globalObject</var>'s <span>the worker's workers</span> that is not a
<code>SharedWorkerGlobalScope</code> object.</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>
<dt><code>WorkletGlobalScope</code></dt>
<dd><p>The set containing <var>globalObject</var> and ?????</p></dd>

<p class="warning">What to do with worklets?</p>
<dt>Otherwise (<code>DedicatedWorkerGlobalScope</code> or
<code>ServiceWorkerGlobalScope</code>)</dt>
<dd><p>The set containing <var>globalObject</var> and any <span
data-x="concept-relevant-global">relevant global object</span> of <var>globalObject</var>'s
<span>the worker's workers</span> that is not a <code>SharedWorkerGlobalScope</code> objects.</p>
</dl>

<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>Then, the transitive closure of all <span data-x="global object">global objects</span> that are
<span>nearby-can-share-with global objects</span> are the <dfn>can-share-with global
objects</dfn>, and a JavaScript <span>agent cluster</span> consists of all their 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>
<p>The following pairs of global objects are each within the same <span>can-share-with global
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>
Expand All @@ -88485,8 +88518,8 @@ import "https://example.com/foo/../module2.js";</pre>
<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>
<p>The following pairs of global objects are <em>not</em> within the same <span>can-share-with
global objects</span>, and thus cannot share memory:</p>

<ul class="brief">
<li>A <code>Window</code> and a shared worker it creates</li>
Expand Down Expand Up @@ -119818,6 +119851,9 @@ INSERT INTERFACES HERE
<dt id="refsWHATWGWIKI">[WHATWGWIKI]</dt>
<dd><cite><a href="https://wiki.whatwg.org/">The WHATWG Wiki</a></cite>. WHATWG.</dd>

<dt id="refsWORKLETS">[WORKLETS]</dt>
<dd><cite><a href="https://drafts.css-houdini.org/worklets/">Worklets</a></cite>. I. Kilpatrick. W3C.</dd>

<dt id="refsWSP">[WSP]</dt>
<dd><cite><a href="https://tools.ietf.org/html/rfc6455">The WebSocket protocol</a></cite>, I. Fette, A. Melnikov. IETF.</dd>

Expand Down

0 comments on commit ba41268

Please sign in to comment.