Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Show how the web platform would integrate zones #3

Open
domenic opened this issue Mar 18, 2016 · 1 comment
Open

Show how the web platform would integrate zones #3

domenic opened this issue Mar 18, 2016 · 1 comment

Comments

@domenic
Copy link
Owner

domenic commented Mar 18, 2016

Rough thoughts: Web IDL's callback function type gets modified to have a zone field. The conversion from JS functions to Web IDL callback functions stores the current zone alongside the JS function. Web IDL's "invoke" algorithm for invoking callback functions uses this spec's CallInZone.

@pavelfeldman
Copy link

For the reference, here is how present native async stacks are implemented in Blink:

Async markup API

class Instrumentation {
    // Notify debugger that native async task has been scheduled (setTimeout).
    // V8 stack is captured here and is associated with the |task|.
    void asyncTaskScheduled(const String& taskName, void* task, bool recurring);

    // Notify debugger that native async was canceled (clearTimeout).
    // Pops stack from async call chain for |task|.
    void asyncTaskCanceled(void* task);

    // Notify debugger that callback for the async task started execution.
    // Sets |task| as currently executing so that further |asyncTaskScheduled|
    // could be associated with it.
    void asyncTaskStarted(void* task);

    // Notify debugger that callback for the async task callback completed.
    void asyncTaskFinished(void* task);

    // RAII object for asyncTaskStarted / asyncTaskFinished.
    class AsyncTask { ... }
}

setTimeout implementation using the above API.

DOMTimer::DOMTimer(ExecutionContext* context, bool singleShot)
{
    Instrumentation::asyncTaskScheduled(context, singleShot ? "setTimeout" : "setInterval", this, !singleShot);
}

void DOMTimer::fired()
{
    Instrumentation::AsyncTask asyncTask(getExecutionContext(), this);
    ...
}

void DOMTimer::stop()
{
    Instrumentation::asyncTaskCanceled(getExecutionContext(), this);
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants