WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-148118-20150817203458.patch (text/plain), 25.09 KB, created by
Yusuke Suzuki
on 2015-08-17 20:35:00 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2015-08-17 20:35:00 PDT
Size:
25.09 KB
patch
obsolete
>Subversion Revision: 188525 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index fe93c60d3448576c668decd6f98f73823af6abb1..b78b2f045cf8ab64307d903da128787724d9e517 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,49 @@ >+2015-08-17 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ Introduce non-user-observable Promise functions to use Promises internally >+ https://bugs.webkit.org/show_bug.cgi?id=148118 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ To leverage the Promises internally (like ES6 Module Loaders), we add >+ the several non-user-observable private methods, like @then, @all. And >+ refactor the existing Promises implementation to make it easy to use >+ internally. >+ >+ No behavior change. >+ >+ * builtins/Operations.Promise.js: >+ (.onFulfilled): >+ (.onRejected): >+ (promiseThen): >+ * builtins/Promise.prototype.js: >+ (then): >+ (privateThen): >+ (.onFulfilled): Deleted. >+ (.onRejected): Deleted. >+ * builtins/PromiseConstructor.js: >+ (privateAll.newResolveElement): >+ (privateAll): >+ * runtime/JSGlobalObject.cpp: >+ (JSC::JSGlobalObject::init): >+ (JSC::JSGlobalObject::visitChildren): Deleted. >+ * runtime/JSGlobalObject.h: >+ (JSC::JSGlobalObject::promiseConstructor): Deleted. >+ (JSC::JSGlobalObject::promisePrototype): Deleted. >+ (JSC::JSGlobalObject::promiseStructure): Deleted. >+ * runtime/JSPromiseConstructor.cpp: >+ (JSC::JSPromiseConstructor::finishCreation): >+ * runtime/JSPromiseDeferred.cpp: >+ (JSC::callFunction): >+ (JSC::JSPromiseDeferred::resolve): >+ (JSC::JSPromiseDeferred::reject): >+ * runtime/JSPromiseDeferred.h: >+ * runtime/JSPromisePrototype.cpp: >+ (JSC::JSPromisePrototype::create): >+ (JSC::JSPromisePrototype::JSPromisePrototype): >+ (JSC::JSPromisePrototype::finishCreation): >+ * runtime/JSPromisePrototype.h: >+ > 2015-08-16 Benjamin Poulain <bpoulain@apple.com> > > [JSC] Use (x + x) instead of (x * 2) when possible >diff --git a/Source/JavaScriptCore/builtins/Operations.Promise.js b/Source/JavaScriptCore/builtins/Operations.Promise.js >index 66f9c2515359c7a51254f937fc7f51ccd131241d..d0d41d4fb2b9ec7f78d1d637a18a1daacbafbb39 100644 >--- a/Source/JavaScriptCore/builtins/Operations.Promise.js >+++ b/Source/JavaScriptCore/builtins/Operations.Promise.js >@@ -218,3 +218,29 @@ function initializePromise(executor) > > return this; > } >+ >+function promiseThen(promise, capability, onFulfilled, onRejected) >+{ >+ "use strict"; >+ >+ if (typeof onFulfilled !== "function") >+ onFulfilled = function (argument) { return argument; }; >+ >+ if (typeof onRejected !== "function") >+ onRejected = function (argument) { throw argument; }; >+ >+ var fulfillReaction = @newPromiseReaction(capability, onFulfilled); >+ var rejectReaction = @newPromiseReaction(capability, onRejected); >+ >+ var state = promise.@promiseState; >+ >+ if (state === @promisePending) { >+ @putByValDirect(promise.@promiseFulfillReactions, promise.@promiseFulfillReactions.length, fulfillReaction) >+ @putByValDirect(promise.@promiseRejectReactions, promise.@promiseRejectReactions.length, rejectReaction) >+ } else if (state === @promiseFulfilled) >+ @enqueueJob(@promiseReactionJob, [fulfillReaction, promise.@promiseResult]); >+ else if (state === @promiseRejected) >+ @enqueueJob(@promiseReactionJob, [rejectReaction, promise.@promiseResult]); >+ >+ return capability.@promise; >+} >diff --git a/Source/JavaScriptCore/builtins/Promise.prototype.js b/Source/JavaScriptCore/builtins/Promise.prototype.js >index 8563df0d927fb233968939e14942396ec85e65aa..ba022aba5a0d58d85efee079b39acbb11362bf8d 100644 >--- a/Source/JavaScriptCore/builtins/Promise.prototype.js >+++ b/Source/JavaScriptCore/builtins/Promise.prototype.js >@@ -41,26 +41,19 @@ function then(onFulfilled, onRejected) > // https://bugs.webkit.org/show_bug.cgi?id=146624 > var constructor = this.constructor; > >- var resultCapability = @newPromiseCapability(constructor); >- >- if (typeof onFulfilled !== "function") >- onFulfilled = function (argument) { return argument; }; >- >- if (typeof onRejected !== "function") >- onRejected = function (argument) { throw argument; }; >- >- var fulfillReaction = @newPromiseReaction(resultCapability, onFulfilled); >- var rejectReaction = @newPromiseReaction(resultCapability, onRejected); >+ return @promiseThen(this, @newPromiseCapability(constructor), onFulfilled, onRejected); >+} > >- var state = this.@promiseState; >+function privateThen(onFulfilled, onRejected) >+{ >+ // This function is intended to be used in the JSC internals. >+ // The implementation should take care not to perform the user >+ // observable / trappable operations. >+ // >+ // 1. Don't look up this.constructor / @@species. Always construct >+ // the plain Promise object. > >- if (state === @promisePending) { >- @putByValDirect(this.@promiseFulfillReactions, this.@promiseFulfillReactions.length, fulfillReaction) >- @putByValDirect(this.@promiseRejectReactions, this.@promiseRejectReactions.length, rejectReaction) >- } else if (state === @promiseFulfilled) >- @enqueueJob(@promiseReactionJob, [fulfillReaction, this.@promiseResult]); >- else if (state === @promiseRejected) >- @enqueueJob(@promiseReactionJob, [rejectReaction, this.@promiseResult]); >+ "use strict"; > >- return resultCapability.@promise; >+ return @promiseThen(this, @newPromiseDeferred(), onFulfilled, onRejected); > } >diff --git a/Source/JavaScriptCore/builtins/PromiseConstructor.js b/Source/JavaScriptCore/builtins/PromiseConstructor.js >index 1f83b47f790a75e5bf8c93d5e6649618cb1aec67..f6610774d01f216206260c704dfc3a10e5345e41 100644 >--- a/Source/JavaScriptCore/builtins/PromiseConstructor.js >+++ b/Source/JavaScriptCore/builtins/PromiseConstructor.js >@@ -137,3 +137,65 @@ function resolve(value) > > return promiseCapability.@promise; > } >+ >+function privateAll(array) >+{ >+ // This function is intended to be used in the JSC internals. >+ // The implementation should take care not to perform the user >+ // observable / trappable operations. >+ // >+ // 1. Don't use for-of and iterables. This function only accepts >+ // the dense array of the promises. >+ // 2. Don't look up this.constructor / @@species. Always construct >+ // the plain Promise object. >+ >+ "use strict"; >+ >+ var promiseCapability = @newPromiseDeferred(); >+ >+ var values = []; >+ var index = 0; >+ var remainingElementsCount = 1; >+ >+ function newResolveElement(index) >+ { >+ var alreadyCalled = false; >+ return function (argument) >+ { >+ if (alreadyCalled) >+ return undefined; >+ alreadyCalled = true; >+ >+ @putByValDirect(values, index, argument); >+ >+ --remainingElementsCount; >+ if (remainingElementsCount === 0) >+ return promiseCapability.@resolve.@call(undefined, values); >+ >+ return undefined; >+ } >+ } >+ >+ try { >+ for (var index = 0, length = array.length; index < length; ++index) { >+ var value = array[index]; >+ @putByValDirect(values, index, undefined); >+ >+ var nextPromiseCapability = @newPromiseDeferred(); >+ nextPromiseCapability.@resolve.@call(undefined, value); >+ var nextPromise = nextPromiseCapability.@promise; >+ >+ var resolveElement = newResolveElement(index); >+ ++remainingElementsCount; >+ nextPromise.@then(resolveElement, promiseCapability.@reject); >+ } >+ >+ --remainingElementsCount; >+ if (remainingElementsCount === 0) >+ promiseCapability.@resolve.@call(undefined, values); >+ } catch (error) { >+ promiseCapability.@reject.@call(undefined, error); >+ } >+ >+ return promiseCapability.@promise; >+} >diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >index 25ace9269180add73c4eae98d389578e46aeb544..6b3a20275a728744e7226f987e46edc5cbdc5f01 100644 >--- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >@@ -336,9 +336,6 @@ void JSGlobalObject::init(VM& vm) > m_regExpPrototype.set(vm, this, RegExpPrototype::create(vm, RegExpPrototype::createStructure(vm, this, m_objectPrototype.get()), emptyRegex)); > m_regExpStructure.set(vm, this, RegExpObject::createStructure(vm, this, m_regExpPrototype.get())); > m_regExpMatchesArrayStructure.set(vm, this, createRegExpMatchesArrayStructure(vm, *this)); >- >- 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())); > > #if ENABLE(WEBASSEMBLY) > m_wasmModuleStructure.set(vm, this, JSWASMModule::createStructure(vm, this)); >@@ -397,13 +394,11 @@ m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->c > 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); >- m_promisePrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, m_promiseConstructor.get(), DontEnum); > > putDirectWithoutTransition(vm, vm.propertyNames->Object, objectConstructor, DontEnum); > putDirectWithoutTransition(vm, vm.propertyNames->Function, functionConstructor, DontEnum); >@@ -415,7 +410,6 @@ m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->c > 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); >- putDirectWithoutTransition(vm, vm.propertyNames->Promise, m_promiseConstructor.get(), DontEnum); > > > #define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \ >@@ -491,7 +485,7 @@ putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct > GlobalPropertyInfo(vm.propertyNames->arrayIterationKindValuePrivateName, jsNumber(ArrayIterateValue), DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->arrayIterationKindKeyValuePrivateName, jsNumber(ArrayIterateKeyValue), DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().symbolIteratorPrivateName(), Symbol::create(vm, static_cast<SymbolImpl&>(*vm.propertyNames->iteratorSymbol.impl())), DontEnum | DontDelete | ReadOnly), >- GlobalPropertyInfo(vm.propertyNames->PromisePrivateName, m_promiseConstructor.get(), DontEnum | DontDelete | ReadOnly), >+ GlobalPropertyInfo(vm.propertyNames->PromisePrivateName, promiseConstructor, DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->promisePendingPrivateName, jsNumber(static_cast<unsigned>(JSPromise::Status::Pending)), DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().promiseFulfilledPrivateName(), jsNumber(static_cast<unsigned>(JSPromise::Status::Fulfilled)), DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().promiseRejectedPrivateName(), jsNumber(static_cast<unsigned>(JSPromise::Status::Rejected)), DontEnum | DontDelete | ReadOnly), >@@ -507,6 +501,8 @@ putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct > GlobalPropertyInfo(vm.propertyNames->builtinNames().createResolvingFunctionsPrivateName(), JSFunction::createBuiltinFunction(vm, operationsPromiseCreateResolvingFunctionsCodeGenerator(vm), this), DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().promiseReactionJobPrivateName(), JSFunction::createBuiltinFunction(vm, operationsPromisePromiseReactionJobCodeGenerator(vm), this), DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().promiseResolveThenableJobPrivateName(), JSFunction::createBuiltinFunction(vm, operationsPromisePromiseResolveThenableJobCodeGenerator(vm), this), DontEnum | DontDelete | ReadOnly), >+ GlobalPropertyInfo(vm.propertyNames->builtinNames().newPromiseDeferredPrivateName(), m_newPromiseDeferredFunction.get(), DontEnum | DontDelete | ReadOnly), >+ GlobalPropertyInfo(vm.propertyNames->builtinNames().promiseThenPrivateName(), JSFunction::createBuiltinFunction(vm, operationsPromisePromiseThenCodeGenerator(vm), this), DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().InspectorInstrumentationPrivateName(), InspectorInstrumentationObject::create(vm, this, InspectorInstrumentationObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum | DontDelete | ReadOnly), > }; > addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals)); >@@ -750,7 +746,6 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor) > visitor.append(&thisObject->m_typeErrorConstructor); > visitor.append(&thisObject->m_URIErrorConstructor); > visitor.append(&thisObject->m_objectConstructor); >- visitor.append(&thisObject->m_promiseConstructor); > > visitor.append(&thisObject->m_nullGetterFunction); > visitor.append(&thisObject->m_nullSetterFunction); >@@ -770,7 +765,6 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor) > visitor.append(&thisObject->m_arrayPrototype); > visitor.append(&thisObject->m_errorPrototype); > visitor.append(&thisObject->m_iteratorPrototype); >- visitor.append(&thisObject->m_promisePrototype); > > visitor.append(&thisObject->m_debuggerScopeStructure); > visitor.append(&thisObject->m_withScopeStructure); >@@ -804,7 +798,6 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor) > visitor.append(&thisObject->m_consoleStructure); > visitor.append(&thisObject->m_dollarVMStructure); > visitor.append(&thisObject->m_internalFunctionStructure); >- visitor.append(&thisObject->m_promiseStructure); > #if ENABLE(WEBASSEMBLY) > visitor.append(&thisObject->m_wasmModuleStructure); > #endif >diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.h b/Source/JavaScriptCore/runtime/JSGlobalObject.h >index 9986bcf6245e2cc46820b13102b2342900ec3d7b..96d22ff1f14e24b8c18ff86ebf1c57620e3beaa6 100644 >--- a/Source/JavaScriptCore/runtime/JSGlobalObject.h >+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.h >@@ -99,6 +99,7 @@ struct HashTable; > macro(Boolean, boolean, booleanObject, BooleanObject, Boolean) \ > macro(Number, number, numberObject, NumberObject, Number) \ > macro(Error, error, error, ErrorInstance, Error) \ >+ macro(JSPromise, promise, promise, JSPromise, Promise) \ > macro(JSArrayBuffer, arrayBuffer, arrayBuffer, JSArrayBuffer, ArrayBuffer) \ > DEFINE_STANDARD_BUILTIN(macro, WeakMap, weakMap) \ > DEFINE_STANDARD_BUILTIN(macro, WeakSet, weakSet) \ >@@ -183,7 +184,6 @@ class JSGlobalObject : public JSSegmentedVariableObject { > WriteBarrier<NativeErrorConstructor> m_syntaxErrorConstructor; > WriteBarrier<NativeErrorConstructor> m_typeErrorConstructor; > WriteBarrier<NativeErrorConstructor> m_URIErrorConstructor; >- WriteBarrier<JSPromiseConstructor> m_promiseConstructor; > WriteBarrier<ObjectConstructor> m_objectConstructor; > > WriteBarrier<NullGetterFunction> m_nullGetterFunction; >@@ -205,7 +205,6 @@ class JSGlobalObject : public JSSegmentedVariableObject { > WriteBarrier<ArrayPrototype> m_arrayPrototype; > WriteBarrier<RegExpPrototype> m_regExpPrototype; > WriteBarrier<IteratorPrototype> m_iteratorPrototype; >- WriteBarrier<JSPromisePrototype> m_promisePrototype; > > WriteBarrier<Structure> m_debuggerScopeStructure; > WriteBarrier<Structure> m_withScopeStructure; >@@ -241,7 +240,6 @@ class JSGlobalObject : public JSSegmentedVariableObject { > WriteBarrier<Structure> m_internalFunctionStructure; > WriteBarrier<Structure> m_iteratorResultStructure; > WriteBarrier<Structure> m_regExpMatchesArrayStructure; >- WriteBarrier<Structure> m_promiseStructure; > #if ENABLE(WEBASSEMBLY) > WriteBarrier<Structure> m_wasmModuleStructure; > #endif >@@ -386,7 +384,6 @@ class JSGlobalObject : public JSSegmentedVariableObject { > 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(); } > > NullGetterFunction* nullGetterFunction() const { return m_nullGetterFunction.get(); } > NullSetterFunction* nullSetterFunction() const { return m_nullSetterFunction.get(); } >@@ -418,7 +415,6 @@ class JSGlobalObject : public JSSegmentedVariableObject { > RegExpPrototype* regExpPrototype() const { return m_regExpPrototype.get(); } > ErrorPrototype* errorPrototype() const { return m_errorPrototype.get(); } > IteratorPrototype* iteratorPrototype() const { return m_iteratorPrototype.get(); } >- JSPromisePrototype* promisePrototype() const { return m_promisePrototype.get(); } > > Structure* debuggerScopeStructure() const { return m_debuggerScopeStructure.get(); } > Structure* withScopeStructure() const { return m_withScopeStructure.get(); } >@@ -475,7 +471,6 @@ class JSGlobalObject : public JSSegmentedVariableObject { > Structure* iteratorResultStructure() const { return m_iteratorResultStructure.get(); } > static ptrdiff_t iteratorResultStructureOffset() { return OBJECT_OFFSETOF(JSGlobalObject, m_iteratorResultStructure); } > Structure* regExpMatchesArrayStructure() const { return m_regExpMatchesArrayStructure.get(); } >- Structure* promiseStructure() const { return m_promiseStructure.get(); } > #if ENABLE(WEBASSEMBLY) > Structure* wasmModuleStructure() const { return m_wasmModuleStructure.get(); } > #endif >diff --git a/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp b/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp >index 44e1e73caba55b0bf54092ec584fe657e5461ae5..243bc527c46ffd5edad364d5200ff8ef946c2d85 100644 >--- a/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp >+++ b/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp >@@ -26,6 +26,7 @@ > #include "config.h" > #include "JSPromiseConstructor.h" > >+#include "BuiltinNames.h" > #include "Error.h" > #include "Exception.h" > #include "IteratorOperations.h" >@@ -81,6 +82,7 @@ void JSPromiseConstructor::finishCreation(VM& vm, JSPromisePrototype* promisePro > Base::finishCreation(vm, ASCIILiteral("Promise")); > putDirectWithoutTransition(vm, vm.propertyNames->prototype, promisePrototype, DontEnum | DontDelete | ReadOnly); > putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete); >+ putDirectBuiltinFunctionWithoutTransition(vm, globalObject(), vm.propertyNames->builtinNames().allPrivateName(), promiseConstructorPrivateAllCodeGenerator(vm), ReadOnly | DontEnum | DontDelete); > } > > static EncodedJSValue JSC_HOST_CALL constructPromise(ExecState* exec) >diff --git a/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp b/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp >index 6f3543235bd8a0938418ff7affcdd02b13584747..000b6462dfc7aad42084e2c96fe32e7807c702de 100644 >--- a/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp >+++ b/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp >@@ -72,6 +72,28 @@ JSPromiseDeferred::JSPromiseDeferred(VM& vm) > { > } > >+static void callFunction(ExecState* exec, JSValue function, JSValue value) >+{ >+ CallData callData; >+ CallType callType = getCallData(function, callData); >+ ASSERT(callType != CallTypeNone); >+ >+ MarkedArgumentBuffer arguments; >+ arguments.append(value); >+ >+ call(exec, function, callType, callData, jsUndefined(), arguments); >+} >+ >+void JSPromiseDeferred::resolve(ExecState* exec, JSValue value) >+{ >+ callFunction(exec, m_resolve.get(), value); >+} >+ >+void JSPromiseDeferred::reject(ExecState* exec, JSValue reason) >+{ >+ callFunction(exec, m_reject.get(), reason); >+} >+ > void JSPromiseDeferred::finishCreation(VM& vm, JSObject* promise, JSValue resolve, JSValue reject) > { > Base::finishCreation(vm); >diff --git a/Source/JavaScriptCore/runtime/JSPromiseDeferred.h b/Source/JavaScriptCore/runtime/JSPromiseDeferred.h >index dea0d17f9b42cec67acc8235506595db51e94107..4a0b4b8568a47bdd9fe2c38f850476f2db91da27 100644 >--- a/Source/JavaScriptCore/runtime/JSPromiseDeferred.h >+++ b/Source/JavaScriptCore/runtime/JSPromiseDeferred.h >@@ -50,6 +50,9 @@ class JSPromiseDeferred final : public JSCell { > JSValue resolve() const { return m_resolve.get(); } > JSValue reject() const { return m_reject.get(); } > >+ JS_EXPORT_PRIVATE void resolve(ExecState*, JSValue); >+ JS_EXPORT_PRIVATE void reject(ExecState*, JSValue); >+ > private: > JSPromiseDeferred(VM&); > void finishCreation(VM&, JSObject*, JSValue, JSValue); >diff --git a/Source/JavaScriptCore/runtime/JSPromisePrototype.cpp b/Source/JavaScriptCore/runtime/JSPromisePrototype.cpp >index a0f1024320c14bb364e810343935ad793a7da486..026837348075da3e4787b4a2df4ceeec51ca619d 100644 >--- a/Source/JavaScriptCore/runtime/JSPromisePrototype.cpp >+++ b/Source/JavaScriptCore/runtime/JSPromisePrototype.cpp >@@ -26,6 +26,7 @@ > #include "config.h" > #include "JSPromisePrototype.h" > >+#include "BuiltinNames.h" > #include "Error.h" > #include "JSCBuiltins.h" > #include "JSCJSValueInlines.h" >@@ -54,10 +55,9 @@ const ClassInfo JSPromisePrototype::s_info = { "PromisePrototype", &JSNonFinalOb > @end > */ > >-JSPromisePrototype* JSPromisePrototype::create(ExecState* exec, JSGlobalObject*, Structure* structure) >+JSPromisePrototype* JSPromisePrototype::create(VM& vm, JSGlobalObject*, Structure* structure) > { >- VM& vm = exec->vm(); >- JSPromisePrototype* object = new (NotNull, allocateCell<JSPromisePrototype>(vm.heap)) JSPromisePrototype(exec, structure); >+ JSPromisePrototype* object = new (NotNull, allocateCell<JSPromisePrototype>(vm.heap)) JSPromisePrototype(vm, structure); > object->finishCreation(vm, structure); > return object; > } >@@ -67,14 +67,15 @@ Structure* JSPromisePrototype::createStructure(VM& vm, JSGlobalObject* globalObj > return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); > } > >-JSPromisePrototype::JSPromisePrototype(ExecState* exec, Structure* structure) >- : JSNonFinalObject(exec->vm(), structure) >+JSPromisePrototype::JSPromisePrototype(VM& vm, Structure* structure) >+ : JSNonFinalObject(vm, structure) > { > } > > void JSPromisePrototype::finishCreation(VM& vm, Structure*) > { > Base::finishCreation(vm); >+ putDirectBuiltinFunctionWithoutTransition(vm, globalObject(), vm.propertyNames->builtinNames().thenPrivateName(), promisePrototypePrivateThenCodeGenerator(vm), ReadOnly | DontEnum | DontDelete); > } > > bool JSPromisePrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot) >diff --git a/Source/JavaScriptCore/runtime/JSPromisePrototype.h b/Source/JavaScriptCore/runtime/JSPromisePrototype.h >index 458d14119ddf9abe0763b77739b4ea9b85c21906..4e871c756cc8e7577a0704115603f93e8553e1f7 100644 >--- a/Source/JavaScriptCore/runtime/JSPromisePrototype.h >+++ b/Source/JavaScriptCore/runtime/JSPromisePrototype.h >@@ -35,7 +35,7 @@ class JSPromisePrototype : public JSNonFinalObject { > typedef JSNonFinalObject Base; > static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot; > >- static JSPromisePrototype* create(ExecState*, JSGlobalObject*, Structure*); >+ static JSPromisePrototype* create(VM&, JSGlobalObject*, Structure*); > static Structure* createStructure(VM&, JSGlobalObject*, JSValue); > > DECLARE_INFO; >@@ -44,7 +44,7 @@ class JSPromisePrototype : public JSNonFinalObject { > void finishCreation(VM&, Structure*); > > private: >- JSPromisePrototype(ExecState*, Structure*); >+ JSPromisePrototype(VM&, Structure*); > static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&); > }; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
saam
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 148118
: 259230