1 ### Begin File: GuardedBuiltinBuiltins.h
3 * Copyright (c) 2015 Canon Inc. All rights reserved.
4 * Copyright (c) 2016 Apple Inc. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
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.
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
34 #if ENABLE(STREAMS_API)
36 #include <builtins/BuiltinUtils.h>
37 #include <bytecode/UnlinkedFunctionExecutable.h>
38 #include <runtime/Identifier.h>
39 #include <runtime/JSFunction.h>
42 class FunctionExecutable;
48 extern const char* s_guardedBuiltinIsReadableStreamLockedCode;
49 extern const int s_guardedBuiltinIsReadableStreamLockedCodeLength;
50 extern const JSC::ConstructAbility s_guardedBuiltinIsReadableStreamLockedCodeConstructAbility;
52 #define WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_DATA(macro) \
53 macro(isReadableStreamLocked, guardedBuiltinIsReadableStreamLocked, 1) \
55 #define WEBCORE_BUILTIN_GUARDEDBUILTIN_ISREADABLESTREAMLOCKED 1
57 #define WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_CODE(macro) \
58 macro(guardedBuiltinIsReadableStreamLockedCode, isReadableStreamLocked, s_guardedBuiltinIsReadableStreamLockedCodeLength) \
60 #define WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_FUNCTION_NAME(macro) \
61 macro(isReadableStreamLocked) \
63 #define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
64 JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
66 WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
67 #undef DECLARE_BUILTIN_GENERATOR
69 class GuardedBuiltinBuiltinsWrapper : private JSC::WeakHandleOwner {
71 explicit GuardedBuiltinBuiltinsWrapper(JSC::VM* vm)
73 WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
74 #define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
75 WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
76 #undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
80 #define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, length) \
81 JSC::UnlinkedFunctionExecutable* name##Executable(); \
82 const JSC::SourceCode& name##Source() const { return m_##name##Source; }
83 WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
84 #undef EXPOSE_BUILTIN_EXECUTABLES
86 WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
93 WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
95 #define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) \
96 JSC::SourceCode m_##name##Source;\
97 JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
98 WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
99 #undef DECLARE_BUILTIN_SOURCE_MEMBERS
103 #define DEFINE_BUILTIN_EXECUTABLES(name, functionName, length) \
104 inline JSC::UnlinkedFunctionExecutable* GuardedBuiltinBuiltinsWrapper::name##Executable() \
106 if (!m_##name##Executable)\
107 m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, functionName##PublicName(), s_##name##ConstructAbility), this, &m_##name##Executable);\
108 return m_##name##Executable.get();\
110 WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
111 #undef DEFINE_BUILTIN_EXECUTABLES
113 inline void GuardedBuiltinBuiltinsWrapper::exportNames()
115 #define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
116 WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
117 #undef EXPORT_FUNCTION_NAME
120 } // namespace WebCore
122 #endif // ENABLE(STREAMS_API)
123 ### End File: GuardedBuiltinBuiltins.h
125 ### Begin File: GuardedBuiltinBuiltins.cpp
127 * Copyright (c) 2015 Canon Inc. All rights reserved.
128 * Copyright (c) 2016 Apple Inc. All rights reserved.
130 * Redistribution and use in source and binary forms, with or without
131 * modification, are permitted provided that the following conditions
133 * 1. Redistributions of source code must retain the above copyright
134 * notice, this list of conditions and the following disclaimer.
135 * 2. Redistributions in binary form must reproduce the above copyright
136 * notice, this list of conditions and the following disclaimer in the
137 * documentation and/or other materials provided with the distribution.
139 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
140 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
141 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
142 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
143 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
144 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
145 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
146 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
147 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
148 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
149 * THE POSSIBILITY OF SUCH DAMAGE.
153 // DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
154 // builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
157 #include "GuardedBuiltinBuiltins.h"
159 #if ENABLE(STREAMS_API)
161 #include "WebCoreJSClientData.h"
162 #include <heap/HeapInlines.h>
163 #include <runtime/Intrinsic.h>
164 #include <runtime/JSCJSValueInlines.h>
165 #include <runtime/JSCellInlines.h>
166 #include <runtime/StructureInlines.h>
167 #include <runtime/VM.h>
171 const JSC::ConstructAbility s_guardedBuiltinIsReadableStreamLockedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
172 const int s_guardedBuiltinIsReadableStreamLockedCodeLength = 70;
173 static const JSC::Intrinsic s_guardedBuiltinIsReadableStreamLockedCodeIntrinsic = JSC::NoIntrinsic;
174 const char* s_guardedBuiltinIsReadableStreamLockedCode =
175 "(function (stream)\n" \
177 " \"use strict\";\n" \
178 " return !!stream.@reader;\n" \
183 #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
184 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
186 JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
187 return clientData->builtinFunctions().guardedBuiltinBuiltins().codeName##Executable()->link(vm, clientData->builtinFunctions().guardedBuiltinBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
189 WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
190 #undef DEFINE_BUILTIN_GENERATOR
193 } // namespace WebCore
195 #endif // ENABLE(STREAMS_API)
197 ### End File: GuardedBuiltinBuiltins.cpp