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 | #include "config.h" |
33 | #include "StreamInternalsBuiltins.h" |
34 | |
35 | #if ENABLE(STREAMS_API) |
36 | |
37 | #include "WebCoreJSClientData.h" |
38 | #include <JavaScriptCore/HeapInlines.h> |
39 | #include <JavaScriptCore/IdentifierInlines.h> |
40 | #include <JavaScriptCore/Intrinsic.h> |
41 | #include <JavaScriptCore/JSCJSValueInlines.h> |
42 | #include <JavaScriptCore/JSCellInlines.h> |
43 | #include <JavaScriptCore/StructureInlines.h> |
44 | #include <JavaScriptCore/VM.h> |
45 | |
46 | namespace WebCore { |
47 | |
48 | const JSC::ConstructAbility s_streamInternalsShieldingPromiseResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
49 | const int s_streamInternalsShieldingPromiseResolveCodeLength = 179; |
50 | static const JSC::Intrinsic s_streamInternalsShieldingPromiseResolveCodeIntrinsic = JSC::NoIntrinsic; |
51 | const char* const s_streamInternalsShieldingPromiseResolveCode = |
52 | "(function (result)\n" \ |
53 | "{\n" \ |
54 | " const promise = @Promise.@resolve(result);\n" \ |
55 | " if (promise.@then === @undefined)\n" \ |
56 | " promise.@then = @Promise.prototype.@then;\n" \ |
57 | " return promise;\n" \ |
58 | "})\n" \ |
59 | ; |
60 | |
61 | const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopNoCatchCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
62 | const int s_streamInternalsPromiseInvokeOrNoopNoCatchCodeLength = 219; |
63 | static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrNoopNoCatchCodeIntrinsic = JSC::NoIntrinsic; |
64 | const char* const s_streamInternalsPromiseInvokeOrNoopNoCatchCode = |
65 | "(function (object, key, args)\n" \ |
66 | "{\n" \ |
67 | " \"use strict\";\n" \ |
68 | "\n" \ |
69 | " const method = object[key];\n" \ |
70 | " if (method === @undefined)\n" \ |
71 | " return @Promise.@resolve();\n" \ |
72 | " return @shieldingPromiseResolve(method.@apply(object, args));\n" \ |
73 | "})\n" \ |
74 | ; |
75 | |
76 | const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
77 | const int s_streamInternalsPromiseInvokeOrNoopCodeLength = 199; |
78 | static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrNoopCodeIntrinsic = JSC::NoIntrinsic; |
79 | const char* const s_streamInternalsPromiseInvokeOrNoopCode = |
80 | "(function (object, key, args)\n" \ |
81 | "{\n" \ |
82 | " \"use strict\";\n" \ |
83 | "\n" \ |
84 | " try {\n" \ |
85 | " return @promiseInvokeOrNoopNoCatch(object, key, args);\n" \ |
86 | " }\n" \ |
87 | " catch(error) {\n" \ |
88 | " return @Promise.@reject(error);\n" \ |
89 | " }\n" \ |
90 | "\n" \ |
91 | "})\n" \ |
92 | ; |
93 | |
94 | const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
95 | const int s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeLength = 362; |
96 | static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeIntrinsic = JSC::NoIntrinsic; |
97 | const char* const s_streamInternalsPromiseInvokeOrFallbackOrNoopCode = |
98 | "(function (object, key1, args1, key2, args2)\n" \ |
99 | "{\n" \ |
100 | " \"use strict\";\n" \ |
101 | "\n" \ |
102 | " try {\n" \ |
103 | " const method = object[key1];\n" \ |
104 | " if (method === @undefined)\n" \ |
105 | " return @promiseInvokeOrNoopNoCatch(object, key2, args2);\n" \ |
106 | " return @shieldingPromiseResolve(method.@apply(object, args1));\n" \ |
107 | " }\n" \ |
108 | " catch(error) {\n" \ |
109 | " return @Promise.@reject(error);\n" \ |
110 | " }\n" \ |
111 | "})\n" \ |
112 | ; |
113 | |
114 | const JSC::ConstructAbility s_streamInternalsValidateAndNormalizeQueuingStrategyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
115 | const int s_streamInternalsValidateAndNormalizeQueuingStrategyCodeLength = 486; |
116 | static const JSC::Intrinsic s_streamInternalsValidateAndNormalizeQueuingStrategyCodeIntrinsic = JSC::NoIntrinsic; |
117 | const char* const s_streamInternalsValidateAndNormalizeQueuingStrategyCode = |
118 | "(function (size, highWaterMark)\n" \ |
119 | "{\n" \ |
120 | " \"use strict\";\n" \ |
121 | "\n" \ |
122 | " if (size !== @undefined && typeof size !== \"function\")\n" \ |
123 | " @throwTypeError(\"size parameter must be a function\");\n" \ |
124 | "\n" \ |
125 | " const normalizedStrategy = {\n" \ |
126 | " size: size,\n" \ |
127 | " highWaterMark: @toNumber(highWaterMark)\n" \ |
128 | " };\n" \ |
129 | "\n" \ |
130 | " if (@isNaN(normalizedStrategy.highWaterMark) || normalizedStrategy.highWaterMark < 0)\n" \ |
131 | " @throwRangeError(\"highWaterMark value is negative or not a number\");\n" \ |
132 | "\n" \ |
133 | " return normalizedStrategy;\n" \ |
134 | "})\n" \ |
135 | ; |
136 | |
137 | const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
138 | const int s_streamInternalsNewQueueCodeLength = 74; |
139 | static const JSC::Intrinsic s_streamInternalsNewQueueCodeIntrinsic = JSC::NoIntrinsic; |
140 | const char* const s_streamInternalsNewQueueCode = |
141 | "(function ()\n" \ |
142 | "{\n" \ |
143 | " \"use strict\";\n" \ |
144 | "\n" \ |
145 | " return { content: [], size: 0 };\n" \ |
146 | "})\n" \ |
147 | ; |
148 | |
149 | const JSC::ConstructAbility s_streamInternalsDequeueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
150 | const int s_streamInternalsDequeueValueCodeLength = 196; |
151 | static const JSC::Intrinsic s_streamInternalsDequeueValueCodeIntrinsic = JSC::NoIntrinsic; |
152 | const char* const s_streamInternalsDequeueValueCode = |
153 | "(function (queue)\n" \ |
154 | "{\n" \ |
155 | " \"use strict\";\n" \ |
156 | "\n" \ |
157 | " const record = queue.content.@shift();\n" \ |
158 | " queue.size -= record.size;\n" \ |
159 | " //\n" \ |
160 | " if (queue.size < 0)\n" \ |
161 | " queue.size = 0;\n" \ |
162 | " return record.value;\n" \ |
163 | "})\n" \ |
164 | ; |
165 | |
166 | const JSC::ConstructAbility s_streamInternalsEnqueueValueWithSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
167 | const int s_streamInternalsEnqueueValueWithSizeCodeLength = 257; |
168 | static const JSC::Intrinsic s_streamInternalsEnqueueValueWithSizeCodeIntrinsic = JSC::NoIntrinsic; |
169 | const char* const s_streamInternalsEnqueueValueWithSizeCode = |
170 | "(function (queue, value, size)\n" \ |
171 | "{\n" \ |
172 | " \"use strict\";\n" \ |
173 | "\n" \ |
174 | " size = @toNumber(size);\n" \ |
175 | " if (!@isFinite(size) || size < 0)\n" \ |
176 | " @throwRangeError(\"size has an incorrect value\");\n" \ |
177 | " queue.content.@push({ value: value, size: size });\n" \ |
178 | " queue.size += size;\n" \ |
179 | "})\n" \ |
180 | ; |
181 | |
182 | const JSC::ConstructAbility s_streamInternalsPeekQueueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
183 | const int s_streamInternalsPeekQueueValueCodeLength = 117; |
184 | static const JSC::Intrinsic s_streamInternalsPeekQueueValueCodeIntrinsic = JSC::NoIntrinsic; |
185 | const char* const s_streamInternalsPeekQueueValueCode = |
186 | "(function (queue)\n" \ |
187 | "{\n" \ |
188 | " \"use strict\";\n" \ |
189 | "\n" \ |
190 | " @assert(queue.content.length > 0);\n" \ |
191 | "\n" \ |
192 | " return queue.content[0].value;\n" \ |
193 | "})\n" \ |
194 | ; |
195 | |
196 | |
197 | #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ |
198 | JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ |
199 | {\ |
200 | JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \ |
201 | return clientData->builtinFunctions().streamInternalsBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().streamInternalsBuiltins().codeName##Source(), WTF::nullopt, s_##codeName##Intrinsic); \ |
202 | } |
203 | WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) |
204 | #undef DEFINE_BUILTIN_GENERATOR |
205 | |
206 | |
207 | } // namespace WebCore |
208 | |
209 | #endif // ENABLE(STREAMS_API) |
210 | |