Ignore:
Timestamp:
Aug 26, 2013, 12:19:50 PM (12 years ago)
Author:
[email protected]
Message:

Add support for Promises
https://bugs.webkit.org/show_bug.cgi?id=120260

Reviewed by Darin Adler.

Source/JavaScriptCore:

Add an initial implementation of Promises - http://dom.spec.whatwg.org/#promises.

  • Despite Promises being defined in the DOM, the implementation is being put in JSC in preparation for the Promises eventually being defined in ECMAScript.
  • CMakeLists.txt:
  • DerivedSources.make:
  • DerivedSources.pri:
  • GNUmakefile.list.am:
  • JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Target.pri:

Add new files.

  • jsc.cpp:

Update jsc's GlobalObjectMethodTable to stub out the new QueueTaskToEventLoop callback. This mean's
you can't quite use Promises with with the command line tool yet.

  • interpreter/CallFrame.h:

(JSC::ExecState::promisePrototypeTable):
(JSC::ExecState::promiseConstructorTable):
(JSC::ExecState::promiseResolverPrototypeTable):

  • runtime/VM.cpp:

(JSC::VM::VM):
(JSC::VM::~VM):

  • runtime/VM.h:

Add supporting code for the new static lookup tables.

  • runtime/CommonIdentifiers.h:

Add 3 new identifiers, "Promise", "PromiseResolver", and "then".

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::reset):
(JSC::JSGlobalObject::visitChildren):
Add supporting code Promise and PromiseResolver's constructors and structures.

  • runtime/JSGlobalObject.h:

(JSC::TaskContext::~TaskContext):
Add a new callback to the GlobalObjectMethodTable to post a task on the embedder's runloop.

(JSC::JSGlobalObject::promisePrototype):
(JSC::JSGlobalObject::promiseResolverPrototype):
(JSC::JSGlobalObject::promiseStructure):
(JSC::JSGlobalObject::promiseResolverStructure):
(JSC::JSGlobalObject::promiseCallbackStructure):
(JSC::JSGlobalObject::promiseWrapperCallbackStructure):
Add supporting code Promise and PromiseResolver's constructors and structures.

  • runtime/JSPromise.cpp: Added.
  • runtime/JSPromise.h: Added.
  • runtime/JSPromiseCallback.cpp: Added.
  • runtime/JSPromiseCallback.h: Added.
  • runtime/JSPromiseConstructor.cpp: Added.
  • runtime/JSPromiseConstructor.h: Added.
  • runtime/JSPromisePrototype.cpp: Added.
  • runtime/JSPromisePrototype.h: Added.
  • runtime/JSPromiseResolver.cpp: Added.
  • runtime/JSPromiseResolver.h: Added.
  • runtime/JSPromiseResolverConstructor.cpp: Added.
  • runtime/JSPromiseResolverConstructor.h: Added.
  • runtime/JSPromiseResolverPrototype.cpp: Added.
  • runtime/JSPromiseResolverPrototype.h: Added.

Add Promise implementation.

Source/WebCore:

Add an initial implementation of Promises - http://dom.spec.whatwg.org/#promises.

  • Despite Promises being defined in the DOM, the implementation is being put in JSC in preparation for the Promises eventually being defined in ECMAScript.

Tests: fast/js/Promise-already-fulfilled.html

fast/js/Promise-already-rejected.html
fast/js/Promise-already-resolved.html
fast/js/Promise-catch-in-workers.html
fast/js/Promise-catch.html
fast/js/Promise-chain.html
fast/js/Promise-exception.html
fast/js/Promise-fulfill-in-workers.html
fast/js/Promise-fulfill.html
fast/js/Promise-init-in-workers.html
fast/js/Promise-init.html
fast/js/Promise-reject-in-workers.html
fast/js/Promise-reject.html
fast/js/Promise-resolve-chain.html
fast/js/Promise-resolve-in-workers.html
fast/js/Promise-resolve-with-then-exception.html
fast/js/Promise-resolve-with-then-fulfill.html
fast/js/Promise-resolve-with-then-reject.html
fast/js/Promise-resolve.html
fast/js/Promise-simple-fulfill-inside-callback.html
fast/js/Promise-simple-fulfill.html
fast/js/Promise-simple-in-workers.html
fast/js/Promise-simple.html
fast/js/Promise-static-fulfill.html
fast/js/Promise-static-reject.html
fast/js/Promise-static-resolve.html
fast/js/Promise-then-in-workers.html
fast/js/Promise-then-without-callbacks-in-workers.html
fast/js/Promise-then-without-callbacks.html
fast/js/Promise-then.html
fast/js/Promise-types.html
fast/js/Promise.html

  • GNUmakefile.list.am:
  • Target.pri:
  • UseJSC.cmake:
  • WebCore.vcxproj/WebCore.vcxproj:
  • WebCore.vcxproj/WebCore.vcxproj.filters:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSBindingsAllInOne.cpp:

Add new files.

  • bindings/js/JSDOMGlobalObjectTask.cpp: Added.

