v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
function-body-decoder-impl.h File Reference
#include <inttypes.h>
#include <optional>
#include "src/base/bounds.h"
#include "src/base/small-vector.h"
#include "src/base/strings.h"
#include "src/base/vector.h"
#include "src/strings/unicode.h"
#include "src/utils/bit-vector.h"
#include "src/wasm/decoder.h"
#include "src/wasm/function-body-decoder.h"
#include "src/wasm/value-type.h"
#include "src/wasm/wasm-features.h"
#include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/wasm/wasm-subtyping.h"
Include dependency graph for function-body-decoder-impl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  v8::internal::wasm::ImmI32Immediate
 
struct  v8::internal::wasm::ImmI64Immediate
 
struct  v8::internal::wasm::ImmF32Immediate
 
struct  v8::internal::wasm::ImmF64Immediate
 
struct  v8::internal::wasm::BrOnCastFlags
 
struct  v8::internal::wasm::BrOnCastImmediate
 
struct  v8::internal::wasm::IndexImmediate
 
struct  v8::internal::wasm::MemoryIndexImmediate
 
struct  v8::internal::wasm::TableIndexImmediate
 
struct  v8::internal::wasm::TagIndexImmediate
 
struct  v8::internal::wasm::GlobalIndexImmediate
 
struct  v8::internal::wasm::TypeIndexImmediate
 
struct  v8::internal::wasm::SigIndexImmediate
 
struct  v8::internal::wasm::ContIndexImmediate
 
struct  v8::internal::wasm::StructIndexImmediate
 
struct  v8::internal::wasm::ArrayIndexImmediate
 
struct  v8::internal::wasm::CallFunctionImmediate
 
struct  v8::internal::wasm::SelectTypeImmediate
 
struct  v8::internal::wasm::BlockTypeImmediate
 
struct  v8::internal::wasm::BranchDepthImmediate
 
struct  v8::internal::wasm::FieldImmediate
 
struct  v8::internal::wasm::CallIndirectImmediate
 
struct  v8::internal::wasm::BranchTableImmediate
 
class  v8::internal::wasm::BranchTableIterator< ValidationTag >
 
struct  v8::internal::wasm::CatchCase
 
union  v8::internal::wasm::CatchCase::MaybeTagIndex
 
class  v8::internal::wasm::TryTableIterator< ValidationTag >
 
struct  v8::internal::wasm::HandlerCase
 
union  v8::internal::wasm::HandlerCase::MaybeHandlerDepth
 
class  v8::internal::wasm::EffectHandlerTableIterator< ValidationTag >
 
struct  v8::internal::wasm::MemoryAccessImmediate
 
struct  v8::internal::wasm::SimdLaneImmediate
 
struct  v8::internal::wasm::Simd128Immediate
 
struct  v8::internal::wasm::MemoryInitImmediate
 
struct  v8::internal::wasm::MemoryCopyImmediate
 
struct  v8::internal::wasm::TableInitImmediate
 
struct  v8::internal::wasm::TableCopyImmediate
 
struct  v8::internal::wasm::HeapTypeImmediate
 
struct  v8::internal::wasm::StringConstImmediate
 
struct  v8::internal::wasm::PcForErrors< validate >
 
struct  v8::internal::wasm::PcForErrors< true >
 
struct  v8::internal::wasm::ValueBase< ValidationTag >
 
struct  v8::internal::wasm::Merge< Value >
 
struct  v8::internal::wasm::ControlBase< Value, ValidationTag >
 
class  v8::internal::wasm::FastZoneVector< T >
 
class  v8::internal::wasm::WasmDecoder< ValidationTag, decoding_mode >
 
class  v8::internal::wasm::NoVector
 
class  v8::internal::wasm::WasmFullDecoder< ValidationTag, Interface, decoding_mode >
 
class  v8::internal::wasm::WasmFullDecoder< ValidationTag, Interface, decoding_mode >::TraceLine
 
class  v8::internal::wasm::EmptyInterface
 

Namespaces

namespace  v8
 
namespace  v8::internal
 
namespace  v8::internal::wasm
 
namespace  v8::internal::wasm::value_type_reader
 

Macros

#define TRACE(...)
 
#define TRACE_INST_FORMAT   " @%-8d #%-30s|"
 
