33 if (size == 0)
return;
39 uint32_t start_index =
static_cast<uint32_t
>(
module->types.size() - size);
55 for (uint32_t
i = 0;
i <
size;
i++) {
58 first_new_canonical_index);
61 canonical_index.
valid()) {
67 for (uint32_t
i = 0;
i <
size;
i++) {
70 module->isorecursive_canonical_type_ids[start_index + i] =
78 for (uint32_t
i = 0;
i <
size;
i++) {
85 module->isorecursive_canonical_type_ids[start_index + i] = canonical_id;
90 [=](
auto& entry) { return entry.index == first_new_canonical_index; }));
93 [=](
auto& entry) { return entry.first == first_new_canonical_index; }));
99 uint32_t type_index =
static_cast<uint32_t
>(
module->types.size() - 1);
112 module->isorecursive_canonical_type_ids[type_index] = index;
118 [=](
auto& entry) { return entry.index == new_canonical_index; }));
121 [=](
auto& entry) { return entry.first == new_canonical_index; }));
129 module->isorecursive_canonical_type_ids[type_index] = new_canonical_index;
138 const bool kFinal =
true;
156 if (index.valid())
return index;
160 sig->parameter_count());
167 canonical.function_sig = builder.
Get();
175 [=](
auto& entry) { return entry.index == new_canonical_index; }));
178 [=](
auto& entry) { return entry.first == new_canonical_index; }));
187 return new_canonical_index;
194 return type->function_sig;
201 return type->struct_type;
208 return type->array_type;
212 static constexpr std::pair<CanonicalTypeIndex, CanonicalValueType>
216 for (
auto [index, element_type] : kPredefinedArrayTypes) {
219 static constexpr bool kMutable =
true;
220 static constexpr bool kFinal =
true;
221 static constexpr bool kShared =
false;
239 if (sub_index == super_index)
return true;
249 while (sub_index.
valid()) {
250 if (sub_index == super_index)
return true;
299 DCHECK(type_index.valid());
300 if (type_index < recgroup_start) {
303 return module->canonical_type_id(type_index);
308 uint32_t new_index = canonical_recgroup_start.
index +
309 (type_index.index - recgroup_start.
index);
320 return type.Canonicalize(CanonicalizeTypeIndex(type.ref_index()));
327 const FunctionSig* original_sig = type.function_sig;
331 builder.
AddReturn(CanonicalizeValueType(ret));
334 builder.
AddParam(CanonicalizeValueType(param));
340 const StructType* original_type = type.struct_type;
351 supertype, CanonicalizeTypeIndex(type.descriptor),
352 CanonicalizeTypeIndex(type.describes), type.is_final, type.is_shared);
356 CanonicalizeValueType(type.array_type->element_type());
358 element_type, type.array_type->mutability());
364 CanonicalizeTypeIndex(type.cont_type->contfun_typeindex());
367 return CanonicalType(canonical_cont, supertype, type.is_final,
404 if (
v8_flags.trace_wasm_offheap_memory) {
418 if (!
id.valid())
return;
423 const int length =
id.index + 1;
429 int old_length = old_rtts_raw->length();
430 DCHECK_EQ(old_length, old_wrappers_raw->length());
431 if (old_length >= length)
return;
435 const int new_length = std::max(old_length * 3 / 2, length);
441 old_rtts_raw = old_wrappers_raw = {};
449 MemsetTagged(new_rtts->RawFieldOfFirstElement() + old_length,
455 MemsetTagged(new_wrappers->RawFieldOfFirstElement() + old_length,
457 heap->SetWasmCanonicalRttsAndJSToWasmWrappers(*new_rtts, *new_wrappers);
463 isolate->heap()->SetWasmCanonicalRttsAndJSToWasmWrappers(
464 roots.empty_weak_fixed_array(), roots.empty_weak_fixed_array());
#define SBXCHECK_EQ(lhs, rhs)
V8_INLINE void AssertHeld() const
size_t GetCurrentMemoryUsage() const
size_t return_count() const
base::Vector< const T > returns() const
base::Vector< const T > parameters() const
size_t parameter_count() const
static void CopyElements(Isolate *isolate, Tagged< WeakFixedArray > dst, int dst_index, Tagged< WeakFixedArray > src, int src_index, int len, WriteBarrierMode mode=kDefaultMode)
static V8_EXPORT_PRIVATE void FatalProcessOutOfMemory(Isolate *isolate, const char *location, const OOMDetails &details=kNoOOMDetails)
static Handle< WeakFixedArray > New(IsolateT *isolate, int capacity, AllocationType allocation=AllocationType::kYoung, MaybeDirectHandle< Object > initial_value={})
void Restore(Zone *zone) const
V8_WARN_UNUSED_RESULT ZoneSnapshot Snapshot() const
CanonicalSig * Get() const
static constexpr CanonicalValueType Primitive(NumericKind kind)
void AddField(ValueTypeSubclass type, bool mutability, uint32_t offset=0)
void set_total_fields_size(uint32_t size)
Subclass * Build(ComputeOffsets compute_offsets=kComputeOffsets)
bool mutability(uint32_t index) const
uint32_t field_offset(uint32_t index) const
bool is_descriptor() const
uint32_t field_count() const
uint32_t total_fields_size() const
ValueType field(uint32_t index) const
const CanonicalTypeIndex FindIndex_Slow(const CanonicalSig *sig) const
void set(CanonicalTypeIndex index, const CanonicalType *type)
void reserve(uint32_t size, Zone *zone)
V8_EXPORT_PRIVATE bool IsCanonicalSubtype(CanonicalTypeIndex sub_index, CanonicalTypeIndex super_index)
V8_EXPORT_PRIVATE void AddRecursiveSingletonGroup(WasmModule *module)
V8_EXPORT_PRIVATE const CanonicalStructType * LookupStruct(CanonicalTypeIndex index) const
V8_EXPORT_PRIVATE bool IsFunctionSignature(CanonicalTypeIndex index) const
bool IsCanonicalSubtype_Locked(CanonicalTypeIndex sub_index, CanonicalTypeIndex super_index) const
void AddPredefinedArrayTypes()
static constexpr uint32_t kNumberOfPredefinedTypes
CanonicalType CanonicalizeTypeDef(const WasmModule *module, ModuleTypeIndex module_type_idx, ModuleTypeIndex recgroup_start, CanonicalTypeIndex canonical_recgroup_start)
CanonicalTypeIndex FindIndex_Slow(const CanonicalSig *sig) const
V8_EXPORT_PRIVATE const CanonicalArrayType * LookupArray(CanonicalTypeIndex index) const
static V8_EXPORT_PRIVATE void ClearWasmCanonicalTypesForTesting(Isolate *isolate)
V8_EXPORT_PRIVATE size_t GetCurrentNumberOfTypes() const
V8_EXPORT_PRIVATE bool IsStruct(CanonicalTypeIndex index) const
void CheckMaxCanonicalIndex() const
static constexpr CanonicalTypeIndex kPredefinedArrayI16Index
CanonicalTypeIndex FindCanonicalGroup(const CanonicalGroup &) const
AccountingAllocator allocator_
bool IsHeapSubtype(CanonicalTypeIndex sub, CanonicalTypeIndex super) const
V8_EXPORT_PRIVATE bool IsArray(CanonicalTypeIndex index) const
V8_EXPORT_PRIVATE const CanonicalSig * LookupFunctionSignature(CanonicalTypeIndex index) const
V8_EXPORT_PRIVATE void AddRecursiveGroup(WasmModule *module, uint32_t size)
static V8_EXPORT_PRIVATE void PrepareForCanonicalTypeId(Isolate *isolate, CanonicalTypeIndex id)
std::unordered_set< CanonicalSingletonGroup > canonical_singleton_groups_
CanonicalTypeVector canonical_types_
std::vector< CanonicalTypeIndex > canonical_supertypes_
static constexpr CanonicalTypeIndex kPredefinedArrayI8Index
std::unordered_set< CanonicalGroup > canonical_groups_
size_t EstimateCurrentMemoryConsumption() const
V8_EXPORT_PRIVATE void EmptyStorageForTesting()
static const int kNumIndexBits
constexpr uint32_t raw_bit_field() const
static constexpr ValueType Primitive(NumericKind kind)
TypeCanonicalizer * type_canonicalizer()
ZoneVector< RpoNumber > & result
static constexpr size_t kMaxCanonicalTypes
constexpr IndependentValueType kWasmI8
TypeCanonicalizer * GetTypeCanonicalizer()
constexpr ModuleTypeIndex kNoSuperType
size_t ContentSize(const std::vector< T > &vector)
static constexpr bool kNotShared
WasmEngine * GetWasmEngine()
constexpr IndependentValueType kWasmI16
void PrintF(const char *format,...)
void MemsetTagged(Tagged_t *start, Tagged< MaybeObject > value, size_t counter)
kWasmInternalFunctionIndirectPointerTag kProtectedInstanceDataOffset sig
Tagged< ClearedWeakValue > ClearedValue(PtrComprCageBase cage_base)
V8_EXPORT_PRIVATE FlagValues v8_flags
#define DCHECK_LE(v1, v2)
#define CHECK_LT(lhs, rhs)
#define CHECK_LE(lhs, rhs)
#define DCHECK_NE(v1, v2)
#define DCHECK_GE(v1, v2)
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
#define DCHECK_GT(v1, v2)
#define UPDATE_WHEN_CLASS_CHANGES(classname, size)
static constexpr CanonicalTypeIndex Invalid()
const base::Vector< CanonicalType > types
CanonicalTypeIndex supertype
constexpr bool valid() const
std::vector< TypeDefinition > types
CanonicalTypeIndex canonical_type_id(ModuleTypeIndex index) const
#define V8_UNLIKELY(condition)