| Index: src/base/logging.h
|
| diff --git a/src/base/logging.h b/src/base/logging.h
|
| index eae8a7fdb6aa68a5343a38936a3059128c451e2e..4de8b537cbd131f20ffe246f5c0ec98a734c3a68 100644
|
| --- a/src/base/logging.h
|
| +++ b/src/base/logging.h
|
| @@ -55,14 +55,13 @@
|
|
|
| // 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) \
|
| - do { \
|
| - if (std::string* _msg = \
|
| - ::v8::base::Check##name##Impl<decltype(lhs), decltype(rhs)>( \
|
| - (lhs), (rhs), #lhs " " #op " " #rhs)) { \
|
| - V8_Fatal(__FILE__, __LINE__, "Check failed: %s.", _msg->c_str()); \
|
| - delete _msg; \
|
| - } \
|
| +#define CHECK_OP(name, op, lhs, rhs) \
|
| + do { \
|
| + if (std::string* _msg = ::v8::base::Check##name##Impl( \
|
| + (lhs), (rhs), #lhs " " #op " " #rhs)) { \
|
| + V8_Fatal(__FILE__, __LINE__, "Check failed: %s.", _msg->c_str()); \
|
| + delete _msg; \
|
| + } \
|
| } while (0)
|
|
|
| #else
|
| @@ -74,26 +73,13 @@
|
|
|
| #endif
|
|
|
| -// Helpers to determine how to pass values: Pass scalars by value, others by
|
| -// const reference.
|
| -template <typename Lhs, typename Rhs>
|
| -struct PassByValue {
|
| - enum : bool {
|
| - value = (std::is_scalar<Lhs>::value || std::is_array<Lhs>::value) &&
|
| - (std::is_scalar<Rhs>::value || std::is_array<Rhs>::value)
|
| - };
|
| -};
|
| -template <typename T>
|
| -struct PassType
|
| - : public std::conditional<PassByValue<T, T>::value, T, T const&> {};
|
|
|
| // 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
|
| // takes ownership of the returned string.
|
| template <typename Lhs, typename Rhs>
|
| -std::string* MakeCheckOpString(typename PassType<Lhs>::type lhs,
|
| - typename PassType<Rhs>::type rhs,
|
| +std::string* MakeCheckOpString(Lhs const& lhs, Rhs const& rhs,
|
| char const* msg) {
|
| std::ostringstream ss;
|
| ss << msg << " (" << lhs << " vs. " << rhs << ")";
|
| @@ -104,7 +90,7 @@
|
| // in logging.cc.
|
| #define DEFINE_MAKE_CHECK_OP_STRING(type) \
|
| extern template V8_BASE_EXPORT std::string* MakeCheckOpString<type, type>( \
|
| - type, type, char const*);
|
| + type const&, type const&, 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)
|
| @@ -115,21 +101,27 @@
|
| DEFINE_MAKE_CHECK_OP_STRING(void const*)
|
| #undef DEFINE_MAKE_CHECK_OP_STRING
|
|
|
| +
|
| // Helper functions for CHECK_OP macro.
|
| +// The (int, int) specialization works around the issue that the compiler
|
| +// will not instantiate the template version of the function on values of
|
| +// unnamed enum type - see comment below.
|
| // The (float, float) and (double, double) instantiations are explicitly
|
| // externialized to ensure proper 32/64-bit comparisons on x86.
|
| #define DEFINE_CHECK_OP_IMPL(NAME, op) \
|
| template <typename Lhs, typename Rhs> \
|
| - V8_INLINE std::string* Check##NAME##Impl(typename PassType<Lhs>::type lhs, \
|
| - typename PassType<Rhs>::type rhs, \
|
| + V8_INLINE std::string* Check##NAME##Impl(Lhs const& lhs, Rhs const& rhs, \
|
| char const* msg) { \
|
| - return V8_LIKELY(lhs op rhs) ? nullptr \
|
| - : MakeCheckOpString<Lhs, Rhs>(lhs, rhs, msg); \
|
| + return V8_LIKELY(lhs op rhs) ? nullptr : MakeCheckOpString(lhs, rhs, msg); \
|
| + } \
|
| + V8_INLINE std::string* Check##NAME##Impl(int lhs, int rhs, \
|
| + char const* msg) { \
|
| + return V8_LIKELY(lhs op rhs) ? nullptr : MakeCheckOpString(lhs, rhs, msg); \
|
| } \
|
| extern template V8_BASE_EXPORT std::string* Check##NAME##Impl<float, float>( \
|
| - const float lhs, const float rhs, char const* msg); \
|
| + float const& lhs, float const& rhs, char const* msg); \
|
| extern template V8_BASE_EXPORT std::string* \
|
| - Check##NAME##Impl<double, double>(const double lhs, const double rhs, \
|
| + Check##NAME##Impl<double, double>(double const& lhs, double const& rhs, \
|
| char const* msg);
|
| DEFINE_CHECK_OP_IMPL(EQ, ==)
|
| DEFINE_CHECK_OP_IMPL(NE, !=)
|
|
|