Update Promises to the https://github.com/domenic/promises-unwrapping spec
https://bugs.webkit.org/show_bug.cgi?id=120954

Reviewed by Filip Pizlo.

Source/JavaScriptCore: 

Update Promises to the revised spec. Notable changes:
- JSPromiseResolver is gone.
- TaskContext has been renamed Microtask and now has a virtual run() function.
- Instead of using custom InternalFunction subclasses, JSFunctions are used
  with PrivateName properties for internal slots.

* CMakeLists.txt:
* DerivedSources.make:
* GNUmakefile.list.am:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* interpreter/CallFrame.h:
(JSC::ExecState::promiseConstructorTable):
* runtime/CommonIdentifiers.cpp:
(JSC::CommonIdentifiers::CommonIdentifiers):
* runtime/CommonIdentifiers.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
(JSC::JSGlobalObject::visitChildren):
(JSC::JSGlobalObject::queueMicrotask):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::promiseConstructor):
(JSC::JSGlobalObject::promisePrototype):
(JSC::JSGlobalObject::promiseStructure):
* runtime/JSPromise.cpp:
(JSC::JSPromise::create):
(JSC::JSPromise::JSPromise):
(JSC::JSPromise::finishCreation):
(JSC::JSPromise::visitChildren):
(JSC::JSPromise::reject):
(JSC::JSPromise::resolve):
(JSC::JSPromise::appendResolveReaction):
(JSC::JSPromise::appendRejectReaction):
(JSC::triggerPromiseReactions):
* runtime/JSPromise.h:
(JSC::JSPromise::status):
(JSC::JSPromise::result):
(JSC::JSPromise::constructor):
* runtime/JSPromiseCallback.cpp: Removed.
* runtime/JSPromiseCallback.h: Removed.
* runtime/JSPromiseConstructor.cpp:
(JSC::constructPromise):
(JSC::JSPromiseConstructor::getCallData):
(JSC::JSPromiseConstructorFuncCast):
(JSC::JSPromiseConstructorFuncResolve):
(JSC::JSPromiseConstructorFuncReject):
* runtime/JSPromiseConstructor.h:
* runtime/JSPromiseDeferred.cpp: Added.
(JSC::JSPromiseDeferred::create):
(JSC::JSPromiseDeferred::JSPromiseDeferred):
(JSC::JSPromiseDeferred::finishCreation):
(JSC::JSPromiseDeferred::visitChildren):
(JSC::createJSPromiseDeferredFromConstructor):
(JSC::updateDeferredFromPotentialThenable):
* runtime/JSPromiseDeferred.h: Added.
(JSC::JSPromiseDeferred::createStructure):
(JSC::JSPromiseDeferred::promise):
(JSC::JSPromiseDeferred::resolve):
(JSC::JSPromiseDeferred::reject):
* runtime/JSPromiseFunctions.cpp: Added.
(JSC::deferredConstructionFunction):
(JSC::createDeferredConstructionFunction):
(JSC::identifyFunction):
(JSC::createIdentifyFunction):
(JSC::promiseAllCountdownFunction):
(JSC::createPromiseAllCountdownFunction):
(JSC::promiseResolutionHandlerFunction):
(JSC::createPromiseResolutionHandlerFunction):
(JSC::rejectPromiseFunction):
(JSC::createRejectPromiseFunction):
(JSC::resolvePromiseFunction):
(JSC::createResolvePromiseFunction):
(JSC::throwerFunction):
(JSC::createThrowerFunction):
* runtime/JSPromiseFunctions.h: Added.
* runtime/JSPromisePrototype.cpp:
(JSC::JSPromisePrototypeFuncThen):
(JSC::JSPromisePrototypeFuncCatch):
* runtime/JSPromiseReaction.cpp: Added.
(JSC::createExecutePromiseReactionMicroTask):
(JSC::ExecutePromiseReactionMicroTask::run):
(JSC::JSPromiseReaction::create):
(JSC::JSPromiseReaction::JSPromiseReaction):
(JSC::JSPromiseReaction::finishCreation):
(JSC::JSPromiseReaction::visitChildren):
* runtime/JSPromiseReaction.h: Added.
(JSC::JSPromiseReaction::createStructure):
(JSC::JSPromiseReaction::deferred):
(JSC::JSPromiseReaction::handler):
* runtime/JSPromiseResolver.cpp: Removed.
* runtime/JSPromiseResolver.h: Removed.
* runtime/JSPromiseResolverConstructor.cpp: Removed.
* runtime/JSPromiseResolverConstructor.h: Removed.
* runtime/JSPromiseResolverPrototype.cpp: Removed.
* runtime/JSPromiseResolverPrototype.h: Removed.
* runtime/Microtask.h: Added.
* runtime/VM.cpp:
(JSC::VM::VM):
(JSC::VM::~VM):
* runtime/VM.h:

Source/WebCore: 

* ForwardingHeaders/runtime/JSPromiseDeferred.h: Added.
* ForwardingHeaders/runtime/JSPromiseResolver.h: Removed.
* bindings/js/JSDOMGlobalObjectTask.cpp:
(WebCore::JSGlobalObjectTask::JSGlobalObjectTask):
* bindings/js/JSDOMGlobalObjectTask.h:
* bindings/js/JSDOMPromise.cpp:
(WebCore::DeferredWrapper::DeferredWrapper):
(WebCore::DeferredWrapper::promise):
(WebCore::DeferredWrapper::resolve):
(WebCore::DeferredWrapper::reject):
* bindings/js/JSDOMPromise.h:
(WebCore::DeferredWrapper::resolve):
(WebCore::DeferredWrapper::reject):
(WebCore::DeferredWrapper::resolve<String>):
(WebCore::DeferredWrapper::resolve<bool>):
(WebCore::char>>):
(WebCore::DeferredWrapper::reject<String>):
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::queueTaskToEventLoop):
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::JSSubtleCrypto::encrypt):
(WebCore::JSSubtleCrypto::decrypt):
(WebCore::JSSubtleCrypto::sign):
(WebCore::JSSubtleCrypto::verify):
(WebCore::JSSubtleCrypto::digest):
(WebCore::JSSubtleCrypto::generateKey):
(WebCore::JSSubtleCrypto::importKey):
(WebCore::JSSubtleCrypto::exportKey):
(WebCore::JSSubtleCrypto::wrapKey):
(WebCore::JSSubtleCrypto::unwrapKey):
* bindings/js/JSWorkerGlobalScopeBase.cpp:
(WebCore::JSWorkerGlobalScopeBase::queueTaskToEventLoop):
* bindings/js/JSWorkerGlobalScopeBase.h:

LayoutTests: 

* crypto/subtle/argument-conversion.html:
* crypto/subtle/resources/common.js:
* crypto/subtle/sha-1.html:
* crypto/subtle/sha-224.html:
* crypto/subtle/sha-256.html:
* crypto/subtle/sha-384.html:
* crypto/subtle/sha-512.html:
* js/dom/Promise-already-fulfilled-expected.txt: Removed.
* js/dom/Promise-already-fulfilled.html: Removed.
* js/dom/Promise-already-rejected.html:
* js/dom/Promise-already-resolved.html:
* js/dom/Promise-catch-expected.txt:
* js/dom/Promise-catch-in-workers-expected.txt:
* js/dom/Promise-catch.html:
* js/dom/Promise-chain.html:
* js/dom/Promise-exception-expected.txt:
* js/dom/Promise-exception.html:
* js/dom/Promise-expected.txt:
* js/dom/Promise-fulfill-expected.txt: Removed.
* js/dom/Promise-fulfill-in-workers-expected.txt: Removed.
* js/dom/Promise-fulfill-in-workers.html: Removed.
* js/dom/Promise-fulfill.html: Removed.
* js/dom/Promise-init-callback-receiver-expected.txt: Added.
* js/dom/Promise-init-callback-receiver.html: Added.
* js/dom/Promise-init-expected.txt:
* js/dom/Promise-init-in-workers-expected.txt:
* js/dom/Promise-init.html:
* js/dom/Promise-onFulfilled-deep-expected.txt: Added.
* js/dom/Promise-onFulfilled-deep.html: Added.
* js/dom/Promise-onRejected-deep-expected.txt: Added.
* js/dom/Promise-onRejected-deep.html: Added.
* js/dom/Promise-reject.html:
* js/dom/Promise-resolve-chain.html:
* js/dom/Promise-resolve-expected.txt:
* js/dom/Promise-resolve-in-workers-expected.txt:
* js/dom/Promise-resolve-state-expected.txt: Added.
* js/dom/Promise-resolve-state-in-workers-expected.txt: Added.
* js/dom/Promise-resolve-state-in-workers.html: Added.
* js/dom/Promise-resolve-state.html: Added.
* js/dom/Promise-resolve-with-itself-expected.txt: Added.
* js/dom/Promise-resolve-with-itself.html: Added.
* js/dom/Promise-resolve-with-then-exception.html:
* js/dom/Promise-resolve-with-then-fulfill-expected.txt:
* js/dom/Promise-resolve-with-then-fulfill.html:
* js/dom/Promise-resolve-with-then-reject-expected.txt:
* js/dom/Promise-resolve-with-then-reject.html:
* js/dom/Promise-resolve.html:
* js/dom/Promise-simple-expected.txt:
* js/dom/Promise-simple-fulfill-expected.txt: Removed.
* js/dom/Promise-simple-fulfill-inside-callback-expected.txt: Removed.
* js/dom/Promise-simple-fulfill-inside-callback.html: Removed.
* js/dom/Promise-simple-fulfill.html: Removed.
* js/dom/Promise-simple-in-workers-expected.txt:
* js/dom/Promise-simple-resolve-expected.txt: Added.
* js/dom/Promise-simple-resolve.html: Added.
* js/dom/Promise-simple.html:
* js/dom/Promise-static-all-expected.txt: Added.
* js/dom/Promise-static-all.html: Added.
* js/dom/Promise-static-cast-expected.txt: Added.
* js/dom/Promise-static-cast.html: Added.
* js/dom/Promise-static-fulfill-expected.txt: Removed.
* js/dom/Promise-static-fulfill.html: Removed.
* js/dom/Promise-static-race-expected.txt: Added.
* js/dom/Promise-static-race.html: Added.
* js/dom/Promise-static-resolve.html:
* js/dom/Promise-then-callback-receiver-expected.txt: Added.
* js/dom/Promise-then-callback-receiver.html: Added.
* js/dom/Promise-then-expected.txt:
* js/dom/Promise-then-in-workers-expected.txt:
* js/dom/Promise-then-without-callbacks.html:
* js/dom/Promise-then.html:
* js/dom/Promise-types-expected.txt:
* js/dom/Promise-types.html:
* js/dom/Promise.html:
* js/resources/Promise-catch-in-workers.js:
* js/resources/Promise-fulfill-in-workers.js: Removed.
* js/resources/Promise-init-in-workers.js:
* js/resources/Promise-reject-in-workers.js:
* js/resources/Promise-resolve-in-workers.js:
* js/resources/Promise-resolve-state-in-workers.js: Added.
* js/resources/Promise-simple-in-workers.js:
* js/resources/Promise-then-in-workers.js:
* js/resources/Promise-then-without-callbacks-in-workers.js:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161241 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt
index 224007f..36b7118 100644
--- a/Source/JavaScriptCore/CMakeLists.txt
+++ b/Source/JavaScriptCore/CMakeLists.txt
@@ -361,12 +361,11 @@
     runtime/JSONObject.cpp
     runtime/JSObject.cpp
     runtime/JSPromise.cpp
-    runtime/JSPromiseCallback.cpp
     runtime/JSPromiseConstructor.cpp
+    runtime/JSPromiseDeferred.cpp
+    runtime/JSPromiseFunctions.cpp
+    runtime/JSPromiseReaction.cpp
     runtime/JSPromisePrototype.cpp
-    runtime/JSPromiseResolver.cpp
-    runtime/JSPromiseResolverConstructor.cpp
-    runtime/JSPromiseResolverPrototype.cpp
     runtime/JSPropertyNameIterator.cpp
     runtime/JSProxy.cpp
     runtime/JSScope.cpp
@@ -467,7 +466,6 @@
     runtime/JSONObject.cpp
     runtime/JSPromiseConstructor.cpp
     runtime/JSPromisePrototype.cpp
-    runtime/JSPromiseResolverPrototype.cpp
     runtime/NamePrototype.cpp
     runtime/NumberConstructor.cpp
     runtime/NumberPrototype.cpp
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 68484fb..d332144 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,112 @@
+2014-01-02  Sam Weinig  <sam@webkit.org>
+
+        Update Promises to the https://github.com/domenic/promises-unwrapping spec
+        https://bugs.webkit.org/show_bug.cgi?id=120954
+
+        Reviewed by Filip Pizlo.
+
+        Update Promises to the revised spec. Notable changes:
+        - JSPromiseResolver is gone.
+        - TaskContext has been renamed Microtask and now has a virtual run() function.
+        - Instead of using custom InternalFunction subclasses, JSFunctions are used
+          with PrivateName properties for internal slots.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * GNUmakefile.list.am:
+        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
+        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * interpreter/CallFrame.h:
+        (JSC::ExecState::promiseConstructorTable):
+        * runtime/CommonIdentifiers.cpp:
+        (JSC::CommonIdentifiers::CommonIdentifiers):
+        * runtime/CommonIdentifiers.h:
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::reset):
+        (JSC::JSGlobalObject::visitChildren):
+        (JSC::JSGlobalObject::queueMicrotask):
+        * runtime/JSGlobalObject.h:
+        (JSC::JSGlobalObject::promiseConstructor):
+        (JSC::JSGlobalObject::promisePrototype):
+        (JSC::JSGlobalObject::promiseStructure):
+        * runtime/JSPromise.cpp:
+        (JSC::JSPromise::create):
+        (JSC::JSPromise::JSPromise):
+        (JSC::JSPromise::finishCreation):
+        (JSC::JSPromise::visitChildren):
+        (JSC::JSPromise::reject):
+        (JSC::JSPromise::resolve):
+        (JSC::JSPromise::appendResolveReaction):
+        (JSC::JSPromise::appendRejectReaction):
+        (JSC::triggerPromiseReactions):
+        * runtime/JSPromise.h:
+        (JSC::JSPromise::status):
+        (JSC::JSPromise::result):
+        (JSC::JSPromise::constructor):
+        * runtime/JSPromiseCallback.cpp: Removed.
+        * runtime/JSPromiseCallback.h: Removed.
+        * runtime/JSPromiseConstructor.cpp:
+        (JSC::constructPromise):
+        (JSC::JSPromiseConstructor::getCallData):
+        (JSC::JSPromiseConstructorFuncCast):
+        (JSC::JSPromiseConstructorFuncResolve):
+        (JSC::JSPromiseConstructorFuncReject):
+        * runtime/JSPromiseConstructor.h:
+        * runtime/JSPromiseDeferred.cpp: Added.
+        (JSC::JSPromiseDeferred::create):
+        (JSC::JSPromiseDeferred::JSPromiseDeferred):
+        (JSC::JSPromiseDeferred::finishCreation):
+        (JSC::JSPromiseDeferred::visitChildren):
+        (JSC::createJSPromiseDeferredFromConstructor):
+        (JSC::updateDeferredFromPotentialThenable):
+        * runtime/JSPromiseDeferred.h: Added.
+        (JSC::JSPromiseDeferred::createStructure):
+        (JSC::JSPromiseDeferred::promise):
+        (JSC::JSPromiseDeferred::resolve):
+        (JSC::JSPromiseDeferred::reject):
+        * runtime/JSPromiseFunctions.cpp: Added.
+        (JSC::deferredConstructionFunction):
+        (JSC::createDeferredConstructionFunction):
+        (JSC::identifyFunction):
+        (JSC::createIdentifyFunction):
+        (JSC::promiseAllCountdownFunction):
+        (JSC::createPromiseAllCountdownFunction):
+        (JSC::promiseResolutionHandlerFunction):
+        (JSC::createPromiseResolutionHandlerFunction):
+        (JSC::rejectPromiseFunction):
+        (JSC::createRejectPromiseFunction):
+        (JSC::resolvePromiseFunction):
+        (JSC::createResolvePromiseFunction):
+        (JSC::throwerFunction):
+        (JSC::createThrowerFunction):
+        * runtime/JSPromiseFunctions.h: Added.
+        * runtime/JSPromisePrototype.cpp:
+        (JSC::JSPromisePrototypeFuncThen):
+        (JSC::JSPromisePrototypeFuncCatch):
+        * runtime/JSPromiseReaction.cpp: Added.
+        (JSC::createExecutePromiseReactionMicroTask):
+        (JSC::ExecutePromiseReactionMicroTask::run):
+        (JSC::JSPromiseReaction::create):
+        (JSC::JSPromiseReaction::JSPromiseReaction):
+        (JSC::JSPromiseReaction::finishCreation):
+        (JSC::JSPromiseReaction::visitChildren):
+        * runtime/JSPromiseReaction.h: Added.
+        (JSC::JSPromiseReaction::createStructure):
+        (JSC::JSPromiseReaction::deferred):
+        (JSC::JSPromiseReaction::handler):
+        * runtime/JSPromiseResolver.cpp: Removed.
+        * runtime/JSPromiseResolver.h: Removed.
+        * runtime/JSPromiseResolverConstructor.cpp: Removed.
+        * runtime/JSPromiseResolverConstructor.h: Removed.
+        * runtime/JSPromiseResolverPrototype.cpp: Removed.
+        * runtime/JSPromiseResolverPrototype.h: Removed.
+        * runtime/Microtask.h: Added.
+        * runtime/VM.cpp:
+        (JSC::VM::VM):
+        (JSC::VM::~VM):
+        * runtime/VM.h:
+
 2014-01-02  Mark Hahnenberg  <mhahnenberg@apple.com>
 
         Add support for StoreBarrier and friends to the FTL
diff --git a/Source/JavaScriptCore/DerivedSources.make b/Source/JavaScriptCore/DerivedSources.make
index c6454fa..501b0f1 100644
--- a/Source/JavaScriptCore/DerivedSources.make
+++ b/Source/JavaScriptCore/DerivedSources.make
@@ -45,7 +45,6 @@
     JSGlobalObject.lut.h \
     JSPromisePrototype.lut.h \
     JSPromiseConstructor.lut.h \
-    JSPromiseResolverPrototype.lut.h \
     KeywordLookup.h \
     Lexer.lut.h \
     NamePrototype.lut.h \
diff --git a/Source/JavaScriptCore/GNUmakefile.list.am b/Source/JavaScriptCore/GNUmakefile.list.am
index fe5423e..b27df09 100644
--- a/Source/JavaScriptCore/GNUmakefile.list.am
+++ b/Source/JavaScriptCore/GNUmakefile.list.am
@@ -22,7 +22,6 @@
 	DerivedSources/JavaScriptCore/JSONObject.lut.h \
 	DerivedSources/JavaScriptCore/JSPromiseConstructor.lut.h \
 	DerivedSources/JavaScriptCore/JSPromisePrototype.lut.h \
-	DerivedSources/JavaScriptCore/JSPromiseResolverPrototype.lut.h \
 	DerivedSources/JavaScriptCore/MathObject.lut.h \
 	DerivedSources/JavaScriptCore/NamePrototype.lut.h \
 	DerivedSources/JavaScriptCore/NumberConstructor.lut.h \
@@ -977,18 +976,16 @@
 	Source/JavaScriptCore/runtime/JSONObject.h \
 	Source/JavaScriptCore/runtime/JSPromise.cpp \
 	Source/JavaScriptCore/runtime/JSPromise.h \
-	Source/JavaScriptCore/runtime/JSPromiseCallback.cpp \
-	Source/JavaScriptCore/runtime/JSPromiseCallback.h \
 	Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp \
 	Source/JavaScriptCore/runtime/JSPromiseConstructor.h \
+	Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp \
+	Source/JavaScriptCore/runtime/JSPromiseDeferred.h \
+	Source/JavaScriptCore/runtime/JSPromiseFunctions.cpp \
+	Source/JavaScriptCore/runtime/JSPromiseFunctions.h \
+	Source/JavaScriptCore/runtime/JSPromiseReaction.cpp \
+	Source/JavaScriptCore/runtime/JSPromiseReaction.h \
 	Source/JavaScriptCore/runtime/JSPromisePrototype.cpp \
 	Source/JavaScriptCore/runtime/JSPromisePrototype.h \
-	Source/JavaScriptCore/runtime/JSPromiseResolver.cpp \
-	Source/JavaScriptCore/runtime/JSPromiseResolver.h \
-	Source/JavaScriptCore/runtime/JSPromiseResolverConstructor.cpp \
-	Source/JavaScriptCore/runtime/JSPromiseResolverConstructor.h \
-	Source/JavaScriptCore/runtime/JSPromiseResolverPrototype.cpp \
-	Source/JavaScriptCore/runtime/JSPromiseResolverPrototype.h \
 	Source/JavaScriptCore/runtime/JSPropertyNameIterator.cpp \
 	Source/JavaScriptCore/runtime/JSPropertyNameIterator.h \
 	Source/JavaScriptCore/runtime/JSSegmentedVariableObject.cpp \
