### Begin File: JSCBuiltins.h /* * Copyright (c) 2015 Yusuke Suzuki . * * 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. * */ // DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for // builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py #ifndef JSCBuiltins_h #define JSCBuiltins_h namespace JSC { class FunctionExecutable; class VM; enum class ConstructAbility : unsigned; } namespace JSC { /* Operations.Promise */ extern const char* s_operationsPromiseIsPromiseCode; extern const int s_operationsPromiseIsPromiseCodeLength; extern const JSC::ConstructAbility s_operationsPromiseIsPromiseCodeConstructAbility; extern const char* s_operationsPromiseNewPromiseReactionCode; extern const int s_operationsPromiseNewPromiseReactionCodeLength; extern const JSC::ConstructAbility s_operationsPromiseNewPromiseReactionCodeConstructAbility; extern const char* s_operationsPromiseNewPromiseCapabilityCode; extern const int s_operationsPromiseNewPromiseCapabilityCodeLength; extern const JSC::ConstructAbility s_operationsPromiseNewPromiseCapabilityCodeConstructAbility; extern const char* s_operationsPromiseTriggerPromiseReactionsCode; extern const int s_operationsPromiseTriggerPromiseReactionsCodeLength; extern const JSC::ConstructAbility s_operationsPromiseTriggerPromiseReactionsCodeConstructAbility; extern const char* s_operationsPromiseRejectPromiseCode; extern const int s_operationsPromiseRejectPromiseCodeLength; extern const JSC::ConstructAbility s_operationsPromiseRejectPromiseCodeConstructAbility; extern const char* s_operationsPromiseFulfillPromiseCode; extern const int s_operationsPromiseFulfillPromiseCodeLength; extern const JSC::ConstructAbility s_operationsPromiseFulfillPromiseCodeConstructAbility; extern const char* s_operationsPromiseCreateResolvingFunctionsCode; extern const int s_operationsPromiseCreateResolvingFunctionsCodeLength; extern const JSC::ConstructAbility s_operationsPromiseCreateResolvingFunctionsCodeConstructAbility; extern const char* s_operationsPromisePromiseReactionJobCode; extern const int s_operationsPromisePromiseReactionJobCodeLength; extern const JSC::ConstructAbility s_operationsPromisePromiseReactionJobCodeConstructAbility; extern const char* s_operationsPromisePromiseResolveThenableJobCode; extern const int s_operationsPromisePromiseResolveThenableJobCodeLength; extern const JSC::ConstructAbility s_operationsPromisePromiseResolveThenableJobCodeConstructAbility; extern const char* s_operationsPromiseInitializePromiseCode; extern const int s_operationsPromiseInitializePromiseCodeLength; extern const JSC::ConstructAbility s_operationsPromiseInitializePromiseCodeConstructAbility; #define JSC_FOREACH_OPERATIONSPROMISE_BUILTIN_DATA(macro) \ macro(isPromise, operationsPromiseIsPromise, 1) \ macro(newPromiseReaction, operationsPromiseNewPromiseReaction, 2) \ macro(newPromiseCapability, operationsPromiseNewPromiseCapability, 1) \ macro(triggerPromiseReactions, operationsPromiseTriggerPromiseReactions, 2) \ macro(rejectPromise, operationsPromiseRejectPromise, 2) \ macro(fulfillPromise, operationsPromiseFulfillPromise, 2) \ macro(createResolvingFunctions, operationsPromiseCreateResolvingFunctions, 1) \ macro(promiseReactionJob, operationsPromisePromiseReactionJob, 2) \ macro(promiseResolveThenableJob, operationsPromisePromiseResolveThenableJob, 3) \ macro(initializePromise, operationsPromiseInitializePromise, 1) \ #define JSC_BUILTIN_OPERATIONSPROMISE_ISPROMISE 1 #define JSC_BUILTIN_OPERATIONSPROMISE_NEWPROMISEREACTION 1 #define JSC_BUILTIN_OPERATIONSPROMISE_NEWPROMISECAPABILITY 1 #define JSC_BUILTIN_OPERATIONSPROMISE_TRIGGERPROMISEREACTIONS 1 #define JSC_BUILTIN_OPERATIONSPROMISE_REJECTPROMISE 1 #define JSC_BUILTIN_OPERATIONSPROMISE_FULFILLPROMISE 1 #define JSC_BUILTIN_OPERATIONSPROMISE_CREATERESOLVINGFUNCTIONS 1 #define JSC_BUILTIN_OPERATIONSPROMISE_PROMISEREACTIONJOB 1 #define JSC_BUILTIN_OPERATIONSPROMISE_PROMISERESOLVETHENABLEJOB 1 #define JSC_BUILTIN_OPERATIONSPROMISE_INITIALIZEPROMISE 1 #define JSC_FOREACH_BUILTIN_CODE(macro) \ macro(operationsPromiseIsPromiseCode, isPromise, s_operationsPromiseIsPromiseCodeLength) \ macro(operationsPromiseNewPromiseReactionCode, newPromiseReaction, s_operationsPromiseNewPromiseReactionCodeLength) \ macro(operationsPromiseNewPromiseCapabilityCode, newPromiseCapability, s_operationsPromiseNewPromiseCapabilityCodeLength) \ macro(operationsPromiseTriggerPromiseReactionsCode, triggerPromiseReactions, s_operationsPromiseTriggerPromiseReactionsCodeLength) \ macro(operationsPromiseRejectPromiseCode, rejectPromise, s_operationsPromiseRejectPromiseCodeLength) \ macro(operationsPromiseFulfillPromiseCode, fulfillPromise, s_operationsPromiseFulfillPromiseCodeLength) \ macro(operationsPromiseCreateResolvingFunctionsCode, createResolvingFunctions, s_operationsPromiseCreateResolvingFunctionsCodeLength) \ macro(operationsPromisePromiseReactionJobCode, promiseReactionJob, s_operationsPromisePromiseReactionJobCodeLength) \ macro(operationsPromisePromiseResolveThenableJobCode, promiseResolveThenableJob, s_operationsPromisePromiseResolveThenableJobCodeLength) \ macro(operationsPromiseInitializePromiseCode, initializePromise, s_operationsPromiseInitializePromiseCodeLength) \ #define JSC_FOREACH_BUILTIN_FUNCTION_NAME(macro) \ macro(createResolvingFunctions) \ macro(fulfillPromise) \ macro(initializePromise) \ macro(isPromise) \ macro(newPromiseCapability) \ macro(newPromiseReaction) \ macro(promiseReactionJob) \ macro(promiseResolveThenableJob) \ macro(rejectPromise) \ macro(triggerPromiseReactions) \ #define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM&); JSC_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) #undef DECLARE_BUILTIN_GENERATOR #define JSC_BUILTIN_EXISTS(object, func) defined JSC_BUILTIN_ ## object ## _ ## func } // namespace JSC #endif // JSCBuiltins_h ### End File: JSCBuiltins.h ### Begin File: JSCBuiltins.cpp /* * Copyright (c) 2015 Yusuke Suzuki . * * 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. * */ // DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for // builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py #include "config.h" #include "JSCBuiltins.h" #include "BuiltinExecutables.h" #include "Executable.h" #include "JSCellInlines.h" #include "VM.h" namespace JSC { const JSC::ConstructAbility s_operationsPromiseIsPromiseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const int s_operationsPromiseIsPromiseCodeLength = 158; const char* s_operationsPromiseIsPromiseCode = "(function (promise)\n" \ "{\n" \ " \"use strict\";\n" \ "\n" \ " return @isObject(promise) && !!promise.@promiseState;\n" \ "})\n" \ ; const JSC::ConstructAbility s_operationsPromiseNewPromiseReactionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const int s_operationsPromiseNewPromiseReactionCodeLength = 220; const char* s_operationsPromiseNewPromiseReactionCode = "(function (capability, handler)\n" \ "{\n" \ " \"use strict\";\n" \ "\n" \ " return {\n" \ " @capabilities: capability,\n" \ " @handler: handler\n" \ " };\n" \ "})\n" \ ; const JSC::ConstructAbility s_operationsPromiseNewPromiseCapabilityCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const int s_operationsPromiseNewPromiseCapabilityCodeLength = 1427; const char* s_operationsPromiseNewPromiseCapabilityCode = "(function (constructor)\n" \ "{\n" \ " \"use strict\";\n" \ "\n" \ " //\n" \ " if (typeof constructor !== \"function\")\n" \ " throw new @TypeError(\"promise capability requires a constructor function\");\n" \ "\n" \ " var promiseCapability = {\n" \ " @promise: undefined,\n" \ " @resolve: undefined,\n" \ " @reject: undefined\n" \ " };\n" \ "\n" \ " function executor(resolve, reject)\n" \ " {\n" \ " if (promiseCapability.@resolve !== undefined)\n" \ " throw new @TypeError(\"resolve function is already set\");\n" \ " if (promiseCapability.@reject !== undefined)\n" \ " throw new @TypeError(\"reject function is already set\");\n" \ "\n" \ " promiseCapability.@resolve = resolve;\n" \ " promiseCapability.@reject = reject;\n" \ " }\n" \ "\n" \ " var promise = new constructor(executor);\n" \ "\n" \ " if (typeof promiseCapability.@resolve !== \"function\")\n" \ " throw new @TypeError(\"executor did not take a resolve function\");\n" \ "\n" \ " if (typeof promiseCapability.@reject !== \"function\")\n" \ " throw new @TypeError(\"executor did not take a reject function\");\n" \ "\n" \ " promiseCapability.@promise = promise;\n" \ "\n" \ " return promiseCapability;\n" \ "})\n" \ ; const JSC::ConstructAbility s_operationsPromiseTriggerPromiseReactionsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const int s_operationsPromiseTriggerPromiseReactionsCodeLength = 269; const char* s_operationsPromiseTriggerPromiseReactionsCode = "(function (reactions, argument)\n" \ "{\n" \ " \"use strict\";\n" \ "\n" \ " for (var index = 0, length = reactions.length; index < length; ++index)\n" \ " @enqueueJob(@promiseReactionJob, [reactions[index], argument]);\n" \ "})\n" \ ; const JSC::ConstructAbility s_operationsPromiseRejectPromiseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const int s_operationsPromiseRejectPromiseCodeLength = 541; const char* s_operationsPromiseRejectPromiseCode = "(function (promise, reason)\n" \ "{\n" \ " \"use strict\";\n" \ "\n" \ " var reactions = promise.@promiseRejectReactions;\n" \ " promise.@promiseResult = reason;\n" \ " promise.@promiseFulfillReactions = undefined;\n" \ " promise.@promiseRejectReactions = undefined;\n" \ " promise.@promiseState = @promiseRejected;\n" \ "\n" \ " @InspectorInstrumentation.promiseRejected(promise, reason, reactions);\n" \ "\n" \ " @triggerPromiseReactions(reactions, reason);\n" \ "})\n" \ ; const JSC::ConstructAbility s_operationsPromiseFulfillPromiseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const int s_operationsPromiseFulfillPromiseCodeLength = 540; const char* s_operationsPromiseFulfillPromiseCode = "(function (promise, value)\n" \ "{\n" \ " \"use strict\";\n" \ "\n" \ " var reactions = promise.@promiseFulfillReactions;\n" \ " promise.@promiseResult = value;\n" \ " promise.@promiseFulfillReactions = undefined;\n" \ " promise.@promiseRejectReactions = undefined;\n" \ " promise.@promiseState = @promiseFulfilled;\n" \ "\n" \ " @InspectorInstrumentation.promiseFulfilled(promise, value, reactions);\n" \ "\n" \ " @triggerPromiseReactions(reactions, value);\n" \ "})\n" \ ; const JSC::ConstructAbility s_operationsPromiseCreateResolvingFunctionsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const int s_operationsPromiseCreateResolvingFunctionsCodeLength = 1468; const char* s_operationsPromiseCreateResolvingFunctionsCode = "(function (promise)\n" \ "{\n" \ " \"use strict\";\n" \ "\n" \ " var alreadyResolved = false;\n" \ "\n" \ " var resolve = function (resolution) {\n" \ " if (alreadyResolved)\n" \ " return undefined;\n" \ " alreadyResolved = true;\n" \ "\n" \ " if (resolution === promise)\n" \ " return @rejectPromise(promise, new @TypeError(\"Resolve a promise with itself\"));\n" \ "\n" \ " if (!@isObject(resolution))\n" \ " return @fulfillPromise(promise, resolution);\n" \ "\n" \ " var then;\n" \ " try {\n" \ " then = resolution.then;\n" \ " } catch (error) {\n" \ " return @rejectPromise(promise, error);\n" \ " }\n" \ "\n" \ " if (typeof then !== 'function')\n" \ " return @fulfillPromise(promise, resolution);\n" \ "\n" \ " @enqueueJob(@promiseResolveThenableJob, [promise, resolution, then]);\n" \ "\n" \ " return undefined;\n" \ " };\n" \ "\n" \ " var reject = function (reason) {\n" \ " if (alreadyResolved)\n" \ " return undefined;\n" \ " alreadyResolved = true;\n" \ "\n" \ " return @rejectPromise(promise, reason);\n" \ " };\n" \ "\n" \ " return {\n" \ " @resolve: resolve,\n" \ " @reject: reject\n" \ " };\n" \ "})\n" \ ; const JSC::ConstructAbility s_operationsPromisePromiseReactionJobCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const int s_operationsPromisePromiseReactionJobCodeLength = 493; const char* s_operationsPromisePromiseReactionJobCode = "(function (reaction, argument)\n" \ "{\n" \ " \"use strict\";\n" \ "\n" \ " var promiseCapability = reaction.@capabilities;\n" \ "\n" \ " var result;\n" \ " try {\n" \ " result = reaction.@handler.@call(undefined, argument);\n" \ " } catch (error) {\n" \ " return promiseCapability.@reject.@call(undefined, error);\n" \ " }\n" \ "\n" \ " return promiseCapability.@resolve.@call(undefined, result);\n" \ "})\n" \ ; const JSC::ConstructAbility s_operationsPromisePromiseResolveThenableJobCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const int s_operationsPromisePromiseResolveThenableJobCodeLength = 453; const char* s_operationsPromisePromiseResolveThenableJobCode = "(function (promiseToResolve, thenable, then)\n" \ "{\n" \ " \"use strict\";\n" \ "\n" \ " var resolvingFunctions = @createResolvingFunctions(promiseToResolve);\n" \ "\n" \ " try {\n" \ " return then.@call(thenable, resolvingFunctions.@resolve, resolvingFunctions.@reject);\n" \ " } catch (error) {\n" \ " return resolvingFunctions.@reject.@call(undefined, error);\n" \ " }\n" \ "})\n" \ ; const JSC::ConstructAbility s_operationsPromiseInitializePromiseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const int s_operationsPromiseInitializePromiseCodeLength = 731; const char* s_operationsPromiseInitializePromiseCode = "(function (executor)\n" \ "{\n" \ " \"use strict\";\n" \ "\n" \ " if (typeof executor !== 'function')\n" \ " throw new @TypeError(\"Promise constructor takes a function argument\");\n" \ "\n" \ " this.@promiseState = @promisePending;\n" \ " this.@promiseFulfillReactions = [];\n" \ " this.@promiseRejectReactions = [];\n" \ "\n" \ " var resolvingFunctions = @createResolvingFunctions(this);\n" \ " try {\n" \ " executor(resolvingFunctions.@resolve, resolvingFunctions.@reject);\n" \ " } catch (error) {\n" \ " return resolvingFunctions.@reject.@call(undefined, error);\n" \ " }\n" \ "\n" \ " return this;\n" \ "})\n" \ ; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ {\ return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source()); } JSC_FOREACH_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) #undef DEFINE_BUILTIN_GENERATOR } // namespace JSC ### End File: JSCBuiltins.cpp