From f0991cc0b0d28cca69a3a5f18f8c5a47d252c1b9 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Tue, 19 Mar 2019 16:14:12 +0100 Subject: [PATCH 1/4] Remove compound microtasks Per https://lists.w3.org/Archives/Public/www-archive/2016Oct/0001.html the rationale for having this concept is the ability for some API to spin the event loop. This used to be the case with showModalDialog(), but that API got removed. Implementations also do not have this concept and treat this as a regular microtoask that just happens to do quite a few things (going through mutation observer callbacks and dispatching slotchange events). --- source | 62 ++++++---------------------------------------------------- 1 file changed, 6 insertions(+), 56 deletions(-) diff --git a/source b/source index d557d6bedb9..685a78bafce 100644 --- a/source +++ b/source @@ -89978,17 +89978,7 @@ dictionary PromiseRejectionEventInit : EventInit {

Each event loop has a microtask queue. A microtask is a task that is originally to - be queued on the microtask queue rather than a task queue. There are two - kinds of microtasks: solitary callback - microtasks, and compound microtasks.

- -

This specification only has solitary - callback microtasks. Specifications that use compound - microtasks have to take extra care to wrap callbacks to handle spinning the event - loop.

+ be queued on the microtask queue rather than a task queue.

When an algorithm requires a microtask to be queued, it must be appended to the @@ -90043,28 +90033,6 @@ dictionary PromiseRejectionEventInit : EventInit {

  • Set the performing a microtask checkpoint flag to false.

  • -

    If, while a compound microtask is running, the user agent is required to - execute a compound microtask subtask to run a series of steps, the user - agent must run the following steps:

    - -
      - -
    1. Let parent be the event loop's currently running - task (the currently running compound microtask).

    2. - -
    3. Let subtask be a new task that - consists of running the given series of steps. The task source of such a - microtask is the microtask task source. This is a compound - microtask subtask.

    4. - -
    5. Set the event loop's currently running task to subtask.

    6. - -
    7. Run subtask.

    8. - -
    9. Set the event loop's currently running task back to parent.

    10. - -
    -

    When an algorithm running in parallel is to await a stable state, the @@ -90089,19 +90057,10 @@ dictionary PromiseRejectionEventInit : EventInit {

    When an algorithm says to spin the event loop until a condition goal is met, the user agent must run the following steps:

      +
    1. Let task be the event loop's currently running + task.

    2. -
    3. - -

      Let task be the event loop's currently running - task.

      - -

      This might be a microtask, in which case it is a solitary - callback microtask. It could also be a compound microtask subtask, or a - regular task that is not a microtask. It will - not be a compound microtask.

      - -
    4. +
    5. Assert: task is not a microtask.

    6. Let task source be task's task source.

    7. @@ -90113,16 +90072,8 @@ dictionary PromiseRejectionEventInit : EventInit {
    8. Perform a microtask checkpoint.

    9. -
    10. - -

      Stop task, allowing whatever algorithm that invoked it to resume, but - continue these steps in parallel.

      - -

      This causes one of the following algorithms to continue: the event - loop's main set of steps, the perform a microtask checkpoint algorithm, or - the execute a compound microtask subtask algorithm.

      - -
    11. +
    12. Stop task, allowing the event loop's main set of steps to resume, + but continue these steps in parallel.

    13. Wait until the condition goal is met.

    14. @@ -90134,7 +90085,6 @@ dictionary PromiseRejectionEventInit : EventInit { stack.

    15. Return to the caller.

    16. -

    From be0ea329fa30ef204d3e39dbfe9d00a22174d88b Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Wed, 20 Mar 2019 18:36:11 +0100 Subject: [PATCH 2/4] spin the event loop can hit microtasks, but only one level of nesting of those --- source | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/source b/source index 685a78bafce..dcb1561ce90 100644 --- a/source +++ b/source @@ -90057,10 +90057,13 @@ dictionary PromiseRejectionEventInit : EventInit {

    When an algorithm says to spin the event loop until a condition goal is met, the user agent must run the following steps:

      -
    1. Let task be the event loop's currently running - task.

    2. +
    3. +

      Let task be the event loop's currently running task.

      -
    4. Assert: task is not a microtask.

    5. +

      This might be a microtask or a regular task. If this is a microtask the performing a + microtask checkpoint flag is set.

      +
    6. Let task source be task's task source.

    7. @@ -90072,6 +90075,14 @@ dictionary PromiseRejectionEventInit : EventInit {
    8. Perform a microtask checkpoint.

    9. +
    10. +

      Stop task, allowing whatever algorithm that invoked it to resume, but continue + these steps in parallel.

      + +

      This causes the event loop's main set of steps or the perform + a microtask checkpoint algorithm to continue.

      +
    11. +
    12. Stop task, allowing the event loop's main set of steps to resume, but continue these steps in parallel.

    13. From ac6bbc0ce2c5a6f322e66ce8275c7c1f94d7ca32 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Wed, 20 Mar 2019 18:39:37 +0100 Subject: [PATCH 3/4] oops --- source | 3 --- 1 file changed, 3 deletions(-) diff --git a/source b/source index dcb1561ce90..319060c956a 100644 --- a/source +++ b/source @@ -90083,9 +90083,6 @@ dictionary PromiseRejectionEventInit : EventInit { a microtask checkpoint algorithm to continue.

      -
    14. Stop task, allowing the event loop's main set of steps to resume, - but continue these steps in parallel.

    15. -
    16. Wait until the condition goal is met.

    17. Queue a task to continue running these steps, using the task From 2a3120ac3010d41ceffd544b008cf2f5e130fcec Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 29 Mar 2019 16:46:14 +0100 Subject: [PATCH 4/4] move part of note, turn remainder into an assert --- source | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source b/source index 319060c956a..3797541035b 100644 --- a/source +++ b/source @@ -90057,13 +90057,11 @@ dictionary PromiseRejectionEventInit : EventInit {

      When an algorithm says to spin the event loop until a condition goal is met, the user agent must run the following steps:

        -
      1. -

        Let task be the event loop's currently running task.

        +
      2. Let task be the event loop's currently running + task.

      3. -

        This might be a microtask or a regular task. If this is a microtask the performing a - microtask checkpoint flag is set.

        - +
      4. Assert: task is a task or a + microtask.

      5. Let task source be task's task source.

      6. @@ -90073,7 +90071,12 @@ dictionary PromiseRejectionEventInit : EventInit {
      7. Empty the JavaScript execution context stack.

      8. -
      9. Perform a microtask checkpoint.

      10. +
      11. +

        Perform a microtask checkpoint.

        + +

        If task is a microtask this step will be a no-op due to + the performing a microtask checkpoint flag being set.

        +
      12. Stop task, allowing whatever algorithm that invoked it to resume, but continue