@@ -1049,6 +1046,7 @@
 	Source/JavaScriptCore/runtime/MathObject.cpp \
 	Source/JavaScriptCore/runtime/MathObject.h \
 	Source/JavaScriptCore/runtime/MemoryStatistics.h \
+	Source/JavaScriptCore/runtime/Microtask.h \
 	Source/JavaScriptCore/runtime/NameConstructor.cpp \
 	Source/JavaScriptCore/runtime/NameConstructor.h \
 	Source/JavaScriptCore/runtime/NameInstance.cpp \
diff --git a/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj b/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
index 089edd7..7c67ba7 100644
--- a/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
+++ b/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
@@ -612,12 +612,11 @@
     <ClCompile Include="..\runtime\JSONObject.cpp" />
     <ClCompile Include="..\runtime\JSObject.cpp" />
     <ClCompile Include="..\runtime\JSPromise.cpp" />
-    <ClCompile Include="..\runtime\JSPromiseCallback.cpp" />
     <ClCompile Include="..\runtime\JSPromiseConstructor.cpp" />
+    <ClCompile Include="..\runtime\JSPromiseDeferred.cpp" />
+    <ClCompile Include="..\runtime\JSPromiseFunctions.cpp" />
+    <ClCompile Include="..\runtime\JSPromiseReaction.cpp" />
     <ClCompile Include="..\runtime\JSPromisePrototype.cpp" />
-    <ClCompile Include="..\runtime\JSPromiseResolver.cpp" />
-    <ClCompile Include="..\runtime\JSPromiseResolverConstructor.cpp" />
-    <ClCompile Include="..\runtime\JSPromiseResolverPrototype.cpp" />
     <ClCompile Include="..\runtime\JSPropertyNameIterator.cpp" />
     <ClCompile Include="..\runtime\JSProxy.cpp" />
     <ClCompile Include="..\runtime\JSScope.cpp" />
@@ -720,7 +719,6 @@
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSONObject.lut.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSPromiseConstructor.lut.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSPromisePrototype.lut.h" />
-    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSPromiseResolverPrototype.lut.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\KeywordLookup.lut.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\Lexer.lut.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\NamePrototype.lut.h" />
@@ -1233,12 +1231,11 @@
     <ClInclude Include="..\runtime\JSONObject.h" />
     <ClInclude Include="..\runtime\JSObject.h" />
     <ClInclude Include="..\runtime\JSPromise.h" />
-    <ClInclude Include="..\runtime\JSPromiseCallback.h" />
     <ClInclude Include="..\runtime\JSPromiseConstructor.h" />
+    <ClInclude Include="..\runtime\JSPromiseDeferred.h" />
+    <ClInclude Include="..\runtime\JSPromiseFunctions.h" />
+    <ClInclude Include="..\runtime\JSPromiseReaction.h" />
     <ClInclude Include="..\runtime\JSPromisePrototype.h" />
-    <ClInclude Include="..\runtime\JSPromiseResolver.h" />
-    <ClInclude Include="..\runtime\JSPromiseResolverConstructor.h" />
-    <ClInclude Include="..\runtime\JSPromiseResolverPrototype.h" />
     <ClInclude Include="..\runtime\JSPropertyNameIterator.h" />
     <ClInclude Include="..\runtime\JSProxy.h" />
     <ClInclude Include="..\runtime\JSScope.h" />
@@ -1271,6 +1268,7 @@
     <ClInclude Include="..\runtime\MapPrototype.h" />
     <ClInclude Include="..\runtime\MatchResult.h" />
     <ClInclude Include="..\runtime\MathObject.h" />
+    <ClInclude Include="..\runtime\Microtask.h" />
     <ClInclude Include="..\runtime\NameConstructor.h" />
     <ClInclude Include="..\runtime\NameInstance.h" />
     <ClInclude Include="..\runtime\NamePrototype.h" />
diff --git a/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters b/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
index d6a6309..11e14a5 100644
--- a/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
+++ b/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
@@ -876,25 +876,22 @@
     <ClCompile Include="..\runtime\SimpleTypedArrayController.cpp">
       <Filter>runtime</Filter>
     </ClCompile>
-    <ClCompile Include="..\runtime\JSPromiseResolverPrototype.cpp">
-      <Filter>runtime</Filter>
-    </ClCompile>
-    <ClCompile Include="..\runtime\JSPromiseResolverConstructor.cpp">
-      <Filter>runtime</Filter>
-    </ClCompile>
-    <ClCompile Include="..\runtime\JSPromiseResolver.cpp">
-      <Filter>runtime</Filter>
-    </ClCompile>
-    <ClCompile Include="..\runtime\JSPromisePrototype.cpp">
+    <ClCompile Include="..\runtime\JSPromise.cpp">
       <Filter>runtime</Filter>
     </ClCompile>
     <ClCompile Include="..\runtime\JSPromiseConstructor.cpp">
       <Filter>runtime</Filter>
     </ClCompile>
-    <ClCompile Include="..\runtime\JSPromiseCallback.cpp">
+    <ClCompile Include="..\runtime\JSPromiseDeferred.cpp">
       <Filter>runtime</Filter>
     </ClCompile>
-    <ClCompile Include="..\runtime\JSPromise.cpp">
+    <ClCompile Include="..\runtime\JSPromiseFunctions.cpp">
+      <Filter>runtime</Filter>
+    </ClCompile>
+    <ClCompile Include="..\runtime\JSPromiseReaction.cpp">
+      <Filter>runtime</Filter>
+    </ClCompile>
+    <ClCompile Include="..\runtime\JSPromisePrototype.cpp">
       <Filter>runtime</Filter>
     </ClCompile>
     <ClCompile Include="..\runtime\WeakMapConstructor.cpp">
@@ -2571,27 +2568,24 @@
     <ClInclude Include="..\runtime\JSGenericTypedArrayViewPrototype.h">
       <Filter>runtime</Filter>
     </ClInclude>
-    <ClInclude Include="..\runtime\JSPromiseResolverPrototype.h">
-      <Filter>runtime</Filter>
-    </ClInclude>
     <ClInclude Include="..\runtime\JSPromise.h">
       <Filter>runtime</Filter>
     </ClInclude>
-    <ClInclude Include="..\runtime\JSPromiseCallback.h">
-      <Filter>runtime</Filter>
-    </ClInclude>
     <ClInclude Include="..\runtime\JSPromiseConstructor.h">
       <Filter>runtime</Filter>
     </ClInclude>
+    <ClInclude Include="..\runtime\JSPromiseDeferred.h">
+      <Filter>runtime</Filter>
+    </ClInclude>
+    <ClInclude Include="..\runtime\JSPromiseFunctions.h">
+      <Filter>runtime</Filter>
+    </ClInclude>
+    <ClInclude Include="..\runtime\JSPromiseReaction.h">
+      <Filter>runtime</Filter>
+    </ClInclude>
     <ClInclude Include="..\runtime\JSPromisePrototype.h">
       <Filter>runtime</Filter>
     </ClInclude>
-    <ClInclude Include="..\runtime\JSPromiseResolver.h">
-      <Filter>runtime</Filter>
-    </ClInclude>
-    <ClInclude Include="..\runtime\JSPromiseResolverConstructor.h">
-      <Filter>runtime</Filter>
-    </ClInclude>
     <ClInclude Include="..\runtime\JSInt8Array.h">
       <Filter>runtime</Filter>
     </ClInclude>
@@ -2703,9 +2697,6 @@
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSPromisePrototype.lut.h">
       <Filter>Derived Sources</Filter>
     </ClInclude>
-    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSPromiseResolverPrototype.lut.h">
-      <Filter>Derived Sources</Filter>
-    </ClInclude>
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\KeywordLookup.lut.h">
       <Filter>Derived Sources</Filter>
     </ClInclude>
@@ -3156,6 +3147,9 @@
     <ClInclude Include="..\runtime\MapIteratorConstructor.h">
       <Filter>runtime</Filter>
     </ClInclude>
+    <ClInclude Include="..\runtime\Microtask.h">
+      <Filter>runtime</Filter>
+    </ClInclude>
     <ClInclude Include="..\jit\AssemblyHelpers.h">
       <Filter>jit</Filter>
     </ClInclude>
diff --git a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
index cf648ace..51cc7a9 100644
--- a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
+++ b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
@@ -748,20 +748,19 @@
 		65C0285C1717966800351E35 /* ARMv7DOpcode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65C0285A1717966800351E35 /* ARMv7DOpcode.cpp */; };
 		65C0285D1717966800351E35 /* ARMv7DOpcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 65C0285B1717966800351E35 /* ARMv7DOpcode.h */; };
 		65FB5117184EEE7000C12B70 /* ProtoCallFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65FB5116184EE9BC00C12B70 /* ProtoCallFrame.cpp */; };
-		7C15F65D17C199CE00794D40 /* JSPromiseCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C15F65B17C199CE00794D40 /* JSPromiseCallback.cpp */; };
-		7C15F65E17C199CE00794D40 /* JSPromiseCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C15F65C17C199CE00794D40 /* JSPromiseCallback.h */; };
+		7C008CD2186F8A9300955C24 /* JSPromiseFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C008CD0186F8A9300955C24 /* JSPromiseFunctions.cpp */; };
+		7C008CD3186F8A9300955C24 /* JSPromiseFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C008CD1186F8A9300955C24 /* JSPromiseFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		7C008CDA187124BB00955C24 /* JSPromiseDeferred.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C008CD8187124BB00955C24 /* JSPromiseDeferred.cpp */; };
+		7C008CDB187124BB00955C24 /* JSPromiseDeferred.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C008CD9187124BB00955C24 /* JSPromiseDeferred.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		7C008CDE1871258D00955C24 /* JSPromiseReaction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C008CDC1871258D00955C24 /* JSPromiseReaction.cpp */; };
+		7C008CDF1871258D00955C24 /* JSPromiseReaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C008CDD1871258D00955C24 /* JSPromiseReaction.h */; };
+		7C008CE7187631B600955C24 /* Microtask.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C008CE5187631B600955C24 /* Microtask.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7C184E1A17BEDBD3007CB63A /* JSPromise.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C184E1817BEDBD3007CB63A /* JSPromise.cpp */; };
 		7C184E1B17BEDBD3007CB63A /* JSPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C184E1917BEDBD3007CB63A /* JSPromise.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7C184E1E17BEE22E007CB63A /* JSPromisePrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C184E1C17BEE22E007CB63A /* JSPromisePrototype.cpp */; };
 		7C184E1F17BEE22E007CB63A /* JSPromisePrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C184E1D17BEE22E007CB63A /* JSPromisePrototype.h */; };
 		7C184E2217BEE240007CB63A /* JSPromiseConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C184E2017BEE240007CB63A /* JSPromiseConstructor.cpp */; };
 		7C184E2317BEE240007CB63A /* JSPromiseConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C184E2117BEE240007CB63A /* JSPromiseConstructor.h */; };
-		7C3BA29417C039560072DDC9 /* JSPromiseResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3BA28E17C039560072DDC9 /* JSPromiseResolver.cpp */; };
-		7C3BA29517C039560072DDC9 /* JSPromiseResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3BA28F17C039560072DDC9 /* JSPromiseResolver.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		7C3BA29617C039560072DDC9 /* JSPromiseResolverConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3BA29017C039560072DDC9 /* JSPromiseResolverConstructor.cpp */; };
-		7C3BA29717C039560072DDC9 /* JSPromiseResolverConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3BA29117C039560072DDC9 /* JSPromiseResolverConstructor.h */; };
-		7C3BA29817C039560072DDC9 /* JSPromiseResolverPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3BA29217C039560072DDC9 /* JSPromiseResolverPrototype.cpp */; };
-		7C3BA29917C039560072DDC9 /* JSPromiseResolverPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3BA29317C039560072DDC9 /* JSPromiseResolverPrototype.h */; };
 		7E4EE7090EBB7963005934AA /* StructureChain.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E4EE7080EBB7963005934AA /* StructureChain.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7E4EE70F0EBB7A5B005934AA /* StructureChain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E4EE70E0EBB7A5B005934AA /* StructureChain.cpp */; };
 		7EFF00640EC05A9A00AA7C93 /* NodeInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 7EFF00630EC05A9A00AA7C93 /* NodeInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -2080,8 +2079,13 @@
 		65FB5115184EE8F800C12B70 /* ProtoCallFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProtoCallFrame.h; sourceTree = "<group>"; };
 		65FB5116184EE9BC00C12B70 /* ProtoCallFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProtoCallFrame.cpp; sourceTree = "<group>"; };
 		704FD35305697E6D003DBED9 /* BooleanObject.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = BooleanObject.h; sourceTree = "<group>"; tabWidth = 8; };
-		7C15F65B17C199CE00794D40 /* JSPromiseCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPromiseCallback.cpp; sourceTree = "<group>"; };
-		7C15F65C17C199CE00794D40 /* JSPromiseCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPromiseCallback.h; sourceTree = "<group>"; };
+		7C008CD0186F8A9300955C24 /* JSPromiseFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPromiseFunctions.cpp; sourceTree = "<group>"; };
+		7C008CD1186F8A9300955C24 /* JSPromiseFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPromiseFunctions.h; sourceTree = "<group>"; };
+		7C008CD8187124BB00955C24 /* JSPromiseDeferred.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPromiseDeferred.cpp; sourceTree = "<group>"; };
+		7C008CD9187124BB00955C24 /* JSPromiseDeferred.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPromiseDeferred.h; sourceTree = "<group>"; };
+		7C008CDC1871258D00955C24 /* JSPromiseReaction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPromiseReaction.cpp; sourceTree = "<group>"; };
+		7C008CDD1871258D00955C24 /* JSPromiseReaction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPromiseReaction.h; sourceTree = "<group>"; };
+		7C008CE5187631B600955C24 /* Microtask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Microtask.h; sourceTree = "<group>"; };
 		7C184E1817BEDBD3007CB63A /* JSPromise.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPromise.cpp; sourceTree = "<group>"; };
 		7C184E1917BEDBD3007CB63A /* JSPromise.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPromise.h; sourceTree = "<group>"; };
 		7C184E1C17BEE22E007CB63A /* JSPromisePrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPromisePrototype.cpp; sourceTree = "<group>"; };
@@ -2090,13 +2094,6 @@
 		7C184E2117BEE240007CB63A /* JSPromiseConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPromiseConstructor.h; sourceTree = "<group>"; };
 		7C184E2417BFFA36007CB63A /* JSPromiseConstructor.lut.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSPromiseConstructor.lut.h; sourceTree = "<group>"; };
 		7C184E2517BFFA36007CB63A /* JSPromisePrototype.lut.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSPromisePrototype.lut.h; sourceTree = "<group>"; };
-		7C3BA28E17C039560072DDC9 /* JSPromiseResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPromiseResolver.cpp; sourceTree = "<group>"; };
-		7C3BA28F17C039560072DDC9 /* JSPromiseResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPromiseResolver.h; sourceTree = "<group>"; };
-		7C3BA29017C039560072DDC9 /* JSPromiseResolverConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPromiseResolverConstructor.cpp; sourceTree = "<group>"; };
-		7C3BA29117C039560072DDC9 /* JSPromiseResolverConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPromiseResolverConstructor.h; sourceTree = "<group>"; };
-		7C3BA29217C039560072DDC9 /* JSPromiseResolverPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPromiseResolverPrototype.cpp; sourceTree = "<group>"; };
-		7C3BA29317C039560072DDC9 /* JSPromiseResolverPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPromiseResolverPrototype.h; sourceTree = "<group>"; };
-		7C3BA29A17C03BE10072DDC9 /* JSPromiseResolverPrototype.lut.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSPromiseResolverPrototype.lut.h; sourceTree = "<group>"; };
 		7E4EE7080EBB7963005934AA /* StructureChain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructureChain.h; sourceTree = "<group>"; };
 		7E4EE70E0EBB7A5B005934AA /* StructureChain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StructureChain.cpp; sourceTree = "<group>"; };
 		7EFF00630EC05A9A00AA7C93 /* NodeInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeInfo.h; sourceTree = "<group>"; };
@@ -3359,7 +3356,6 @@
 				BC87CDB810712ACA000614CF /* JSONObject.lut.h */,
 				7C184E2417BFFA36007CB63A /* JSPromiseConstructor.lut.h */,
 				7C184E2517BFFA36007CB63A /* JSPromisePrototype.lut.h */,
-				7C3BA29A17C03BE10072DDC9 /* JSPromiseResolverPrototype.lut.h */,
 				A7C225CD1399849C00FF1662 /* KeywordLookup.h */,
 				BC18C52D0E16FCE100B34460 /* Lexer.lut.h */,
 				BC2680E60E16D52300A06E92 /* NumberConstructor.lut.h */,
@@ -3621,18 +3617,16 @@
 				A7F9935D0FD7325100A0B2D0 /* JSONObject.h */,
 				7C184E1817BEDBD3007CB63A /* JSPromise.cpp */,
 				7C184E1917BEDBD3007CB63A /* JSPromise.h */,
-				7C15F65B17C199CE00794D40 /* JSPromiseCallback.cpp */,
-				7C15F65C17C199CE00794D40 /* JSPromiseCallback.h */,
+				7C008CD0186F8A9300955C24 /* JSPromiseFunctions.cpp */,
+				7C008CD1186F8A9300955C24 /* JSPromiseFunctions.h */,
 				7C184E2017BEE240007CB63A /* JSPromiseConstructor.cpp */,
 				7C184E2117BEE240007CB63A /* JSPromiseConstructor.h */,
 				7C184E1C17BEE22E007CB63A /* JSPromisePrototype.cpp */,
 				7C184E1D17BEE22E007CB63A /* JSPromisePrototype.h */,
-				7C3BA28E17C039560072DDC9 /* JSPromiseResolver.cpp */,
-				7C3BA28F17C039560072DDC9 /* JSPromiseResolver.h */,
-				7C3BA29017C039560072DDC9 /* JSPromiseResolverConstructor.cpp */,
-				7C3BA29117C039560072DDC9 /* JSPromiseResolverConstructor.h */,
-				7C3BA29217C039560072DDC9 /* JSPromiseResolverPrototype.cpp */,
-				7C3BA29317C039560072DDC9 /* JSPromiseResolverPrototype.h */,
+				7C008CD8187124BB00955C24 /* JSPromiseDeferred.cpp */,
+				7C008CD9187124BB00955C24 /* JSPromiseDeferred.h */,
+				7C008CDC1871258D00955C24 /* JSPromiseReaction.cpp */,
+				7C008CDD1871258D00955C24 /* JSPromiseReaction.h */,
 				A727FF660DA3053B00E548D7 /* JSPropertyNameIterator.cpp */,
 				A727FF650DA3053B00E548D7 /* JSPropertyNameIterator.h */,
 				862553CE16136AA5009F17D0 /* JSProxy.cpp */,
@@ -3691,6 +3685,7 @@
 				F692A86B0255597D01FF60F7 /* MathObject.h */,
 				90213E3B123A40C200D422F3 /* MemoryStatistics.cpp */,
 				90213E3C123A40C200D422F3 /* MemoryStatistics.h */,
+				7C008CE5187631B600955C24 /* Microtask.h */,
 				86EBF2F91560F036008E9222 /* NameConstructor.cpp */,
 				86EBF2FA1560F036008E9222 /* NameConstructor.h */,
 				86EBF2FB1560F036008E9222 /* NameInstance.cpp */,
@@ -4795,13 +4790,9 @@
 				BC87CDB910712AD4000614CF /* JSONObject.lut.h in Headers */,
 				9534AAFB0E5B7A9600B8A45B /* JSProfilerPrivate.h in Headers */,
 				7C184E1B17BEDBD3007CB63A /* JSPromise.h in Headers */,
-				7C15F65E17C199CE00794D40 /* JSPromiseCallback.h in Headers */,
 				7C184E2317BEE240007CB63A /* JSPromiseConstructor.h in Headers */,
 				7C184E1F17BEE22E007CB63A /* JSPromisePrototype.h in Headers */,
-				7C3BA29517C039560072DDC9 /* JSPromiseResolver.h in Headers */,
 				A74DEF96182D991400522C22 /* JSMapIterator.h in Headers */,
-				7C3BA29717C039560072DDC9 /* JSPromiseResolverConstructor.h in Headers */,
-				7C3BA29917C039560072DDC9 /* JSPromiseResolverPrototype.h in Headers */,
 				862553D216136E1A009F17D0 /* JSProxy.h in Headers */,
 				BC18C4260E16F5CD00B34460 /* JSRetainPtr.h in Headers */,
 				14874AE615EBDE4A002E3587 /* JSScope.h in Headers */,
