Integrate automatic microtask draining into JSC framework and re-enable Promise
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Jul 2015 22:40:40 +0000 (22:40 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Jul 2015 22:40:40 +0000 (22:40 +0000)
commit4f532884c6a44afc572d42352d298039e7244ad8
treefd258e33bff8fb9fdd3e6a1644712b34eee2c2b8
parentda14af67703844002897b8fda88166f47654b688
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@186966 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/js/promise-nested-microtasks-expected.txt [new file with mode: 0644]
LayoutTests/js/promise-nested-microtasks.html [new file with mode: 0644]
LayoutTests/js/promise-resolve-in-non-dom-expected.txt [new file with mode: 0644]
LayoutTests/js/promise-resolve-in-non-dom.html [new file with mode: 0644]
LayoutTests/js/script-tests/promise-nested-microtasks.js [new file with mode: 0644]
LayoutTests/js/script-tests/promise-resolve-non-dom.js [new file with mode: 0644]
LayoutTests/resources/standalone-post.js
Source/JavaScriptCore/API/JSContextRef.cpp
Source/JavaScriptCore/API/tests/testapi.c
Source/JavaScriptCore/API/tests/testapi.mm
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/JavaScriptCore/runtime/JSLock.cpp
Source/JavaScriptCore/runtime/VM.cpp
Source/JavaScriptCore/runtime/VM.h