#define VALIDATE(condition)
 
#define CHECK_PROTOTYPE_OPCODE(feat)
 
#define ATOMIC_OP_LIST(V)
 
#define ATOMIC_STORE_OP_LIST(V)
 
#define INTERFACE_FUNCTIONS(F)
 
#define INTERFACE_META_FUNCTIONS(F)
 
#define INTERFACE_CONSTANT_FUNCTIONS(F)
 
#define INTERFACE_NON_CONSTANT_FUNCTIONS(F)
 
#define DECLARE_OPCODE_CASE(name, ...)
 
#define CALL_INTERFACE(name, ...)
 
#define CALL_INTERFACE_IF_OK_AND_REACHABLE(name, ...)
 
#define CALL_INTERFACE_IF_OK_AND_PARENT_REACHABLE(name, ...)
 
#define DECODE(name)
 
#define BUILD_SIMPLE_OPCODE(op, _, sig, ...)
 
#define BUILD_SIMPLE_OPCODE(op, _, sig, ...)
 
#define SIMPLE_PROTOTYPE_CASE(name, ...)
 
#define DECODE_IMPL(opcode)
 
#define DECODE_IMPL2(opcode, name)
 
#define DECODE_IMPL_CONST(opcode)
 
#define DECODE_IMPL_CONST2(opcode, name)
 
#define BUILD_SIMPLE_OPCODE(op, ...)
 
#define BUILD_SIMPLE_EXTENDED_CONST_OPCODE(op, ...)
 
#define DECODE_LOAD_MEM(op, ...)
 
#define DECODE_STORE_MEM(op, ...)
 
#define SIMPLE_PROTOTYPE_CASE(name, ...)
 
#define NON_CONST_ONLY
 
#define CASE_ATOMIC_STORE_OP(Name, Type)
 
#define CASE_ATOMIC_OP(Name, Type)
 
#define ASMJS_CASE(Op, ...)
 
#define DEFINE_SIMPLE_SIG_OPERATOR(sig, ...)
 
#define DEFINE_EMPTY_CALLBACK(name, ...)
 

Typedefs

using v8::internal::wasm::TryTableImmediate = BranchTableImmediate
 
using v8::internal::wasm::EffectHandlerTableImmediate = BranchTableImmediate
 

Enumerations

enum  v8::internal::wasm::DecodingMode { v8::internal::wasm::kFunctionBody , v8::internal::wasm::kConstantExpression }
 
enum  v8::internal::wasm::ControlKind : uint8_t {
  v8::internal::wasm::kControlIf , v8::internal::wasm::kControlIfElse , v8::internal::wasm::kControlBlock , v8::internal::wasm::kControlLoop ,
  v8::internal::wasm::kControlTry , v8::internal::wasm::kControlTryTable , v8::internal::wasm::kControlTryCatch , v8::internal::wasm::kControlTryCatchAll
}
 
enum  v8::internal::wasm::Reachability : uint8_t { v8::internal::wasm::kReachable , v8::internal::wasm::kSpecOnlyReachable , v8::internal::wasm::kUnreachable }
 

Functions

static constexpr LoadType v8::internal::wasm::GetLoadType (WasmOpcode opcode)
 
static constexpr StoreType v8::internal::wasm::GetStoreType (WasmOpcode opcode)
 
template<typename ValidationTag , typename... Args>
V8_INLINE void v8::internal::wasm::DecodeError (Decoder *decoder, const uint8_t *pc, const char *str, Args &&... args)
 
template<typename ValidationTag , typename... Args>
V8_INLINE void v8::internal::wasm::DecodeError (Decoder *decoder, const char *str, Args &&... args)
 
template<typename ValidationTag >
std::pair< HeapType, uint32_t > v8::internal::wasm::value_type_reader::read_heap_type (Decoder *decoder, const uint8_t *pc, WasmEnabledFeatures enabled)
 
template<typename ValidationTag >
std::pair< ValueType, uint32_t > v8::internal::wasm::value_type_reader::read_value_type (Decoder *decoder, const uint8_t *pc, WasmEnabledFeatures enabled)
 
template<typename ValidationTag >
bool v8::internal::wasm::value_type_reader::ValidateHeapType (Decoder *decoder, const uint8_t *pc, const WasmModule *module, HeapType type)
 