@@ -4859,6 +4850,7 @@
 				0F4680A314BA7F8D00BFE272 /* LLIntExceptions.h in Headers */,
 				0F4680CB14BBB17200BFE272 /* LLIntOfflineAsmConfig.h in Headers */,
 				FED287B215EC9A5700DA8161 /* LLIntOpcode.h in Headers */,
+				7C008CDB187124BB00955C24 /* JSPromiseDeferred.h in Headers */,
 				0F4680A514BA7F8D00BFE272 /* LLIntSlowPaths.h in Headers */,
 				0F0B839D14BCF46600885B4F /* LLIntThunks.h in Headers */,
 				0FCEFACE1805E75500472CE4 /* LLVMAPI.h in Headers */,
@@ -4960,6 +4952,7 @@
 				1474C33B16AA2D950062F01D /* PrototypeMap.h in Headers */,
 				0F9332A414CA7DD90085F3C6 /* PutByIdStatus.h in Headers */,
 				0F0CD4C215F1A6070032F1C0 /* PutDirectIndexMode.h in Headers */,
+				7C008CE7187631B600955C24 /* Microtask.h in Headers */,
 				0F9FC8C514E1B60400D52AE0 /* PutKind.h in Headers */,
 				147B84630E6DE6B1004775A4 /* PutPropertySlot.h in Headers */,
 				A593CF7D1840360300BFCE27 /* InspectorBackendDispatcher.h in Headers */,
@@ -4967,6 +4960,7 @@
 				BC18C45A0E16F5CD00B34460 /* RegExp.h in Headers */,
 				A1712B3F11C7B228007A5315 /* RegExpCache.h in Headers */,
 				BCD202C20E1706A7002C7E82 /* RegExpConstructor.h in Headers */,
+				7C008CDF1871258D00955C24 /* JSPromiseReaction.h in Headers */,
 				BCD202D60E170708002C7E82 /* RegExpConstructor.lut.h in Headers */,
 				A1712B4111C7B235007A5315 /* RegExpKey.h in Headers */,
 				0F3AC752183EA1040032029F /* StackAlignment.h in Headers */,
@@ -4989,6 +4983,7 @@
 				A7299DA217D12848005F5FF9 /* SetPrototype.h in Headers */,
 				86AE64AA135E5E1C00963012 /* SH4Assembler.h in Headers */,
 				0F2B670517B6B5AB00A7AE3F /* SimpleTypedArrayController.h in Headers */,
+				7C008CD3186F8A9300955C24 /* JSPromiseFunctions.h in Headers */,
 				A790DD6C182F499700588807 /* SetIteratorConstructor.h in Headers */,
 				14BA78F113AAB88F005B7C2C /* SlotVisitor.h in Headers */,
 				C2160FE715F7E95E00942DFC /* SlotVisitorInlines.h in Headers */,
@@ -5670,6 +5665,7 @@
 				0FEA0A1E1708B00700BB722C /* FTLAbstractHeapRepository.cpp in Sources */,
 				0FEA0A09170513DB00BB722C /* FTLCapabilities.cpp in Sources */,
 				0FEA0A271709623B00BB722C /* FTLCommonValues.cpp in Sources */,
+				7C008CDA187124BB00955C24 /* JSPromiseDeferred.cpp in Sources */,
 				A532438918568335002ED692 /* InspectorJSFrontendDispatchers.cpp in Sources */,
 				0FEA0A0B170513DB00BB722C /* FTLCompile.cpp in Sources */,
 				0F235BD317178E1C00690C7F /* FTLExitArgument.cpp in Sources */,
@@ -5695,6 +5691,7 @@
 				0F25F1B3181635F300522F39 /* FTLSlowPathCallKey.cpp in Sources */,
 				0F9D339A1803ADB70073C2BC /* FTLStackMaps.cpp in Sources */,
 				0FEA0A161706BB9000BB722C /* FTLState.cpp in Sources */,
+				7C008CD2186F8A9300955C24 /* JSPromiseFunctions.cpp in Sources */,
 				0F235BE117178E1C00690C7F /* FTLThunks.cpp in Sources */,
 				A593CF7C1840360300BFCE27 /* InspectorBackendDispatcher.cpp in Sources */,
 				0F235BE317178E1C00690C7F /* FTLValueFormat.cpp in Sources */,
@@ -5706,6 +5703,7 @@
 				C2239D1A16262BDD005AC5FD /* GCThread.cpp in Sources */,
 				C21122E115DD9AB300790E3A /* GCThreadSharedData.cpp in Sources */,
 				0F93329F14CA7DCA0085F3C6 /* GetByIdStatus.cpp in Sources */,
+				7C008CDE1871258D00955C24 /* JSPromiseReaction.cpp in Sources */,
 				14280855107EC0E70013E7B2 /* GetterSetter.cpp in Sources */,
 				142E3135134FF0A600AFADB5 /* HandleSet.cpp in Sources */,
 				142E3137134FF0A600AFADB5 /* HandleStack.cpp in Sources */,
@@ -5782,12 +5780,8 @@
 				A7F993600FD7325100A0B2D0 /* JSONObject.cpp in Sources */,
 				95F6E6950E5B5F970091E860 /* JSProfilerPrivate.cpp in Sources */,
 				7C184E1A17BEDBD3007CB63A /* JSPromise.cpp in Sources */,
-				7C15F65D17C199CE00794D40 /* JSPromiseCallback.cpp in Sources */,
 				7C184E2217BEE240007CB63A /* JSPromiseConstructor.cpp in Sources */,
 				7C184E1E17BEE22E007CB63A /* JSPromisePrototype.cpp in Sources */,
-				7C3BA29417C039560072DDC9 /* JSPromiseResolver.cpp in Sources */,
-				7C3BA29617C039560072DDC9 /* JSPromiseResolverConstructor.cpp in Sources */,
-				7C3BA29817C039560072DDC9 /* JSPromiseResolverPrototype.cpp in Sources */,
 				A727FF6B0DA3092200E548D7 /* JSPropertyNameIterator.cpp in Sources */,
 				862553D116136DA9009F17D0 /* JSProxy.cpp in Sources */,
 				14874AE515EBDE4A002E3587 /* JSScope.cpp in Sources */,
diff --git a/Source/JavaScriptCore/heap/SlotVisitor.h b/Source/JavaScriptCore/heap/SlotVisitor.h
index 733e9c1..a4aacdc 100644
--- a/Source/JavaScriptCore/heap/SlotVisitor.h
+++ b/Source/JavaScriptCore/heap/SlotVisitor.h
@@ -53,6 +53,7 @@
     
     template<typename T> void append(JITWriteBarrier<T>*);
     template<typename T> void append(WriteBarrierBase<T>*);
+    template<typename Iterator> void append(Iterator begin , Iterator end);
     void appendValues(WriteBarrierBase<Unknown>*, size_t count);
     
     template<typename T>
diff --git a/Source/JavaScriptCore/heap/SlotVisitorInlines.h b/Source/JavaScriptCore/heap/SlotVisitorInlines.h
index 90f18efe..d503d1c 100644
--- a/Source/JavaScriptCore/heap/SlotVisitorInlines.h
+++ b/Source/JavaScriptCore/heap/SlotVisitorInlines.h
@@ -116,6 +116,12 @@
     internalAppend(slot, *slot->slot());
 }
 
+template<typename Iterator> inline void SlotVisitor::append(Iterator begin, Iterator end)
+{
+    for (auto it = begin; it != end; ++it)
+        append(&*it);
+}
+
 ALWAYS_INLINE void SlotVisitor::appendValues(WriteBarrierBase<Unknown>* barriers, size_t count)
 {
     append(barriers->slot(), count);
diff --git a/Source/JavaScriptCore/interpreter/CallFrame.h b/Source/JavaScriptCore/interpreter/CallFrame.h
index c9de2ad..21b0a6d 100644
--- a/Source/JavaScriptCore/interpreter/CallFrame.h
+++ b/Source/JavaScriptCore/interpreter/CallFrame.h
@@ -104,7 +104,6 @@
 #if ENABLE(PROMISES)
         static const HashTable& promisePrototypeTable(CallFrame* callFrame) { return *callFrame->vm().promisePrototypeTable; }
         static const HashTable& promiseConstructorTable(CallFrame* callFrame) { return *callFrame->vm().promiseConstructorTable; }
-        static const HashTable& promiseResolverPrototypeTable(CallFrame* callFrame) { return *callFrame->vm().promiseResolverPrototypeTable; }
 #endif
 
         static CallFrame* create(Register* callFrameBase) { return static_cast<CallFrame*>(callFrameBase); }
diff --git a/Source/JavaScriptCore/runtime/CommonIdentifiers.cpp b/Source/JavaScriptCore/runtime/CommonIdentifiers.cpp
index 9fbdea6..3f5c645 100644
--- a/Source/JavaScriptCore/runtime/CommonIdentifiers.cpp
+++ b/Source/JavaScriptCore/runtime/CommonIdentifiers.cpp
@@ -27,6 +27,7 @@
 
 #define INITIALIZE_PROPERTY_NAME(name) , name(vm, #name)
 #define INITIALIZE_KEYWORD(name) , name##Keyword(vm, #name)
+#define INITIALIZE_PRIVATE_NAME(name) , name##PrivateName(Identifier::from(PrivateName()))
 
 CommonIdentifiers::CommonIdentifiers(VM* vm)
     : nullIdentifier()
@@ -34,11 +35,10 @@
     , underscoreProto(vm, "__proto__")
     , thisIdentifier(vm, "this")
     , useStrictIdentifier(vm, "use strict")
-    , iteratorPrivateName(Identifier::from(PrivateName()))
-    , iteratorNextPrivateName(Identifier::from(PrivateName()))
     , hasNextIdentifier(vm, "hasNext")
     JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(INITIALIZE_KEYWORD)
     JSC_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALIZE_PROPERTY_NAME)
+    JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALIZE_PRIVATE_NAME)
 {
 }
 
diff --git a/Source/JavaScriptCore/runtime/CommonIdentifiers.h b/Source/JavaScriptCore/runtime/CommonIdentifiers.h
index e4c2685..be8c0bf 100644
--- a/Source/JavaScriptCore/runtime/CommonIdentifiers.h
+++ b/Source/JavaScriptCore/runtime/CommonIdentifiers.h
@@ -46,7 +46,6 @@
     macro(Number) \
     macro(Object) \
     macro(Promise) \
-    macro(PromiseResolver) \
     macro(RangeError) \
     macro(ReferenceError) \
     macro(RegExp) \
@@ -205,6 +204,15 @@
     macro(with) \
     macro(yield)
 
+#define JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
+    macro(iterator) \
+    macro(iteratorNext) \
+    macro(resolve) \
+    macro(reject) \
+    macro(promise) \
+    macro(fulfillmentHandler) \
+    macro(rejectionHandler)
+
 namespace JSC {
 
     class CommonIdentifiers {
@@ -219,10 +227,7 @@
         const Identifier underscoreProto;
         const Identifier thisIdentifier;
         const Identifier useStrictIdentifier;
-        const Identifier iteratorPrivateName;
-        const Identifier iteratorNextPrivateName;
         const Identifier hasNextIdentifier;
-
         
 #define JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL(name) const Identifier name##Keyword;
         JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL)
@@ -231,6 +236,10 @@
 #define JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) const Identifier name;
         JSC_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL)
 #undef JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL
+
+#define JSC_IDENTIFIER_DECLARE_PRIVATE_PROPERTY_NAME_GLOBAL(name) const Identifier name##PrivateName;
+        JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(JSC_IDENTIFIER_DECLARE_PRIVATE_PROPERTY_NAME_GLOBAL)
+#undef JSC_IDENTIFIER_DECLARE_PRIVATE_PROPERTY_NAME_GLOBAL
     };
 
 } // namespace JSC
diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
index 3c025c1..e2dec0e 100644
--- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
@@ -89,6 +89,7 @@
 #include "MapIteratorPrototype.h"
 #include "MapPrototype.h"
 #include "MathObject.h"
+#include "Microtask.h"
 #include "NameConstructor.h"
 #include "NameInstance.h"
 #include "NamePrototype.h"
@@ -117,12 +118,8 @@
 
 #if ENABLE(PROMISES)
 #include "JSPromise.h"
-#include "JSPromiseCallback.h"
 #include "JSPromiseConstructor.h"
 #include "JSPromisePrototype.h"
-#include "JSPromiseResolver.h"
-#include "JSPromiseResolverConstructor.h"
-#include "JSPromiseResolverPrototype.h"
 #endif // ENABLE(PROMISES)
 
 #if ENABLE(REMOTE_INSPECTOR)
@@ -337,11 +334,6 @@
 #if ENABLE(PROMISES)
     m_promisePrototype.set(vm, this, JSPromisePrototype::create(exec, this, JSPromisePrototype::createStructure(vm, this, m_objectPrototype.get())));
     m_promiseStructure.set(vm, this, JSPromise::createStructure(vm, this, m_promisePrototype.get()));
-
-    m_promiseResolverPrototype.set(vm, this, JSPromiseResolverPrototype::create(exec, this, JSPromiseResolverPrototype::createStructure(vm, this, m_objectPrototype.get())));
-    m_promiseResolverStructure.set(vm, this, JSPromiseResolver::createStructure(vm, this, m_promiseResolverPrototype.get()));
-    m_promiseCallbackStructure.set(vm, this, JSPromiseCallback::createStructure(vm, this, m_functionPrototype.get()));
-    m_promiseWrapperCallbackStructure.set(vm, this, JSPromiseWrapperCallback::createStructure(vm, this, m_functionPrototype.get()));
 #endif // ENABLE(PROMISES)
 
 #define CREATE_PROTOTYPE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
@@ -358,11 +350,6 @@
     JSCell* functionConstructor = FunctionConstructor::create(vm, FunctionConstructor::createStructure(vm, this, m_functionPrototype.get()), m_functionPrototype.get());
     JSCell* arrayConstructor = ArrayConstructor::create(vm, ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_arrayPrototype.get());
 
-#if ENABLE(PROMISES)
-    JSCell* promiseConstructor = JSPromiseConstructor::create(vm, JSPromiseConstructor::createStructure(vm, this, m_functionPrototype.get()), m_promisePrototype.get());
-    JSCell* promiseResolverConstructor = JSPromiseResolverConstructor::create(vm, JSPromiseResolverConstructor::createStructure(vm, this, m_functionPrototype.get()), m_promiseResolverPrototype.get());
-#endif // ENABLE(PROMISES)
-
     m_regExpConstructor.set(vm, this, RegExpConstructor::create(vm, RegExpConstructor::createStructure(vm, this, m_functionPrototype.get()), m_regExpPrototype.get()));
 
 #define CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
@@ -383,14 +370,14 @@
     m_syntaxErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("SyntaxError")));
     m_typeErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("TypeError")));
     m_URIErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("URIError")));
+    m_promiseConstructor.set(vm, this, JSPromiseConstructor::create(vm, JSPromiseConstructor::createStructure(vm, this, m_functionPrototype.get()), m_promisePrototype.get()));
 
     m_objectPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, objectConstructor, DontEnum);
     m_functionPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, functionConstructor, DontEnum);
     m_arrayPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, arrayConstructor, DontEnum);
     m_regExpPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, m_regExpConstructor.get(), DontEnum);
 #if ENABLE(PROMISES)
-    m_promisePrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, promiseConstructor, DontEnum);
-    m_promiseResolverPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, promiseResolverConstructor, DontEnum);
+    m_promisePrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, m_promiseConstructor.get(), DontEnum);
 #endif
 
     putDirectWithoutTransition(vm, vm.propertyNames->Object, objectConstructor, DontEnum);
@@ -403,10 +390,7 @@
     putDirectWithoutTransition(vm, vm.propertyNames->SyntaxError, m_syntaxErrorConstructor.get(), DontEnum);
     putDirectWithoutTransition(vm, vm.propertyNames->TypeError, m_typeErrorConstructor.get(), DontEnum);
     putDirectWithoutTransition(vm, vm.propertyNames->URIError, m_URIErrorConstructor.get(), DontEnum);
-#if ENABLE(PROMISES)
-    putDirectWithoutTransition(vm, vm.propertyNames->Promise, promiseConstructor, DontEnum);
-    putDirectWithoutTransition(vm, vm.propertyNames->PromiseResolver, promiseResolverConstructor, DontEnum);
-#endif
+    putDirectWithoutTransition(vm, vm.propertyNames->Promise, m_promiseConstructor.get(), DontEnum);
 
 
 #define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
@@ -624,6 +608,7 @@
     visitor.append(&thisObject->m_syntaxErrorConstructor);
     visitor.append(&thisObject->m_typeErrorConstructor);
     visitor.append(&thisObject->m_URIErrorConstructor);
+    visitor.append(&thisObject->m_promiseConstructor);
 
     visitor.append(&thisObject->m_evalFunction);
     visitor.append(&thisObject->m_callFunction);
@@ -636,7 +621,6 @@
     visitor.append(&thisObject->m_errorPrototype);
 #if ENABLE(PROMISES)
     visitor.append(&thisObject->m_promisePrototype);
-    visitor.append(&thisObject->m_promiseResolverPrototype);
 #endif
 
     visitor.append(&thisObject->m_withScopeStructure);
@@ -668,9 +652,6 @@
 
 #if ENABLE(PROMISES)
     visitor.append(&thisObject->m_promiseStructure);
-    visitor.append(&thisObject->m_promiseResolverStructure);
-    visitor.append(&thisObject->m_promiseCallbackStructure);
-    visitor.append(&thisObject->m_promiseWrapperCallbackStructure);
 #endif // ENABLE(PROMISES)
 
 #define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName) \
@@ -798,4 +779,12 @@
 #endif
 }
 
+void JSGlobalObject::queueMicrotask(PassRefPtr<Microtask> task)
+{
+    if (globalObjectMethodTable()->queueTaskToEventLoop)
+        globalObjectMethodTable()->queueTaskToEventLoop(this, task);
+    else
+        WTFLogAlways("ERROR: Event loop not supported.");
+}
+
 } // namespace JSC
diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.h b/Source/JavaScriptCore/runtime/JSGlobalObject.h
index a681a79..f9d2900 100644
--- a/Source/JavaScriptCore/runtime/JSGlobalObject.h
+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.h
@@ -61,10 +61,11 @@
 class GetterSetter;
 class GlobalCodeBlock;
 class JSGlobalObjectDebuggable;
+class JSPromiseConstructor;
 class JSPromisePrototype;
-class JSPromiseResolverPrototype;
 class JSStack;
 class LLIntOffsetsExtractor;
+class Microtask;
 class NativeErrorConstructor;
 class ProgramCodeBlock;
 class ProgramExecutable;
@@ -103,13 +104,6 @@
 
 typedef Vector<ExecState*, 16> ExecStateStack;
 
-class TaskContext : public RefCounted<TaskContext> {
-public:
-    virtual ~TaskContext()
-    {
-    }
-};
-
 struct GlobalObjectMethodTable {
     typedef bool (*AllowsAccessFromFunctionPtr)(const JSGlobalObject*, ExecState*);
     AllowsAccessFromFunctionPtr allowsAccessFrom;
@@ -126,8 +120,7 @@
     typedef bool (*JavaScriptExperimentsEnabledFunctionPtr)(const JSGlobalObject*);
     JavaScriptExperimentsEnabledFunctionPtr javaScriptExperimentsEnabled;
 
-    typedef void (*QueueTaskToEventLoopCallbackFunctionPtr)(ExecState*, TaskContext*);
-    typedef void (*QueueTaskToEventLoopFunctionPtr)(const JSGlobalObject*, QueueTaskToEventLoopCallbackFunctionPtr, PassRefPtr<TaskContext>);
+    typedef void (*QueueTaskToEventLoopFunctionPtr)(const JSGlobalObject*, PassRefPtr<Microtask>);
     QueueTaskToEventLoopFunctionPtr queueTaskToEventLoop;
 
     typedef bool (*ShouldInterruptScriptBeforeTimeoutPtr)(const JSGlobalObject*);
@@ -152,7 +145,6 @@
     };
 
 protected:
-
     Register m_globalCallFrame[JSStack::CallFrameHeaderSize];
 
     WriteBarrier<JSObject> m_globalThis;
@@ -165,6 +157,7 @@
     WriteBarrier<NativeErrorConstructor> m_syntaxErrorConstructor;
     WriteBarrier<NativeErrorConstructor> m_typeErrorConstructor;
     WriteBarrier<NativeErrorConstructor> m_URIErrorConstructor;
+    WriteBarrier<JSPromiseConstructor> m_promiseConstructor;
 
     WriteBarrier<JSFunction> m_evalFunction;
     WriteBarrier<JSFunction> m_callFunction;
@@ -176,7 +169,6 @@
     WriteBarrier<ArrayPrototype> m_arrayPrototype;
     WriteBarrier<RegExpPrototype> m_regExpPrototype;
     WriteBarrier<JSPromisePrototype> m_promisePrototype;
-    WriteBarrier<JSPromiseResolverPrototype> m_promiseResolverPrototype;
 
     WriteBarrier<Structure> m_withScopeStructure;
     WriteBarrier<Structure> m_strictEvalActivationStructure;