(WebCore::JSGlobalObjectCallback::create):
(WebCore::JSGlobalObjectCallback::~JSGlobalObjectCallback):
(WebCore::JSGlobalObjectCallback::call):
(WebCore::JSGlobalObjectCallback::JSGlobalObjectCallback):
(WebCore::JSGlobalObjectTask::JSGlobalObjectTask):
(WebCore::JSGlobalObjectTask::~JSGlobalObjectTask):
(WebCore::JSGlobalObjectTask::performTask):

  • bindings/js/JSDOMGlobalObjectTask.h: Added.

(WebCore::JSGlobalObjectTask::create):
Add a new task type to be used with the GlobalObjectMethodTable's new QueueTaskToEventLoop callback.

  • bindings/js/JSDOMWindowBase.cpp:

(WebCore::JSDOMWindowBase::queueTaskToEventLoop):

  • bindings/js/JSDOMWindowBase.h:

Implement the GlobalObjectMethodTable callback, QueueTaskToEventLoop.

  • bindings/js/JSMainThreadExecState.h:

All using JSMainThreadExecState as a simple RAII object.

  • bindings/js/JSWorkerGlobalScopeBase.cpp:

(WebCore::JSWorkerGlobalScopeBase::JSWorkerGlobalScopeBase):
(WebCore::JSWorkerGlobalScopeBase::allowsAccessFrom):
(WebCore::JSWorkerGlobalScopeBase::supportsProfiling):
(WebCore::JSWorkerGlobalScopeBase::supportsRichSourceInfo):
(WebCore::JSWorkerGlobalScopeBase::shouldInterruptScript):
(WebCore::JSWorkerGlobalScopeBase::javaScriptExperimentsEnabled):
(WebCore::JSWorkerGlobalScopeBase::queueTaskToEventLoop):

  • bindings/js/JSWorkerGlobalScopeBase.h:

Add a GlobalObjectMethodTable and implement QueueTaskToEventLoop. Forward the other callbacks
to JSGlobalObject so they retain their existing behavior.

LayoutTests:

Add tests adapted from the Mozilla and Blink projects.

  • fast/js/Promise-already-fulfilled-expected.txt: Added.
  • fast/js/Promise-already-fulfilled.html: Added.
  • fast/js/Promise-already-rejected-expected.txt: Added.
  • fast/js/Promise-already-rejected.html: Added.
  • fast/js/Promise-already-resolved-expected.txt: Added.
  • fast/js/Promise-already-resolved.html: Added.
  • fast/js/Promise-catch-expected.txt: Added.
  • fast/js/Promise-catch-in-workers-expected.txt: Added.
  • fast/js/Promise-catch-in-workers.html: Added.
  • fast/js/Promise-catch.html: Added.
  • fast/js/Promise-chain-expected.txt: Added.
  • fast/js/Promise-chain.html: Added.
  • fast/js/Promise-exception-expected.txt: Added.
  • fast/js/Promise-exception.html: Added.
  • fast/js/Promise-expected.txt: Added.
  • fast/js/Promise-fulfill-expected.txt: Added.
  • fast/js/Promise-fulfill-in-workers-expected.txt: Added.
  • fast/js/Promise-fulfill-in-workers.html: Added.
  • fast/js/Promise-fulfill.html: Added.
  • fast/js/Promise-init-expected.txt: Added.
  • fast/js/Promise-init-in-workers-expected.txt: Added.
  • fast/js/Promise-init-in-workers.html: Added.
  • fast/js/Promise-init.html: Added.
  • fast/js/Promise-reject-expected.txt: Added.
  • fast/js/Promise-reject-in-workers-expected.txt: Added.
  • fast/js/Promise-reject-in-workers.html: Added.
  • fast/js/Promise-reject.html: Added.
  • fast/js/Promise-resolve-chain-expected.txt: Added.
  • fast/js/Promise-resolve-chain.html: Added.
  • fast/js/Promise-resolve-expected.txt: Added.
  • fast/js/Promise-resolve-in-workers-expected.txt: Added.
  • fast/js/Promise-resolve-in-workers.html: Added.
  • fast/js/Promise-resolve-with-then-exception-expected.txt: Added.
  • fast/js/Promise-resolve-with-then-exception.html: Added.
  • fast/js/Promise-resolve-with-then-fulfill-expected.txt: Added.
  • fast/js/Promise-resolve-with-then-fulfill.html: Added.
  • fast/js/Promise-resolve-with-then-reject-expected.txt: Added.
  • fast/js/Promise-resolve-with-then-reject.html: Added.
  • fast/js/Promise-resolve.html: Added.
  • fast/js/Promise-simple-expected.txt: Added.
  • fast/js/Promise-simple-fulfill-expected.txt: Added.
  • fast/js/Promise-simple-fulfill-inside-callback-expected.txt: Added.
  • fast/js/Promise-simple-fulfill-inside-callback.html: Added.
  • fast/js/Promise-simple-fulfill.html: Added.
  • fast/js/Promise-simple-in-workers-expected.txt: Added.
  • fast/js/Promise-simple-in-workers.html: Added.
  • fast/js/Promise-simple.html: Added.
  • fast/js/Promise-static-fulfill-expected.txt: Added.
  • fast/js/Promise-static-fulfill.html: Added.
  • fast/js/Promise-static-reject-expected.txt: Added.
  • fast/js/Promise-static-reject.html: Added.
  • fast/js/Promise-static-resolve-expected.txt: Added.
  • fast/js/Promise-static-resolve.html: Added.
  • fast/js/Promise-then-expected.txt: Added.
  • fast/js/Promise-then-in-workers-expected.txt: Added.
  • fast/js/Promise-then-in-workers.html: Added.
  • fast/js/Promise-then-without-callbacks-expected.txt: Added.
  • fast/js/Promise-then-without-callbacks-in-workers-expected.txt: Added.
  • fast/js/Promise-then-without-callbacks-in-workers.html: Added.
  • fast/js/Promise-then-without-callbacks.html: Added.
  • fast/js/Promise-then.html: Added.
  • fast/js/Promise-types-expected.txt: Added.
  • fast/js/Promise-types.html: Added.
  • fast/js/Promise.html: Added.
  • fast/js/resources/Promise-catch-in-workers.js: Added.
  • fast/js/resources/Promise-fulfill-in-workers.js: Added.
  • fast/js/resources/Promise-init-in-workers.js: Added.
  • fast/js/resources/Promise-reject-in-workers.js: Added.
  • fast/js/resources/Promise-resolve-in-workers.js: Added.
  • fast/js/resources/Promise-simple-in-workers.js: Added.
  • fast/js/resources/Promise-then-in-workers.js: Added.
  • fast/js/resources/Promise-then-without-callbacks-in-workers.js: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r154626 r154629  
     12013-08-24  Sam Weinig  <[email protected]>
     2
     3        Add support for Promises
     4        https://bugs.webkit.org/show_bug.cgi?id=120260
     5
     6        Reviewed by Darin Adler.
     7
     8        Add an initial implementation of Promises - http://dom.spec.whatwg.org/#promises.
     9        - Despite Promises being defined in the DOM, the implementation is being put in JSC
     10          in preparation for the Promises eventually being defined in ECMAScript.
     11
     12        * CMakeLists.txt:
     13        * DerivedSources.make:
     14        * DerivedSources.pri:
     15        * GNUmakefile.list.am:
     16        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
     17        * JavaScriptCore.xcodeproj/project.pbxproj:
     18        * Target.pri:
     19        Add new files.
     20
     21        * jsc.cpp:
     22        Update jsc's GlobalObjectMethodTable to stub out the new QueueTaskToEventLoop callback. This mean's
     23        you can't quite use Promises with with the command line tool yet.
     24   
     25        * interpreter/CallFrame.h:
     26        (JSC::ExecState::promisePrototypeTable):
     27        (JSC::ExecState::promiseConstructorTable):
     28        (JSC::ExecState::promiseResolverPrototypeTable):
     29        * runtime/VM.cpp:
     30        (JSC::VM::VM):
     31        (JSC::VM::~VM):
     32        * runtime/VM.h:
     33        Add supporting code for the new static lookup tables.
     34
     35        * runtime/CommonIdentifiers.h:
     36        Add 3 new identifiers, "Promise", "PromiseResolver", and "then".
     37
     38        * runtime/JSGlobalObject.cpp:
     39        (JSC::JSGlobalObject::reset):
     40        (JSC::JSGlobalObject::visitChildren):
     41        Add supporting code Promise and PromiseResolver's constructors and structures.
     42
     43        * runtime/JSGlobalObject.h:
     44        (JSC::TaskContext::~TaskContext):
     45        Add a new callback to the GlobalObjectMethodTable to post a task on the embedder's runloop.
     46
     47        (JSC::JSGlobalObject::promisePrototype):
     48        (JSC::JSGlobalObject::promiseResolverPrototype):
     49        (JSC::JSGlobalObject::promiseStructure):
     50        (JSC::JSGlobalObject::promiseResolverStructure):
     51        (JSC::JSGlobalObject::promiseCallbackStructure):
     52        (JSC::JSGlobalObject::promiseWrapperCallbackStructure):
     53        Add supporting code Promise and PromiseResolver's constructors and structures.
     54
     55        * runtime/JSPromise.cpp: Added.
     56        * runtime/JSPromise.h: Added.
     57        * runtime/JSPromiseCallback.cpp: Added.
     58        * runtime/JSPromiseCallback.h: Added.
     59        * runtime/JSPromiseConstructor.cpp: Added.
     60        * runtime/JSPromiseConstructor.h: Added.
     61        * runtime/JSPromisePrototype.cpp: Added.
     62        * runtime/JSPromisePrototype.h: Added.
     63        * runtime/JSPromiseResolver.cpp: Added.
     64        * runtime/JSPromiseResolver.h: Added.
     65        * runtime/JSPromiseResolverConstructor.cpp: Added.
     66        * runtime/JSPromiseResolverConstructor.h: Added.
     67        * runtime/JSPromiseResolverPrototype.cpp: Added.
     68        * runtime/JSPromiseResolverPrototype.h: Added.
     69        Add Promise implementation.
     70
    1712013-08-26  Zan Dobersek  <[email protected]>
    272
Note: See TracChangeset for help on using the changeset viewer.