chromium/v8/src/wasm/canonical-types.cc

// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/wasm/canonical-types.h"

#include "src/execution/isolate.h"
#include "src/handles/handles-inl.h"
#include "src/heap/heap-inl.h"
#include "src/init/v8.h"
#include "src/roots/roots-inl.h"
#include "src/utils/utils.h"
#include "src/wasm/std-object-sizes.h"
#include "src/wasm/wasm-engine.h"

namespace v8::internal::wasm {

TypeCanonicalizer* GetTypeCanonicalizer() {}

TypeCanonicalizer::TypeCanonicalizer() {}

// Inside the TypeCanonicalizer, we use ValueType instances constructed
// from canonical type indices, so we can't let them get bigger than what
// we have storage space for. Code outside the TypeCanonicalizer already
// supports up to Smi range for canonical type indices.
// TODO(jkummerow): Raise this limit. Possible options:
// - increase the size of ValueType::HeapTypeField, using currently-unused bits.
// - change the encoding of ValueType: one bit says whether it's a ref type,
//   the other bits then encode the index or the kind of non-ref type.
// - refactor the TypeCanonicalizer's internals to no longer use ValueTypes
//   and related infrastructure, and use a wider encoding of canonicalized
//   type indices only here.
// - wait for 32-bit platforms to no longer be relevant, and increase the
//   size of ValueType to 64 bits.
// None of this seems urgent, as we have no evidence of the current limit
// being an actual limitation in practice.
static constexpr size_t kMaxCanonicalTypes =;
// We don't want any valid modules to fail canonicalization.
static_assert;
// We want the invalid index to fail any range checks.
static_assert;

void TypeCanonicalizer::CheckMaxCanonicalIndex() const {}

void TypeCanonicalizer::AddRecursiveGroup(WasmModule* module, uint32_t size) {}

void TypeCanonicalizer::AddRecursiveGroup(WasmModule* module, uint32_t size,
                                          uint32_t start_index) {}

void TypeCanonicalizer::AddRecursiveSingletonGroup(WasmModule* module) {}

void TypeCanonicalizer::AddRecursiveSingletonGroup(WasmModule* module,
                                                   uint32_t start_index) {}

uint32_t TypeCanonicalizer::AddRecursiveGroup(const FunctionSig* sig) {}

// It's only valid to call this for signatures that were previously registered
// with {AddRecursiveGroup(const FunctionSig* sig)}.
const FunctionSig* TypeCanonicalizer::LookupSignature(
    uint32_t canonical_index) const {}

void TypeCanonicalizer::AddPredefinedArrayTypes() {}

ValueType TypeCanonicalizer::CanonicalizeValueType(
    const WasmModule* module, ValueType type,
    uint32_t recursive_group_start) const {}

bool TypeCanonicalizer::IsCanonicalSubtype(uint32_t canonical_sub_index,
                                           uint32_t canonical_super_index) {}

bool TypeCanonicalizer::IsCanonicalSubtype(uint32_t sub_index,
                                           uint32_t super_index,
                                           const WasmModule* sub_module,
                                           const WasmModule* super_module) {}

void TypeCanonicalizer::EmptyStorageForTesting() {}

TypeCanonicalizer::CanonicalType TypeCanonicalizer::CanonicalizeTypeDef(
    const WasmModule* module, TypeDefinition type,
    uint32_t recursive_group_start) {}

// Returns the index of the canonical representative of the first type in this
// group, or -1 if an identical group does not exist.
int TypeCanonicalizer::FindCanonicalGroup(const CanonicalGroup& group) const {}

// Returns the canonical index of the given group if it already exists.
// Optionally returns the FunctionSig* providing the type definition if
// the type in the group is a function type.
int TypeCanonicalizer::FindCanonicalGroup(const CanonicalSingletonGroup& group,
                                          const FunctionSig** out_sig) const {}

size_t TypeCanonicalizer::EstimateCurrentMemoryConsumption() const {}

size_t TypeCanonicalizer::GetCurrentNumberOfTypes() const {}

// static
void TypeCanonicalizer::PrepareForCanonicalTypeId(Isolate* isolate, int id) {}

// static
void TypeCanonicalizer::ClearWasmCanonicalTypesForTesting(Isolate* isolate) {}

}  // namespace v8::internal::wasm