@@ -210,9 +202,6 @@
 
 #if ENABLE(PROMISES)
     WriteBarrier<Structure> m_promiseStructure;
-    WriteBarrier<Structure> m_promiseResolverStructure;
-    WriteBarrier<Structure> m_promiseCallbackStructure;
-    WriteBarrier<Structure> m_promiseWrapperCallbackStructure;
 #endif // ENABLE(PROMISES)
 
 #define DEFINE_STORAGE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
@@ -347,6 +336,7 @@
     NativeErrorConstructor* syntaxErrorConstructor() const { return m_syntaxErrorConstructor.get(); }
     NativeErrorConstructor* typeErrorConstructor() const { return m_typeErrorConstructor.get(); }
     NativeErrorConstructor* URIErrorConstructor() const { return m_URIErrorConstructor.get(); }
+    JSPromiseConstructor* promiseConstructor() const { return m_promiseConstructor.get(); }
 
     JSFunction* evalFunction() const { return m_evalFunction.get(); }
     JSFunction* callFunction() const { return m_callFunction.get(); }
@@ -368,7 +358,6 @@
     RegExpPrototype* regExpPrototype() const { return m_regExpPrototype.get(); }
     ErrorPrototype* errorPrototype() const { return m_errorPrototype.get(); }
     JSPromisePrototype* promisePrototype() const { return m_promisePrototype.get(); }
-    JSPromiseResolverPrototype* promiseResolverPrototype() const { return m_promiseResolverPrototype.get(); }
 
     Structure* withScopeStructure() const { return m_withScopeStructure.get(); }
     Structure* strictEvalActivationStructure() const { return m_strictEvalActivationStructure.get(); }
@@ -423,9 +412,6 @@
 
 #if ENABLE(PROMISES)
     Structure* promiseStructure() const { return m_promiseStructure.get(); }
-    Structure* promiseResolverStructure() const { return m_promiseResolverStructure.get(); }
-    Structure* promiseCallbackStructure() const { return m_promiseCallbackStructure.get(); }
-    Structure* promiseWrapperCallbackStructure() const { return m_promiseWrapperCallbackStructure.get(); }
 #endif // ENABLE(PROMISES)
 
     JS_EXPORT_PRIVATE void setRemoteDebuggingEnabled(bool);
@@ -500,6 +486,8 @@
     static bool shouldInterruptScriptBeforeTimeout(const JSGlobalObject*) { return false; }
     static bool javaScriptExperimentsEnabled(const JSGlobalObject*) { return false; }
 
+    void queueMicrotask(PassRefPtr<Microtask>);
+
     bool evalEnabled() const { return m_evalEnabled; }
     const String& evalDisabledErrorMessage() const { return m_evalDisabledErrorMessage; }
     void setEvalEnabled(bool enabled, const String& errorMessage = String())
diff --git a/Source/JavaScriptCore/runtime/JSPromise.cpp b/Source/JavaScriptCore/runtime/JSPromise.cpp
index 80e17ea..9f182c9 100644
--- a/Source/JavaScriptCore/runtime/JSPromise.cpp
+++ b/Source/JavaScriptCore/runtime/JSPromise.cpp
@@ -31,48 +31,22 @@
 #include "Error.h"
 #include "JSCJSValueInlines.h"
 #include "JSCellInlines.h"
-#include "JSPromiseResolver.h"
+#include "JSPromiseConstructor.h"
+#include "JSPromiseReaction.h"
+#include "Microtask.h"
 #include "SlotVisitorInlines.h"
-#include "StrongInlines.h"
 #include "StructureInlines.h"
 
 namespace JSC {
 
-class JSPromiseTaskContext : public TaskContext {
-public:
-    static PassRefPtr<JSPromiseTaskContext> create(VM& vm, JSPromise* promise)
-    {
-        return adoptRef(new JSPromiseTaskContext(vm, promise));
-    }
-
-    JSPromise& promise() const { return *m_promise.get(); }
-
-private:
-    JSPromiseTaskContext(VM& vm, JSPromise* promise)
-    {
-        m_promise.set(vm, promise);
-    }
-
-    Strong<JSPromise> m_promise;
-};
+static void triggerPromiseReactions(VM&, JSGlobalObject*, Vector<WriteBarrier<JSPromiseReaction>>&, JSValue);
 
 const ClassInfo JSPromise::s_info = { "Promise", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSPromise) };
 
-JSPromise* JSPromise::create(VM& vm, Structure* structure)
-{
-    JSPromise* promise = new (NotNull, allocateCell<JSPromise>(vm.heap)) JSPromise(vm, structure);
-    promise->finishCreation(vm);
-    return promise;
-}
-
-JSPromise* JSPromise::createWithResolver(VM& vm, JSGlobalObject* globalObject)
+JSPromise* JSPromise::create(VM& vm, JSGlobalObject* globalObject, JSPromiseConstructor* constructor)
 {
     JSPromise* promise = new (NotNull, allocateCell<JSPromise>(vm.heap)) JSPromise(vm, globalObject->promiseStructure());
-    promise->finishCreation(vm);
-
-    JSPromiseResolver* resolver = JSPromiseResolver::create(vm, globalObject->promiseResolverStructure(), promise);
-    promise->setResolver(vm, resolver);
-
+    promise->finishCreation(vm, constructor);
     return promise;
 }
 
@@ -83,14 +57,16 @@
 
 JSPromise::JSPromise(VM& vm, Structure* structure)
     : JSDestructibleObject(vm, structure)
-    , m_state(Pending)
+    , m_status(Status::Unresolved)
 {
 }
 
-void JSPromise::finishCreation(VM& vm)
+void JSPromise::finishCreation(VM& vm, JSPromiseConstructor* constructor)
 {
     Base::finishCreation(vm);
     ASSERT(inherits(info()));
+    
+    m_constructor.set(vm, this, constructor);
 }
 
 void JSPromise::destroy(JSCell* cell)
@@ -107,137 +83,87 @@
 
     Base::visitChildren(thisObject, visitor);
 
-    visitor.append(&thisObject->m_resolver);
     visitor.append(&thisObject->m_result);
-
-    for (size_t i = 0; i < thisObject->m_fulfillCallbacks.size(); ++i)
-        visitor.append(&thisObject->m_fulfillCallbacks[i]);
-    for (size_t i = 0; i < thisObject->m_rejectCallbacks.size(); ++i)
-        visitor.append(&thisObject->m_rejectCallbacks[i]);
+    visitor.append(&thisObject->m_constructor);
+    visitor.append(thisObject->m_resolveReactions.begin(), thisObject->m_resolveReactions.end());
+    visitor.append(thisObject->m_rejectReactions.begin(), thisObject->m_rejectReactions.end());
 }
 
-void JSPromise::setResolver(VM& vm, JSPromiseResolver* resolver)
+void JSPromise::reject(VM& vm, JSValue reason)
 {
-    m_resolver.set(vm, this, resolver);
-}
-
-JSPromiseResolver* JSPromise::resolver() const
-{
-    return m_resolver.get();
-}
-
-void JSPromise::setResult(VM& vm, JSValue result)
-{
-    m_result.set(vm, this, result);
-}
-
-JSValue JSPromise::result() const
-{
-    return m_result.get();
-}
-
-void JSPromise::setState(JSPromise::State state)
-{
-    ASSERT(m_state == Pending);
-    m_state = state;
-}
-
-JSPromise::State JSPromise::state() const
-{
-    return m_state;
-}
-
-void JSPromise::appendCallbacks(ExecState* exec, InternalFunction* fulfillCallback, InternalFunction* rejectCallback)
-{
-    // 1. Append fulfillCallback to promise's fulfill callbacks.
-    m_fulfillCallbacks.append(WriteBarrier<InternalFunction>(exec->vm(), this, fulfillCallback));
-    
-    // 2. Append rejectCallback to promise' reject callbacks.
-    m_rejectCallbacks.append(WriteBarrier<InternalFunction>(exec->vm(), this, rejectCallback));
-
-    // 3. If promise's state is fulfilled, queue a task to process promise's fulfill callbacks with promise's result.
-    if (m_state == Fulfilled) {
-        queueTaskToProcessFulfillCallbacks(exec);
+    // 1. If the value of promise's internal slot [[PromiseStatus]] is not "unresolved", return.
+    if (m_status != Status::Unresolved)
         return;
-    }
 
-    // 4. If promise's state is rejected, queue a task to process promise's reject callbacks with promise's result.
-    if (m_state == Rejected) {
-        queueTaskToProcessRejectCallbacks(exec);
+    DeferGC deferGC(vm.heap);
+
+    // 2. Let 'reactions' be the value of promise's [[RejectReactions]] internal slot.
+    Vector<WriteBarrier<JSPromiseReaction>> reactions;
+    reactions.swap(m_rejectReactions);
+
+    // 3. Set the value of promise's [[Result]] internal slot to reason.
+    m_result.set(vm, this, reason);
+
+    // 4. Set the value of promise's [[ResolveReactions]] internal slot to undefined.
+    m_resolveReactions.clear();
+
+    // 5. Set the value of promise's [[RejectReactions]] internal slot to undefined.
+    // NOTE: Handled by the swap above.
+
+    // 6. Set the value of promise's [[PromiseStatus]] internal slot to "has-rejection".
+    m_status = Status::HasRejection;
+
+    // 7. Return the result of calling TriggerPromiseReactions(reactions, reason).
+    triggerPromiseReactions(vm, globalObject(), reactions, reason);
+}
+
+void JSPromise::resolve(VM& vm, JSValue resolution)
+{
+    // 1. If the value of promise's internal slot [[PromiseStatus]] is not "unresolved", return.
+    if (m_status != Status::Unresolved)
         return;
-    }
+
+    DeferGC deferGC(vm.heap);
+
+    // 2. Let 'reactions' be the value of promise's [[ResolveReactions]] internal slot.
+    Vector<WriteBarrier<JSPromiseReaction>> reactions;
+    reactions.swap(m_resolveReactions);
+    
+    // 3. Set the value of promise's [[Result]] internal slot to resolution.
+    m_result.set(vm, this, resolution);
+
+    // 4. Set the value of promise's [[ResolveReactions]] internal slot to undefined.
+    // NOTE: Handled by the swap above.
+
+    // 5. Set the value of promise's [[RejectReactions]] internal slot to undefined.
+    m_rejectReactions.clear();
+
+    // 6. Set the value of promise's [[PromiseStatus]] internal slot to "has-resolution".
+    m_status = Status::HasResolution;
+
+    // 7. Return the result of calling TriggerPromiseReactions(reactions, resolution).
+    triggerPromiseReactions(vm, globalObject(), reactions, resolution);
 }
 
-void JSPromise::queueTaskToProcessFulfillCallbacks(ExecState* exec)
+void JSPromise::appendResolveReaction(VM& vm, JSPromiseReaction* reaction)
 {
-    JSGlobalObject* globalObject = this->globalObject();
-    if (globalObject->globalObjectMethodTable()->queueTaskToEventLoop)
-        globalObject->globalObjectMethodTable()->queueTaskToEventLoop(globalObject, processFulfillCallbacksForTask, JSPromiseTaskContext::create(exec->vm(), this));
-    else
-        WTFLogAlways("ERROR: Event loop not supported.");
+    m_resolveReactions.append(WriteBarrier<JSPromiseReaction>(vm, this, reaction));
 }
 
-void JSPromise::queueTaskToProcessRejectCallbacks(ExecState* exec)
+void JSPromise::appendRejectReaction(VM& vm, JSPromiseReaction* reaction)
 {
-    JSGlobalObject* globalObject = this->globalObject();
-    if (globalObject->globalObjectMethodTable()->queueTaskToEventLoop)
-        globalObject->globalObjectMethodTable()->queueTaskToEventLoop(globalObject, processRejectCallbacksForTask, JSPromiseTaskContext::create(exec->vm(), this));
-    else
-        WTFLogAlways("ERROR: Event loop not supported.");
+    m_rejectReactions.append(WriteBarrier<JSPromiseReaction>(vm, this, reaction));
 }
 
-void JSPromise::processFulfillCallbacksForTask(ExecState* exec, TaskContext* taskContext)
+void triggerPromiseReactions(VM& vm, JSGlobalObject* globalObject, Vector<WriteBarrier<JSPromiseReaction>>& reactions, JSValue argument)
 {
-    JSPromiseTaskContext* promiseTaskContext = static_cast<JSPromiseTaskContext*>(taskContext);
-    JSPromise& promise = promiseTaskContext->promise();
-
-    promise.processFulfillCallbacksWithValue(exec, promise.result());
-}
-
-void JSPromise::processRejectCallbacksForTask(ExecState* exec, TaskContext* taskContext)
-{
-    JSPromiseTaskContext* promiseTaskContext = static_cast<JSPromiseTaskContext*>(taskContext);
-    JSPromise& promise = promiseTaskContext->promise();
-
-    promise.processRejectCallbacksWithValue(exec, promise.result());
-}
-
-void JSPromise::processFulfillCallbacksWithValue(ExecState* exec, JSValue value)
-{
-    ASSERT(m_state == Fulfilled);
-
-    for (size_t i = 0; i < m_fulfillCallbacks.size(); ++i) {
-        JSValue callback = m_fulfillCallbacks[i].get();
-
-        CallData callData;
-        CallType callType = JSC::getCallData(callback, callData);
-        ASSERT(callType != CallTypeNone);
-
-        MarkedArgumentBuffer arguments;
-        arguments.append(value);
-        call(exec, callback, callType, callData, this, arguments);
+    // 1. Repeat for each reaction in reactions, in original insertion order
+    for (auto& reaction : reactions) {
+        // i. Call QueueMicrotask(ExecutePromiseReaction, (reaction, argument)).
+        globalObject->queueMicrotask(createExecutePromiseReactionMicrotask(vm, reaction.get(), argument));
     }
     
-    m_fulfillCallbacks.clear();
-}
-
-void JSPromise::processRejectCallbacksWithValue(ExecState* exec, JSValue value)
-{
-    ASSERT(m_state == Rejected);
-
-    for (size_t i = 0; i < m_rejectCallbacks.size(); ++i) {
-        JSValue callback = m_rejectCallbacks[i].get();
-
-        CallData callData;
-        CallType callType = JSC::getCallData(callback, callData);
-        ASSERT(callType != CallTypeNone);
-
-        MarkedArgumentBuffer arguments;
-        arguments.append(value);
-        call(exec, callback, callType, callData, this, arguments);
-    }
-    
-    m_rejectCallbacks.clear();
+    // 2. Return.
 }
 
 } // namespace JSC
