Bug Summary

File:Source/JavaScriptCore/wasm/WasmConstExprGenerator.cpp
Warning:line 738, column 5
Member variable 'm_info' in 'JSC::Wasm::ConstExprGenerator' is a reference to ref-countable type 'JSC::Wasm::ModuleInformation'; member variables must be Ref, RefPtr, WeakRef, or WeakPtr

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple arm64-apple-ios26.2.0-simulator -O3 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name UnifiedSource151.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=osx -analyzer-checker=security.insecureAPI.decodeValueOfObjCType -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -target-sdk-version=26.2 -fdepfile-entry=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/SDKSettings.json -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -fno-modulemap-allow-subdirectory-search -fdefine-target-os-macros -enable-tlsdesc -target-cpu apple-m1 -target-feature +v8.4a -target-feature +aes -target-feature +altnzcv -target-feature +ccdp -target-feature +ccpp -target-feature +complxnum -target-feature +crc -target-feature +dotprod -target-feature +flagm -target-feature +fp-armv8 -target-feature +fp16fml -target-feature +fptoint -target-feature +fullfp16 -target-feature +jsconv -target-feature +lse -target-feature +neon -target-feature +pauth -target-feature +perfmon -target-feature +predres -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +sb -target-feature +sha2 -target-feature +sha3 -target-feature +specrestrict -target-feature +ssbs -target-abi darwinpcs -debug-info-kind=standalone -dwarf-version=5 -debugger-tuning=lldb -fdebug-compilation-dir=/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/JavaScriptCore -target-linker-version 1230.1 -fcoverage-compilation-dir=/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/JavaScriptCore -resource-dir /Users/buildbot/Library/Developer/Toolchains/swift-webkit.xctoolchain/usr/lib/clang/21 -dependency-file /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/scan-build-output/StaticAnalyzer/JavaScriptCore/libJavaScriptCore/normal/arm64/UnifiedSource151.d -skip-unused-modulemap-deps -MT dependencies -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk -iquote /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/JavaScriptCore.build/Release-iphonesimulator/libJavaScriptCore.build/JavaScriptCore-generated-files.hmap -iquote /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/JavaScriptCore.build/Release-iphonesimulator/libJavaScriptCore.build/JavaScriptCore-project-headers.hmap -isystem /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitLibraries/SDKs/iphonesimulator26.0-additions.sdk/usr/local/include -isystem /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/SDKAdditions/usr/include -iframework /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/SDKAdditions/System/Library/Frameworks --system-header-prefix=unicode/ -isystem /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitLibraries/SDKs/iphonesimulator26.0-additions.sdk/usr/local/include -include-pch /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/PrecompiledHeaders/SharedPrecompiledHeaders/8310809495935473269/JavaScriptCorePrefix.h.gch -D _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D NDEBUG -D ENABLE_JSC_RESTRICTED_OPTIONS_BY_DEFAULT=1 -D PAS_BMALLOC_HIDDEN -D __clang_analyzer__ -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/JavaScriptCore.build/Release-iphonesimulator/libJavaScriptCore.build/JavaScriptCore-own-target-headers.hmap -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/JavaScriptCore.build/Release-iphonesimulator/libJavaScriptCore.build/JavaScriptCore-all-target-headers.hmap -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/include -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/DerivedSources/JavaScriptCore -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/JavaScriptCore -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/JavaScriptCore.build/Release-iphonesimulator/libJavaScriptCore.build/DerivedSources-normal/arm64 -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/JavaScriptCore.build/Release-iphonesimulator/libJavaScriptCore.build/DerivedSources/arm64 -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/JavaScriptCore.build/Release-iphonesimulator/libJavaScriptCore.build/DerivedSources -F/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator -D __STDC_WANT_LIB_EXT1__=1 -I/usr/local/include -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include -internal-isystem /Users/buildbot/Library/Developer/Toolchains/swift-webkit.xctoolchain/usr/lib/clang/21/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/include -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/System/Library/Frameworks -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/System/Library/SubFrameworks -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/Library/Frameworks -Wno-trigraphs -Werror -Wno-missing-field-initializers -Wmissing-prototypes -Wdocumentation -Wunreachable-code -Wnon-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wsign-compare -Wno-shorten-64-to-32 -Wnewline-eof -Wno-c++11-extensions -Wno-implicit-fallthrough -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wall -Wc99-designator -Wconditional-uninitialized -Wextra -Wdeprecated-enum-enum-conversion -Wdeprecated-enum-float-conversion -Wenum-float-conversion -Wfinal-dtor-non-final-class -Wformat=2 -Wmisleading-indentation -Wpointer-to-int-cast -Wreorder-init-list -Wundef -Wunused-but-set-variable -Wvla -Werror=unguarded-availability -Wno-elaborated-enum-base -Wcast-qual -Wchar-subscripts -Wextra-tokens -Winit-self -Wmissing-noreturn -Wpacked -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wexit-time-destructors -Wglobal-constructors -Wtautological-compare -Wimplicit-fallthrough -Wvla -Wliteral-conversion -Wthread-safety -Wno-profile-instr-out-of-date -Wno-profile-instr-unprofiled -Wno-backend-plugin -Wunsafe-buffer-usage -Wno-unknown-warning-option -std=c++2b -fdeprecated-macro -ferror-limit 19 -fmacro-backtrace-limit=0 -fvisibility=hidden -fvisibility-inlines-hidden -stack-protector 1 -fblocks -fencode-extended-block-signature -fno-rtti -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-threadsafe-statics -fno-implicit-modules -fskip-odr-check-in-gmf -fpascal-strings -fmax-type-align=16 -fdiagnostics-show-note-include-stack -vectorize-loops -analyzer-output=html -analyzer-config report-in-main-source-file=true -analyzer-config nullability:NoDiagnoseCallsToSystemHeaders=true -analyzer-checker optin.osx.cocoa.localizability.NonLocalizedStringChecker -analyzer-checker security.insecureAPI.UncheckedReturn -analyzer-checker security.insecureAPI.getpw -analyzer-checker security.insecureAPI.gets -analyzer-checker security.insecureAPI.mkstemp -analyzer-checker security.insecureAPI.mktemp -analyzer-disable-checker security.insecureAPI.rand -analyzer-disable-checker security.insecureAPI.strcpy -analyzer-checker security.insecureAPI.vfork -analyzer-disable-checker alpha,apiModeling,core,cplusplus,deadcode,debug,fuchsia,nullability,optin,osx,security,unix,webkit -analyzer-checker alpha.webkit.ForwardDeclChecker,alpha.webkit.MemoryUnsafeCastChecker,alpha.webkit.NoDeleteChecker,alpha.webkit.NoUncheckedPtrMemberChecker,alpha.webkit.NoUnretainedMemberChecker,alpha.webkit.RetainPtrCtorAdoptChecker,alpha.webkit.UncheckedCallArgsChecker,alpha.webkit.UncheckedLocalVarsChecker,alpha.webkit.UncountedCallArgsChecker,alpha.webkit.UncountedLocalVarsChecker,alpha.webkit.UnretainedCallArgsChecker,alpha.webkit.UnretainedLambdaCapturesChecker,alpha.webkit.UnretainedLocalVarsChecker,webkit.NoUncountedMemberChecker,webkit.RefCntblBaseVirtualDtor,webkit.UncountedLambdaCapturesChecker -analyzer-config max-nodes=10000000 -analyzer-config verbose-report-filename=true -fdwarf2-cfi-asm -o /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/scan-build-output/StaticAnalyzer/JavaScriptCore/libJavaScriptCore/normal/arm64/UnifiedSource151.plist -x c++ /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/DerivedSources/JavaScriptCore/unified-sources/UnifiedSource151.cpp
1/*
2 * Copyright (C) 2023 Igalia S.L. All rights reserved.
3 * Copyright (C) 2025 Apple Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "config.h"
28#include "WasmConstExprGenerator.h"
29
30#if ENABLE(WEBASSEMBLY)(defined 1 && 1)
31
32#include "JSCJSValueInlines.h"
33#include "JSWebAssemblyArray.h"
34#include "JSWebAssemblyInstance.h"
35#include "JSWebAssemblyStruct.h"
36#include "WasmFunctionParser.h"
37#include "WasmModuleInformation.h"
38#include "WasmOperationsInlines.h"
39#include "WasmParser.h"
40#include "WasmTypeDefinition.h"
41#include <wtf/Assertions.h>
42#include <wtf/Expected.h>
43#include <wtf/text/MakeString.h>
44
45namespace JSC { namespace Wasm {
46
47class ConstExprGenerator {
48public:
49 using ErrorType = String;
50 using PartialResult = Expected<void, ErrorType>;
51 using UnexpectedResult = std::unexpected<ErrorType>;
52 using CallType = CallLinkInfo::CallType;
53
54 enum InvalidTag { InvalidConstExpr };
55
56 // Represents values that a constant expression may evaluate to.
57 // If a constant expression allocates an object, it should be put in a Strong handle.
58 struct ConstExprValue {
59 enum ConstExprValueType : uint8_t {
60 Invalid,
61 Numeric,
62 Vector,
63 Ref,
64 };
65
66 ConstExprValue(InvalidTag)
67 : m_type(ConstExprValueType::Invalid)
68 , m_bits(0)
69 { }
70
71 ConstExprValue()
72 : m_type(ConstExprValueType::Numeric)
73 , m_bits(0)
74 { }
75
76 ConstExprValue(uint64_t value)
77 : m_type(ConstExprValueType::Numeric)
78 , m_bits(value)
79 { }
80
81 ConstExprValue(v128_t value)
82 : m_type(ConstExprValueType::Vector)
83 , m_vector(value)
84 { }
85
86 ConstExprValue(JSValue value)
87 : m_type(ConstExprValueType::Ref)
88 , m_bits(JSValue::encode(value))
89 { }
90
91 bool NODELETE[[clang::annotate_type("webkit.nodelete")]] isInvalid()
92 {
93 return m_type == ConstExprValueType::Invalid;
94 }
95
96 uint64_t NODELETE[[clang::annotate_type("webkit.nodelete")]] getValue()
97 {
98 ASSERT(m_type == ConstExprValueType::Numeric || m_type == ConstExprValueType::Ref)((void)0);
99 return m_bits;
100 }
101
102 v128_t NODELETE[[clang::annotate_type("webkit.nodelete")]] getVector()
103 {
104 ASSERT(m_type == ConstExprValueType::Vector)((void)0);
105 return m_vector;
106 }
107
108 ConstExprValueType NODELETE[[clang::annotate_type("webkit.nodelete")]] type()
109 {
110 return m_type;
111 }
112
113 ConstExprValue NODELETE[[clang::annotate_type("webkit.nodelete")]] operator+(ConstExprValue value)
114 {
115 ASSERT(m_type == ConstExprValueType::Numeric)((void)0);
116 return ConstExprValue(m_bits + value.getValue());
117 }
118
119 ConstExprValue NODELETE[[clang::annotate_type("webkit.nodelete")]] operator-(ConstExprValue value)
120 {
121 ASSERT(m_type == ConstExprValueType::Numeric)((void)0);
122 return ConstExprValue(m_bits - value.getValue());
123 }
124
125 ConstExprValue NODELETE[[clang::annotate_type("webkit.nodelete")]] operator*(ConstExprValue value)
126 {
127 ASSERT(m_type == ConstExprValueType::Numeric)((void)0);
128 return ConstExprValue(m_bits * value.getValue());
129 }
130
131 private:
132 ConstExprValueType m_type;
133 union {
134 uint64_t m_bits;
135 v128_t m_vector;
136 };
137 };
138
139 using ExpressionType = ConstExprValue;
140 using ResultList = Vector<ExpressionType, 8>;
141
142 // Structured blocks should not appear in the constant expression except
143 // for a dummy top-level block from parseBody() that cannot be jumped to.
144 struct ControlData {
145 static bool NODELETE[[clang::annotate_type("webkit.nodelete")]] isIf(const ControlData&) { return false; }
146 static bool NODELETE[[clang::annotate_type("webkit.nodelete")]] isElse(const ControlData&) { return false; }
147 static bool NODELETE[[clang::annotate_type("webkit.nodelete")]] isTry(const ControlData&) { return false; }
148 static bool NODELETE[[clang::annotate_type("webkit.nodelete")]] isAnyCatch(const ControlData&) { return false; }
149 static bool NODELETE[[clang::annotate_type("webkit.nodelete")]] isCatch(const ControlData&) { return false; }
150 static bool NODELETE[[clang::annotate_type("webkit.nodelete")]] isTopLevel(const ControlData&) { return true; }
151 static bool NODELETE[[clang::annotate_type("webkit.nodelete")]] isLoop(const ControlData&) { return false; }
152 static bool NODELETE[[clang::annotate_type("webkit.nodelete")]] isBlock(const ControlData&) { return false; }
153
154 ControlData()
155 { }
156 ControlData(BlockSignature&& signature)
157 : m_signature(WTF::move(signature))
158 { }
159
160 const BlockSignature& NODELETE[[clang::annotate_type("webkit.nodelete")]] signature() const { return m_signature; }
161 FunctionArgCount NODELETE[[clang::annotate_type("webkit.nodelete")]] branchTargetArity() const { return 0; }
162 Type NODELETE[[clang::annotate_type("webkit.nodelete")]] branchTargetType(unsigned) const { return Types::Void; }
163 private:
164 BlockSignature m_signature;
165 };
166
167 using ControlType = ControlData;
168 using ControlEntry = FunctionParser<ConstExprGenerator>::ControlEntry;
169 using ControlStack = FunctionParser<ConstExprGenerator>::ControlStack;
170 using Stack = FunctionParser<ConstExprGenerator>::Stack;
171 using TypedExpression = FunctionParser<ConstExprGenerator>::TypedExpression;
172 using CatchHandler = FunctionParser<ConstExprGenerator>::CatchHandler;
173 using ArgumentList = FunctionParser<ConstExprGenerator>::ArgumentList;
174
175 enum class Mode : uint8_t {
176 Validate,
177 Evaluate
178 };
179
180 static constexpr bool shouldFuseBranchCompare = false;
181 static constexpr bool NODELETE[[clang::annotate_type("webkit.nodelete")]] tierSupportsSIMD() { return true; }
182 static constexpr bool validateFunctionBodySize = false;
183 static ExpressionType NODELETE[[clang::annotate_type("webkit.nodelete")]] emptyExpression() { return { }; };
184
185protected:
186 template <typename ...Args>
187 [[nodiscard]] NEVER_INLINE__attribute__((__noinline__)) UnexpectedResult fail(Args... args) const
188 {
189 using namespace FailureHelper; // See ADL comment in WasmParser.h.
190 return UnexpectedResult(makeString("WebAssembly.Module doesn't parse at byte "_s, String::number(m_parser->offset() + m_offsetInSource), ": "_s, makeString(args)...));
191 }
192#define WASM_COMPILE_FAIL_IF(condition, ...)do { if (condition) [[unlikely]] return fail(...); } while (0
)
do { \
193 if (condition) [[unlikely]] \
194 return fail(__VA_ARGS__); \
195 } while (0)
196
197public:
198 ConstExprGenerator(Mode mode, size_t offsetInSource, const ModuleInformation& info)
199 : m_mode(mode)
200 , m_offsetInSource(offsetInSource)
201 , m_info(info)
202 {
203 ASSERT(mode == Mode::Validate)((void)0);
204 }
205
206 ConstExprGenerator(Mode mode, size_t offsetInSource, const ModuleInformation& info, JSWebAssemblyInstance* instance)
207 : m_mode(mode)
208 , m_offsetInSource(offsetInSource)
209 , m_info(info)
210 , m_instance(instance)
211 {
212 ASSERT(mode == Mode::Evaluate)((void)0);
213 }
214
215 ExpressionType NODELETE[[clang::annotate_type("webkit.nodelete")]] result() const { return m_result; }
216 const Vector<FunctionSpaceIndex>& NODELETE[[clang::annotate_type("webkit.nodelete")]] declaredFunctions() const { return m_declaredFunctions; }
217 void NODELETE[[clang::annotate_type("webkit.nodelete")]] setParser(FunctionParser<ConstExprGenerator>* parser) { m_parser = parser; };
218
219 bool NODELETE[[clang::annotate_type("webkit.nodelete")]] addArguments(const RTT&) { RELEASE_ASSERT_NOT_REACHED()do { WTF::isIntegralOrPointerType(); compilerFenceForCrash();
WTFCrashWithInfo(219, "/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/JavaScriptCore/wasm/WasmConstExprGenerator.cpp"
, __PRETTY_FUNCTION__ ); } while (false)
; }
220
221 ExpressionType NODELETE[[clang::annotate_type("webkit.nodelete")]] addConstant(Type type, uint64_t value)
222 {
223 switch (type.kind) {
224 case TypeKind::I32:
225 case TypeKind::I64:
226 case TypeKind::F32:
227 case TypeKind::F64:
228 return ConstExprValue(value);
229 case TypeKind::Ref:
230 case TypeKind::RefNull:
231 case TypeKind::Structref:
232 case TypeKind::Arrayref:
233 case TypeKind::Funcref:
234 case TypeKind::Exnref:
235 case TypeKind::Externref:
236 case TypeKind::Eqref:
237 case TypeKind::Anyref:
238 case TypeKind::Noexnref:
239 case TypeKind::Noneref:
240 case TypeKind::Nofuncref:
241 case TypeKind::Noexternref:
242 return ConstExprValue(JSValue::encode(jsNull()));
243 default:
244 RELEASE_ASSERT_NOT_REACHED_WITH_MESSAGE("Unimplemented constant type.\n")do { if (__builtin_expect(!!(!(assertionFailureDueToUnreachableCode
)), 0)) do { WTF::isIntegralOrPointerType(); compilerFenceForCrash
(); WTFCrashWithInfo(244, "/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/JavaScriptCore/wasm/WasmConstExprGenerator.cpp"
, __PRETTY_FUNCTION__ ); } while (false); } while (0)
;
245 }
246 }
247
248#define CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
{ return fail("Invalid instruction for constant expression"); }
249
250 PartialResult addDrop(ExpressionType) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
251 PartialResult NODELETE[[clang::annotate_type("webkit.nodelete")]] addLocal(Type, uint32_t) { RELEASE_ASSERT_NOT_REACHED()do { WTF::isIntegralOrPointerType(); compilerFenceForCrash();
WTFCrashWithInfo(251, "/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/JavaScriptCore/wasm/WasmConstExprGenerator.cpp"
, __PRETTY_FUNCTION__ ); } while (false)
; }
252 [[nodiscard]] PartialResult addTableGet(unsigned, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
253 [[nodiscard]] PartialResult addTableSet(unsigned, ExpressionType, ExpressionType) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
254 [[nodiscard]] PartialResult addTableInit(unsigned, unsigned, ExpressionType, ExpressionType, ExpressionType) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
255 [[nodiscard]] PartialResult addElemDrop(unsigned) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
256 [[nodiscard]] PartialResult addTableSize(unsigned, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
257 [[nodiscard]] PartialResult addTableGrow(unsigned, ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
258 [[nodiscard]] PartialResult addTableFill(unsigned, ExpressionType, ExpressionType, ExpressionType) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
259 [[nodiscard]] PartialResult addTableCopy(unsigned, unsigned, ExpressionType, ExpressionType, ExpressionType) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
260 [[nodiscard]] PartialResult getLocal(uint32_t, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
261 [[nodiscard]] PartialResult setLocal(uint32_t, ExpressionType) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
262 [[nodiscard]] PartialResult teeLocal(uint32_t, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
263
264 [[nodiscard]] PartialResult getGlobal(uint32_t index, ExpressionType& result)
265 {
266 // Note that this check works for table initializers too, because no globals are registered when the table section is read and the count is 0.
267 WASM_COMPILE_FAIL_IF(index >= m_info.globals.size(), "get_global's index ", index, " exceeds the number of globals ", m_info.globals.size())do { if (index >= m_info.globals.size()) [[unlikely]] return
fail("get_global's index ", index, " exceeds the number of globals "
, m_info.globals.size()); } while (0)
;
268 WASM_COMPILE_FAIL_IF(m_info.globals[index].mutability != Mutability::Immutable, "get_global import kind index ", index, " is mutable ")do { if (m_info.globals[index].mutability != Mutability::Immutable
) [[unlikely]] return fail("get_global import kind index ", index
, " is mutable "); } while (0)
;
269
270 if (m_mode == Mode::Evaluate) {
271 if (m_info.globals[index].type.kind == TypeKind::V128)
272 result = ConstExprValue(m_instance->loadV128Global(index));
273 else
274 result = ConstExprValue(m_instance->loadI64Global(index));
275 }
276
277 return { };
278 }
279
280 [[nodiscard]] PartialResult setGlobal(uint32_t, ExpressionType) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
281 [[nodiscard]] PartialResult load(LoadOpType, ExpressionType, ExpressionType&, uint32_t, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
282 [[nodiscard]] PartialResult store(StoreOpType, ExpressionType, ExpressionType, uint32_t, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
283 [[nodiscard]] PartialResult addGrowMemory(ExpressionType, ExpressionType&, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
284 [[nodiscard]] PartialResult addCurrentMemory(ExpressionType&, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
285 [[nodiscard]] PartialResult addMemoryFill(ExpressionType, ExpressionType, ExpressionType, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
286 [[nodiscard]] PartialResult addMemoryCopy(ExpressionType, ExpressionType, ExpressionType, uint8_t, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
287 [[nodiscard]] PartialResult addMemoryInit(unsigned, ExpressionType, ExpressionType, ExpressionType, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
288 [[nodiscard]] PartialResult addDataDrop(unsigned) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
289 [[nodiscard]] PartialResult atomicLoad(ExtAtomicOpType, Type, ExpressionType, ExpressionType&, uint64_t, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
290 [[nodiscard]] PartialResult atomicStore(ExtAtomicOpType, Type, ExpressionType, ExpressionType, uint64_t, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
291 [[nodiscard]] PartialResult atomicBinaryRMW(ExtAtomicOpType, Type, ExpressionType, ExpressionType, ExpressionType&, uint64_t, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
292 [[nodiscard]] PartialResult atomicCompareExchange(ExtAtomicOpType, Type, ExpressionType, ExpressionType, ExpressionType, ExpressionType&, uint64_t, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
293 [[nodiscard]] PartialResult atomicWait(ExtAtomicOpType, ExpressionType, ExpressionType, ExpressionType, ExpressionType&, uint64_t, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
294 [[nodiscard]] PartialResult atomicNotify(ExtAtomicOpType, ExpressionType, ExpressionType, ExpressionType&, uint64_t, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
295 [[nodiscard]] PartialResult atomicFence(ExtAtomicOpType, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
296 [[nodiscard]] PartialResult truncTrapping(OpType, ExpressionType, ExpressionType&, Type, Type) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
297 [[nodiscard]] PartialResult truncSaturated(Ext1OpType, ExpressionType, ExpressionType&, Type, Type) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
298 [[nodiscard]] PartialResult addI64Add128(ExpressionType, ExpressionType, ExpressionType, ExpressionType, ExpressionType&, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
299 [[nodiscard]] PartialResult addI64Sub128(ExpressionType, ExpressionType, ExpressionType, ExpressionType, ExpressionType&, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
300 [[nodiscard]] PartialResult addI64MulWideS(ExpressionType, ExpressionType, ExpressionType&, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
301 [[nodiscard]] PartialResult addI64MulWideU(ExpressionType, ExpressionType, ExpressionType&, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
302
303 [[nodiscard]] PartialResult NODELETE[[clang::annotate_type("webkit.nodelete")]] addRefI31(ExpressionType value, ExpressionType& result)
304 {
305 if (m_mode == Mode::Evaluate) {
306 JSValue i31 = JSValue((((static_cast<int32_t>(value.getValue()) & 0x7fffffff) << 1) >> 1));
307 ASSERT(i31.isInt32())((void)0);
308 result = ConstExprValue(i31);
309 }
310 return { };
311 }
312
313 [[nodiscard]] PartialResult addI31GetS(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
314 [[nodiscard]] PartialResult addI31GetU(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
315
316 ExpressionType createNewArray(WebAssemblyGCStructure* structure, uint32_t size, ExpressionType value)
317 {
318 JSValue result;
319 if (value.type() == ConstExprValue::Vector)
320 result = arrayNew(m_instance, structure, size, value.getVector());
321 else
322 result = arrayNew(m_instance, structure, size, value.getValue());
323 if (result.isNull()) [[unlikely]]
324 return ConstExprValue(InvalidConstExpr);
325 m_keepAlive.appendWithCrashOnOverflow(asObject(result));
326 return ConstExprValue(result);
327 }
328
329 [[nodiscard]] PartialResult addArrayNew(TypeSignatureIndex typeIndex, ExpressionType size, ExpressionType value, ExpressionType& result)
330 {
331 if (m_mode == Mode::Evaluate) {
332 auto* structure = m_instance->gcObjectStructure(typeIndex.rawIndex());
333 result = createNewArray(structure, static_cast<uint32_t>(size.getValue()), value);
334 WASM_ALLOCATOR_FAIL_IF(result.isInvalid(), "Failed to allocate new array"_s)do { if (result.isInvalid()) [[unlikely]] return fail("Failed to allocate new array"_s
); } while (0)
;
335 }
336 return { };
337 }
338
339 [[nodiscard]] PartialResult addArrayNewDefault(TypeSignatureIndex typeIndex, ExpressionType size, ExpressionType& result)
340 {
341 if (m_mode == Mode::Evaluate) {
342 auto* structure = m_instance->gcObjectStructure(typeIndex.rawIndex());
343 const Wasm::RTT& arraySignature = structure->rtt();
344 auto elementType = arraySignature.elementType().type.unpacked();
345 ExpressionType initValue { };
346 if (isRefType(elementType))
347 initValue = { static_cast<uint64_t>(JSValue::encode(jsNull())) };
348 if (elementType == Wasm::Types::V128)
349 initValue = { vectorAllZeros() };
350 result = createNewArray(structure, static_cast<uint32_t>(size.getValue()), initValue);
351 WASM_ALLOCATOR_FAIL_IF(result.isInvalid(), "Failed to allocate new array"_s)do { if (result.isInvalid()) [[unlikely]] return fail("Failed to allocate new array"_s
); } while (0)
;
352 }
353
354 return { };
355 }
356
357 [[nodiscard]] PartialResult addArrayNewFixed(TypeSignatureIndex typeIndex, ArgumentList& args, ExpressionType& result)
358 {
359 if (m_mode == Mode::Evaluate) {
360 auto* structure = m_instance->gcObjectStructure(typeIndex.rawIndex());
361 const Wasm::RTT& arraySignature = structure->rtt();
362 if (arraySignature.elementType().type.unpacked().isV128()) {
363 result = createNewArray(structure, args.size(), { vectorAllZeros() });
364 WASM_ALLOCATOR_FAIL_IF(result.isInvalid(), "Failed to allocate new array"_s)do { if (result.isInvalid()) [[unlikely]] return fail("Failed to allocate new array"_s
); } while (0)
;
365 JSWebAssemblyArray* arrayObject = uncheckedDowncast<JSWebAssemblyArray>(JSValue::decode(result.getValue()));
366 for (size_t i = 0; i < args.size(); i++)
367 arrayObject->set(arrayObject->vm(), i, args[i].value().getVector());
368 } else {
369 result = createNewArray(structure, args.size(), { });
370 WASM_ALLOCATOR_FAIL_IF(result.isInvalid(), "Failed to allocate new array"_s)do { if (result.isInvalid()) [[unlikely]] return fail("Failed to allocate new array"_s
); } while (0)
;
371 JSWebAssemblyArray* arrayObject = uncheckedDowncast<JSWebAssemblyArray>(JSValue::decode(result.getValue()));
372 for (size_t i = 0; i < args.size(); i++)
373 arrayObject->set(arrayObject->vm(), i, args[i].value().getValue());
374 }
375 }
376
377 return { };
378 }
379
380 [[nodiscard]] PartialResult addArrayNewData(TypeSignatureIndex, uint32_t, ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
381 [[nodiscard]] PartialResult addArrayNewElem(TypeSignatureIndex, uint32_t, ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
382 [[nodiscard]] PartialResult addArrayGet(ExtGCOpType, TypeSignatureIndex, ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
383 [[nodiscard]] PartialResult addArraySet(TypeSignatureIndex, ExpressionType, ExpressionType, ExpressionType) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
384 [[nodiscard]] PartialResult addArrayLen(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
385 [[nodiscard]] PartialResult addArrayFill(TypeSignatureIndex, ExpressionType, ExpressionType, ExpressionType, ExpressionType) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
386 [[nodiscard]] PartialResult addArrayCopy(TypeSignatureIndex, ExpressionType, ExpressionType, TypeSignatureIndex, ExpressionType, ExpressionType, ExpressionType) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
387 [[nodiscard]] PartialResult addArrayInitElem(TypeSignatureIndex, ExpressionType, ExpressionType, uint32_t, ExpressionType, ExpressionType) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
;
388 [[nodiscard]] PartialResult addArrayInitData(TypeSignatureIndex, ExpressionType, ExpressionType, uint32_t, ExpressionType, ExpressionType) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
;
389
390 ExpressionType createNewStruct(TypeSignatureIndex typeIndex)
391 {
392 auto* structure = m_instance->gcObjectStructure(typeIndex.rawIndex());
393 JSValue result = structNew(m_instance, structure, static_cast<bool>(UseDefaultValue::Yes), nullptr);
394 if (result.isNull()) [[unlikely]]
395 return ConstExprValue(InvalidConstExpr);
396 m_keepAlive.appendWithCrashOnOverflow(asObject(result));
397 return ConstExprValue(result);
398 }
399
400 [[nodiscard]] PartialResult addStructNewDefault(TypeSignatureIndex typeIndex, ExpressionType& result)
401 {
402 if (m_mode == Mode::Evaluate) {
403 result = createNewStruct(typeIndex);
404 WASM_ALLOCATOR_FAIL_IF(result.isInvalid(), "Failed to allocate new struct"_s)do { if (result.isInvalid()) [[unlikely]] return fail("Failed to allocate new struct"_s
); } while (0)
;
405 }
406
407 return { };
408 }
409
410 [[nodiscard]] PartialResult addStructNew(TypeSignatureIndex typeIndex, ArgumentList& args, ExpressionType& result)
411 {
412 if (m_mode == Mode::Evaluate) {
413 result = createNewStruct(typeIndex);
414 WASM_ALLOCATOR_FAIL_IF(result.isInvalid(), "Failed to allocate new struct"_s)do { if (result.isInvalid()) [[unlikely]] return fail("Failed to allocate new struct"_s
); } while (0)
;
415 JSWebAssemblyStruct* structObject = uncheckedDowncast<JSWebAssemblyStruct>(JSValue::decode(result.getValue()));
416 for (size_t i = 0; i < args.size(); i++) {
417 if (args[i].value().type() == ConstExprValue::Vector)
418 structObject->set(i, args[i].value().getVector());
419 else
420 structObject->set(i, args[i].value().getValue());
421 }
422 }
423
424 return { };
425 }
426
427 [[nodiscard]] PartialResult addStructGet(ExtGCOpType, ExpressionType, const RTT&, uint32_t, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
428 [[nodiscard]] PartialResult addStructSet(ExpressionType, const RTT&, uint32_t, ExpressionType) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
429 [[nodiscard]] PartialResult addRefTest(ExpressionType, bool, int32_t, bool, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
430 [[nodiscard]] PartialResult addRefCast(ExpressionType, bool, int32_t, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
431
432 [[nodiscard]] PartialResult addAnyConvertExtern(ExpressionType reference, ExpressionType& result)
433 {
434 if (m_mode == Mode::Evaluate) {
435 if (reference.type() == ConstExprValue::Numeric)
436 result = ConstExprValue(externInternalize(reference.getValue()));
437 else
438 // To avoid creating a new Strong handle, we pass the original reference.
439 // This is valid because we know extern.internalize is a no-op on object
440 // references, but if this changes in the future this will need to change.
441 result = reference;
442 }
443 return { };
444 }
445
446 [[nodiscard]] PartialResult NODELETE[[clang::annotate_type("webkit.nodelete")]] addExternConvertAny(ExpressionType reference, ExpressionType& result)
447 {
448 result = reference;
449 return { };
450 }
451
452 [[nodiscard]] PartialResult addSelect(ExpressionType, ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
453
454 [[nodiscard]] PartialResult NODELETE[[clang::annotate_type("webkit.nodelete")]] addI32Add(ExpressionType lhs, ExpressionType rhs, ExpressionType& result)
455 {
456 if (m_mode == Mode::Evaluate)
457 result = lhs + rhs;
458 return { };
459 }
460 [[nodiscard]] PartialResult NODELETE[[clang::annotate_type("webkit.nodelete")]] addI64Add(ExpressionType lhs, ExpressionType rhs, ExpressionType& result)
461 {
462 if (m_mode == Mode::Evaluate)
463 result = lhs + rhs;
464 return { };
465 }
466
467 [[nodiscard]] PartialResult addF32Add(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
468 [[nodiscard]] PartialResult addF64Add(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
469
470 [[nodiscard]] PartialResult NODELETE[[clang::annotate_type("webkit.nodelete")]] addI32Sub(ExpressionType lhs, ExpressionType rhs, ExpressionType& result)
471 {
472 if (m_mode == Mode::Evaluate)
473 result = lhs - rhs;
474 return { };
475 }
476
477 [[nodiscard]] PartialResult NODELETE[[clang::annotate_type("webkit.nodelete")]] addI64Sub(ExpressionType lhs, ExpressionType rhs, ExpressionType& result)
478 {
479 if (m_mode == Mode::Evaluate)
480 result = lhs - rhs;
481 return { };
482 }
483
484 [[nodiscard]] PartialResult addF32Sub(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
485 [[nodiscard]] PartialResult addF64Sub(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
486
487 [[nodiscard]] PartialResult NODELETE[[clang::annotate_type("webkit.nodelete")]] addI32Mul(ExpressionType lhs, ExpressionType rhs, ExpressionType& result)
488 {
489 if (m_mode == Mode::Evaluate)
490 result = lhs * rhs;
491 return { };
492 }
493
494 [[nodiscard]] PartialResult NODELETE[[clang::annotate_type("webkit.nodelete")]] addI64Mul(ExpressionType lhs, ExpressionType rhs, ExpressionType& result)
495 {
496 if (m_mode == Mode::Evaluate)
497 result = lhs * rhs;
498 return { };
499 }
500
501 [[nodiscard]] PartialResult addF32Mul(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
502 [[nodiscard]] PartialResult addF64Mul(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
503 [[nodiscard]] PartialResult addI32DivS(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
504 [[nodiscard]] PartialResult addI64DivS(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
505 [[nodiscard]] PartialResult addI32DivU(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
506 [[nodiscard]] PartialResult addI64DivU(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
507 [[nodiscard]] PartialResult addI32RemS(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
508 [[nodiscard]] PartialResult addI64RemS(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
509 [[nodiscard]] PartialResult addI32RemU(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
510 [[nodiscard]] PartialResult addI64RemU(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
511 [[nodiscard]] PartialResult addF32Div(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
512 [[nodiscard]] PartialResult addF64Div(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
513 [[nodiscard]] PartialResult addF32Min(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
514 [[nodiscard]] PartialResult addF64Min(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
515 [[nodiscard]] PartialResult addF32Max(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
516 [[nodiscard]] PartialResult addF64Max(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
517 [[nodiscard]] PartialResult addI32And(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
518 [[nodiscard]] PartialResult addI64And(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
519 [[nodiscard]] PartialResult addI32Xor(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
520 [[nodiscard]] PartialResult addI64Xor(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
521 [[nodiscard]] PartialResult addI32Or(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
522 [[nodiscard]] PartialResult addI64Or(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
523 [[nodiscard]] PartialResult addI32Shl(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
524 [[nodiscard]] PartialResult addI64Shl(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
525 [[nodiscard]] PartialResult addI32ShrS(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
526 [[nodiscard]] PartialResult addI64ShrS(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
527 [[nodiscard]] PartialResult addI32ShrU(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
528 [[nodiscard]] PartialResult addI64ShrU(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
529 [[nodiscard]] PartialResult addI32Rotl(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
530 [[nodiscard]] PartialResult addI64Rotl(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
531 [[nodiscard]] PartialResult addI32Rotr(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
532 [[nodiscard]] PartialResult addI64Rotr(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
533 [[nodiscard]] PartialResult addI32Clz(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
534 [[nodiscard]] PartialResult addI64Clz(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
535 [[nodiscard]] PartialResult addI32Ctz(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
536 [[nodiscard]] PartialResult addI64Ctz(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
537 [[nodiscard]] PartialResult addI32Eq(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
538 [[nodiscard]] PartialResult addI64Eq(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
539 [[nodiscard]] PartialResult addI32Ne(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
540 [[nodiscard]] PartialResult addI64Ne(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
541 [[nodiscard]] PartialResult addI32LtS(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
542 [[nodiscard]] PartialResult addI64LtS(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
543 [[nodiscard]] PartialResult addI32LeS(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
544 [[nodiscard]] PartialResult addI64LeS(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
545 [[nodiscard]] PartialResult addI32GtS(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
546 [[nodiscard]] PartialResult addI64GtS(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
547 [[nodiscard]] PartialResult addI32GeS(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
548 [[nodiscard]] PartialResult addI64GeS(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
549 [[nodiscard]] PartialResult addI32LtU(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
550 [[nodiscard]] PartialResult addI64LtU(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
551 [[nodiscard]] PartialResult addI32LeU(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
552 [[nodiscard]] PartialResult addI64LeU(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
553 [[nodiscard]] PartialResult addI32GtU(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
554 [[nodiscard]] PartialResult addI64GtU(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
555 [[nodiscard]] PartialResult addI32GeU(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
556 [[nodiscard]] PartialResult addI64GeU(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
557 [[nodiscard]] PartialResult addF32Eq(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
558 [[nodiscard]] PartialResult addF64Eq(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
559 [[nodiscard]] PartialResult addF32Ne(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
560 [[nodiscard]] PartialResult addF64Ne(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
561 [[nodiscard]] PartialResult addF32Lt(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
562 [[nodiscard]] PartialResult addF64Lt(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
563 [[nodiscard]] PartialResult addF32Le(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
564 [[nodiscard]] PartialResult addF64Le(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
565 [[nodiscard]] PartialResult addF32Gt(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
566 [[nodiscard]] PartialResult addF64Gt(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
567 [[nodiscard]] PartialResult addF32Ge(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
568 [[nodiscard]] PartialResult addF64Ge(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
569 PartialResult addI32WrapI64(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
570 PartialResult addI32Extend8S(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
571 [[nodiscard]] PartialResult addI32Extend16S(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
572 [[nodiscard]] PartialResult addI64Extend8S(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
573 [[nodiscard]] PartialResult addI64Extend16S(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
574 [[nodiscard]] PartialResult addI64Extend32S(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
575 [[nodiscard]] PartialResult addI64ExtendSI32(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
576 [[nodiscard]] PartialResult addI64ExtendUI32(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
577 [[nodiscard]] PartialResult addI32Eqz(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
578 [[nodiscard]] PartialResult addI64Eqz(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
579 [[nodiscard]] PartialResult addI32Popcnt(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
580 [[nodiscard]] PartialResult addI64Popcnt(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
581 [[nodiscard]] PartialResult addI32ReinterpretF32(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
582 [[nodiscard]] PartialResult addI64ReinterpretF64(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
583 [[nodiscard]] PartialResult addF32ReinterpretI32(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
584 [[nodiscard]] PartialResult addF64ReinterpretI64(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
585 [[nodiscard]] PartialResult addF32DemoteF64(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
586 [[nodiscard]] PartialResult addF64PromoteF32(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
587 [[nodiscard]] PartialResult addF32ConvertSI32(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
588 [[nodiscard]] PartialResult addF32ConvertUI32(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
589 [[nodiscard]] PartialResult addF32ConvertSI64(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
590 [[nodiscard]] PartialResult addF32ConvertUI64(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
591 [[nodiscard]] PartialResult addF64ConvertSI32(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
592 [[nodiscard]] PartialResult addF64ConvertUI32(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
593 [[nodiscard]] PartialResult addF64ConvertSI64(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
594 [[nodiscard]] PartialResult addF64ConvertUI64(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
595 [[nodiscard]] PartialResult addF32Copysign(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
596 [[nodiscard]] PartialResult addF64Copysign(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
597 [[nodiscard]] PartialResult addF32Floor(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
598 [[nodiscard]] PartialResult addF64Floor(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
599 [[nodiscard]] PartialResult addF32Ceil(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
600 [[nodiscard]] PartialResult addF64Ceil(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
601 [[nodiscard]] PartialResult addF32Abs(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
602 [[nodiscard]] PartialResult addF64Abs(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
603 [[nodiscard]] PartialResult addF32Sqrt(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
604 [[nodiscard]] PartialResult addF64Sqrt(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
605 [[nodiscard]] PartialResult addF32Neg(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
606 [[nodiscard]] PartialResult addF64Neg(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
607 [[nodiscard]] PartialResult addF32Nearest(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
608 [[nodiscard]] PartialResult addF64Nearest(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
609 [[nodiscard]] PartialResult addF32Trunc(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
610 [[nodiscard]] PartialResult addF64Trunc(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
611 [[nodiscard]] PartialResult addI32TruncSF32(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
612 [[nodiscard]] PartialResult addI32TruncSF64(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
613 [[nodiscard]] PartialResult addI32TruncUF32(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
614 [[nodiscard]] PartialResult addI32TruncUF64(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
615 [[nodiscard]] PartialResult addI64TruncSF32(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
616 [[nodiscard]] PartialResult addI64TruncSF64(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
617 [[nodiscard]] PartialResult addI64TruncUF32(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
618 [[nodiscard]] PartialResult addI64TruncUF64(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
619 [[nodiscard]] PartialResult addRefIsNull(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
620 [[nodiscard]] PartialResult addRefAsNonNull(ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
621 [[nodiscard]] PartialResult addRefEq(ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
622
623 [[nodiscard]] PartialResult addRefFunc(FunctionSpaceIndex index, ExpressionType& result)
624 {
625 if (m_mode == Mode::Evaluate) {
626 JSValue wrapper = m_instance->ensureFunctionWrapper(index);
627 ASSERT(!wrapper.isNull())((void)0);
628 ASSERT(wrapper.isObject())((void)0);
629 m_keepAlive.appendWithCrashOnOverflow(asObject(wrapper));
630 result = ConstExprValue(wrapper);
631 } else
632 m_declaredFunctions.append(index);
633
634 return { };
635 }
636
637 ControlData NODELETE[[clang::annotate_type("webkit.nodelete")]] addTopLevel(BlockSignature&& signature)
638 {
639 return ControlData(WTF::move(signature));
640 }
641
642 [[nodiscard]] PartialResult addBlock(BlockSignature, Stack&, ControlType&, Stack&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
643 [[nodiscard]] PartialResult addLoop(BlockSignature, Stack&, ControlType&, Stack&, uint32_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
644 [[nodiscard]] PartialResult addIf(ExpressionType, BlockSignature, Stack&, ControlData&, Stack&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
645 [[nodiscard]] PartialResult addElse(ControlData&, Stack&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
646 [[nodiscard]] PartialResult addElseToUnreachable(ControlData&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
647 [[nodiscard]] PartialResult addTry(BlockSignature, Stack&, ControlType&, Stack&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
648 [[nodiscard]] PartialResult addTryTable(BlockSignature, Stack&, const Vector<CatchHandler>&, ControlType&, Stack&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
649 [[nodiscard]] PartialResult addCatch(unsigned, const RTT&, Stack&, ControlType&, ResultList&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
650 [[nodiscard]] PartialResult addCatchToUnreachable(unsigned, const RTT&, ControlType&, ResultList&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
651 [[nodiscard]] PartialResult addCatchAll(Stack&, ControlType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
652 [[nodiscard]] PartialResult addCatchAllToUnreachable(ControlType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
653 [[nodiscard]] PartialResult addDelegate(ControlType&, ControlType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
654 [[nodiscard]] PartialResult addDelegateToUnreachable(ControlType&, ControlType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
655 [[nodiscard]] PartialResult addThrow(unsigned, ArgumentList&, Stack&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
656 [[nodiscard]] PartialResult addRethrow(unsigned, ControlType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
657 [[nodiscard]] PartialResult addThrowRef(ExpressionType, Stack&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
658 [[nodiscard]] PartialResult addReturn(const ControlData&, const Stack&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
659 [[nodiscard]] PartialResult addBranch(ControlData&, ExpressionType, Stack&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
660 [[nodiscard]] PartialResult addBranchNull(ControlType&, ExpressionType, Stack&, bool, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
661 [[nodiscard]] PartialResult addBranchCast(ControlType&, ExpressionType, Stack&, bool, int32_t, bool) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
662 [[nodiscard]] PartialResult addSwitch(ExpressionType, const Vector<ControlData*>&, ControlData&, Stack&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
663 [[nodiscard]] PartialResult addFusedBranchCompare(OpType, ControlType&, ExpressionType, const Stack&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
664 [[nodiscard]] PartialResult addFusedBranchCompare(OpType, ControlType&, ExpressionType, ExpressionType, const Stack&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
665 [[nodiscard]] PartialResult addFusedIfCompare(OpType, ExpressionType, BlockSignature, Stack&, ControlType&, Stack&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
666 [[nodiscard]] PartialResult addFusedIfCompare(OpType, ExpressionType, ExpressionType, BlockSignature, Stack&, ControlType&, Stack&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
667
668 [[nodiscard]] PartialResult NODELETE[[clang::annotate_type("webkit.nodelete")]] endBlock(ControlEntry& entry, Stack& expressionStack)
669 {
670 ASSERT(expressionStack.size() == 1)((void)0);
671 ASSERT_UNUSED(entry, ControlType::isTopLevel(entry.controlData))((void)entry);
672 m_result = expressionStack.first().value();
673 return { };
674 }
675
676 [[nodiscard]] PartialResult addEndToUnreachable(ControlEntry&, Stack&, bool = true) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
677
678 [[nodiscard]] PartialResult endTopLevel(const Stack&)
679 {
680 // Some opcodes like "nop" are not detectable by an error stub because the context
681 // doesn't get called by the parser. This flag is set by didParseOpcode() to signal
682 // such cases.
683 WASM_COMPILE_FAIL_IF(m_shouldError, "Invalid instruction for constant expression")do { if (m_shouldError) [[unlikely]] return fail("Invalid instruction for constant expression"
); } while (0)
;
684 return { };
685 }
686
687 [[nodiscard]] PartialResult addCall(unsigned, FunctionSpaceIndex, const RTT&, ArgumentList&, ResultList&, CallType = CallType::Call) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
688 [[nodiscard]] PartialResult addCallIndirect(unsigned, unsigned, const RTT&, ArgumentList&, ResultList&, CallType = CallType::Call) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
689 [[nodiscard]] PartialResult addCallRef(unsigned, const RTT&, ArgumentList&, ResultList&, CallType = CallType::Call) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
690 [[nodiscard]] PartialResult addUnreachable() CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
691 [[nodiscard]] PartialResult addCrash() CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
692 bool NODELETE[[clang::annotate_type("webkit.nodelete")]] usesSIMD() { return false; }
693 void NODELETE[[clang::annotate_type("webkit.nodelete")]] notifyFunctionUsesSIMD() { }
694 [[nodiscard]] PartialResult addSIMDLoad(ExpressionType, uint32_t, ExpressionType&, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
695 [[nodiscard]] PartialResult addSIMDStore(ExpressionType, ExpressionType, uint32_t, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
696 [[nodiscard]] PartialResult addSIMDSplat(SIMDLane, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
697 [[nodiscard]] PartialResult addSIMDShuffle(v128_t, ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
698 [[nodiscard]] PartialResult addSIMDShift(SIMDLaneOperation, SIMDInfo, ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
699 [[nodiscard]] PartialResult addSIMDExtmul(SIMDLaneOperation, SIMDInfo, ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
700 [[nodiscard]] PartialResult addSIMDLoadSplat(SIMDLaneOperation, ExpressionType, uint32_t, ExpressionType&, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
701 [[nodiscard]] PartialResult addSIMDLoadLane(SIMDLaneOperation, ExpressionType, ExpressionType, uint32_t, uint8_t, ExpressionType&, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
702 [[nodiscard]] PartialResult addSIMDStoreLane(SIMDLaneOperation, ExpressionType, ExpressionType, uint32_t, uint8_t, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
703 [[nodiscard]] PartialResult addSIMDLoadExtend(SIMDLaneOperation, ExpressionType, uint32_t, ExpressionType&, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
704 [[nodiscard]] PartialResult addSIMDLoadPad(SIMDLaneOperation, ExpressionType, uint32_t, ExpressionType&, uint8_t) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
705 [[nodiscard]] ExpressionType NODELETE[[clang::annotate_type("webkit.nodelete")]] addSIMDConstant(v128_t vector)
706 {
707 RELEASE_ASSERT(Options::useWasmSIMD())do { if (__builtin_expect(!!(!(Options::useWasmSIMD())), 0)) do
{ WTF::isIntegralOrPointerType(); compilerFenceForCrash(); WTFCrashWithInfo
(707, "/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/JavaScriptCore/wasm/WasmConstExprGenerator.cpp"
, __PRETTY_FUNCTION__ ); } while (false); } while (0)
;
708 if (m_mode == Mode::Evaluate)
709 return ConstExprValue(vector);
710 return { };
711 }
712 [[nodiscard]] PartialResult addSIMDExtractLane(SIMDInfo, uint8_t, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
713 [[nodiscard]] PartialResult addSIMDReplaceLane(SIMDInfo, uint8_t, ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
714 [[nodiscard]] PartialResult addSIMDI_V(SIMDLaneOperation, SIMDInfo, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
715 [[nodiscard]] PartialResult addSIMDV_V(SIMDLaneOperation, SIMDInfo, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
716 [[nodiscard]] PartialResult addSIMDBitwiseSelect(ExpressionType, ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
717#if ENABLE(B3_JIT)(defined 1 && 1)
718 [[nodiscard]] PartialResult addSIMDRelOp(SIMDLaneOperation, SIMDInfo, ExpressionType, ExpressionType, B3::Air::Arg, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
719#endif
720 [[nodiscard]] PartialResult addSIMDV_VV(SIMDLaneOperation, SIMDInfo, ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
721 [[nodiscard]] PartialResult addSIMDRelaxedFMA(SIMDLaneOperation, SIMDInfo, ExpressionType, ExpressionType, ExpressionType, ExpressionType&) CONST_EXPR_STUB{ return fail("Invalid instruction for constant expression");
}
722
723 void NODELETE[[clang::annotate_type("webkit.nodelete")]] dump(const ControlStack&, const Stack*) { }
724 ALWAYS_INLINEinline __attribute__((__always_inline__)) void willParseOpcode() { }
725 ALWAYS_INLINEinline __attribute__((__always_inline__)) void willParseExtendedOpcode() { }
726 ALWAYS_INLINEinline __attribute__((__always_inline__)) void didParseOpcode() {
727 if (m_parser->currentOpcode() == Nop)
728 m_shouldError = true;
729 }
730 void NODELETE[[clang::annotate_type("webkit.nodelete")]] didFinishParsingLocals() { }
731 void NODELETE[[clang::annotate_type("webkit.nodelete")]] didPopValueFromStack(ExpressionType, ASCIILiteral) { }
732
733private:
734 FunctionParser<ConstExprGenerator>* m_parser { nullptr };
735 Mode m_mode;
736 size_t m_offsetInSource { 0 };
737 ExpressionType m_result;
738 const ModuleInformation& m_info;
Member variable 'm_info' in 'JSC::Wasm::ConstExprGenerator' is a reference to ref-countable type 'JSC::Wasm::ModuleInformation'; member variables must be Ref, RefPtr, WeakRef, or WeakPtr
739 JSWebAssemblyInstance* m_instance { nullptr };
740 bool m_shouldError = false;
741 Vector<FunctionSpaceIndex> m_declaredFunctions;
742 MarkedArgumentBufferWithSize<16> m_keepAlive;
743};
744
745Expected<void, String> parseExtendedConstExpr(std::span<const uint8_t> source, size_t offsetInSource, size_t& offset, ModuleInformation& info, Type expectedType)
746{
747 ConstExprGenerator generator(ConstExprGenerator::Mode::Validate, offsetInSource, info);
748 FunctionParser<ConstExprGenerator> parser(generator, source, BlockSignature { expectedType }, info);
749 WASM_FAIL_IF_HELPER_FAILS(parser.parseConstantExpression())do { auto helperResult = parser.parseConstantExpression(); if
(!helperResult) [[unlikely]] return makeUnexpected(WTF::move
(helperResult.error())); } while (0)
;
750 offset = parser.offset();
751
752 for (const auto& declaredFunctionIndex : generator.declaredFunctions())
753 info.addDeclaredFunction(declaredFunctionIndex);
754
755 return { };
756}
757
758Expected<uint64_t, String> evaluateExtendedConstExpr(const ModuleInformation::ConstantExpressionAndSourceOffset& constantExpressionAndSourceOffset, JSWebAssemblyInstance* instance, const ModuleInformation& info, Type expectedType)
759{
760 auto constantExpression = constantExpressionAndSourceOffset.first;
761 size_t offsetInSource = constantExpressionAndSourceOffset.second;
762 ConstExprGenerator generator(ConstExprGenerator::Mode::Evaluate, offsetInSource, info, instance);
763 FunctionParser<ConstExprGenerator> parser(generator, constantExpression, BlockSignature { expectedType }, info);
764 WASM_FAIL_IF_HELPER_FAILS(parser.parseConstantExpression())do { auto helperResult = parser.parseConstantExpression(); if
(!helperResult) [[unlikely]] return makeUnexpected(WTF::move
(helperResult.error())); } while (0)
;
765
766 ConstExprGenerator::ExpressionType result = generator.result();
767 ASSERT(result.type() != ConstExprGenerator::ExpressionType::Vector)((void)0);
768
769 return { result.getValue() };
770}
771
772} } // namespace JSC::Wasm
773
774#endif // ENABLE(WEBASSEMBLY)