template<typename ValidationTag >
bool v8::internal::wasm::value_type_reader::ValidateValueType (Decoder *decoder, const uint8_t *pc, const WasmModule *module, ValueType type)
 
static void v8::internal::wasm::value_type_reader::Populate (HeapType *unfinished_type, const WasmModule *module)
 
static void v8::internal::wasm::value_type_reader::Populate (ValueType *unfinished_type, const WasmModule *module)
 

Variables

const std::pair< uint32_t, uint32_t > v8::internal::wasm::invalid_instruction_trace = {0, 0}
 

Macro Definition Documentation

◆ ASMJS_CASE

#define ASMJS_CASE ( Op,
... )
Value:
case kExpr##Op:

◆ ATOMIC_OP_LIST

#define ATOMIC_OP_LIST ( V)

Definition at line 107 of file function-body-decoder-impl.h.

◆ ATOMIC_STORE_OP_LIST

#define ATOMIC_STORE_OP_LIST ( V)
Value:
V(I32AtomicStore, Uint32) \
V(I64AtomicStore, Uint64) \
V(I32AtomicStore8U, Uint8) \
V(I32AtomicStore16U, Uint16) \
V(I64AtomicStore8U, Uint8) \
V(I64AtomicStore16U, Uint16) \
V(I64AtomicStore32U, Uint32)
#define V(Name)

Definition at line 168 of file function-body-decoder-impl.h.

◆ BUILD_SIMPLE_EXTENDED_CONST_OPCODE

#define BUILD_SIMPLE_EXTENDED_CONST_OPCODE ( op,
... )
Value:
#define DECODE_IMPL_CONST(opcode)

◆ BUILD_SIMPLE_OPCODE [1/3]

#define BUILD_SIMPLE_OPCODE ( op,
_,
sig,
... )
Value:
DECODE(op) { return BuildSimpleOperator_##sig(kExpr##op); }
#define DECODE(name)

Definition at line 3344 of file function-body-decoder-impl.h.

◆ BUILD_SIMPLE_OPCODE [2/3]

#define BUILD_SIMPLE_OPCODE ( op,
_,
sig,
... )
Value:
DECODE(op) { \
if constexpr (decoding_mode == kConstantExpression) { \
this->detected_->add_extended_const(); \
} \
return BuildSimpleOperator_##sig(kExpr##op); \
}

Definition at line 3344 of file function-body-decoder-impl.h.

◆ BUILD_SIMPLE_OPCODE [3/3]

#define BUILD_SIMPLE_OPCODE ( op,
... )
Value:
#define DECODE_IMPL(opcode)

Definition at line 3344 of file function-body-decoder-impl.h.

◆ CALL_INTERFACE

#define CALL_INTERFACE ( name,
... )
Value:
do { \
DCHECK(!control_.empty()); \
DCHECK(current_code_reachable_and_ok_); \
DCHECK_EQ(current_code_reachable_and_ok_, \
this->ok() && control_.back().reachable()); \
interface_.name(this, ##__VA_ARGS__); \
} while (false)
Control control_

Definition at line 2835 of file function-body-decoder-impl.h.

◆ CALL_INTERFACE_IF_OK_AND_PARENT_REACHABLE

#define CALL_INTERFACE_IF_OK_AND_PARENT_REACHABLE ( name,
... )
Value:
do { \
DCHECK(!control_.empty()); \
if (VALIDATE(this->ok()) && \
(control_.size() == 1 || control_at(1)->reachable())) { \
interface_.name(this, ##__VA_ARGS__); \
} \
} while (false)
#define VALIDATE(condition)

Definition at line 2852 of file function-body-decoder-impl.h.

◆ CALL_INTERFACE_IF_OK_AND_REACHABLE

#define CALL_INTERFACE_IF_OK_AND_REACHABLE ( name,
... )
Value:
do { \
DCHECK(!control_.empty()); \
DCHECK_EQ(current_code_reachable_and_ok_, \
this->ok() && control_.back().reachable()); \
if (V8_LIKELY(current_code_reachable_and_ok_)) { \
interface_.name(this, ##__VA_ARGS__); \
} \
} while (false)
#define V8_LIKELY(condition)
Definition v8config.h:661

Definition at line 2843 of file function-body-decoder-impl.h.

◆ CASE_ATOMIC_OP

#define CASE_ATOMIC_OP ( Name,
Type )
Value:
case kExpr##Name: { \
memtype = MachineType::Type(); \
break; /* to generic mem access code below */ \
}