diff --git a/Source/JavaScriptCore/runtime/JSPromise.h b/Source/JavaScriptCore/runtime/JSPromise.h
index 26d2e0b..d1d1854d9 100644
--- a/Source/JavaScriptCore/runtime/JSPromise.h
+++ b/Source/JavaScriptCore/runtime/JSPromise.h
@@ -32,61 +32,58 @@
 
 namespace JSC {
 
-class JSPromiseResolver;
-class InternalFunction;
-class TaskContext;
+class JSPromiseReaction;
+class JSPromiseConstructor;
 
 class JSPromise : public JSDestructibleObject {
 public:
     typedef JSDestructibleObject Base;
 
-    static JSPromise* create(VM&, Structure*);
+    static JSPromise* create(VM&, JSGlobalObject*, JSPromiseConstructor*);
     static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
 
-    JS_EXPORT_PRIVATE static JSPromise* createWithResolver(VM&, JSGlobalObject*);
-
     DECLARE_INFO;
 
-    void setResolver(VM&, JSPromiseResolver*);
-    JS_EXPORT_PRIVATE JSPromiseResolver* resolver() const;
-
-    enum State {
-        Pending,
-        Fulfilled,
-        Rejected,
+    enum class Status {
+        Unresolved,
+        HasResolution,
+        HasRejection
     };
 
-    void setState(State);
-    State state() const;
+    Status status() const
+    {
+        return m_status;
+    }
 
-    void setResult(VM&, JSValue);
-    JSValue result() const;
+    JSValue result() const
+    {
+        ASSERT(m_status != Status::Unresolved);
+        return m_result.get();
+    }
 
-    void appendCallbacks(ExecState*, InternalFunction* fulfillCallback, InternalFunction* rejectCallback);
+    JSPromiseConstructor* constructor() const
+    {
+        return m_constructor.get();
+    }
 
-    void queueTaskToProcessFulfillCallbacks(ExecState*);
-    void queueTaskToProcessRejectCallbacks(ExecState*);
-    void processFulfillCallbacksWithValue(ExecState*, JSValue);
-    void processRejectCallbacksWithValue(ExecState*, JSValue);
+    void reject(VM&, JSValue);
+    void resolve(VM&, JSValue);
 
-protected:
-    void finishCreation(VM&);
-    static const unsigned StructureFlags = OverridesVisitChildren | JSObject::StructureFlags;
+    void appendResolveReaction(VM&, JSPromiseReaction*);
+    void appendRejectReaction(VM&, JSPromiseReaction*);
 
 private:
     JSPromise(VM&, Structure*);
-
-    static void processFulfillCallbacksForTask(ExecState*, TaskContext*);
-    static void processRejectCallbacksForTask(ExecState*, TaskContext*);
-
+    void finishCreation(VM&, JSPromiseConstructor*);
+    static const unsigned StructureFlags = OverridesVisitChildren | JSObject::StructureFlags;
     static void destroy(JSCell*);
     static void visitChildren(JSCell*, SlotVisitor&);
 
-    WriteBarrier<JSPromiseResolver> m_resolver;
+    Status m_status;
     WriteBarrier<Unknown> m_result;
-    Vector<WriteBarrier<InternalFunction>> m_fulfillCallbacks;
-    Vector<WriteBarrier<InternalFunction>> m_rejectCallbacks;
-    State m_state;
+    WriteBarrier<JSPromiseConstructor> m_constructor;
+    Vector<WriteBarrier<JSPromiseReaction>> m_resolveReactions;
+    Vector<WriteBarrier<JSPromiseReaction>> m_rejectReactions;
 };
 
 } // namespace JSC
diff --git a/Source/JavaScriptCore/runtime/JSPromiseCallback.cpp b/Source/JavaScriptCore/runtime/JSPromiseCallback.cpp
deleted file mode 100644
index 79d3421..0000000
--- a/Source/JavaScriptCore/runtime/JSPromiseCallback.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "JSPromiseCallback.h"
-
-#if ENABLE(PROMISES)
-
-#include "JSCJSValueInlines.h"
-#include "JSCellInlines.h"
-#include "JSPromise.h"
-#include "JSPromiseResolver.h"
-#include "SlotVisitorInlines.h"
-#include "StructureInlines.h"
-
-namespace JSC {
-
-const ClassInfo JSPromiseCallback::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSPromiseCallback) };
-
-JSPromiseCallback* JSPromiseCallback::create(VM& vm, Structure* structure, JSPromiseResolver* resolver, Algorithm algorithm)
-{
-    JSPromiseCallback* constructor = new (NotNull, allocateCell<JSPromiseCallback>(vm.heap)) JSPromiseCallback(vm, structure, algorithm);
-    constructor->finishCreation(vm, resolver);
-    return constructor;
-}
-
-Structure* JSPromiseCallback::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
-{
-    return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
-}
-
-JSPromiseCallback::JSPromiseCallback(VM& vm, Structure* structure, Algorithm algorithm)
-    : InternalFunction(vm, structure)
-    , m_algorithm(algorithm)
-{
-}
-
-void JSPromiseCallback::finishCreation(VM& vm, JSPromiseResolver* resolver)
-{
-    Base::finishCreation(vm, "PromiseCallback");
-    m_resolver.set(vm, this, resolver);
-}
-
-void JSPromiseCallback::visitChildren(JSCell* cell, SlotVisitor& visitor)
-{
-    JSPromiseCallback* thisObject = jsCast<JSPromiseCallback*>(cell);
-    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-    COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
-    ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
-
-    Base::visitChildren(thisObject, visitor);
-
-    visitor.append(&thisObject->m_resolver);
-}
-
-EncodedJSValue JSC_HOST_CALL JSPromiseCallback::callPromiseCallback(ExecState* exec)
-{
-    JSPromiseCallback* promiseCallback = jsCast<JSPromiseCallback*>(exec->callee());
-    JSPromiseResolver* resolver = promiseCallback->m_resolver.get();
-
-    // 1. Let value be the first argument that is passed, and undefined otherwise.
-    JSValue value = exec->argument(0);
-
-    // 2. Run resolver's algorithm with value and the synchronous flag set.
-    switch (promiseCallback->m_algorithm) {
-    case JSPromiseCallback::Fulfill:
-        resolver->fulfill(exec, value, JSPromiseResolver::ResolveSynchronously);
-        break;
-
-    case JSPromiseCallback::Resolve:
-        resolver->resolve(exec, value, JSPromiseResolver::ResolveSynchronously);
-        break;
-
-    case JSPromiseCallback::Reject:
-        resolver->reject(exec, value, JSPromiseResolver::ResolveSynchronously);
-        break;
-    }
-
-    return JSValue::encode(jsUndefined());
-}
-
-CallType JSPromiseCallback::getCallData(JSCell*, CallData& callData)
-{
-    callData.native.function = callPromiseCallback;
-    return CallTypeHost;
-}
-
-
-
-
-const ClassInfo JSPromiseWrapperCallback::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSPromiseWrapperCallback) };
-
-JSPromiseWrapperCallback* JSPromiseWrapperCallback::create(VM& vm, Structure* structure, JSPromiseResolver* resolver, JSValue callback)
-{
-    JSPromiseWrapperCallback* constructor = new (NotNull, allocateCell<JSPromiseWrapperCallback>(vm.heap)) JSPromiseWrapperCallback(vm, structure);
-    constructor->finishCreation(vm, resolver, callback);
-    return constructor;
-}
-
-Structure* JSPromiseWrapperCallback::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
-{
-    return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
-}
-
-JSPromiseWrapperCallback::JSPromiseWrapperCallback(VM& vm, Structure* structure)
-    : InternalFunction(vm, structure)
-{
-}
-
-void JSPromiseWrapperCallback::finishCreation(VM& vm, JSPromiseResolver* resolver, JSValue callback)
-{
-    Base::finishCreation(vm, "PromiseWrapperCallback");
-    m_resolver.set(vm, this, resolver);
-    m_callback.set(vm, this, callback);
-}
-
-void JSPromiseWrapperCallback::visitChildren(JSCell* cell, SlotVisitor& visitor)
-{
-    JSPromiseWrapperCallback* thisObject = jsCast<JSPromiseWrapperCallback*>(cell);
-    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-    COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
-    ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
-
-    Base::visitChildren(thisObject, visitor);
-
-    visitor.append(&thisObject->m_resolver);
-    visitor.append(&thisObject->m_callback);
-}
-
-EncodedJSValue JSC_HOST_CALL JSPromiseWrapperCallback::callPromiseWrapperCallback(ExecState* exec)
-{
-    JSPromiseWrapperCallback* promiseWrapperCallback = jsCast<JSPromiseWrapperCallback*>(exec->callee());
-
-    JSPromiseResolver* resolver = promiseWrapperCallback->m_resolver.get();
-    JSValue callback = promiseWrapperCallback->m_callback.get();
-
-    // 1. Let argument be the first argument that is passed, and undefined otherwise.
-    JSValue argument = exec->argument(0);
-
-    // 2. Set callback's callback this value to resolver's associated promise.
-    // 3. Let value be the result of invoking callback with argument as argument.
-    CallData callData;
-    CallType callType = JSC::getCallData(callback, callData);
-    ASSERT(callType != CallTypeNone);
-
-    MarkedArgumentBuffer callbackArguments;
-    callbackArguments.append(argument);
-    JSValue value = JSC::call(exec, callback, callType, callData, resolver->promise(), callbackArguments);
-
-    // 4. If invoking callback threw an exception, catch it and run resolver's reject
-    //    with the thrown exception as argument and the synchronous flag set.
-    if (exec->hadException()) {
-        JSValue exception = exec->exception();
-        exec->clearException();
-
-        resolver->reject(exec, exception, JSPromiseResolver::ResolveSynchronously);
-        return JSValue::encode(jsUndefined());
-    }
-
-    // 5. Otherwise, run resolver's resolve with value and the synchronous flag set.
-    resolver->resolve(exec, value, JSPromiseResolver::ResolveSynchronously);
-
-    return JSValue::encode(jsUndefined());
-}
-
-CallType JSPromiseWrapperCallback::getCallData(JSCell*, CallData& callData)
-{
-    callData.native.function = callPromiseWrapperCallback;
-    return CallTypeHost;
-}
-
-} // namespace JSC
-
-#endif // ENABLE(PROMISES)
diff --git a/Source/JavaScriptCore/runtime/JSPromiseCallback.h b/Source/JavaScriptCore/runtime/JSPromiseCallback.h
deleted file mode 100644
index ab9353b..0000000
--- a/Source/JavaScriptCore/runtime/JSPromiseCallback.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef JSPromiseCallback_h
-#define JSPromiseCallback_h
-
-#if ENABLE(PROMISES)
-
-#include "InternalFunction.h"
-
-namespace JSC {
-
-class JSPromiseResolver;
-
-class JSPromiseCallback : public InternalFunction {
-public:
-    typedef InternalFunction Base;
-
-    enum Algorithm {
-        Fulfill,
-        Resolve,
-        Reject,
-    };
-
-    static JSPromiseCallback* create(VM&, Structure*, JSPromiseResolver*, Algorithm);
-    static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
-
-    DECLARE_INFO;
-
-private:
-    JSPromiseCallback(VM&, Structure*, Algorithm);
-    void finishCreation(VM&, JSPromiseResolver*);
-    static const unsigned StructureFlags = OverridesVisitChildren | JSObject::StructureFlags;
-
-    static EncodedJSValue JSC_HOST_CALL callPromiseCallback(ExecState*);
-    static CallType getCallData(JSCell*, CallData&);
-
-    static void visitChildren(JSCell*, SlotVisitor&);
-
-    WriteBarrier<JSPromiseResolver> m_resolver;
-    Algorithm m_algorithm;
-};
-
-class JSPromiseWrapperCallback : public InternalFunction {
-public:
-    typedef InternalFunction Base;
-
-    static JSPromiseWrapperCallback* create(VM&, Structure*, JSPromiseResolver*, JSValue callback);
-    static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
-
-    DECLARE_INFO;
-
-private:
-    JSPromiseWrapperCallback(VM&, Structure*);
-    void finishCreation(VM&, JSPromiseResolver*, JSValue callback);
-    static const unsigned StructureFlags = OverridesVisitChildren | JSObject::StructureFlags;
-
-    static EncodedJSValue JSC_HOST_CALL callPromiseWrapperCallback(ExecState*);
-    static CallType getCallData(JSCell*, CallData&);
-
-    static void visitChildren(JSCell*, SlotVisitor&);
-
-    WriteBarrier<JSPromiseResolver> m_resolver;
-    WriteBarrier<Unknown> m_callback;
-};
-
-} // namespace JSC
-
-#endif // ENABLE(PROMISES)
-
-#endif // JSPromiseCallback_h
diff --git a/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp b/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp
index 88cfb48..3c3aa63 100644
--- a/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp
@@ -32,9 +32,9 @@
 #include "JSCJSValueInlines.h"
 #include "JSCellInlines.h"
 #include "JSPromise.h"
-#include "JSPromiseCallback.h"
+#include "JSPromiseDeferred.h"
+#include "JSPromiseFunctions.h"
 #include "JSPromisePrototype.h"
-#include "JSPromiseResolver.h"
 #include "Lookup.h"
 #include "StructureInlines.h"
 
@@ -42,13 +42,9 @@
 
 STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSPromiseConstructor);
 
-// static Promise fulfill(any value);
-static EncodedJSValue JSC_HOST_CALL JSPromiseConstructorFuncFulfill(ExecState*);
-// static Promise resolve(any value); // same as any(value)
+static EncodedJSValue JSC_HOST_CALL JSPromiseConstructorFuncCast(ExecState*);
 static EncodedJSValue JSC_HOST_CALL JSPromiseConstructorFuncResolve(ExecState*);
-// static Promise reject(any value);
 static EncodedJSValue JSC_HOST_CALL JSPromiseConstructorFuncReject(ExecState*);
-
 }
 
 #include "JSPromiseConstructor.lut.h"
