14namespace value_type_impl {
17#define CHECK_MASK(kind, ...) \
19 static_cast<uint32_t>(GenericKind::k##kind) == \
20 (static_cast<uint32_t>(GenericKind::k##kind) & kGenericKindMask));
23#define CHECK_MASK(kind, ...) \
25 static_cast<uint32_t>(NumericKind::k##kind) == \
26 (static_cast<uint32_t>(NumericKind::k##kind) & kNumericKindMask));
34#define CHECK_EXACT(kind, ...) \
35 static_assert(IndependentHeapType{GenericKind::k##kind}.is_exact());
46#define NUMERIC_CASE(kind, ...) \
47 case NumericKind::k##kind: \
57#define ABSTRACT_TYPE_CASE(name, code, ...) \
58 case GenericKind::k##name: \
61#undef ABSTRACT_TYPE_CASE
63#define INTERNAL_TYPE_CASE(name, code, ...) \
64 case GenericKind::k##name: \
65 if constexpr (GenericKind::k##name == GenericKind::kVoid) { \
66 return k##code##Code; \
71#undef INTERNAL_TYPE_CASE
78 std::ostringstream buf;
81#define GENERIC_CASE(kind, code, typekind, name) \
82 case GenericKind::k##kind: \
93void PrintGenericHeaptypeName(std::ostringstream& buf,
ValueTypeBase type) {
95 if (type.is_nullable()) {
97 if (
kind == GenericKind::kNone) {
102 }
else if (
kind == GenericKind::kNoExn) {
105 }
else if (
kind == GenericKind::kNoExtern) {
106 buf <<
"nullexternref";
108 }
else if (
kind == GenericKind::kNoFunc) {
109 buf <<
"nullfuncref";
111 }
else if (
kind == GenericKind::kNoCont) {
112 buf <<
"nullcontref";
116 buf << type.generic_heaptype_name();
124#define NUMERIC_CASE(kind, log2, code, mtype, shortName, name) \
125 case NumericKind::k##kind: \
132 std::ostringstream buf;
142 if (
kind == GenericKind::kNone) {
146 }
else if (
kind == GenericKind::kNoExn) {
148 }
else if (
kind == GenericKind::kNoExtern) {
149 return "nullexternref";
150 }
else if (
kind == GenericKind::kNoFunc) {
151 return "nullfuncref";
152 }
else if (
kind == GenericKind::kNoCont) {
153 return "nullcontref";
159 if (!shorthand) buf <<
"(ref ";
161 PrintGenericHeaptypeName(buf, *
this);
162 if (append_ref) buf <<
"ref";
163 if (!shorthand) buf <<
")";
174 return {return_type.
kind()};
179 if (a->return_count() != b->
return_count())
return false;
182 for (
size_t i = 0;
i < a_types.
size();
i++) {
183 if (!a_types[
i].is_numeric())
return false;
184 if (a_types[
i].
kind() != b_types[
i].
kind())
return false;
191 std::ostringstream os;
192 os <<
sig->parameter_count() <<
" parameters:\n";
193 for (
size_t i = 0;
i <
sig->parameter_count();
i++) {
194 os <<
" " <<
i <<
": " <<
sig->GetParam(
i) <<
"\n";
196 os <<
sig->return_count() <<
" returns:\n";
197 for (
size_t i = 0;
i <
sig->return_count();
i++) {
198 os <<
" " <<
i <<
": " <<
sig->GetReturn() <<
"\n";
200 PrintF(
"%s", os.str().c_str());
207 wasm::ValueType from,
209 size_t num_replacements) {
210 size_t param_occurences =
211 std::count(
sig->parameters().begin(),
sig->parameters().end(), from);
212 size_t return_occurences =
213 std::count(
sig->returns().begin(),
sig->returns().end(), from);
214 if (param_occurences == 0 && return_occurences == 0)
return sig;
217 zone,
sig->return_count() + return_occurences * (num_replacements - 1),
218 sig->parameter_count() + param_occurences * (num_replacements - 1));
220 for (wasm::ValueType ret :
sig->returns()) {
222 for (
size_t i = 0;
i < num_replacements;
i++) builder.AddReturn(to);
224 builder.AddReturn(ret);
228 for (wasm::ValueType param :
sig->parameters()) {
230 for (
size_t i = 0;
i < num_replacements;
i++) builder.AddParam(to);
232 builder.AddParam(param);
236 return builder.Get();
constexpr size_t size() const
size_t return_count() const
T GetReturn(size_t index=0) const
SignatureBuilder< Signature< T >, T > Builder
size_t parameter_count() const
base::Vector< const T > all() const
CanonicalSig * Get() const
static uint64_t Hash(const SigType *sig)
V8_EXPORT_PRIVATE ValueTypeCode value_type_code_numeric() const
V8_EXPORT_PRIVATE std::string generic_heaptype_name() const
V8_EXPORT_PRIVATE ValueTypeCode value_type_code_generic() const
constexpr TypeIndex raw_index() const
constexpr bool is_sentinel() const
constexpr NumericKind numeric_kind() const
constexpr bool is_bottom() const
constexpr ValueKind kind() const
constexpr bool is_shared() const
constexpr bool is_string_view() const
constexpr bool has_index() const
constexpr bool is_generic() const
constexpr bool is_numeric() const
constexpr bool is_nullable() const
constexpr bool is_exact() const
V8_EXPORT_PRIVATE std::string name() const
constexpr bool is_top() const
constexpr GenericKind generic_kind() const
constexpr uint32_t ToZeroBasedIndex(NumericKind kind)
bool EquivalentNumericSig(const CanonicalSig *a, const FunctionSig *b)
std::optional< wasm::ValueKind > WasmReturnTypeFromSignature(const CanonicalSig *wasm_signature)
constexpr IndependentValueType kWasmI32
const wasm::FunctionSig * GetI32Sig(Zone *zone, const wasm::FunctionSig *sig)
constexpr IndependentHeapType kWasmTop
constexpr IndependentHeapType kWasmBottom
Signature< ValueType > FunctionSig
constexpr IndependentValueType kWasmI64
void PrintF(const char *format,...)
kWasmInternalFunctionIndirectPointerTag kProtectedInstanceDataOffset sig
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
#define V8_EXPORT_PRIVATE
#define INTERNAL_TYPE_CASE(name, code,...)
#define CHECK_EXACT(kind,...)
#define NUMERIC_CASE(kind,...)
#define GENERIC_CASE(kind, code, typekind, name)
#define ABSTRACT_TYPE_CASE(name, code,...)
#define CHECK_MASK(kind,...)
#define FOREACH_NUMERIC_VALUE_TYPE(V)
#define FOREACH_ABSTRACT_TYPE(V)
#define FOREACH_NONE_TYPE(V)
#define FOREACH_INTERNAL_TYPE(V)