v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
wasm-compiler-definitions.h
Go to the documentation of this file.
1// Copyright 2022 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_COMPILER_WASM_COMPILER_DEFINITIONS_H_
6#define V8_COMPILER_WASM_COMPILER_DEFINITIONS_H_
7
8#if !V8_ENABLE_WEBASSEMBLY
9#error This header should only be included if WebAssembly is enabled.
10#endif // !V8_ENABLE_WEBASSEMBLY
11
12#include <ostream>
13
14#include "src/base/hashing.h"
15#include "src/base/vector.h"
20#include "src/wasm/value-type.h"
21#include "src/zone/zone.h"
22
23namespace v8 {
24namespace internal {
25
26namespace wasm {
27struct WasmModule;
28class WireBytesStorage;
29struct ModuleWireBytes;
30} // namespace wasm
31
32namespace compiler {
33class CallDescriptor;
34
35// If {to} is nullable, it means that null passes the check.
36// {from} may change in compiler optimization passes as the object's type gets
37// narrowed.
38// TODO(12166): Add modules if we have cross-module inlining.
39enum ExactOrSubtype : bool {
42};
48
49V8_INLINE std::ostream& operator<<(std::ostream& os,
50 WasmTypeCheckConfig const& p) {
51 return os << p.from.name() << " -> " << p.to.name();
52}
53
55 return base::hash_combine(p.from.raw_bit_field(), p.to.raw_bit_field());
56}
57
59 const WasmTypeCheckConfig& p2) {
60 return p1.from == p2.from && p1.to == p2.to;
61}
62
63static constexpr int kCharWidthBailoutSentinel = 3;
64
66
67enum class EnforceBoundsCheck : bool { // --
68 kNeedsBoundsCheck = true,
70};
71
72enum class AlignmentCheck : bool { // --
73 kYes = true,
74 kNo = false,
75};
76
78 // Dynamically checked (using 1-2 conditional branches).
80 // OOB handled via the trap handler.
82 // Statically known to be in bounds.
84};
85
86// Static knowledge about whether a wasm-gc operation, such as struct.get, needs
87// a null check.
89std::ostream& operator<<(std::ostream& os, CheckForNull null_check);
90
92 const wasm::WasmModule* module,
93 const wasm::WireBytesStorage* wire_bytes,
94 int index);
101
102template <typename T>
103CallDescriptor* GetWasmCallDescriptor(Zone* zone, const Signature<T>* signature,
105 bool need_frame_state = false);
106
110 WasmCallKind, bool);
111
112template <typename T>
114 bool extra_callable_param,
115 int* parameter_slots, int* return_slots) {
116 int extra_params = extra_callable_param ? 2 : 1;
117 LocationSignature::Builder locations(zone, sig->return_count(),
118 sig->parameter_count() + extra_params);
119 int untagged_parameter_slots; // Unused.
120 int untagged_return_slots; // Unused.
121 wasm::IterateSignatureImpl(sig, extra_callable_param, locations,
122 &untagged_parameter_slots, parameter_slots,
123 &untagged_return_slots, return_slots);
124 return locations.Get();
125}
126} // namespace compiler
127} // namespace internal
128} // namespace v8
129
130#endif // V8_COMPILER_WASM_COMPILER_DEFINITIONS_H_
Builtins::Kind kind
Definition builtins.cc:40
V8_EXPORT_PRIVATE std::string name() const
constexpr uint32_t raw_bit_field() const
Definition value-type.h:594
#define EXPORT_TEMPLATE_DECLARE(export)
V8_INLINE size_t hash_combine(size_t seed, size_t hash)
Definition hashing.h:77
base::Vector< const char > GetDebugName(Zone *zone, const wasm::WasmModule *module, const wasm::WireBytesStorage *wire_bytes, int index)
LocationSignature * BuildLocations(Zone *zone, const Signature< T > *sig, bool extra_callable_param, int *parameter_slots, int *return_slots)
size_t hash_value(const BranchParameters &p)
CallDescriptor * GetWasmCallDescriptor(Zone *zone, const Signature< T > *fsig, WasmCallKind call_kind, bool need_frame_state)
bool operator==(const BranchParameters &lhs, const BranchParameters &rhs)
static constexpr int kCharWidthBailoutSentinel
std::ostream & operator<<(std::ostream &os, AccessMode access_mode)
void IterateSignatureImpl(const SigType *sig, bool extra_callable_param, ResultCollector &locations, int *untagged_parameter_slots, int *total_parameter_slots, int *untagged_return_slots, int *total_return_slots)
wasm::WasmModule WasmModule
kWasmInternalFunctionIndirectPointerTag kProtectedInstanceDataOffset sig
Definition c-api.cc:87
#define V8_EXPORT_PRIVATE
Definition macros.h:460
#define V8_INLINE
Definition v8config.h:500