chromium/v8/src/wasm/wasm-module.cc

// Copyright 2015 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/wasm-module.h"

#include <functional>
#include <memory>

#include "src/api/api-inl.h"
#include "src/compiler/wasm-compiler.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/objects.h"
#include "src/wasm/jump-table-assembler.h"
#include "src/wasm/module-decoder.h"
#include "src/wasm/std-object-sizes.h"
#include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-init-expr.h"
#include "src/wasm/wasm-js.h"
#include "src/wasm/wasm-module-builder.h"  // For {ZoneBuffer}.
#include "src/wasm/wasm-objects-inl.h"
#include "src/wasm/wasm-result.h"
#include "src/wasm/wasm-subtyping.h"

namespace v8::internal::wasm {

// Ensure that the max subtyping depth can be stored in the TypeDefinition.
static_assert;

// static
int WasmMemory::GetMemory64GuardsShift(uint64_t max_memory_size) {}

template <class Value>
void AdaptiveMap<Value>::FinishInitialization() {}
template void NameMap::FinishInitialization();
template void IndirectNameMap::FinishInitialization();

WireBytesRef LazilyGeneratedNames::LookupFunctionName(
    ModuleWireBytes wire_bytes, uint32_t function_index) {}

bool LazilyGeneratedNames::Has(uint32_t function_index) {}

// static
int GetWasmFunctionOffset(const WasmModule* module, uint32_t func_index) {}

// static
int GetNearestWasmFunction(const WasmModule* module, uint32_t byte_offset) {}

// static
int GetContainingWasmFunction(const WasmModule* module, uint32_t byte_offset) {}

int GetSubtypingDepth(const WasmModule* module, uint32_t type_index) {}

void LazilyGeneratedNames::AddForTesting(int function_index,
                                         WireBytesRef name) {}

AsmJsOffsetInformation::AsmJsOffsetInformation(
    base::Vector<const uint8_t> encoded_offsets)
    :{}

AsmJsOffsetInformation::~AsmJsOffsetInformation() = default;

int AsmJsOffsetInformation::GetSourcePosition(int declared_func_index,
                                              int byte_offset,
                                              bool is_at_number_conversion) {}

std::pair<int, int> AsmJsOffsetInformation::GetFunctionOffsets(
    int declared_func_index) {}

void AsmJsOffsetInformation::EnsureDecodedOffsets() {}

// Get a string stored in the module bytes representing a name.
WasmName ModuleWireBytes::GetNameOrNull(WireBytesRef ref) const {}

// Get a string stored in the module bytes representing a function name.
WasmName ModuleWireBytes::GetNameOrNull(int func_index,
                                        const WasmModule* module) const {}

std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name) {}

WasmModule::WasmModule(ModuleOrigin origin)
    :{}

bool IsWasmCodegenAllowed(Isolate* isolate, Handle<NativeContext> context) {}

DirectHandle<String> ErrorStringForCodegen(Isolate* isolate,
                                           DirectHandle<Context> context) {}

namespace {

// Converts the given {type} into a string representation that can be used in
// reflective functions. Should be kept in sync with the {GetValueType} helper.
Handle<String> ToValueTypeString(Isolate* isolate, ValueType type) {}
}  // namespace

Handle<JSObject> GetTypeForFunction(Isolate* isolate, const FunctionSig* sig,
                                    bool for_exception) {}

Handle<JSObject> GetTypeForGlobal(Isolate* isolate, bool is_mutable,
                                  ValueType type) {}

Handle<JSObject> GetTypeForMemory(Isolate* isolate, uint32_t min_size,
                                  std::optional<uint32_t> max_size, bool shared,
                                  bool is_memory64) {}

Handle<JSObject> GetTypeForTable(Isolate* isolate, ValueType type,
                                 uint32_t min_size,
                                 std::optional<uint32_t> max_size,
                                 bool is_table64) {}

Handle<JSArray> GetImports(Isolate* isolate,
                           DirectHandle<WasmModuleObject> module_object) {}

Handle<JSArray> GetExports(Isolate* isolate,
                           DirectHandle<WasmModuleObject> module_object) {}

Handle<JSArray> GetCustomSections(Isolate* isolate,
                                  DirectHandle<WasmModuleObject> module_object,
                                  DirectHandle<String> name,
                                  ErrorThrower* thrower) {}

// Get the source position from a given function index and wire bytes offset
// (relative to the function entry), for either asm.js or pure Wasm modules.
int GetSourcePosition(const WasmModule* module, uint32_t func_index,
                      uint32_t byte_offset, bool is_at_number_conversion) {}

size_t WasmModule::EstimateStoredSize() const {}

template <class Value>
size_t AdaptiveMap<Value>::EstimateCurrentMemoryConsumption() const {}

template <>
size_t NameMap::EstimateCurrentMemoryConsumption() const {}

size_t LazilyGeneratedNames::EstimateCurrentMemoryConsumption() const {}

template <>
size_t IndirectNameMap::EstimateCurrentMemoryConsumption() const {
  size_t result = ContentSize(vector_);
  for (const auto& inner_map : vector_) {
    result += inner_map.EstimateCurrentMemoryConsumption();
  }
  if (map_) {
    result += ContentSize(*map_);
    for (const auto& [outer_index, inner_map] : *map_) {
      result += inner_map.EstimateCurrentMemoryConsumption();
    }
  }
  return result;
}

size_t TypeFeedbackStorage::EstimateCurrentMemoryConsumption() const {}

size_t WasmModule::EstimateCurrentMemoryConsumption() const {}

size_t PrintSignature(base::Vector<char> buffer, const wasm::FunctionSig* sig,
                      char delimiter) {}

int JumpTableOffset(const WasmModule* module, int func_index) {}

size_t GetWireBytesHash(base::Vector<const uint8_t> wire_bytes) {}

int NumFeedbackSlots(const WasmModule* module, int func_index) {}

}  // namespace v8::internal::wasm