Ignore:
Timestamp:
Jul 17, 2015, 3:40:40 PM (10 years ago)
Author:
Yusuke Suzuki
Message:

Integrate automatic microtask draining into JSC framework and re-enable Promise
https://bugs.webkit.org/show_bug.cgi?id=146828

Reviewed by Sam Weinig.

Source/JavaScriptCore:

Add automatic microtask draining system into JSC framework.
When the depth of VM lock becomes 0, before this, we drain the queued microtasks.
Enqueuing behavior can be injected by the JSGlobalObject's method table.
It is utilized in WebCore to post the microtask to WebCore's event loop.

In the case of JSC interactive shell, VM depth is always greater than 0.
So we manually drains the queued microtasks after evaluating the written line.

Since now JSC framework has the microtask queue, we can drain the queued microtasks.
So re-enable the Promise in the JSC framework context.

  • API/JSContextRef.cpp:

(javaScriptRuntimeFlags): Deleted.

  • API/tests/testapi.c:

(main):

  • API/tests/testapi.mm:

(testObjectiveCAPIMain):

  • jsc.cpp:

(runInteractive):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::queueMicrotask):

  • runtime/JSLock.cpp:

(JSC::JSLock::willReleaseLock):

  • runtime/VM.cpp:

(JSC::VM::queueMicrotask):
(JSC::VM::drainMicrotasks):
(JSC::QueuedTask::run):

  • runtime/VM.h:

(JSC::QueuedTask::QueuedTask):

LayoutTests:

Add Promise tests mainly focusing on microtasks.
They can be executed in JSC shell. So they are locate in js/ directory (not js/dom).

  • js/promise-nested-microtasks-expected.txt: Added.
  • js/promise-nested-microtasks.html: Added.
  • js/promise-resolve-in-non-dom-expected.txt: Added.
  • js/promise-resolve-in-non-dom.html: Added.
  • js/script-tests/promise-nested-microtasks.js: Added.

(Promise.resolve.then):

  • js/script-tests/promise-resolve-non-dom.js: Added.

(value.then):

  • resources/standalone-post.js:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSContextRef.cpp

    r185346 r186966  
    6060using namespace JSC;
    6161
    62 static RuntimeFlags javaScriptRuntimeFlags(const JSGlobalObject* globalObject)
    63 {
    64     RuntimeFlags runtimeFlags = JSGlobalObject::javaScriptRuntimeFlags(globalObject);
    65     runtimeFlags.setPromiseDisabled(true);
    66     return runtimeFlags;
    67 }
    68 
    69 const GlobalObjectMethodTable JSC::javaScriptCoreAPIGlobalObjectMethodTable = { &JSGlobalObject::allowsAccessFrom, &JSGlobalObject::supportsProfiling, &JSGlobalObject::supportsRichSourceInfo, &JSGlobalObject::shouldInterruptScript, &javaScriptRuntimeFlags, nullptr, &JSGlobalObject::shouldInterruptScriptBeforeTimeout };
     62const GlobalObjectMethodTable JSC::javaScriptCoreAPIGlobalObjectMethodTable = { &JSGlobalObject::allowsAccessFrom, &JSGlobalObject::supportsProfiling, &JSGlobalObject::supportsRichSourceInfo, &JSGlobalObject::shouldInterruptScript, &JSGlobalObject::javaScriptRuntimeFlags, nullptr, &JSGlobalObject::shouldInterruptScriptBeforeTimeout };
    7063
    7164// From the API's perspective, a context group remains alive iff
Note: See TracChangeset for help on using the changeset viewer.