◆ CASE_ATOMIC_STORE_OP

#define CASE_ATOMIC_STORE_OP ( Name,
Type )
Value:
case kExpr##Name: { \
memtype = MachineType::Type(); \
break; /* to generic mem access code below */ \
}

◆ CHECK_PROTOTYPE_OPCODE

#define CHECK_PROTOTYPE_OPCODE ( feat)
Value:
DCHECK(this->module_->origin == kWasmOrigin); \
if (!VALIDATE(this->enabled_.has_##feat())) { \
this->DecodeError( \
"Invalid opcode 0x%02x (enable with --experimental-wasm-" #feat ")", \
opcode); \
return 0; \
} \
this->detected_->add_##feat()
#define DCHECK(condition)
Definition logging.h:482
bool enabled_
Definition string.cc:1013
const wasm::WasmModule * module_

Definition at line 63 of file function-body-decoder-impl.h.

◆ DECLARE_OPCODE_CASE

#define DECLARE_OPCODE_CASE ( name,
... )
Value:
case kExpr##name:
const char * name
Definition builtins.cc:39

◆ DECODE

#define DECODE ( name)
Value:
static int Decode##name(WasmFullDecoder* decoder, WasmOpcode opcode) { \
TraceLine trace_msg(decoder); \
return decoder->Decode##name##Impl(&trace_msg, opcode); \
} \
V8_INLINE int Decode##name##Impl(TraceLine* trace_msg, WasmOpcode opcode)
#define V8_INLINE
Definition v8config.h:500

Definition at line 3321 of file function-body-decoder-impl.h.

◆ DECODE_IMPL

#define DECODE_IMPL ( opcode)
Value:
DECODE_IMPL2(kExpr##opcode, opcode)
#define DECODE_IMPL2(opcode, name)

Definition at line 4520 of file function-body-decoder-impl.h.

◆ DECODE_IMPL2

#define DECODE_IMPL2 ( opcode,
name )
Value:
if (idx == opcode) { \
if constexpr (decoding_mode == kConstantExpression) { \
return &WasmFullDecoder::NonConstError; \
} else { \
return &WasmFullDecoder::Decode##name; \
} \
}

Definition at line 4521 of file function-body-decoder-impl.h.

◆ DECODE_IMPL_CONST

#define DECODE_IMPL_CONST ( opcode)
Value:
DECODE_IMPL_CONST2(kExpr##opcode, opcode)
#define DECODE_IMPL_CONST2(opcode, name)

Definition at line 4529 of file function-body-decoder-impl.h.

◆ DECODE_IMPL_CONST2

#define DECODE_IMPL_CONST2 ( opcode,
name )
Value:
if (idx == opcode) return &WasmFullDecoder::Decode##name

Definition at line 4530 of file function-body-decoder-impl.h.

◆ DECODE_LOAD_MEM

#define DECODE_LOAD_MEM ( op,
... )
Value:
DECODE_IMPL2(kExpr##op, LoadMem);

◆ DECODE_STORE_MEM

#define DECODE_STORE_MEM ( op,
... )
Value:
DECODE_IMPL2(kExpr##op, StoreMem);

◆ DEFINE_EMPTY_CALLBACK

#define DEFINE_EMPTY_CALLBACK ( name,
... )
Value:
void name(FullDecoder* decoder, ##__VA_ARGS__) {}

Definition at line 7116 of file function-body-decoder-impl.h.

◆ DEFINE_SIMPLE_SIG_OPERATOR

#define DEFINE_SIMPLE_SIG_OPERATOR ( sig,
... )
Value:
int BuildSimpleOperator_##sig(WasmOpcode opcode) { \
return BuildSimpleOperator(opcode, __VA_ARGS__); \
}

Definition at line 7097 of file function-body-decoder-impl.h.

◆ INTERFACE_CONSTANT_FUNCTIONS