@@ -59,7 +55,7 @@
 
 /* Source for JSPromiseConstructor.lut.h
 @begin promiseConstructorTable
-  fulfill         JSPromiseConstructorFuncFulfill             DontEnum|Function 1
+  cast            JSPromiseConstructorFuncCast                DontEnum|Function 1
   resolve         JSPromiseConstructorFuncResolve             DontEnum|Function 1
   reject          JSPromiseConstructorFuncReject              DontEnum|Function 1
 @end
@@ -91,39 +87,58 @@
 
 static EncodedJSValue JSC_HOST_CALL constructPromise(ExecState* exec)
 {
-    if (!exec->argumentCount())
-        return throwVMError(exec, createTypeError(exec, "Expected at least one argument"));
+    // NOTE: We ignore steps 1-4 as they only matter if you support subclassing, which we do not yet.
+    // 1. Let promise be the this value.
+    // 2. If Type(promise) is not Object, then throw a TypeError exception.
+    // 3. If promise does not have a [[PromiseStatus]] internal slot, then throw a TypeError exception.
+    // 4. If promise's [[PromiseStatus]] internal slot is not undefined, then throw a TypeError exception.
 
-    JSValue function = exec->uncheckedArgument(0);
+    JSValue resolver = exec->argument(0);
 
+    // 5. IsCallable(resolver) is false, then throw a TypeError exception
     CallData callData;
-    CallType callType = getCallData(function, callData);
+    CallType callType = getCallData(resolver, callData);
     if (callType == CallTypeNone)
-        return throwVMError(exec, createTypeError(exec, "Expected function as as first argument"));
+        return JSValue::encode(throwTypeError(exec, ASCIILiteral("Promise constructor takes a function argument")));
 
-    JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();
+    VM& vm = exec->vm();
+    JSGlobalObject* globalObject = exec->callee()->globalObject();
+
+    JSPromise* promise = JSPromise::create(vm, globalObject, jsCast<JSPromiseConstructor*>(exec->callee()));
+
+    // NOTE: Steps 6-8 are handled by JSPromise::create().
+    // 6. Set promise's [[PromiseStatus]] internal slot to "unresolved".
+    // 7. Set promise's [[ResolveReactions]] internal slot to a new empty List.
+    // 8. Set promise's [[RejectReactions]] internal slot to a new empty List.
     
-    // 1. Let promise be a new promise.
-    JSPromise* promise = JSPromise::createWithResolver(exec->vm(), globalObject);
+    // 9. Let 'resolve' be a new built-in function object as defined in Resolve Promise Functions.
+    JSFunction* resolve = createResolvePromiseFunction(vm, globalObject);
 
-    // 2. Let resolver be promise's associated resolver.
-    JSPromiseResolver* resolver = promise->resolver();
+    // 10. Set the [[Promise]] internal slot of 'resolve' to 'promise'.
+    resolve->putDirect(vm, vm.propertyNames->promisePrivateName, promise);
+    
+    // 11. Let 'reject' be a new built-in function object as defined in Reject Promise Functions
+    JSFunction* reject = createRejectPromiseFunction(vm, globalObject);
 
-    // 3. Set init's callback this value to promise.
-    // 4. Invoke init with resolver passed as parameter.
-    MarkedArgumentBuffer initArguments;
-    initArguments.append(resolver);
-    call(exec, function, callType, callData, promise, initArguments);
+    // 12. Set the [[Promise]] internal slot of 'reject' to 'promise'.
+    reject->putDirect(vm, vm.propertyNames->promisePrivateName, promise);
 
-    // 5. If init threw an exception, catch it, and then, if resolver's resolved flag
-    //    is unset, run resolver's reject with the thrown exception as argument.
+    // 13. Let 'result' be the result of calling the [[Call]] internal method of resolver with
+    //     undefined as thisArgument and a List containing resolve and reject as argumentsList.
+    MarkedArgumentBuffer arguments;
+    arguments.append(resolve);
+    arguments.append(reject);
+    call(exec, resolver, callType, callData, jsUndefined(), arguments);
+
+    // 14. If result is an abrupt completion, call PromiseReject(promise, result.[[value]]).
     if (exec->hadException()) {
         JSValue exception = exec->exception();
         exec->clearException();
 
-        resolver->rejectIfNotResolved(exec, exception);
+        promise->reject(vm, exception);
     }
 
+    // 15. Return promise.
     return JSValue::encode(promise);
 }
 
@@ -135,6 +150,7 @@
 
 CallType JSPromiseConstructor::getCallData(JSCell*, CallData&)
 {
+    // FIXME: Implement
     return CallTypeNone;
 }
 
@@ -143,43 +159,148 @@
     return getStaticFunctionSlot<InternalFunction>(exec, ExecState::promiseConstructorTable(exec), jsCast<JSPromiseConstructor*>(object), propertyName, slot);
 }
 
-EncodedJSValue JSC_HOST_CALL JSPromiseConstructorFuncFulfill(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL JSPromiseConstructorFuncCast(ExecState* exec)
 {
-    if (!exec->argumentCount())
-        return throwVMError(exec, createTypeError(exec, "Expected at least one argument"));
+    // -- Promise.cast(x) --
+    JSValue x = exec->argument(0);
 
-    JSGlobalObject* globalObject = exec->callee()->globalObject();
+    // 1. Let 'C' be the this value.
+    JSValue C = exec->thisValue();
 
-    JSPromise* promise = JSPromise::createWithResolver(exec->vm(), globalObject);
-    promise->resolver()->fulfill(exec, exec->uncheckedArgument(0));
+    // 2. If IsPromise(x) is true,
+    JSPromise* promise = jsDynamicCast<JSPromise*>(x);
+    if (promise) {
+        // i. Let 'constructor' be the value of x's [[PromiseConstructor]] internal slot.
+        JSValue constructor = promise->constructor();
+        // ii. If SameValue(constructor, C) is true, return x.
+        if (sameValue(exec, constructor, C))
+            return JSValue::encode(x);
+    }
 
-    return JSValue::encode(promise);
+    // 3. Let 'deferred' be the result of calling GetDeferred(C).
+    JSValue deferredValue = createJSPromiseDeferredFromConstructor(exec, C);
+    
+    // 4. ReturnIfAbrupt(deferred).
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    JSPromiseDeferred* deferred = jsCast<JSPromiseDeferred*>(deferredValue);
+
+    // 5. Let 'resolveResult' be the result of calling the [[Call]] internal method
+    //    of deferred.[[Resolve]] with undefined as thisArgument and a List containing x
+    //    as argumentsList.
+    
+    JSValue deferredResolve = deferred->resolve();
+
+    CallData resolveCallData;
+    CallType resolveCallType = getCallData(deferredResolve, resolveCallData);
+    ASSERT(resolveCallType != CallTypeNone);
+
+    MarkedArgumentBuffer arguments;
+    arguments.append(x);
+
+    call(exec, deferredResolve, resolveCallType, resolveCallData, jsUndefined(), arguments);
+
+    // 6. ReturnIfAbrupt(resolveResult).
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    // 7. Return deferred.[[Promise]].
+    return JSValue::encode(deferred->promise());
 }
 
 EncodedJSValue JSC_HOST_CALL JSPromiseConstructorFuncResolve(ExecState* exec)
 {
-    if (!exec->argumentCount())
-        return throwVMError(exec, createTypeError(exec, "Expected at least one argument"));
+    // -- Promise.resolve(x) --
+    JSValue x = exec->argument(0);
 
-    JSGlobalObject* globalObject = exec->callee()->globalObject();
+    // 1. Let 'C' be the this value.
+    JSValue C = exec->thisValue();
 
-    JSPromise* promise = JSPromise::createWithResolver(exec->vm(), globalObject);
-    promise->resolver()->resolve(exec, exec->uncheckedArgument(0));
+    // 2. Let 'deferred' be the result of calling GetDeferred(C).
+    JSValue deferredValue = createJSPromiseDeferredFromConstructor(exec, C);
 
-    return JSValue::encode(promise);
+    // 3. ReturnIfAbrupt(deferred).
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    JSPromiseDeferred* deferred = jsCast<JSPromiseDeferred*>(deferredValue);
+
+    // 4. Let 'resolveResult' be the result of calling the [[Call]] internal method
+    //    of deferred.[[Resolve]] with undefined as thisArgument and a List containing x
+    //    as argumentsList.
+
+    JSValue deferredResolve = deferred->resolve();
+
+    CallData resolveCallData;
+    CallType resolveCallType = getCallData(deferredResolve, resolveCallData);
+    ASSERT(resolveCallType != CallTypeNone);
+
+    MarkedArgumentBuffer arguments;
+    arguments.append(x);
+
+    call(exec, deferredResolve, resolveCallType, resolveCallData, jsUndefined(), arguments);
+    
+    // 5. ReturnIfAbrupt(resolveResult).
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    // 6. Return deferred.[[Promise]].
+    return JSValue::encode(deferred->promise());
 }
 
 EncodedJSValue JSC_HOST_CALL JSPromiseConstructorFuncReject(ExecState* exec)
 {
-    if (!exec->argumentCount())
-        return throwVMError(exec, createTypeError(exec, "Expected at least one argument"));
+    // -- Promise.reject(x) --
+    JSValue r = exec->argument(0);
 
-    JSGlobalObject* globalObject = exec->callee()->globalObject();
+    // 1. Let 'C' be the this value.
+    JSValue C = exec->thisValue();
 
-    JSPromise* promise = JSPromise::createWithResolver(exec->vm(), globalObject);
-    promise->resolver()->reject(exec, exec->uncheckedArgument(0));
+    // 2. Let 'deferred' be the result of calling GetDeferred(C).
+    JSValue deferredValue = createJSPromiseDeferredFromConstructor(exec, C);
 
-    return JSValue::encode(promise);
+    // 3. ReturnIfAbrupt(deferred).
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    JSPromiseDeferred* deferred = jsCast<JSPromiseDeferred*>(deferredValue);
+
+    // 4. Let 'rejectResult' be the result of calling the [[Call]] internal method
+    //    of deferred.[[Reject]] with undefined as thisArgument and a List containing r
+    //    as argumentsList.
+
+    JSValue deferredReject = deferred->reject();
+
+    CallData rejectCallData;
+    CallType rejectCallType = getCallData(deferredReject, rejectCallData);
+    ASSERT(rejectCallType != CallTypeNone);
+
+    MarkedArgumentBuffer arguments;
+    arguments.append(r);
+
+    call(exec, deferredReject, rejectCallType, rejectCallData, jsUndefined(), arguments);
+
+    // 5. ReturnIfAbrupt(resolveResult).
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    // 6. Return deferred.[[Promise]].
+    return JSValue::encode(deferred->promise());
+}
+
+JSPromise* constructPromise(ExecState* exec, JSGlobalObject* globalObject, JSFunction* resolver)
+{
+    JSPromiseConstructor* promiseConstructor = globalObject->promiseConstructor();
+
+    ConstructData constructData;
+    ConstructType constructType = getConstructData(promiseConstructor, constructData);
+    ASSERT(constructType != ConstructTypeNone);
+
+    MarkedArgumentBuffer arguments;
+    arguments.append(resolver);
+
+    return jsCast<JSPromise*>(construct(exec, promiseConstructor, constructType, constructData, arguments));
 }
 
 } // namespace JSC
diff --git a/Source/JavaScriptCore/runtime/JSPromiseConstructor.h b/Source/JavaScriptCore/runtime/JSPromiseConstructor.h
index 601e955..498bb8b 100644
--- a/Source/JavaScriptCore/runtime/JSPromiseConstructor.h
+++ b/Source/JavaScriptCore/runtime/JSPromiseConstructor.h
@@ -32,6 +32,7 @@
 
 namespace JSC {
 
+class JSPromise;
 class JSPromisePrototype;
 
 class JSPromiseConstructor : public InternalFunction {
@@ -54,6 +55,8 @@
     static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
 };
 
+JSPromise* constructPromise(ExecState*, JSGlobalObject*, JSFunction*);
+
 } // namespace JSC
 
 #endif // ENABLE(PROMISES)
diff --git a/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp b/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp
new file mode 100644
index 0000000..e4ccc1f
--- /dev/null
+++ b/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSPromiseDeferred.h"
+
+#include "Error.h"
+#include "JSCJSValueInlines.h"
+#include "JSCellInlines.h"
+#include "JSPromise.h"
+#include "JSPromiseConstructor.h"
+#include "JSPromiseFunctions.h"
+#include "SlotVisitorInlines.h"
+
+namespace JSC {
+
+const ClassInfo JSPromiseDeferred::s_info = { "JSPromiseDeferred", 0, 0, 0, CREATE_METHOD_TABLE(JSPromiseDeferred) };
+
+JSPromiseDeferred* JSPromiseDeferred::create(ExecState* exec, JSGlobalObject* globalObject)
+{
+    VM& vm = exec->vm();
+    
+    JSFunction* resolver = createDeferredConstructionFunction(vm, globalObject);
+
+    JSPromise* promise = constructPromise(exec, globalObject, resolver);
+    JSValue resolve = resolver->get(exec, vm.propertyNames->resolvePrivateName);
+    JSValue reject = resolver->get(exec, vm.propertyNames->rejectPrivateName);
+
+    return JSPromiseDeferred::create(vm, promise, resolve, reject);
+}
+
+JSPromiseDeferred* JSPromiseDeferred::create(VM& vm, JSObject* promise, JSValue resolve, JSValue reject)
+{
+    JSPromiseDeferred* deferred = new (NotNull, allocateCell<JSPromiseDeferred>(vm.heap)) JSPromiseDeferred(vm);
+    deferred->finishCreation(vm, promise, resolve, reject);
+    return deferred;
+}
+
+JSPromiseDeferred::JSPromiseDeferred(VM& vm)
+    : Base(vm, vm.promiseDeferredStructure.get())
+{
+}
+
+void JSPromiseDeferred::finishCreation(VM& vm, JSObject* promise, JSValue resolve, JSValue reject)
+{
+    Base::finishCreation(vm);
+    m_promise.set(vm, this, promise);
+    m_resolve.set(vm, this, resolve);
+    m_reject.set(vm, this, reject);
+}
+
+void JSPromiseDeferred::visitChildren(JSCell* cell, SlotVisitor& visitor)
+{
+    JSPromiseDeferred* thisObject = jsCast<JSPromiseDeferred*>(cell);
+    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+    COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
+    ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
+
+    Base::visitChildren(thisObject, visitor);
+
+    visitor.append(&thisObject->m_promise);
+    visitor.append(&thisObject->m_resolve);
+    visitor.append(&thisObject->m_reject);
+}
+
+JSValue createJSPromiseDeferredFromConstructor(ExecState* exec, JSValue C)
+{
+    // -- This implements the GetDeferred(C) abstract operation --
+
+    // 1. If IsConstructor(C) is false, throw a TypeError.
+    if (!C.isObject())
+        return throwTypeError(exec);
+
+    ConstructData constructData;
+    ConstructType constructType = getConstructData(C, constructData);
+    if (constructType == ConstructTypeNone)
+        return throwTypeError(exec);
+
+    VM& vm = exec->vm();
+
+    // 2. Let 'resolver' be a new built-in function object as defined in Deferred Construction Functions.
+    JSFunction* resolver = createDeferredConstructionFunction(vm, asObject(C)->globalObject());
+
+    // 3. Let 'promise' be the result of calling the [[Construct]] internal method of 'C' with
+    //    an argument list containing the single item resolver.
+    MarkedArgumentBuffer constructArguments;
+    constructArguments.append(resolver);
+    JSObject* promise = construct(exec, C, constructType, constructData, constructArguments);
+
+    // 4. ReturnIfAbrupt(promise).
+    if (exec->hadException())
+        return jsUndefined();
+
+    // 5. Let 'resolve' be the value of resolver's [[Resolve]] internal slot.
+    JSValue resolve = resolver->get(exec, vm.propertyNames->resolvePrivateName);
+
+    // 6. If IsCallable(resolve) is false, throw a TypeError.
+    CallData resolveCallData;
+    CallType resolveCallType = getCallData(resolve, resolveCallData);
+    if (resolveCallType == CallTypeNone)
+        return throwTypeError(exec);
+
+    // 7. Let 'reject' be the value of resolver's [[Reject]] internal slot.
+    JSValue reject = resolver->get(exec, vm.propertyNames->rejectPrivateName);
+
+    // 8. If IsCallable(reject) is false, throw a TypeError.
+    CallData rejectCallData;
+    CallType rejectCallType = getCallData(reject, rejectCallData);
+    if (rejectCallType == CallTypeNone)
+        return throwTypeError(exec);
+
+    // 9. Return the Deferred { [[Promise]]: promise, [[Resolve]]: resolve, [[Reject]]: reject }.
+    return JSPromiseDeferred::create(exec->vm(), promise, resolve, reject);
+}
+
+ThenableStatus updateDeferredFromPotentialThenable(ExecState* exec, JSValue x, JSPromiseDeferred* deferred)
+{
+    // 1. If Type(x) is not Object, return "not a thenable".
+    if (!x.isObject())
+        return NotAThenable;
+    
+    // 2. Let 'then' be the result of calling Get(x, "then").
+    JSValue thenValue = x.get(exec, exec->vm().propertyNames->then);
+    
+    // 3. If then is an abrupt completion,
+    if (exec->hadException()) {
+        // i. Let 'rejectResult' be the result of calling the [[Call]] internal method of
+        //    deferred.[[Reject]] with undefined as thisArgument and a List containing
+        //    then.[[value]] as argumentsList.
+        JSValue exception = exec->exception();
+        exec->clearException();
+
+        JSValue deferredReject = deferred->reject();
+
+        CallData rejectCallData;
+        CallType rejectCallType = getCallData(deferredReject, rejectCallData);
+        ASSERT(rejectCallType != CallTypeNone);
+
+        MarkedArgumentBuffer rejectArguments;
+        rejectArguments.append(exception);
+
+        call(exec, deferredReject, rejectCallType, rejectCallData, jsUndefined(), rejectArguments);
+
+        // ii. ReturnIfAbrupt(rejectResult).
+        // NOTE: Nothing to do.
+
+        // iii. Return.
+        return WasAThenable;
+    }
+
+    // 4. Let 'then' be then.[[value]].
+    // Note: Nothing to do.
+
+    // 5. If IsCallable(then) is false, return "not a thenable".
+    CallData thenCallData;
+    CallType thenCallType = getCallData(thenValue, thenCallData);
+    if (thenCallType == CallTypeNone)
+        return NotAThenable;
+
+    // 6. Let 'thenCallResult' be the result of calling the [[Call]] internal method of
+    //    'then' passing x as thisArgument and a List containing deferred.[[Resolve]] and
+    //    deferred.[[Reject]] as argumentsList.
+    MarkedArgumentBuffer thenArguments;
+    thenArguments.append(deferred->resolve());
+    thenArguments.append(deferred->reject());
+    
+    call(exec, thenValue, thenCallType, thenCallData, x, thenArguments);
+
+    // 7. If 'thenCallResult' is an abrupt completion,
+    if (exec->hadException()) {
+        // i. Let 'rejectResult' be the result of calling the [[Call]] internal method of
+        //    deferred.[[Reject]] with undefined as thisArgument and a List containing
+        //    thenCallResult.[[value]] as argumentsList.
+        JSValue exception = exec->exception();
+        exec->clearException();
+
+        JSValue deferredReject = deferred->reject();
+
+        CallData rejectCallData;
+        CallType rejectCallType = getCallData(deferredReject, rejectCallData);
+        ASSERT(rejectCallType != CallTypeNone);
+
+        MarkedArgumentBuffer rejectArguments;
+        rejectArguments.append(exception);
+
+        call(exec, deferredReject, rejectCallType, rejectCallData, jsUndefined(), rejectArguments);
+
+        // ii. ReturnIfAbrupt(rejectResult).
+        // NOTE: Nothing to do.
+    }
+
+    return WasAThenable;
+}
+
+} // namespace JSC
diff --git a/Source/JavaScriptCore/runtime/JSPromiseDeferred.h b/Source/JavaScriptCore/runtime/JSPromiseDeferred.h
new file mode 100644
index 0000000..77024cf
--- /dev/null
+++ b/Source/JavaScriptCore/runtime/JSPromiseDeferred.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JSPromiseDeferred_h
+#define JSPromiseDeferred_h
+
+#include "JSCell.h"
+#include "Structure.h"
+
+namespace JSC {
+
+class JSPromiseDeferred : public JSCell {
+public:
+    typedef JSCell Base;
+
+    JS_EXPORT_PRIVATE static JSPromiseDeferred* create(ExecState*, JSGlobalObject*);
+    JS_EXPORT_PRIVATE static JSPromiseDeferred* create(VM&, JSObject* promise, JSValue resolve, JSValue reject);
+
+    static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+    {
+        return Structure::create(vm, globalObject, prototype, TypeInfo(CompoundType, StructureFlags), info());
+    }
+
+    static const bool hasImmortalStructure = true;
+
+    DECLARE_EXPORT_INFO;
+
+    JSObject* promise() const { return m_promise.get(); }
+    JSValue resolve() const { return m_resolve.get(); }
+    JSValue reject() const { return m_reject.get(); }
+
+private:
+    JSPromiseDeferred(VM&);
+    void finishCreation(VM&, JSObject*, JSValue, JSValue);
+    static const unsigned StructureFlags = OverridesVisitChildren | Base::StructureFlags;
+    static void visitChildren(JSCell*, SlotVisitor&);
+
+    WriteBarrier<JSObject> m_promise;
+    WriteBarrier<Unknown> m_resolve;
+    WriteBarrier<Unknown> m_reject;
+};
+
+enum ThenableStatus {
+    WasAThenable,
+    NotAThenable
+};
+
+JSValue createJSPromiseDeferredFromConstructor(ExecState*, JSValue constructor);
+ThenableStatus updateDeferredFromPotentialThenable(ExecState*, JSValue, JSPromiseDeferred*);
+
+} // namespace JSC
+
+#endif // JSPromiseDeferred_h
diff --git a/Source/JavaScriptCore/runtime/JSPromiseFunctions.cpp b/Source/JavaScriptCore/runtime/JSPromiseFunctions.cpp
new file mode 100644
index 0000000..95490b9
--- /dev/null
+++ b/Source/JavaScriptCore/runtime/JSPromiseFunctions.cpp
@@ -0,0 +1,224 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSPromiseFunctions.h"
+
+#if ENABLE(PROMISES)
+
+#include "Error.h"
+#include "JSCJSValueInlines.h"
+#include "JSCellInlines.h"
+#include "JSPromise.h"
+#include "JSPromiseConstructor.h"
+#include "JSPromiseDeferred.h"
+
+namespace JSC {
+
+// Deferred Construction Functions
+static EncodedJSValue JSC_HOST_CALL deferredConstructionFunction(ExecState* exec)
+{
+    JSObject* F = exec->callee();
+
+    VM& vm = exec->vm();
+
+    // 1. Set F's [[Resolve]] internal slot to resolve.
+    F->putDirect(vm, vm.propertyNames->resolvePrivateName, exec->argument(0));
+
+    // 2. Set F's [[Reject]] internal slot to reject.
+    F->putDirect(vm, vm.propertyNames->rejectPrivateName, exec->argument(1));
+
+    // 3. Return.
+    return JSValue::encode(jsUndefined());
+}
+
+JSFunction* createDeferredConstructionFunction(VM& vm, JSGlobalObject* globalObject)
+{
+    return JSFunction::create(vm, globalObject, 2, ASCIILiteral("DeferredConstructionFunction"), deferredConstructionFunction);
+}
+
+// Identity Functions
+
+static EncodedJSValue JSC_HOST_CALL identifyFunction(ExecState* exec)
+{
+    return JSValue::encode(exec->argument(0));
+}
+
+JSFunction* createIdentifyFunction(VM& vm, JSGlobalObject* globalObject)
+{
+    return JSFunction::create(vm, globalObject, 1, ASCIILiteral("IdentityFunction"), identifyFunction);
+}
+
+// Promise Resolution Handler Functions
+
+static EncodedJSValue JSC_HOST_CALL promiseResolutionHandlerFunction(ExecState* exec)
+{
+    JSValue x = exec->argument(0);
+    VM& vm = exec->vm();
+    JSObject* F = exec->callee();
+
+    // 1. Let 'promise' be the value of F's [[Promise]] internal slot
+    JSPromise* promise = jsCast<JSPromise*>(F->get(exec, vm.propertyNames->promisePrivateName));
+
+    // 2. Let 'fulfillmentHandler' be the value of F's [[FulfillmentHandler]] internal slot.
+    JSValue fulfillmentHandler = F->get(exec, vm.propertyNames->fulfillmentHandlerPrivateName);
+    
+    // 3. Let 'rejectionHandler' be the value of F's [[RejectionHandler]] internal slot.
+    JSValue rejectionHandler = F->get(exec, vm.propertyNames->rejectionHandlerPrivateName);
+    
+    // 4. If SameValue(x, promise) is true,
+    if (sameValue(exec, x, promise)) {
+        // i. Let 'selfResolutionError' be a newly-created TypeError object.
+        JSObject* selfResolutionError = createTypeError(exec, ASCIILiteral("Resolve a promise with itself"));
+        // ii. Return the result of calling the [[Call]] internal method of rejectionHandler with
+        //     undefined as thisArgument and a List containing selfResolutionError as argumentsList.
+        CallData rejectCallData;
+        CallType rejectCallType = getCallData(rejectionHandler, rejectCallData);
+        ASSERT(rejectCallType != CallTypeNone);
+
+        MarkedArgumentBuffer rejectArguments;
+        rejectArguments.append(selfResolutionError);
+
+        return JSValue::encode(call(exec, rejectionHandler, rejectCallType, rejectCallData, jsUndefined(), rejectArguments));
+    }
+
+    // 5. Let 'C' be the value of promise's [[PromiseConstructor]] internal slot.
+    JSValue C = promise->constructor();
+
+    // 6. Let 'deferred' be the result of calling GetDeferred(C)
+    JSValue deferredValue = createJSPromiseDeferredFromConstructor(exec, C);
+
+    // 7. ReturnIfAbrupt(deferred).
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    JSPromiseDeferred* deferred = jsCast<JSPromiseDeferred*>(deferredValue);
+
+    // 8. Let 'updateResult' be the result of calling UpdateDeferredFromPotentialThenable(x, deferred).
+    ThenableStatus updateResult = updateDeferredFromPotentialThenable(exec, x, deferred);
+
+    // 9. ReturnIfAbrupt(updateResult).
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    // 10. If 'updateResult' is not "not a thenable", return the result of calling
+    //     Invoke(deferred.[[Promise]], "then", (fulfillmentHandler, rejectionHandler)).
+    // NOTE: Invoke does not seem to be defined anywhere, so I am guessing here.
+    if (updateResult != NotAThenable) {
+        JSObject* deferredPromise = deferred->promise();
+    
+        JSValue thenValue = deferredPromise->get(exec, exec->vm().propertyNames->then);
+        if (exec->hadException())
+            return JSValue::encode(jsUndefined());
+
+        CallData thenCallData;
+        CallType thenCallType = getCallData(thenValue, thenCallData);
+        if (thenCallType == CallTypeNone)
+            return JSValue::encode(throwTypeError(exec));
+
+        MarkedArgumentBuffer arguments;
+        arguments.append(fulfillmentHandler);
+        arguments.append(rejectionHandler);
+
+        return JSValue::encode(call(exec, thenValue, thenCallType, thenCallData, deferredPromise, arguments));
+    }
+    
+    // 11. Return the result of calling the [[Call]] internal method of fulfillmentHandler
+    //     with undefined as thisArgument and a List containing x as argumentsList.
+    CallData fulfillmentHandlerCallData;
+    CallType fulfillmentHandlerCallType = getCallData(fulfillmentHandler, fulfillmentHandlerCallData);
+    ASSERT(fulfillmentHandlerCallType != CallTypeNone);
+    
+    MarkedArgumentBuffer fulfillmentHandlerArguments;
+    fulfillmentHandlerArguments.append(x);
+
+    return JSValue::encode(call(exec, fulfillmentHandler, fulfillmentHandlerCallType, fulfillmentHandlerCallData, jsUndefined(), fulfillmentHandlerArguments));
+}
+
+JSFunction* createPromiseResolutionHandlerFunction(VM& vm, JSGlobalObject* globalObject)
+{
+    return JSFunction::create(vm, globalObject, 1, ASCIILiteral("PromiseResolutionHandlerFunction"), promiseResolutionHandlerFunction);
+}
+
+// Reject Promise Functions
+
+static EncodedJSValue JSC_HOST_CALL rejectPromiseFunction(ExecState* exec)
+{
+    JSValue reason = exec->argument(0);
+    JSObject* F = exec->callee();
+    VM& vm = exec->vm();
+
+    // 1. Let 'promise' be the value of F's [[Promise]] internal slot.
+    JSPromise* promise = jsCast<JSPromise*>(F->get(exec, exec->vm().propertyNames->promisePrivateName));
+
+    // 2. Return the result of calling PromiseReject(promise, reason);
+    promise->reject(vm, reason);
+
+    return JSValue::encode(jsUndefined());
+}
+
+JSFunction* createRejectPromiseFunction(VM& vm, JSGlobalObject* globalObject)
+{
+    return JSFunction::create(vm, globalObject, 1, ASCIILiteral("RejectPromiseFunction"), rejectPromiseFunction);
+}
+
+// Resolve Promise Functions
+
+static EncodedJSValue JSC_HOST_CALL resolvePromiseFunction(ExecState* exec)
+{
+    JSValue resolution = exec->argument(0);
+    JSObject* F = exec->callee();
+    VM& vm = exec->vm();
+
+    // 1. Let 'promise' be the value of F's [[Promise]] internal slot.
+    JSPromise* promise = jsCast<JSPromise*>(F->get(exec, vm.propertyNames->promisePrivateName));
+
+    // 2. Return the result of calling PromiseResolve(promise, resolution);
+    promise->resolve(vm, resolution);
+
+    return JSValue::encode(jsUndefined());
+}
+
+JSFunction* createResolvePromiseFunction(VM& vm, JSGlobalObject* globalObject)
+{
+    return JSFunction::create(vm, globalObject, 1, ASCIILiteral("ResolvePromiseFunction"), resolvePromiseFunction);
+}
+
+// Thrower Functions
+
+static EncodedJSValue JSC_HOST_CALL throwerFunction(ExecState* exec)
+{
+    return JSValue::encode(exec->vm().throwException(exec, exec->argument(0)));
+}
+
+JSFunction* createThrowerFunction(VM& vm, JSGlobalObject* globalObject)
+{
+    return JSFunction::create(vm, globalObject, 1, ASCIILiteral("ThrowerFunction"), throwerFunction);
+}
+
+
+} // namespace JSC
+
+#endif // ENABLE(PROMISES)
diff --git a/Source/JavaScriptCore/runtime/JSPromiseResolverPrototype.h b/Source/JavaScriptCore/runtime/JSPromiseFunctions.h
similarity index 66%
rename from Source/JavaScriptCore/runtime/JSPromiseResolverPrototype.h
rename to Source/JavaScriptCore/runtime/JSPromiseFunctions.h
index 071c196..e41fd65 100644
--- a/Source/JavaScriptCore/runtime/JSPromiseResolverPrototype.h
+++ b/Source/JavaScriptCore/runtime/JSPromiseFunctions.h
@@ -23,35 +23,24 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef JSPromiseResolverPrototype_h
-#define JSPromiseResolverPrototype_h
+#ifndef JSPromiseFunctions_h
+#define JSPromiseFunctions_h
 
 #if ENABLE(PROMISES)
 
-#include "JSObject.h"
+#include "JSFunction.h"
 
 namespace JSC {
 
-class JSPromiseResolverPrototype : public JSNonFinalObject {
-public:
-    typedef JSNonFinalObject Base;
-
-    static JSPromiseResolverPrototype* create(ExecState*, JSGlobalObject*, Structure*);
-    static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
-
-    DECLARE_INFO;
-
-protected:
-    void finishCreation(VM&, Structure*);
-    static const unsigned StructureFlags = OverridesGetOwnPropertySlot | JSObject::StructureFlags;
-
-private:
-    JSPromiseResolverPrototype(ExecState*, Structure*);
-    static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
-};
+JSFunction* createDeferredConstructionFunction(VM&, JSGlobalObject*);
+JSFunction* createIdentifyFunction(VM&, JSGlobalObject*);
+JSFunction* createPromiseResolutionHandlerFunction(VM&, JSGlobalObject*);
+JSFunction* createRejectPromiseFunction(VM&, JSGlobalObject*);
+JSFunction* createResolvePromiseFunction(VM&, JSGlobalObject*);
+JSFunction* createThrowerFunction(VM&, JSGlobalObject*);
 
 } // namespace JSC
 
 #endif // ENABLE(PROMISES)
 
-#endif // JSPromiseResolverPrototype_h
+#endif // JSPromiseFunctions_h
diff --git a/Source/JavaScriptCore/runtime/JSPromisePrototype.cpp b/Source/JavaScriptCore/runtime/JSPromisePrototype.cpp
index aaf3d2f..69e54da 100644
--- a/Source/JavaScriptCore/runtime/JSPromisePrototype.cpp
+++ b/Source/JavaScriptCore/runtime/JSPromisePrototype.cpp
@@ -33,17 +33,17 @@
 #include "JSCellInlines.h"
 #include "JSGlobalObject.h"
 #include "JSPromise.h"
-#include "JSPromiseCallback.h"
-#include "JSPromiseResolver.h"
+#include "JSPromiseDeferred.h"
+#include "JSPromiseFunctions.h"
+#include "JSPromiseReaction.h"
+#include "Microtask.h"
 #include "StructureInlines.h"
 
 namespace JSC {
 
 STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSPromisePrototype);
 
-// Promise then([TreatUndefinedAs=Missing] optional AnyCallback fulfillCallback, [TreatUndefinedAs=Missing] optional AnyCallback rejectCallback);
 static EncodedJSValue JSC_HOST_CALL JSPromisePrototypeFuncThen(ExecState*);
-// Promise catch([TreatUndefinedAs=Missing] optional AnyCallback rejectCallback);
 static EncodedJSValue JSC_HOST_CALL JSPromisePrototypeFuncCatch(ExecState*);
 
 }
@@ -56,8 +56,8 @@
 
 /* Source for JSPromisePrototype.lut.h
 @begin promisePrototypeTable
-  then         JSPromisePrototypeFuncThen             DontEnum|Function 0
-  catch        JSPromisePrototypeFuncCatch            DontEnum|Function 0
+  then         JSPromisePrototypeFuncThen             DontEnum|Function 2
+  catch        JSPromisePrototypeFuncCatch            DontEnum|Function 1
 @end
 */
 
