diff options
author | Michaƫl Zasso <targos@protonmail.com> | 2017-09-12 11:34:59 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-09-13 16:15:18 +0200 |
commit | d82e1075dbc2cec2d6598ade10c1f43805f690fd (patch) | |
tree | ccd242b9b491dfc341d1099fe11b0ef528839877 /deps/v8/src/base/logging.h | |
parent | b4b7ac6ae811b2b5a3082468115dfb5a5246fe3f (diff) | |
download | android-node-v8-d82e1075dbc2cec2d6598ade10c1f43805f690fd.tar.gz android-node-v8-d82e1075dbc2cec2d6598ade10c1f43805f690fd.tar.bz2 android-node-v8-d82e1075dbc2cec2d6598ade10c1f43805f690fd.zip |
deps: update V8 to 6.1.534.36
PR-URL: https://github.com/nodejs/node/pull/14730
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'deps/v8/src/base/logging.h')
-rw-r--r-- | deps/v8/src/base/logging.h | 126 |
1 files changed, 92 insertions, 34 deletions
diff --git a/deps/v8/src/base/logging.h b/deps/v8/src/base/logging.h index 6e54508d43..1e6e7a3091 100644 --- a/deps/v8/src/base/logging.h +++ b/deps/v8/src/base/logging.h @@ -13,7 +13,7 @@ #include "src/base/build_config.h" #include "src/base/compiler-specific.h" -extern "C" PRINTF_FORMAT(3, 4) V8_NORETURN V8_BASE_EXPORT +[[noreturn]] PRINTF_FORMAT(3, 4) V8_BASE_EXPORT void V8_Fatal(const char* file, int line, const char* format, ...); // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during @@ -56,6 +56,14 @@ V8_BASE_EXPORT void SetPrintStackTrace(void (*print_stack_trace_)()); #ifdef DEBUG +#define DCHECK_WITH_MSG(condition, message) \ + do { \ + if (V8_UNLIKELY(!(condition))) { \ + V8_Fatal(__FILE__, __LINE__, "Debug check failed: %s.", message); \ + } \ + } while (0) +#define DCHECK(condition) DCHECK_WITH_MSG(condition, #condition) + // Helper macro for binary operators. // Don't use this macro directly in your code, use CHECK_EQ et al below. #define CHECK_OP(name, op, lhs, rhs) \ @@ -68,6 +76,16 @@ V8_BASE_EXPORT void SetPrintStackTrace(void (*print_stack_trace_)()); } \ } while (0) +#define DCHECK_OP(name, op, lhs, rhs) \ + do { \ + if (std::string* _msg = \ + ::v8::base::Check##name##Impl<decltype(lhs), decltype(rhs)>( \ + (lhs), (rhs), #lhs " " #op " " #rhs)) { \ + V8_Fatal(__FILE__, __LINE__, "Debug check failed: %s.", _msg->c_str()); \ + delete _msg; \ + } \ + } while (0) + #else // Make all CHECK functions discard their log strings to reduce code @@ -91,6 +109,27 @@ struct PassType : public std::conditional< std::is_scalar<typename std::decay<T>::type>::value, typename std::decay<T>::type, T const&> {}; +template <typename Op> +void PrintCheckOperand(std::ostream& os, Op op) { + os << op; +} + +// Define specializations for character types, defined in logging.cc. +#define DEFINE_PRINT_CHECK_OPERAND_CHAR(type) \ + template <> \ + V8_BASE_EXPORT void PrintCheckOperand<type>(std::ostream & os, type ch); \ + template <> \ + V8_BASE_EXPORT void PrintCheckOperand<type*>(std::ostream & os, \ + type * cstr); \ + template <> \ + V8_BASE_EXPORT void PrintCheckOperand<const type*>(std::ostream & os, \ + const type* cstr); + +DEFINE_PRINT_CHECK_OPERAND_CHAR(char) +DEFINE_PRINT_CHECK_OPERAND_CHAR(signed char) +DEFINE_PRINT_CHECK_OPERAND_CHAR(unsigned char) +#undef DEFINE_PRINT_CHECK_OPERAND_CHAR + // Build the error message string. This is separate from the "Impl" // function template because it is not performance critical and so can // be out of line, while the "Impl" code should be inline. Caller @@ -100,35 +139,55 @@ std::string* MakeCheckOpString(typename PassType<Lhs>::type lhs, typename PassType<Rhs>::type rhs, char const* msg) { std::ostringstream ss; - ss << msg << " (" << lhs << " vs. " << rhs << ")"; + ss << msg << " ("; + PrintCheckOperand(ss, lhs); + ss << " vs. "; + PrintCheckOperand(ss, rhs); + ss << ")"; return new std::string(ss.str()); } // Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated // in logging.cc. -#define DEFINE_MAKE_CHECK_OP_STRING(type) \ +#define EXPLICIT_CHECK_OP_INSTANTIATION(type) \ extern template V8_BASE_EXPORT std::string* MakeCheckOpString<type, type>( \ - type, type, char const*); -DEFINE_MAKE_CHECK_OP_STRING(int) -DEFINE_MAKE_CHECK_OP_STRING(long) // NOLINT(runtime/int) -DEFINE_MAKE_CHECK_OP_STRING(long long) // NOLINT(runtime/int) -DEFINE_MAKE_CHECK_OP_STRING(unsigned int) -DEFINE_MAKE_CHECK_OP_STRING(unsigned long) // NOLINT(runtime/int) -DEFINE_MAKE_CHECK_OP_STRING(unsigned long long) // NOLINT(runtime/int) -DEFINE_MAKE_CHECK_OP_STRING(char const*) -DEFINE_MAKE_CHECK_OP_STRING(void const*) -#undef DEFINE_MAKE_CHECK_OP_STRING + type, type, char const*); \ + extern template V8_BASE_EXPORT void PrintCheckOperand<type>(std::ostream&, \ + type); + +EXPLICIT_CHECK_OP_INSTANTIATION(int) +EXPLICIT_CHECK_OP_INSTANTIATION(long) // NOLINT(runtime/int) +EXPLICIT_CHECK_OP_INSTANTIATION(long long) // NOLINT(runtime/int) +EXPLICIT_CHECK_OP_INSTANTIATION(unsigned int) +EXPLICIT_CHECK_OP_INSTANTIATION(unsigned long) // NOLINT(runtime/int) +EXPLICIT_CHECK_OP_INSTANTIATION(unsigned long long) // NOLINT(runtime/int) +EXPLICIT_CHECK_OP_INSTANTIATION(void const*) +#undef EXPLICIT_CHECK_OP_INSTANTIATION + +// comparison_underlying_type provides the underlying integral type of an enum, +// or std::decay<T>::type if T is not an enum. +template <typename T> +struct comparison_underlying_type { + // std::underlying_type must only be used with enum types, thus use this + // {Dummy} type if the given type is not an enum. + enum Dummy {}; + using decay = typename std::decay<T>::type; + static constexpr bool is_enum = std::is_enum<decay>::value; + using underlying = typename std::underlying_type< + typename std::conditional<is_enum, decay, Dummy>::type>::type; + using type = typename std::conditional<is_enum, underlying, decay>::type; +}; // is_signed_vs_unsigned::value is true if both types are integral, Lhs is // signed, and Rhs is unsigned. False in all other cases. template <typename Lhs, typename Rhs> struct is_signed_vs_unsigned { - enum : bool { - value = std::is_integral<typename std::decay<Lhs>::type>::value && - std::is_integral<typename std::decay<Rhs>::type>::value && - std::is_signed<typename std::decay<Lhs>::type>::value && - std::is_unsigned<typename std::decay<Rhs>::type>::value - }; + using lhs_underlying = typename comparison_underlying_type<Lhs>::type; + using rhs_underlying = typename comparison_underlying_type<Rhs>::type; + static constexpr bool value = std::is_integral<lhs_underlying>::value && + std::is_integral<rhs_underlying>::value && + std::is_signed<lhs_underlying>::value && + std::is_unsigned<rhs_underlying>::value; }; // Same thing, other way around: Lhs is unsigned, Rhs signed. template <typename Lhs, typename Rhs> @@ -137,14 +196,13 @@ struct is_unsigned_vs_signed : public is_signed_vs_unsigned<Rhs, Lhs> {}; // Specialize the compare functions for signed vs. unsigned comparisons. // std::enable_if ensures that this template is only instantiable if both Lhs // and Rhs are integral types, and their signedness does not match. -#define MAKE_UNSIGNED(Type, value) \ - static_cast< \ - typename std::make_unsigned<typename std::decay<Type>::type>::type>( \ - value) +#define MAKE_UNSIGNED(Type, value) \ + static_cast<typename std::make_unsigned< \ + typename comparison_underlying_type<Type>::type>::type>(value) #define DEFINE_SIGNED_MISMATCH_COMP(CHECK, NAME, IMPL) \ template <typename Lhs, typename Rhs> \ V8_INLINE typename std::enable_if<CHECK<Lhs, Rhs>::value, bool>::type \ - Cmp##NAME##Impl(Lhs const& lhs, Rhs const& rhs) { \ + Cmp##NAME##Impl(Lhs lhs, Rhs rhs) { \ return IMPL; \ } DEFINE_SIGNED_MISMATCH_COMP(is_signed_vs_unsigned, EQ, @@ -221,16 +279,16 @@ DEFINE_CHECK_OP_IMPL(GT, > ) // The DCHECK macro is equivalent to CHECK except that it only // generates code in debug builds. #ifdef DEBUG -#define DCHECK(condition) CHECK(condition) -#define DCHECK_EQ(v1, v2) CHECK_EQ(v1, v2) -#define DCHECK_NE(v1, v2) CHECK_NE(v1, v2) -#define DCHECK_GT(v1, v2) CHECK_GT(v1, v2) -#define DCHECK_GE(v1, v2) CHECK_GE(v1, v2) -#define DCHECK_LT(v1, v2) CHECK_LT(v1, v2) -#define DCHECK_LE(v1, v2) CHECK_LE(v1, v2) -#define DCHECK_NULL(val) CHECK_NULL(val) -#define DCHECK_NOT_NULL(val) CHECK_NOT_NULL(val) -#define DCHECK_IMPLIES(v1, v2) CHECK_IMPLIES(v1, v2) +#define DCHECK_EQ(lhs, rhs) DCHECK_OP(EQ, ==, lhs, rhs) +#define DCHECK_NE(lhs, rhs) DCHECK_OP(NE, !=, lhs, rhs) +#define DCHECK_GT(lhs, rhs) DCHECK_OP(GT, >, lhs, rhs) +#define DCHECK_GE(lhs, rhs) DCHECK_OP(GE, >=, lhs, rhs) +#define DCHECK_LT(lhs, rhs) DCHECK_OP(LT, <, lhs, rhs) +#define DCHECK_LE(lhs, rhs) DCHECK_OP(LE, <=, lhs, rhs) +#define DCHECK_NULL(val) DCHECK((val) == nullptr) +#define DCHECK_NOT_NULL(val) DCHECK((val) != nullptr) +#define DCHECK_IMPLIES(lhs, rhs) \ + DCHECK_WITH_MSG(!(lhs) || (rhs), #lhs " implies " #rhs) #else #define DCHECK(condition) ((void) 0) #define DCHECK_EQ(v1, v2) ((void) 0) |