#define INTERFACE_CONSTANT_FUNCTIONS ( F)
Value:
/* force 80 columns */ \
F(I32Const, Value* result, int32_t value) \
F(I64Const, Value* result, int64_t value) \
F(F32Const, Value* result, float value) \
F(F64Const, Value* result, double value) \
F(S128Const, const Simd128Immediate& imm, Value* result) \
F(GlobalGet, Value* result, const GlobalIndexImmediate& imm) \
F(DoReturn, uint32_t drop_values) \
F(UnOp, WasmOpcode opcode, const Value& value, Value* result) \
F(BinOp, WasmOpcode opcode, const Value& lhs, const Value& rhs, \
Value* result) \
F(RefNull, ValueType type, Value* result) \
F(RefFunc, uint32_t function_index, Value* result) \
F(StructNew, const StructIndexImmediate& imm, const Value& descriptor, \
const Value args[], Value* result) \
F(StructNewDefault, const StructIndexImmediate& imm, \
const Value& descriptor, Value* result) \
F(ArrayNew, const ArrayIndexImmediate& imm, const Value& length, \
const Value& initial_value, Value* result) \
F(ArrayNewDefault, const ArrayIndexImmediate& imm, const Value& length, \
Value* result) \
F(ArrayNewFixed, const ArrayIndexImmediate& imm, \
const IndexImmediate& length_imm, const Value elements[], Value* result) \
F(ArrayNewSegment, const ArrayIndexImmediate& array_imm, \
const IndexImmediate& data_segment, const Value& offset, \
const Value& length, Value* result) \
F(RefI31, const Value& input, Value* result) \
F(StringConst, const StringConstImmediate& imm, Value* result)
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
int32_t offset
ZoneVector< RpoNumber > & result

Definition at line 1288 of file function-body-decoder-impl.h.

◆ INTERFACE_FUNCTIONS

#define INTERFACE_FUNCTIONS ( F)
Value:
INTERFACE_CONSTANT_FUNCTIONS(F) \
INTERFACE_NON_CONSTANT_FUNCTIONS(F)
#define F(name, str)
#define INTERFACE_META_FUNCTIONS(F)

Definition at line 1275 of file function-body-decoder-impl.h.

◆ INTERFACE_META_FUNCTIONS

#define INTERFACE_META_FUNCTIONS ( F)
Value:
F(TraceInstruction, uint32_t value) \
F(StartFunction) \
F(StartFunctionBody, Control* block) \
F(FinishFunction) \
F(OnFirstError) \
F(NextInstruction, WasmOpcode)

Definition at line 1280 of file function-body-decoder-impl.h.

◆ INTERFACE_NON_CONSTANT_FUNCTIONS

#define INTERFACE_NON_CONSTANT_FUNCTIONS ( F)

Definition at line 1317 of file function-body-decoder-impl.h.

◆ NON_CONST_ONLY

#define NON_CONST_ONLY
Value:
if constexpr (decoding_mode == kConstantExpression) { \
this->DecodeError("opcode %s is not allowed in constant expressions", \
this->SafeOpcodeNameAt(this->pc())); \
return 0; \
}

Definition at line 5156 of file function-body-decoder-impl.h.

◆ SIMPLE_PROTOTYPE_CASE [1/2]

#define SIMPLE_PROTOTYPE_CASE ( name,
... )
Value:
DECODE(name) { return BuildSimplePrototypeOperator(opcode); }

Definition at line 4494 of file function-body-decoder-impl.h.

◆ SIMPLE_PROTOTYPE_CASE [2/2]

#define SIMPLE_PROTOTYPE_CASE ( name,
... )
Value:

Definition at line 4494 of file function-body-decoder-impl.h.

◆ TRACE

#define TRACE ( ...)
Value:
do { \
if (v8_flags.trace_wasm_decoder) PrintF(__VA_ARGS__); \
} while (false)

Definition at line 39 of file function-body-decoder-impl.h.

◆ TRACE_INST_FORMAT

#define TRACE_INST_FORMAT   " @%-8d #%-30s|"

Definition at line 44 of file function-body-decoder-impl.h.

◆ VALIDATE

#define VALIDATE ( condition)
Value:
(!ValidationTag::validate || V8_LIKELY(condition))

Definition at line 60 of file function-body-decoder-impl.h.