@@ -89,95 +89,127 @@
     return getStaticFunctionSlot<JSObject>(exec, ExecState::promisePrototypeTable(exec), jsCast<JSPromisePrototype*>(object), propertyName, slot);
 }
 
-static InternalFunction* wrapCallback(ExecState* exec, JSGlobalObject* globalObject, JSValue callback, JSPromiseResolver* resolver, JSPromiseCallback::Algorithm algorithm)
-{
-    if (!callback.isUndefined())
-        return JSPromiseWrapperCallback::create(exec->vm(), globalObject->promiseWrapperCallbackStructure(), resolver, callback);
-    return JSPromiseCallback::create(exec->vm(), globalObject->promiseCallbackStructure(), resolver, algorithm);
-}
-
 EncodedJSValue JSC_HOST_CALL JSPromisePrototypeFuncThen(ExecState* exec)
 {
-    JSPromise* thisObject = jsDynamicCast<JSPromise*>(exec->thisValue());
-    if (!thisObject)
-        return throwVMError(exec, createTypeError(exec, "Receiver of then must be a Promise"));
+    // -- Promise.prototype.then(onFulfilled, onRejected) --
 
-    JSValue fulfillCallback = exec->argument(0);
-    if (!fulfillCallback.isUndefined()) {
-        CallData callData;
-        CallType callType = getCallData(fulfillCallback, callData);
-        if (callType == CallTypeNone)
-            return throwVMError(exec, createTypeError(exec, "Expected function or undefined as as first argument"));
-    }
+    // 1. Let promise be the this value.
+    // 2. If IsPromise(promise) is false, throw a TypeError exception.
+    JSPromise* promise = jsDynamicCast<JSPromise*>(exec->thisValue());
+    if (!promise)
+        return JSValue::encode(throwTypeError(exec));
+
+    // 3. Let 'C' be the result of calling Get(promise, "constructor").
+    JSValue C = promise->get(exec, exec->propertyNames().constructor);
     
-    JSValue rejectCallback = exec->argument(1);
-    if (!rejectCallback.isUndefined()) {
-        CallData callData;
-        CallType callType = getCallData(rejectCallback, callData);
-        if (callType == CallTypeNone)
-            return throwVMError(exec, createTypeError(exec, "Expected function or undefined as as second argument"));
+    // 4. ReturnIfAbrupt(C).
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+    
+    // 5. Let 'deferred' be the result of calling GetDeferred(C).
+    JSValue deferred = createJSPromiseDeferredFromConstructor(exec, C);
+
+    // 6. ReturnIfAbrupt(deferred).
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    VM& vm = exec->vm();
+    JSGlobalObject* globalObject = promise->globalObject();
+
+    // 7. Let 'rejectionHandler' be a new built-in function object as defined in Thrower Functions
+    // 8. If IsCallable(onRejected), set rejectionHandler to onRejected.
+    JSValue onRejected = exec->argument(1);
+    CallData onRejectedCallData;
+    CallType onRejectedCallType = getCallData(onRejected, onRejectedCallData);
+    JSObject* rejectionHandler = (onRejectedCallType == CallTypeNone) ? createThrowerFunction(vm, globalObject) : asObject(onRejected);
+    
+    // 9. Let 'fulfillmentHandler' be a new built-in function object as defined in Identity Functions
+    // 10. If IsCallable(onFulfilled), set fulfillmentHandler to onFulfilled
+    JSValue onFulfilled = exec->argument(0);
+    CallData onFulfilledCallData;
+    CallType onFulfilledCallType = getCallData(onFulfilled, onFulfilledCallData);
+    JSObject* fulfillmentHandler = (onFulfilledCallType == CallTypeNone) ? createIdentifyFunction(vm, globalObject) : asObject(onFulfilled);
+
+    // 11. Let 'resolutionHandler' be a new built-in function object as defined in Promise Resolution Handler Functions
+    JSObject* resolutionHandler = createPromiseResolutionHandlerFunction(vm, globalObject);
+
+    // 12. Set the [[Promise]] internal slot of resolutionHandler to promise.
+    resolutionHandler->putDirect(vm, vm.propertyNames->promisePrivateName, promise);
+
+    // 13. Set the [[FulfillmentHandler]] internal slot of resolutionHandler to fulfillmentHandler.
+    resolutionHandler->putDirect(vm, vm.propertyNames->fulfillmentHandlerPrivateName, fulfillmentHandler);
+
+    // 14. Set the [[RejectionHandler]] internal slot of resolutionHandler to rejectionHandler.
+    resolutionHandler->putDirect(vm, vm.propertyNames->rejectionHandlerPrivateName, rejectionHandler);
+
+    // 15. Let 'resolveReaction' be the PromiseReaction { [[Deferred]]: deferred, [[Handler]]: resolutionHandler }.
+    JSPromiseReaction* resolveReaction = JSPromiseReaction::create(vm, jsCast<JSPromiseDeferred*>(deferred), resolutionHandler);
+
+    // 16. Let 'rejectReaction' be the PromiseReaction { [[Deferred]]: deferred, [[Handler]]: rejectionHandler }.
+    JSPromiseReaction* rejectReaction = JSPromiseReaction::create(vm, jsCast<JSPromiseDeferred*>(deferred), rejectionHandler);
+
+    switch (promise->status()) {
+    case JSPromise::Status::Unresolved: {
+        // 17. If the value of promise's [[PromiseStatus]] internal slot is "unresolved",
+
+        // i. Append resolveReaction as the last element of promise's [[ResolveReactions]] internal slot.
+        promise->appendResolveReaction(vm, resolveReaction);
+
+        // ii. Append rejectReaction as the last element of promise's [[RejectReactions]] internal slot.
+        promise->appendRejectReaction(vm, rejectReaction);
+        break;
     }
 
-    JSFunction* callee = jsCast<JSFunction*>(exec->callee());
-    JSGlobalObject* globalObject = callee->globalObject();
+    case JSPromise::Status::HasResolution: {
+        // 18. If the value of promise's [[PromiseStatus]] internal slot is "has-resolution",
 
-    // 1. Let promise be a new promise.
-    JSPromise* promise = JSPromise::createWithResolver(exec->vm(), globalObject);
+        // i. Let 'resolution' be the value of promise's [[Result]] internal slot.
+        JSValue resolution = promise->result();
 
-    // 2. Let resolver be promise's associated resolver.
-    JSPromiseResolver* resolver = promise->resolver();
+        // ii. Call QueueMicrotask(ExecutePromiseReaction, (resolveReaction, resolution)).
+        globalObject->queueMicrotask(createExecutePromiseReactionMicrotask(vm, resolveReaction, resolution));
+        break;
+    }
 
-    // 3. Let fulfillWrapper be a promise wrapper callback for resolver and fulfillCallback if fulfillCallback is
-    //    not omitted and a promise callback for resolver and its fulfill algorithm otherwise.
-    InternalFunction* fulfillWrapper = wrapCallback(exec, globalObject, fulfillCallback, resolver, JSPromiseCallback::Fulfill);
+    case JSPromise::Status::HasRejection: {
+        // 19. If the value of promise's [[PromiseStatus]] internal slot is "has-rejection",
 
-    // 4. Let rejectWrapper be a promise wrapper callback for resolver and rejectCallback if rejectCallback is
-    //    not omitted and a promise callback for resolver and its reject algorithm otherwise.
-    InternalFunction* rejectWrapper = wrapCallback(exec, globalObject, rejectCallback, resolver, JSPromiseCallback::Reject);
+        // i. Let reason be the value of promise's [[Result]] internal slot.
+        JSValue reason = promise->result();
 
-    // 5. Append fulfillWrapper and rejectWrapper to the context object.
-    thisObject->appendCallbacks(exec, fulfillWrapper, rejectWrapper);
+        // ii. Call QueueMicrotask(ExecutePromiseReaction, (rejectReaction, reason)).
+        globalObject->queueMicrotask(createExecutePromiseReactionMicrotask(vm, rejectReaction, reason));
+        break;
+    }
+    }
 
-    // 6. Return promise.
-    return JSValue::encode(promise);
+    // 20. Return deferred.[[Promise]].
+    return JSValue::encode(jsCast<JSPromiseDeferred*>(deferred)->promise());
 }
 
 EncodedJSValue JSC_HOST_CALL JSPromisePrototypeFuncCatch(ExecState* exec)
 {
-    JSPromise* thisObject = jsDynamicCast<JSPromise*>(exec->thisValue());
-    if (!thisObject)
-        return throwVMError(exec, createTypeError(exec, "Receiver of catch must be a Promise"));
+    // -- Promise.prototype.catch(onRejected) --
+
+    // 1. Let 'promise' be the this value.
+    JSValue promise = exec->thisValue();
     
-    JSValue rejectCallback = exec->argument(0);
-    if (!rejectCallback.isUndefined()) {
-        CallData callData;
-        CallType callType = getCallData(rejectCallback, callData);
-        if (callType == CallTypeNone)
-            return throwVMError(exec, createTypeError(exec, "Expected function or undefined as as first argument"));
-    }
+    // 2. Return the result of calling Invoke(promise, "then", (undefined, onRejected)).
+    // NOTE: Invoke does not seem to be defined anywhere, so I am guessing here.
+    JSValue thenValue = promise.get(exec, exec->vm().propertyNames->then);
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
 
-    JSFunction* callee = jsCast<JSFunction*>(exec->callee());
-    JSGlobalObject* globalObject = callee->globalObject();
-    VM& vm = exec->vm();
+    CallData thenCallData;
+    CallType thenCallType = getCallData(thenValue, thenCallData);
+    if (thenCallType == CallTypeNone)
+        return JSValue::encode(throwTypeError(exec));
 
-    // 1. Let promise be a new promise.
-    JSPromise* promise = JSPromise::createWithResolver(vm, globalObject);
+    MarkedArgumentBuffer arguments;
+    arguments.append(jsUndefined());
+    arguments.append(exec->argument(0));
 
-    // 2. Let resolver be promise's associated resolver.
-    JSPromiseResolver* resolver = promise->resolver();
-
-    // 3. Let fulfillCallback be a new promise callback for resolver and its fulfill algorithm.
-    InternalFunction* fulfillWrapper = JSPromiseCallback::create(vm, globalObject->promiseCallbackStructure(), resolver, JSPromiseCallback::Fulfill);
-
-    // 4. Let rejectWrapper be a promise wrapper callback for resolver and rejectCallback if rejectCallback is
-    //    not omitted and a promise callback for resolver and its reject algorithm otherwise.
-    InternalFunction* rejectWrapper = wrapCallback(exec, globalObject, rejectCallback, resolver, JSPromiseCallback::Reject);
-
-    // 5. Append fulfillWrapper and rejectWrapper to the context object.
-    thisObject->appendCallbacks(exec, fulfillWrapper, rejectWrapper);
-
-    // 6. Return promise.
-    return JSValue::encode(promise);
+    return JSValue::encode(call(exec, thenValue, thenCallType, thenCallData, promise, arguments));
 }
 
 } // namespace JSC
