chromium/v8/src/wasm/wasm-constants.h

// 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.

#if !V8_ENABLE_WEBASSEMBLY
#error This header should only be included if WebAssembly is enabled.
#endif  // !V8_ENABLE_WEBASSEMBLY

#ifndef V8_WASM_WASM_CONSTANTS_H_
#define V8_WASM_WASM_CONSTANTS_H_

#include <cstddef>
#include <cstdint>

#include "src/common/globals.h"

namespace v8 {
namespace internal {
namespace wasm {

// Binary encoding of the module header.
constexpr uint32_t kWasmMagic =;
constexpr uint32_t kWasmVersion =;

// Binary encoding of value and heap types.
enum ValueTypeCode : uint8_t {};

// Binary encoding of type definitions.
constexpr uint8_t kSharedFlagCode =;
constexpr uint8_t kWasmFunctionTypeCode =;
constexpr uint8_t kWasmStructTypeCode =;
constexpr uint8_t kWasmArrayTypeCode =;
constexpr uint8_t kWasmSubtypeCode =;
constexpr uint8_t kWasmSubtypeFinalCode =;
constexpr uint8_t kWasmRecursiveTypeGroupCode =;

// Binary encoding of import/export kinds.
enum ImportExportKindCode : uint8_t {};

// The limits structure: valid for both memory and table limits.
enum LimitsFlags : uint8_t {};

// Flags for data and element segments.
enum SegmentFlags : uint8_t {};

// Binary encoding of sections identifiers.
enum SectionCode : int8_t {};

// Binary encoding of compilation hints.
constexpr uint8_t kDefaultCompilationHint =;
constexpr uint8_t kNoCompilationHint =;

// Binary encoding of name section kinds.
enum NameSectionKindCode : uint8_t {};

enum CatchKind : uint8_t {};

constexpr size_t kWasmPageSize =;
constexpr uint32_t kWasmPageSizeLog2 =;
static_assert;

// TODO(wasm): Wrap WasmCodePosition in a struct.
WasmCodePosition;
constexpr WasmCodePosition kNoCodePosition =;

constexpr uint32_t kExceptionAttribute =;

constexpr int kAnonymousFuncIndex =;

// This needs to survive round-tripping through a Smi without changing
// its value.
constexpr uint32_t kInvalidCanonicalIndex =;
static_assert;

// The number of calls to an exported Wasm function that will be handled
// by the generic wrapper. Once the budget is exhausted, a specific wrapper
// is to be compiled for the function's signature.
// The abstract goal of the tiering strategy for the js-to-wasm wrappers is to
// use the generic wrapper as much as possible (less space, no need to compile),
// but fall back to compiling a specific wrapper for any function (signature)
// that is used often enough for the generic wrapper's small execution penalty
// to start adding up.
// So, when choosing a value for the initial budget, we are interested in a
// value that skips on tiering up functions that are called only a few times and
// the tier-up only wastes resources, but triggers compilation of specific
// wrappers early on for those functions that have the potential to be called
// often enough.
constexpr uint32_t kGenericWrapperBudget =;

// The minimum length of supertype arrays for wasm-gc types. Having a size > 0
// gives up some module size for faster access to the supertypes.
constexpr uint32_t kMinimumSupertypeArraySize =;

// Maximum number of call targets tracked per call.
constexpr int kMaxPolymorphism =;

// A struct field beyond this limit needs an explicit null check (trapping null
// access not guaranteed to behave properly).
constexpr int kMaxStructFieldIndexForImplicitNullCheck =;

#if V8_TARGET_ARCH_X64
constexpr int32_t kOSRTargetOffset =;
#endif

}  // namespace wasm
}  // namespace internal
}  // namespace v8

#endif  // V8_WASM_WASM_CONSTANTS_H_