v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
overflowing-math.h File Reference
#include <stdint.h>
#include <cmath>
#include <type_traits>
#include "src/base/macros.h"
Include dependency graph for overflowing-math.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  v8
 
namespace  v8::base
 

Macros

#define ASSERT_SIGNED_INTEGER_TYPE(Type)
 
#define OP_WITH_WRAPAROUND(Name, OP)
 

Functions

template<>
int16_t v8::base::MulWithWraparound (int16_t a, int16_t b)
 
template<typename signed_type >
signed_type v8::base::NegateWithWraparound (signed_type a)
 
template<typename signed_type >
signed_type v8::base::ShlWithWraparound (signed_type a, signed_type b)
 
template<typename T >
T v8::base::Divide (T x, T y)
 
float v8::base::Recip (float a)
 
float v8::base::RecipSqrt (float a)
 

Macro Definition Documentation

◆ ASSERT_SIGNED_INTEGER_TYPE

#define ASSERT_SIGNED_INTEGER_TYPE ( Type)
Value:
static_assert(std::is_integral<Type>::value && std::is_signed<Type>::value, \
"use this for signed integer types");

Definition at line 20 of file overflowing-math.h.

◆ OP_WITH_WRAPAROUND

#define OP_WITH_WRAPAROUND ( Name,
OP )
Value:
template <typename signed_type> \
inline signed_type Name##WithWraparound(signed_type a, signed_type b) { \
ASSERT_SIGNED_INTEGER_TYPE(signed_type); \
using unsigned_type = typename std::make_unsigned<signed_type>::type; \
unsigned_type a_unsigned = static_cast<unsigned_type>(a); \
unsigned_type b_unsigned = static_cast<unsigned_type>(b); \
unsigned_type result = a_unsigned OP b_unsigned; \
return static_cast<signed_type>(result); \
}
std::optional< TNode< JSArray > > a
ZoneVector< RpoNumber > & result
#define OP(kType)

Definition at line 23 of file overflowing-math.h.