diff --git a/Source/JavaScriptCore/runtime/JSPromiseReaction.cpp b/Source/JavaScriptCore/runtime/JSPromiseReaction.cpp
new file mode 100644
index 0000000..466856a
--- /dev/null
+++ b/Source/JavaScriptCore/runtime/JSPromiseReaction.cpp
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSPromiseReaction.h"
+
+#include "Error.h"
+#include "JSCJSValueInlines.h"
+#include "JSCellInlines.h"
+#include "JSGlobalObject.h"
+#include "JSPromiseDeferred.h"
+#include "Microtask.h"
+#include "SlotVisitorInlines.h"
+#include "StrongInlines.h"
+
+namespace JSC {
+
+class ExecutePromiseReactionMicrotask final : public Microtask {
+public:
+    ExecutePromiseReactionMicrotask(VM& vm, JSPromiseReaction* reaction, JSValue argument)
+    {
+        m_reaction.set(vm, reaction);
+        m_argument.set(vm, argument);
+    }
+
+    virtual ~ExecutePromiseReactionMicrotask()
+    {
+    }
+
+private:
+    virtual void run(ExecState*) override;
+
+    Strong<JSPromiseReaction> m_reaction;
+    Strong<Unknown> m_argument;
+};
+
+PassRefPtr<Microtask> createExecutePromiseReactionMicrotask(VM& vm, JSPromiseReaction* reaction, JSValue argument)
+{
+    return adoptRef(new ExecutePromiseReactionMicrotask(vm, reaction, argument));
+}
+
+void ExecutePromiseReactionMicrotask::run(ExecState* exec)
+{
+    // 1. Let 'deferred' be reaction.[[Deferred]].
+    JSPromiseDeferred* deferred = m_reaction->deferred();
+    
+    // 2. Let 'handler' be reaction.[[Handler]].
+    JSValue handler = m_reaction->handler();
+
+    // 3. Let 'handlerResult' be the result of calling the [[Call]] internal method of
+    //    handler passing undefined as thisArgument and a List containing argument as
+    //    argumentsList.
+
+    CallData handlerCallData;
+    CallType handlerCallType = getCallData(handler, handlerCallData);
+    ASSERT(handlerCallType != CallTypeNone);
+
+    MarkedArgumentBuffer handlerArguments;
+    handlerArguments.append(m_argument.get());
+
+    JSValue handlerResult = call(exec, handler, handlerCallType, handlerCallData, jsUndefined(), handlerArguments);
+
+    // 4. If handlerResult is an abrupt completion, return the result of calling the
+    //    [[Call]] internal method of deferred.[[Reject]] passing undefined as thisArgument
+    //    and a List containing handlerResult.[[value]] as argumentsList.
+    if (exec->hadException()) {
+        JSValue exception = exec->exception();
+        exec->clearException();
+
+        JSValue deferredReject = deferred->reject();
+
+        CallData rejectCallData;
+        CallType rejectCallType = getCallData(deferredReject, rejectCallData);
+        ASSERT(rejectCallType != CallTypeNone);
+
+        MarkedArgumentBuffer rejectArguments;
+        rejectArguments.append(exception);
+
+        call(exec, deferredReject, rejectCallType, rejectCallData, jsUndefined(), rejectArguments);
+        // FIXME: Should we return the result somewhere?
+    }
+    
+    // 5. Let 'handlerResult' be handlerResult.[[value]].
+    // Note: Nothing to do.
+
+    // 6. If SameValue(handlerResult, deferred.[[Promise]]) is true,
+    if (sameValue(exec, handlerResult, deferred->promise())) {
+        // i. Let 'selfResolutionError' be a newly-created TypeError object.
+        JSObject* selfResolutionError = createTypeError(exec, ASCIILiteral("Resolve a promise with itself"));
+        // ii. Return the result of calling the [[Call]] internal method of deferred.[[Reject]] passing
+        //     undefined as thisArgument and a List containing selfResolutionError as argumentsList.
+        JSValue deferredReject = deferred->reject();
+
+        CallData rejectCallData;
+        CallType rejectCallType = getCallData(deferredReject, rejectCallData);
+        ASSERT(rejectCallType != CallTypeNone);
+
+        MarkedArgumentBuffer rejectArguments;
+        rejectArguments.append(selfResolutionError);
+
+        call(exec, deferredReject, rejectCallType, rejectCallData, jsUndefined(), rejectArguments);
+        // FIXME: Should we return the result somewhere?
+    }
+
+    // 7. Let 'updateResult' be the result of calling UpdateDeferredFromPotentialThenable(handlerResult, deferred).
+    ThenableStatus updateResult = updateDeferredFromPotentialThenable(exec, handlerResult, deferred);
+    
+    // 8. ReturnIfAbrupt(updateResult).
+    if (exec->hadException())
+        return;
+
+    // 9. If 'updateResult' is "not a thenable",
+    if (updateResult == NotAThenable) {
+        // i. Return the result of calling the [[Call]] internal method of deferred.[[Resolve]]
+        //    passing undefined as thisArgument and a List containing handlerResult as argumentsList.
+
+        JSValue deferredResolve = deferred->resolve();
+
+        CallData resolveCallData;
+        CallType resolveCallType = getCallData(deferredResolve, resolveCallData);
+        ASSERT(resolveCallType != CallTypeNone);
+
+        MarkedArgumentBuffer arguments;
+        arguments.append(handlerResult);
+
+        call(exec, deferredResolve, resolveCallType, resolveCallData, jsUndefined(), arguments);
+        // FIXME: Should we return the result somewhere?
+    }
+}
+
+
+const ClassInfo JSPromiseReaction::s_info = { "JSPromiseReaction", 0, 0, 0, CREATE_METHOD_TABLE(JSPromiseReaction) };
+
+JSPromiseReaction* JSPromiseReaction::create(VM& vm, JSPromiseDeferred* deferred, JSValue handler)
+{
+    JSPromiseReaction* promiseReaction = new (NotNull, allocateCell<JSPromiseReaction>(vm.heap)) JSPromiseReaction(vm);
+    promiseReaction->finishCreation(vm, deferred, handler);
+    return promiseReaction;
+}
+
+JSPromiseReaction::JSPromiseReaction(VM& vm)
+    : Base(vm, vm.promiseReactionStructure.get())
+{
+}
+
+void JSPromiseReaction::finishCreation(VM& vm, JSPromiseDeferred* deferred, JSValue handler)
+{
+    Base::finishCreation(vm);
+    m_deferred.set(vm, this, deferred);
+    m_handler.set(vm, this, handler);
+}
+
+void JSPromiseReaction::visitChildren(JSCell* cell, SlotVisitor& visitor)
+{
+    JSPromiseReaction* thisObject = jsCast<JSPromiseReaction*>(cell);
+    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+    COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
+    ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
+
+    Base::visitChildren(thisObject, visitor);
+
+    visitor.append(&thisObject->m_deferred);
+    visitor.append(&thisObject->m_handler);
+}
+
+} // namespace JSC
diff --git a/Source/JavaScriptCore/runtime/JSPromiseReaction.h b/Source/JavaScriptCore/runtime/JSPromiseReaction.h
new file mode 100644
index 0000000..fc7146c
--- /dev/null
+++ b/Source/JavaScriptCore/runtime/JSPromiseReaction.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JSPromiseReaction_h
+#define JSPromiseReaction_h
+
+#include "JSCell.h"
+#include "Structure.h"
+
+namespace JSC {
+
+class JSPromiseDeferred;
+class Microtask;
+
+class JSPromiseReaction : public JSCell {
+public:
+    typedef JSCell Base;
+
+    static JSPromiseReaction* create(VM&, JSPromiseDeferred*, JSValue);
+    static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+    {
+        return Structure::create(vm, globalObject, prototype, TypeInfo(CompoundType, StructureFlags), info());
+    }
+
+    static const bool hasImmortalStructure = true;
+
+    DECLARE_INFO;
+
+    JSPromiseDeferred* deferred() const { return m_deferred.get(); }
+    JSValue handler() const { return m_handler.get(); }
+
+private:
+    JSPromiseReaction(VM&);
+    void finishCreation(VM&, JSPromiseDeferred*, JSValue);
+    static const unsigned StructureFlags = OverridesVisitChildren | Base::StructureFlags;
+    static void visitChildren(JSCell*, SlotVisitor&);
+
+    WriteBarrier<JSPromiseDeferred> m_deferred;
+    WriteBarrier<Unknown> m_handler;
+};
+
+PassRefPtr<Microtask> createExecutePromiseReactionMicrotask(VM&, JSPromiseReaction*, JSValue);
+
+} // namespace JSC
+
+#endif // JSPromiseReaction_h
diff --git a/Source/JavaScriptCore/runtime/JSPromiseResolver.cpp b/Source/JavaScriptCore/runtime/JSPromiseResolver.cpp
deleted file mode 100644
index 368b598..0000000
--- a/Source/JavaScriptCore/runtime/JSPromiseResolver.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "JSPromiseResolver.h"
-
-#if ENABLE(PROMISES)
-
-#include "JSCJSValueInlines.h"
-#include "JSCellInlines.h"
-#include "JSGlobalObject.h"
-#include "JSPromise.h"
-#include "JSPromiseCallback.h"
-#include "SlotVisitorInlines.h"
-#include "StructureInlines.h"
-
-namespace JSC {
-
-const ClassInfo JSPromiseResolver::s_info = { "PromiseResolver", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSPromiseResolver) };
-
-JSPromiseResolver* JSPromiseResolver::create(VM& vm, Structure* structure, JSPromise* promise)
-{
-    JSPromiseResolver* object = new (NotNull, allocateCell<JSPromiseResolver>(vm.heap)) JSPromiseResolver(vm, structure);
-    object->finishCreation(vm, promise);
-    return object;
-}
-
-Structure* JSPromiseResolver::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
-{
-    return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
-}
-
-JSPromiseResolver::JSPromiseResolver(VM& vm, Structure* structure)
-    : JSNonFinalObject(vm, structure)
-    , m_isResolved(false)
-{
-}
-
-void JSPromiseResolver::finishCreation(VM& vm, JSPromise* promise)
-{
-    Base::finishCreation(vm);
-    ASSERT(inherits(info()));
-    m_promise.set(vm, this, promise);
-}
-
-void JSPromiseResolver::visitChildren(JSCell* cell, SlotVisitor& visitor)
-{
-    JSPromiseResolver* thisObject = jsCast<JSPromiseResolver*>(cell);
-    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-    COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
-    ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
-
-    Base::visitChildren(thisObject, visitor);
-    visitor.append(&thisObject->m_promise);
-}
-
-JSPromise* JSPromiseResolver::promise() const
-{
-    return m_promise.get();
-}
-
-void JSPromiseResolver::fulfillIfNotResolved(ExecState* exec, JSValue value)
-{
-    if (!m_isResolved) {
-        m_isResolved = true;
-        fulfill(exec, value);
-    }
-}
-
-void JSPromiseResolver::resolveIfNotResolved(ExecState* exec, JSValue value)
-{
-    if (!m_isResolved) {
-        m_isResolved = true;
-        resolve(exec, value);
-    }
-}
-
-void JSPromiseResolver::rejectIfNotResolved(ExecState* exec, JSValue value)
-{
-    if (!m_isResolved) {
-        m_isResolved = true;
-        reject(exec, value);
-    }
-}
-
-void JSPromiseResolver::fulfill(ExecState* exec, JSValue value, ResolverMode mode)
-{
-    // 1. Let promise be the context object's associated promise.
-    // 2. Set promise's state to fulfilled.
-    m_promise->setState(JSPromise::Fulfilled);
-
-    // 3. Set promise's result to value.
-    m_promise->setResult(exec->vm(), value);
-
-    // 4. If the synchronous flag is set, process promise's fulfill callbacks with value.
-    if (mode == ResolveSynchronously) {
-        m_promise->processFulfillCallbacksWithValue(exec, value);
-        return;
-    }
-    
-    // 5. Otherwise, the synchronous flag is unset, queue a task to process promise's fulfill callbacks with value.
-    m_promise->queueTaskToProcessFulfillCallbacks(exec);
-}
-
-void JSPromiseResolver::resolve(ExecState* exec, JSValue value, ResolverMode mode)
-{
-    // 1. Let then be null.
-    JSValue then = jsNull();
-    
-    // 2. If value is a JavaScript Object, set then to the result of calling the JavaScript [[Get]] internal
-    //    method of value with property name then.
-    if (value.isObject()) {
-        then = value.get(exec, exec->propertyNames().then);
-
-        // 3. If calling the [[Get]] internal method threw an exception, catch it and run reject with the thrown
-        //    exception and the synchronous flag if set, and then terminate these steps.
-        if (exec->hadException()) {
-            JSValue exception = exec->exception();
-            exec->clearException();
-
-            reject(exec, exception, mode);
-            return;
-        }
-
-        // 4. If JavaScript IsCallable(then) is true, run these substeps and then terminate these steps:
-        CallData callData;
-        CallType callType = JSC::getCallData(then, callData);
-        if (callType != CallTypeNone) {
-            VM& vm = exec->vm();
-            // 4.1. Let fulfillCallback be a promise callback for the context object and its resolve algorithm.
-            JSPromiseCallback* fulfillCallback = JSPromiseCallback::create(vm, globalObject()->promiseCallbackStructure(), this, JSPromiseCallback::Resolve);
-
-            // 4.2. Let rejectCallback be a promise callback for the context object and its reject algorithm.
-            JSPromiseCallback* rejectCallback = JSPromiseCallback::create(vm, globalObject()->promiseCallbackStructure(), this, JSPromiseCallback::Reject);
-            
-            // 4.3. Call the JavaScript [[Call]] internal method of then with this value value and fulfillCallback
-            //      and rejectCallback as arguments.
-            MarkedArgumentBuffer thenArguments;
-            thenArguments.append(fulfillCallback);
-            thenArguments.append(rejectCallback);
-            call(exec, then, callType, callData, value, thenArguments);
-
-            // 4.4 If calling the [[Call]] internal method threw an exception, catch it and run context object's
-            //     reject with the thrown exception and the synchronous flag if set.
-            if (exec->hadException()) {
-                JSValue exception = exec->exception();
-                exec->clearException();
-
-                reject(exec, exception, mode);
-                return;
-            }
-            return;
-        }
-    }
-
-    // 5. Run context object's fulfill with value and the synchronous flag if set.
-    fulfill(exec, value, mode);
-}
-
-void JSPromiseResolver::reject(ExecState* exec, JSValue value, ResolverMode mode)
-{
-    // 1. Let promise be the context object's associated promise.
-    // 2. Set promise's state to rejected.
-    m_promise->setState(JSPromise::Rejected);
-
-    // 3. Set promise's result to value.
-    m_promise->setResult(exec->vm(), value);
-
-    // 4. If the synchronous flag is set, process promise's reject callbacks with value.
-    if (mode == ResolveSynchronously) {
-        m_promise->processRejectCallbacksWithValue(exec, value);
-        return;
-    }
-    
-    // 5. Otherwise, the synchronous flag is unset, queue a task to process promise's reject callbacks with value.
-    m_promise->queueTaskToProcessRejectCallbacks(exec);
-}
-
-} // namespace JSC
-
-#endif // ENABLE(PROMISES)
diff --git a/Source/JavaScriptCore/runtime/JSPromiseResolver.h b/Source/JavaScriptCore/runtime/JSPromiseResolver.h
deleted file mode 100644
index 7fa4797..0000000
--- a/Source/JavaScriptCore/runtime/JSPromiseResolver.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef JSPromiseResolver_h
-#define JSPromiseResolver_h
-
-#if ENABLE(PROMISES)
-
-#include "JSObject.h"
-
-namespace JSC {
-
-class JSPromise;
-
-class JSPromiseResolver : public JSNonFinalObject {
-public:
-    typedef JSNonFinalObject Base;
-
-    static JSPromiseResolver* create(VM&, Structure*, JSPromise*);
-    static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
-
-    DECLARE_INFO;
-
-    JSPromise* promise() const;
-
-    JS_EXPORT_PRIVATE void fulfillIfNotResolved(ExecState*, JSValue);
-    void resolveIfNotResolved(ExecState*, JSValue);
-    JS_EXPORT_PRIVATE void rejectIfNotResolved(ExecState*, JSValue);
-
-    enum ResolverMode {
-        ResolveSynchronously,
-        ResolveAsynchronously,
-    };
-
-    void fulfill(ExecState*, JSValue, ResolverMode = ResolveAsynchronously);
-    void resolve(ExecState*, JSValue, ResolverMode = ResolveAsynchronously);
-    void reject(ExecState*, JSValue, ResolverMode = ResolveAsynchronously);
-
-protected:
-    void finishCreation(VM&, JSPromise*);
-    static const unsigned StructureFlags = OverridesVisitChildren | JSObject::StructureFlags;
-
-private:
-    JSPromiseResolver(VM&, Structure*);
-
-    static void visitChildren(JSCell*, SlotVisitor&);
-
-    WriteBarrier<JSPromise> m_promise;
-    bool m_isResolved;
-};
-
-} // namespace JSC
-
-#endif // ENABLE(PROMISES)
-
-#endif // JSPromiseResolver_h
diff --git a/Source/JavaScriptCore/runtime/JSPromiseResolverConstructor.cpp b/Source/JavaScriptCore/runtime/JSPromiseResolverConstructor.cpp
deleted file mode 100644
index 47fc801..0000000
--- a/Source/JavaScriptCore/runtime/JSPromiseResolverConstructor.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "JSPromiseResolverConstructor.h"
-
-#if ENABLE(PROMISES)
-
-#include "JSCJSValueInlines.h"
-#include "JSCellInlines.h"
-#include "JSPromiseResolverPrototype.h"
-#include "Lookup.h"
-#include "StructureInlines.h"
-
-namespace JSC {
-
-STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSPromiseResolverConstructor);
-
-const ClassInfo JSPromiseResolverConstructor::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSPromiseResolverConstructor) };
-
-JSPromiseResolverConstructor* JSPromiseResolverConstructor::create(VM& vm, Structure* structure, JSPromiseResolverPrototype* promisePrototype)
-{
-    JSPromiseResolverConstructor* constructor = new (NotNull, allocateCell<JSPromiseResolverConstructor>(vm.heap)) JSPromiseResolverConstructor(vm, structure);
-    constructor->finishCreation(vm, promisePrototype);
-    return constructor;
-}
-
-Structure* JSPromiseResolverConstructor::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
-{
-    return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
-}
-
-JSPromiseResolverConstructor::JSPromiseResolverConstructor(VM& vm, Structure* structure)
-    : InternalFunction(vm, structure)
-{
-}
-
-void JSPromiseResolverConstructor::finishCreation(VM& vm, JSPromiseResolverPrototype* promiseResolverPrototype)
-{
-    Base::finishCreation(vm, "PromiseResolver");
-    putDirectWithoutTransition(vm, vm.propertyNames->prototype, promiseResolverPrototype, DontEnum | DontDelete | ReadOnly);
-}
-
-ConstructType JSPromiseResolverConstructor::getConstructData(JSCell*, ConstructData&)
-{
-    return ConstructTypeNone;
-}
-
-CallType JSPromiseResolverConstructor::getCallData(JSCell*, CallData&)
-{
-    return CallTypeNone;
-}
-
-} // namespace JSC
-
-#endif // ENABLE(PROMISES)
diff --git a/Source/JavaScriptCore/runtime/JSPromiseResolverConstructor.h b/Source/JavaScriptCore/runtime/JSPromiseResolverConstructor.h
deleted file mode 100644
index c415ed8..0000000
--- a/Source/JavaScriptCore/runtime/JSPromiseResolverConstructor.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef JSPromiseResolverConstructor_h
-#define JSPromiseResolverConstructor_h
-
-#if ENABLE(PROMISES)
-
-#include "InternalFunction.h"
-
-namespace JSC {
-
-class JSPromiseResolverPrototype;
-
-class JSPromiseResolverConstructor : public InternalFunction {
-public:
-    typedef InternalFunction Base;
-
-    static JSPromiseResolverConstructor* create(VM&, Structure*, JSPromiseResolverPrototype*);
-    static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
-
-    DECLARE_INFO;
-
-protected:
-    void finishCreation(VM&, JSPromiseResolverPrototype*);
-    static const unsigned StructureFlags = InternalFunction::StructureFlags;
-
-private:
-    JSPromiseResolverConstructor(VM&, Structure*);
-    static ConstructType getConstructData(JSCell*, ConstructData&);
-    static CallType getCallData(JSCell*, CallData&);
-};
-
-} // namespace JSC
-
-#endif // ENABLE(PROMISES)
-
-#endif // JSPromiseResolverConstructor_h
diff --git a/Source/JavaScriptCore/runtime/JSPromiseResolverPrototype.cpp b/Source/JavaScriptCore/runtime/JSPromiseResolverPrototype.cpp
deleted file mode 100644
index 93caa57..0000000
--- a/Source/JavaScriptCore/runtime/JSPromiseResolverPrototype.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "JSPromiseResolverPrototype.h"
-
-#if ENABLE(PROMISES)
-
-#include "Error.h"
-#include "JSCJSValueInlines.h"
-#include "JSCellInlines.h"
-#include "JSPromiseResolver.h"
-#include "StructureInlines.h"
-
-namespace JSC {
-
-STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSPromiseResolverPrototype);
-
-// void fulfill(optional any value);
-static EncodedJSValue JSC_HOST_CALL JSPromiseResolverPrototypeFuncFulfill(ExecState*);
-// void resolve(optional any value);
-static EncodedJSValue JSC_HOST_CALL JSPromiseResolverPrototypeFuncResolve(ExecState*);
-// void reject(optional any value);
-static EncodedJSValue JSC_HOST_CALL JSPromiseResolverPrototypeFuncReject(ExecState*);
-
-}
-
-#include "JSPromiseResolverPrototype.lut.h"
-
-namespace JSC {
-
-const ClassInfo JSPromiseResolverPrototype::s_info = { "PromiseResolverPrototype", &Base::s_info, 0, ExecState::promiseResolverPrototypeTable, CREATE_METHOD_TABLE(JSPromiseResolverPrototype) };
-
-/* Source for JSPromiseResolverPrototype.lut.h
-@begin promiseResolverPrototypeTable
-  fulfill         JSPromiseResolverPrototypeFuncFulfill             DontEnum|Function 1
-  resolve         JSPromiseResolverPrototypeFuncResolve             DontEnum|Function 1
-  reject          JSPromiseResolverPrototypeFuncReject              DontEnum|Function 1
-@end
-*/
-
-JSPromiseResolverPrototype* JSPromiseResolverPrototype::create(ExecState* exec, JSGlobalObject*, Structure* structure)
-{
-    VM& vm = exec->vm();
-    JSPromiseResolverPrototype* object = new (NotNull, allocateCell<JSPromiseResolverPrototype>(vm.heap)) JSPromiseResolverPrototype(exec, structure);
-    object->finishCreation(vm, structure);
-    return object;
-}
-
-Structure* JSPromiseResolverPrototype::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
-{
-    return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
-}
-
-JSPromiseResolverPrototype::JSPromiseResolverPrototype(ExecState* exec, Structure* structure)
-    : JSNonFinalObject(exec->vm(), structure)
-{
-}
-
-void JSPromiseResolverPrototype::finishCreation(VM& vm, Structure*)
-{
-    Base::finishCreation(vm);
-}
-
-bool JSPromiseResolverPrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
-{
-    return getStaticFunctionSlot<JSObject>(exec, ExecState::promiseResolverPrototypeTable(exec), jsCast<JSPromiseResolverPrototype*>(object), propertyName, slot);
-}
-
-EncodedJSValue JSC_HOST_CALL JSPromiseResolverPrototypeFuncFulfill(ExecState* exec)
-{
-    JSPromiseResolver* thisObject = jsDynamicCast<JSPromiseResolver*>(exec->thisValue());
-    if (!thisObject)
-        return throwVMError(exec, createTypeError(exec, "Receiver of fulfill must be a PromiseResolver"));
-
-    thisObject->fulfillIfNotResolved(exec, exec->argument(0));
-    return JSValue::encode(jsUndefined());
-}
-
-EncodedJSValue JSC_HOST_CALL JSPromiseResolverPrototypeFuncResolve(ExecState* exec)
-{
-    JSPromiseResolver* thisObject = jsDynamicCast<JSPromiseResolver*>(exec->thisValue());
-    if (!thisObject)
-        return throwVMError(exec, createTypeError(exec, "Receiver of resolve must be a PromiseResolver"));
-
-    thisObject->resolveIfNotResolved(exec, exec->argument(0));
-    return JSValue::encode(jsUndefined());
-}
-
-EncodedJSValue JSC_HOST_CALL JSPromiseResolverPrototypeFuncReject(ExecState* exec)
-{
-    JSPromiseResolver* thisObject = jsDynamicCast<JSPromiseResolver*>(exec->thisValue());
-    if (!thisObject)
-        return throwVMError(exec, createTypeError(exec, "Receiver of reject must be a PromiseResolver"));
-
-    thisObject->rejectIfNotResolved(exec, exec->argument(0));
-    return JSValue::encode(jsUndefined());
-}
-
-} // namespace JSC
-
-#endif // ENABLE(PROMISES)
diff --git a/Source/JavaScriptCore/runtime/JSPromiseResolverPrototype.h b/Source/JavaScriptCore/runtime/Microtask.h
similarity index 62%
copy from Source/JavaScriptCore/runtime/JSPromiseResolverPrototype.h
copy to Source/JavaScriptCore/runtime/Microtask.h
index 071c196..f996a7c 100644
--- a/Source/JavaScriptCore/runtime/JSPromiseResolverPrototype.h
+++ b/Source/JavaScriptCore/runtime/Microtask.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -23,35 +23,24 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef JSPromiseResolverPrototype_h
-#define JSPromiseResolverPrototype_h
+#ifndef Microtask_h
+#define Microtask_h
 
-#if ENABLE(PROMISES)
-
-#include "JSObject.h"
+#include <wtf/RefCounted.h>
 
 namespace JSC {
 
-class JSPromiseResolverPrototype : public JSNonFinalObject {
+class ExecState;
+
+class Microtask : public RefCounted<Microtask> {
 public:
-    typedef JSNonFinalObject Base;
+    virtual ~Microtask()
+    {
+    }
 
-    static JSPromiseResolverPrototype* create(ExecState*, JSGlobalObject*, Structure*);
-    static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
-
-    DECLARE_INFO;
-
-protected:
-    void finishCreation(VM&, Structure*);
-    static const unsigned StructureFlags = OverridesGetOwnPropertySlot | JSObject::StructureFlags;
-
-private:
-    JSPromiseResolverPrototype(ExecState*, Structure*);
-    static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
+    virtual void run(ExecState*) = 0;
 };
 
 } // namespace JSC
 
-#endif // ENABLE(PROMISES)
-
-#endif // JSPromiseResolverPrototype_h
+#endif // Microtask_h
diff --git a/Source/JavaScriptCore/runtime/VM.cpp b/Source/JavaScriptCore/runtime/VM.cpp
index 19689a6..9558b8d 100644
--- a/Source/JavaScriptCore/runtime/VM.cpp
+++ b/Source/JavaScriptCore/runtime/VM.cpp
@@ -57,6 +57,8 @@
 #include "JSLock.h"
 #include "JSNameScope.h"
 #include "JSNotAnObject.h"
+#include "JSPromiseDeferred.h"
+#include "JSPromiseReaction.h"
 #include "JSPropertyNameIterator.h"
 #include "JSWithScope.h"
 #include "Lexer.h"
@@ -114,7 +116,6 @@
 #if ENABLE(PROMISES)
 extern const HashTable promisePrototypeTable;
 extern const HashTable promiseConstructorTable;
-extern const HashTable promiseResolverPrototypeTable;
 #endif
 
 // Note: Platform.h will enforce that ENABLE(ASSEMBLER) is true if either
@@ -185,7 +186,6 @@
 #if ENABLE(PROMISES)
     , promisePrototypeTable(adoptPtr(new HashTable(JSC::promisePrototypeTable)))
     , promiseConstructorTable(adoptPtr(new HashTable(JSC::promiseConstructorTable)))
-    , promiseResolverPrototypeTable(adoptPtr(new HashTable(JSC::promiseResolverPrototypeTable)))
 #endif
     , identifierTable(vmType == Default ? wtfThreadData().currentIdentifierTable() : createIdentifierTable())
     , propertyNames(new CommonIdentifiers(this))
@@ -258,6 +258,8 @@
     propertyTableStructure.set(*this, PropertyTable::createStructure(*this, 0, jsNull()));
     mapDataStructure.set(*this, MapData::createStructure(*this, 0, jsNull()));
     weakMapDataStructure.set(*this, WeakMapData::createStructure(*this, 0, jsNull()));
+    promiseDeferredStructure.set(*this, JSPromiseDeferred::createStructure(*this, 0, jsNull()));
+    promiseReactionStructure.set(*this, JSPromiseReaction::createStructure(*this, 0, jsNull()));
     iterationTerminator.set(*this, JSFinalObject::create(*this, JSFinalObject::createStructure(*this, 0, jsNull(), 1)));
     smallStrings.initializeCommonStrings(*this);
 
@@ -350,7 +352,6 @@
 #if ENABLE(PROMISES)
     promisePrototypeTable->deleteTable();
     promiseConstructorTable->deleteTable();
-    promiseResolverPrototypeTable->deleteTable();
 #endif
 
     delete emptyList;
diff --git a/Source/JavaScriptCore/runtime/VM.h b/Source/JavaScriptCore/runtime/VM.h
index 691357d..f2f2b553 100644
--- a/Source/JavaScriptCore/runtime/VM.h
+++ b/Source/JavaScriptCore/runtime/VM.h
@@ -252,7 +252,6 @@
 #if ENABLE(PROMISES)
         const OwnPtr<const HashTable> promisePrototypeTable;
         const OwnPtr<const HashTable> promiseConstructorTable;
-        const OwnPtr<const HashTable> promiseResolverPrototypeTable;
 #endif
 
         Strong<Structure> structureStructure;
@@ -283,6 +282,8 @@
         Strong<Structure> propertyTableStructure;
         Strong<Structure> mapDataStructure;
         Strong<Structure> weakMapDataStructure;
+        Strong<Structure> promiseDeferredStructure;
+        Strong<Structure> promiseReactionStructure;
         Strong<JSCell> iterationTerminator;
 
         IdentifierTable* identifierTable;