diff options
-rw-r--r-- | compiler/optimizing/code_generator_x86_64.cc | 3 | ||||
-rw-r--r-- | libartbase/base/logging.h | 18 |
2 files changed, 19 insertions, 2 deletions
diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc index 1016652478..ff4ab59760 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -5195,8 +5195,7 @@ void InstructionCodeGeneratorX86_64::HandleFieldSet(HInstruction* instruction, if (byte_swap) { v = BSWAP(v); } - // `field_type == DataType::Type::kReference` implies `v == 0`. - DCHECK((field_type != DataType::Type::kReference) || (v == 0)); + DCHECK_IMPLIES(field_type == DataType::Type::kReference, v == 0); // Note: if heap poisoning is enabled, no need to poison // (negate) `v` if it is a reference, as it would be null. __ movl(field_addr, Immediate(v)); diff --git a/libartbase/base/logging.h b/libartbase/base/logging.h index e573f03be3..7a421a4171 100644 --- a/libartbase/base/logging.h +++ b/libartbase/base/logging.h @@ -149,6 +149,24 @@ class VlogMessage { -1) \ .stream() +// Check whether an implication holds between x and y, LOG(FATAL) if not. The value +// of the expressions x and y is evaluated once. Extra logging can be appended +// using << after. For example: +// +// CHECK_IMPLIES(1==1, 0==1) results in +// "Check failed: 1==1 (true) implies 0==1 (false) ". +// clang-format off +#define CHECK_IMPLIES(LHS, RHS) \ + LIKELY(!(LHS) || (RHS)) || ABORT_AFTER_LOG_FATAL_EXPR(false) || \ + ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::FATAL, _LOG_TAG_INTERNAL, \ + -1) \ + .stream() \ + << "Check failed: " #LHS << " (true) implies " #RHS << " (false)" +// clang-format on + +#define DCHECK_IMPLIES(a, b) \ + if (::android::base::kEnableDChecks) CHECK_IMPLIES(a, b) + } // namespace art #endif // ART_LIBARTBASE_BASE_LOGGING_H_ |