1 | /* |
2 | * Copyright (c) 2015 Canon Inc. |
3 | * Copyright (c) 2015 Igalia. |
4 | * Copyright (c) 2016 Apple Inc. All rights reserved. |
5 | * |
6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions |
8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
14 | * |
15 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
17 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
19 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | * THE POSSIBILITY OF SUCH DAMAGE. |
26 | * |
27 | */ |
28 | |
29 | // DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for |
30 | // builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py |
31 | |
32 | #pragma once |
33 | |
34 | #if ENABLE(STREAMS_API) |
35 | |
36 | #include <JavaScriptCore/BuiltinUtils.h> |
37 | #include <JavaScriptCore/Identifier.h> |
38 | #include <JavaScriptCore/JSFunction.h> |
39 | #include <JavaScriptCore/UnlinkedFunctionExecutable.h> |
40 | |
41 | namespace JSC { |
42 | class FunctionExecutable; |
43 | } |
44 | |
45 | namespace WebCore { |
46 | |
47 | /* StreamInternals */ |
48 | extern const char* const s_streamInternalsShieldingPromiseResolveCode; |
49 | extern const int s_streamInternalsShieldingPromiseResolveCodeLength; |
50 | extern const JSC::ConstructAbility s_streamInternalsShieldingPromiseResolveCodeConstructAbility; |
51 | extern const char* const s_streamInternalsPromiseInvokeOrNoopNoCatchCode; |
52 | extern const int s_streamInternalsPromiseInvokeOrNoopNoCatchCodeLength; |
53 | extern const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopNoCatchCodeConstructAbility; |
54 | extern const char* const s_streamInternalsPromiseInvokeOrNoopCode; |
55 | extern const int s_streamInternalsPromiseInvokeOrNoopCodeLength; |
56 | extern const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopCodeConstructAbility; |
57 | extern const char* const s_streamInternalsPromiseInvokeOrFallbackOrNoopCode; |
58 | extern const int s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeLength; |
59 | extern const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeConstructAbility; |
60 | extern const char* const s_streamInternalsValidateAndNormalizeQueuingStrategyCode; |
61 | extern const int s_streamInternalsValidateAndNormalizeQueuingStrategyCodeLength; |
62 | extern const JSC::ConstructAbility s_streamInternalsValidateAndNormalizeQueuingStrategyCodeConstructAbility; |
63 | extern const char* const s_streamInternalsNewQueueCode; |
64 | extern const int s_streamInternalsNewQueueCodeLength; |
65 | extern const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility; |
66 | extern const char* const s_streamInternalsDequeueValueCode; |
67 | extern const int s_streamInternalsDequeueValueCodeLength; |
68 | extern const JSC::ConstructAbility s_streamInternalsDequeueValueCodeConstructAbility; |
69 | extern const char* const s_streamInternalsEnqueueValueWithSizeCode; |
70 | extern const int s_streamInternalsEnqueueValueWithSizeCodeLength; |
71 | extern const JSC::ConstructAbility s_streamInternalsEnqueueValueWithSizeCodeConstructAbility; |
72 | extern const char* const s_streamInternalsPeekQueueValueCode; |
73 | extern const int s_streamInternalsPeekQueueValueCodeLength; |
74 | extern const JSC::ConstructAbility s_streamInternalsPeekQueueValueCodeConstructAbility; |
75 | |
76 | #define WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_DATA(macro) \ |
77 | macro(shieldingPromiseResolve, streamInternalsShieldingPromiseResolve, 1) \ |
78 | macro(promiseInvokeOrNoopNoCatch, streamInternalsPromiseInvokeOrNoopNoCatch, 3) \ |
79 | macro(promiseInvokeOrNoop, streamInternalsPromiseInvokeOrNoop, 3) \ |
80 | macro(promiseInvokeOrFallbackOrNoop, streamInternalsPromiseInvokeOrFallbackOrNoop, 5) \ |
81 | macro(validateAndNormalizeQueuingStrategy, streamInternalsValidateAndNormalizeQueuingStrategy, 2) \ |
82 | macro(newQueue, streamInternalsNewQueue, 0) \ |
83 | macro(dequeueValue, streamInternalsDequeueValue, 1) \ |
84 | macro(enqueueValueWithSize, streamInternalsEnqueueValueWithSize, 3) \ |
85 | macro(peekQueueValue, streamInternalsPeekQueueValue, 1) \ |
86 | |
87 | #define WEBCORE_BUILTIN_STREAMINTERNALS_SHIELDINGPROMISERESOLVE 1 |
88 | #define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORNOOPNOCATCH 1 |
89 | #define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORNOOP 1 |
90 | #define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORFALLBACKORNOOP 1 |
91 | #define WEBCORE_BUILTIN_STREAMINTERNALS_VALIDATEANDNORMALIZEQUEUINGSTRATEGY 1 |
92 | #define WEBCORE_BUILTIN_STREAMINTERNALS_NEWQUEUE 1 |
93 | #define WEBCORE_BUILTIN_STREAMINTERNALS_DEQUEUEVALUE 1 |
94 | #define WEBCORE_BUILTIN_STREAMINTERNALS_ENQUEUEVALUEWITHSIZE 1 |
95 | #define WEBCORE_BUILTIN_STREAMINTERNALS_PEEKQUEUEVALUE 1 |
96 | |
97 | #define WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(macro) \ |
98 | macro(streamInternalsShieldingPromiseResolveCode, shieldingPromiseResolve, static_cast<const char*>(nullptr), s_streamInternalsShieldingPromiseResolveCodeLength) \ |
99 | macro(streamInternalsPromiseInvokeOrNoopNoCatchCode, promiseInvokeOrNoopNoCatch, static_cast<const char*>(nullptr), s_streamInternalsPromiseInvokeOrNoopNoCatchCodeLength) \ |
100 | macro(streamInternalsPromiseInvokeOrNoopCode, promiseInvokeOrNoop, static_cast<const char*>(nullptr), s_streamInternalsPromiseInvokeOrNoopCodeLength) \ |
101 | macro(streamInternalsPromiseInvokeOrFallbackOrNoopCode, promiseInvokeOrFallbackOrNoop, static_cast<const char*>(nullptr), s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeLength) \ |
102 | macro(streamInternalsValidateAndNormalizeQueuingStrategyCode, validateAndNormalizeQueuingStrategy, static_cast<const char*>(nullptr), s_streamInternalsValidateAndNormalizeQueuingStrategyCodeLength) \ |
103 | macro(streamInternalsNewQueueCode, newQueue, static_cast<const char*>(nullptr), s_streamInternalsNewQueueCodeLength) \ |
104 | macro(streamInternalsDequeueValueCode, dequeueValue, static_cast<const char*>(nullptr), s_streamInternalsDequeueValueCodeLength) \ |
105 | macro(streamInternalsEnqueueValueWithSizeCode, enqueueValueWithSize, static_cast<const char*>(nullptr), s_streamInternalsEnqueueValueWithSizeCodeLength) \ |
106 | macro(streamInternalsPeekQueueValueCode, peekQueueValue, static_cast<const char*>(nullptr), s_streamInternalsPeekQueueValueCodeLength) \ |
107 | |
108 | #define WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(macro) \ |
109 | macro(dequeueValue) \ |
110 | macro(enqueueValueWithSize) \ |
111 | macro(newQueue) \ |
112 | macro(peekQueueValue) \ |
113 | macro(promiseInvokeOrFallbackOrNoop) \ |
114 | macro(promiseInvokeOrNoop) \ |
115 | macro(promiseInvokeOrNoopNoCatch) \ |
116 | macro(shieldingPromiseResolve) \ |
117 | macro(validateAndNormalizeQueuingStrategy) \ |
118 | |
119 | #define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ |
120 | JSC::FunctionExecutable* codeName##Generator(JSC::VM&); |
121 | |
122 | WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) |
123 | #undef DECLARE_BUILTIN_GENERATOR |
124 | |
125 | class StreamInternalsBuiltinsWrapper : private JSC::WeakHandleOwner { |
126 | public: |
127 | explicit StreamInternalsBuiltinsWrapper(JSC::VM* vm) |
128 | : m_vm(*vm) |
129 | WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES) |
130 | #define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { })) |
131 | WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS) |
132 | #undef INITIALIZE_BUILTIN_SOURCE_MEMBERS |
133 | { |
134 | } |
135 | |
136 | #define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ |
137 | JSC::UnlinkedFunctionExecutable* name##Executable(); \ |
138 | const JSC::SourceCode& name##Source() const { return m_##name##Source; } |
139 | WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) |
140 | #undef EXPOSE_BUILTIN_EXECUTABLES |
141 | |
142 | WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) |
143 | |
144 | void exportNames(); |
145 | |
146 | private: |
147 | JSC::VM& m_vm; |
148 | |
149 | WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES) |
150 | |
151 | #define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \ |
152 | JSC::SourceCode m_##name##Source;\ |
153 | JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable; |
154 | WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) |
155 | #undef DECLARE_BUILTIN_SOURCE_MEMBERS |
156 | |
157 | }; |
158 | |
159 | #define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ |
160 | inline JSC::UnlinkedFunctionExecutable* StreamInternalsBuiltinsWrapper::name##Executable() \ |
161 | {\ |
162 | if (!m_##name##Executable) {\ |
163 | JSC::Identifier executableName = functionName##PublicName();\ |
164 | if (overriddenName)\ |
165 | executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\ |
166 | m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\ |
167 | }\ |
168 | return m_##name##Executable.get();\ |
169 | } |
170 | WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) |
171 | #undef DEFINE_BUILTIN_EXECUTABLES |
172 | |
173 | inline void StreamInternalsBuiltinsWrapper::exportNames() |
174 | { |
175 | #define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); |
176 | WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) |
177 | #undef EXPORT_FUNCTION_NAME |
178 | } |
179 | |
180 | class StreamInternalsBuiltinFunctions { |
181 | public: |
182 | explicit StreamInternalsBuiltinFunctions(JSC::VM& vm) : m_vm(vm) { } |
183 | |
184 | void init(JSC::JSGlobalObject&); |
185 | void visit(JSC::SlotVisitor&); |
186 | |
187 | public: |
188 | JSC::VM& m_vm; |
189 | |
190 | #define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \ |
191 | JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function; |
192 | WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS) |
193 | #undef DECLARE_BUILTIN_SOURCE_MEMBERS |
194 | }; |
195 | |
196 | inline void StreamInternalsBuiltinFunctions::init(JSC::JSGlobalObject& globalObject) |
197 | { |
198 | #define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\ |
199 | m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject)); |
200 | WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(EXPORT_FUNCTION) |
201 | #undef EXPORT_FUNCTION |
202 | } |
203 | |
204 | inline void StreamInternalsBuiltinFunctions::visit(JSC::SlotVisitor& visitor) |
205 | { |
206 | #define VISIT_FUNCTION(name) visitor.append(m_##name##Function); |
207 | WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION) |
208 | #undef VISIT_FUNCTION |
209 | } |
210 | |
211 | |
212 | } // namespace WebCore |
213 | |
214 | #endif // ENABLE(STREAMS_API) |
215 | |