#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits>
#include "src/base/bits.h"
#include "src/base/ieee754.h"
#include "src/base/safe_conversions.h"
#include "src/common/assert-scope.h"
#include "src/execution/pointer-authentication.h"
#include "src/numbers/conversions.h"
#include "src/roots/roots-inl.h"
#include "src/utils/memcopy.h"
#include "src/wasm/float16.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-objects-inl.h"
#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
defined(THREAD_SANITIZER) || defined(LEAK_SANITIZER) || \
defined(UNDEFINED_SANITIZER)
#define V8_WITH_SANITIZER
#endif
#if defined(V8_OS_WIN) && defined(V8_WITH_SANITIZER)
#define RESET_THREAD_IN_WASM_FLAG_FOR_ASAN_ON_WINDOWS
#include "src/trap-handler/trap-handler.h"
#endif
#include "src/base/memory.h"
#include "src/base/overflowing-math.h"
#include "src/utils/utils.h"
#include "src/wasm/wasm-external-refs.h"
namespace v8::internal::wasm {
ReadUnalignedValue;
WriteUnalignedValue;
void f32_trunc_wrapper(Address data) { … }
void f32_floor_wrapper(Address data) { … }
void f32_ceil_wrapper(Address data) { … }
void f32_nearest_int_wrapper(Address data) { … }
void f64_trunc_wrapper(Address data) { … }
void f64_floor_wrapper(Address data) { … }
void f64_ceil_wrapper(Address data) { … }
void f64_nearest_int_wrapper(Address data) { … }
void int64_to_float32_wrapper(Address data) { … }
void uint64_to_float32_wrapper(Address data) { … }
void int64_to_float64_wrapper(Address data) { … }
void uint64_to_float64_wrapper(Address data) { … }
int32_t float32_to_int64_wrapper(Address data) { … }
int32_t float32_to_uint64_wrapper(Address data) { … }
int32_t float64_to_int64_wrapper(Address data) { … }
int32_t float64_to_uint64_wrapper(Address data) { … }
void float32_to_int64_sat_wrapper(Address data) { … }
void float32_to_uint64_sat_wrapper(Address data) { … }
void float64_to_int64_sat_wrapper(Address data) { … }
void float64_to_uint64_sat_wrapper(Address data) { … }
void float16_to_float32_wrapper(Address data) { … }
void float32_to_float16_wrapper(Address data) { … }
int32_t int64_div_wrapper(Address data) { … }
int32_t int64_mod_wrapper(Address data) { … }
int32_t uint64_div_wrapper(Address data) { … }
int32_t uint64_mod_wrapper(Address data) { … }
uint32_t word32_rol_wrapper(uint32_t input, uint32_t shift) { … }
uint32_t word32_ror_wrapper(uint32_t input, uint32_t shift) { … }
uint64_t word64_rol_wrapper(uint64_t input, uint32_t shift) { … }
uint64_t word64_ror_wrapper(uint64_t input, uint32_t shift) { … }
void float64_pow_wrapper(Address data) { … }
template <typename T, T (*float_round_op)(T)>
void simd_float_round_wrapper(Address data) { … }
void f64x2_ceil_wrapper(Address data) { … }
void f64x2_floor_wrapper(Address data) { … }
void f64x2_trunc_wrapper(Address data) { … }
void f64x2_nearest_int_wrapper(Address data) { … }
void f32x4_ceil_wrapper(Address data) { … }
void f32x4_floor_wrapper(Address data) { … }
void f32x4_trunc_wrapper(Address data) { … }
void f32x4_nearest_int_wrapper(Address data) { … }
Float16 f16_abs(Float16 a) { … }
void f16x8_abs_wrapper(Address data) { … }
Float16 f16_neg(Float16 a) { … }
void f16x8_neg_wrapper(Address data) { … }
Float16 f16_sqrt(Float16 a) { … }
void f16x8_sqrt_wrapper(Address data) { … }
Float16 f16_ceil(Float16 a) { … }
void f16x8_ceil_wrapper(Address data) { … }
Float16 f16_floor(Float16 a) { … }
void f16x8_floor_wrapper(Address data) { … }
Float16 f16_trunc(Float16 a) { … }
void f16x8_trunc_wrapper(Address data) { … }
Float16 f16_nearest_int(Float16 a) { … }
void f16x8_nearest_int_wrapper(Address data) { … }
template <typename R, R (*float_bin_op)(Float16, Float16)>
void simd_float16_bin_wrapper(Address data) { … }
int16_t f16_eq(Float16 a, Float16 b) { … }
void f16x8_eq_wrapper(Address data) { … }
int16_t f16_ne(Float16 a, Float16 b) { … }
void f16x8_ne_wrapper(Address data) { … }
int16_t f16_lt(Float16 a, Float16 b) { … }
void f16x8_lt_wrapper(Address data) { … }
int16_t f16_le(Float16 a, Float16 b) { … }
void f16x8_le_wrapper(Address data) { … }
Float16 f16_add(Float16 a, Float16 b) { … }
void f16x8_add_wrapper(Address data) { … }
Float16 f16_sub(Float16 a, Float16 b) { … }
void f16x8_sub_wrapper(Address data) { … }
Float16 f16_mul(Float16 a, Float16 b) { … }
void f16x8_mul_wrapper(Address data) { … }
Float16 f16_div(Float16 a, Float16 b) { … }
void f16x8_div_wrapper(Address data) { … }
Float16 f16_min(Float16 a, Float16 b) { … }
void f16x8_min_wrapper(Address data) { … }
Float16 f16_max(Float16 a, Float16 b) { … }
void f16x8_max_wrapper(Address data) { … }
Float16 f16_pmin(Float16 a, Float16 b) { … }
void f16x8_pmin_wrapper(Address data) { … }
Float16 f16_pmax(Float16 a, Float16 b) { … }
void f16x8_pmax_wrapper(Address data) { … }
template <typename T, typename R, R (*float_un_op)(T)>
void simd_float_un_wrapper(Address data) { … }
int16_t ConvertToIntS(Float16 val) { … }
uint16_t ConvertToIntU(Float16 val) { … }
void i16x8_sconvert_f16x8_wrapper(Address data) { … }
void i16x8_uconvert_f16x8_wrapper(Address data) { … }
Float16 ConvertToF16S(int16_t val) { … }
void f16x8_sconvert_i16x8_wrapper(Address data) { … }
Float16 ConvertToF16U(uint16_t val) { … }
void f16x8_uconvert_i16x8_wrapper(Address data) { … }
void f32x4_promote_low_f16x8_wrapper(Address data) { … }
void f16x8_demote_f32x4_zero_wrapper(Address data) { … }
void f16x8_demote_f64x2_zero_wrapper(Address data) { … }
template <float (*float_fma_op)(float, float, float)>
void simd_float16_fma_wrapper(Address data) { … }
float Qfma(float a, float b, float c) { … }
void f16x8_qfma_wrapper(Address data) { … }
float Qfms(float a, float b, float c) { … }
void f16x8_qfms_wrapper(Address data) { … }
namespace {
class V8_NODISCARD ThreadNotInWasmScope { … };
inline uint8_t* EffectiveAddress(Tagged<WasmTrustedInstanceData> trusted_data,
uint32_t mem_index, uintptr_t index) { … }
template <typename V>
V ReadAndIncrementOffset(Address data, size_t* offset) { … }
constexpr int32_t kSuccess = …;
constexpr int32_t kOutOfBounds = …;
}
int32_t memory_init_wrapper(Address trusted_data_addr, uint32_t mem_index,
uintptr_t dst, uint32_t src, uint32_t seg_index,
uint32_t size) { … }
int32_t memory_copy_wrapper(Address trusted_data_addr, uint32_t dst_mem_index,
uint32_t src_mem_index, uintptr_t dst,
uintptr_t src, uintptr_t size) { … }
int32_t memory_fill_wrapper(Address trusted_data_addr, uint32_t mem_index,
uintptr_t dst, uint8_t value, uintptr_t size) { … }
namespace {
inline void* ArrayElementAddress(Address array, uint32_t index,
int element_size_bytes) { … }
inline void* ArrayElementAddress(Tagged<WasmArray> array, uint32_t index,
int element_size_bytes) { … }
}
void array_copy_wrapper(Address raw_dst_array, uint32_t dst_index,
Address raw_src_array, uint32_t src_index,
uint32_t length) { … }
void array_fill_wrapper(Address raw_array, uint32_t index, uint32_t length,
uint32_t emit_write_barrier, uint32_t raw_type,
Address initial_value_addr) { … }
double flat_string_to_f64(Address string_address) { … }
void sync_stack_limit(Isolate* isolate) { … }
void return_switch(Isolate* isolate, Address raw_continuation) { … }
intptr_t switch_to_the_central_stack(Isolate* isolate, uintptr_t current_sp) { … }
void switch_from_the_central_stack(Isolate* isolate) { … }
intptr_t switch_to_the_central_stack_for_js(Isolate* isolate, Address fp) { … }
void switch_from_the_central_stack_for_js(Isolate* isolate) { … }
Address grow_stack(Isolate* isolate, void* current_sp, size_t frame_size,
size_t gap, Address current_fp) { … }
Address shrink_stack(Isolate* isolate) { … }
Address load_old_fp(Isolate* isolate) { … }
}
#undef V8_WITH_SANITIZER
#undef RESET_THREAD_IN_WASM_FLAG_FOR_ASAN_ON_WINDOWS