Introduce CONSTEXPR_UNREACHABLE
g++ versions <= 8 cannot use UNREACHABLE() in a constexpr function. As a workaround a new macro is defined to instead use `abort` if this feature is not properly handled by the compiler. Change-Id: Id6daf02b86c38daa12b7e6f42629091c9833f6fe Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3988005 Reviewed-by: Clemens Backes <clemensb@chromium.org> Reviewed-by: Nico Hartmann <nicohartmann@chromium.org> Commit-Queue: Milad Farazmand <mfarazma@redhat.com> Cr-Commit-Position: refs/heads/main@{#83985}
This commit is contained in:
parent
45427e4d77
commit
708d75cd4c
@ -48,6 +48,13 @@ V8_BASE_EXPORT V8_NOINLINE void V8_Dcheck(const char* file, int line,
|
||||
|
||||
#define UNIMPLEMENTED() FATAL("unimplemented code")
|
||||
#define UNREACHABLE() FATAL("unreachable code")
|
||||
// g++ versions <= 8 cannot use UNREACHABLE() in a constexpr function.
|
||||
// TODO(miladfarca): Remove once all compilers handle this properly.
|
||||
#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ <= 8)
|
||||
#define CONSTEXPR_UNREACHABLE() abort()
|
||||
#else
|
||||
#define CONSTEXPR_UNREACHABLE() UNREACHABLE()
|
||||
#endif
|
||||
|
||||
namespace v8 {
|
||||
namespace base {
|
||||
|
@ -220,9 +220,9 @@ inline constexpr int ElementsKindToShiftSize(ElementsKind elements_kind) {
|
||||
return kTaggedSizeLog2;
|
||||
case WASM_ARRAY_ELEMENTS:
|
||||
case NO_ELEMENTS:
|
||||
UNREACHABLE();
|
||||
CONSTEXPR_UNREACHABLE();
|
||||
}
|
||||
UNREACHABLE();
|
||||
CONSTEXPR_UNREACHABLE();
|
||||
}
|
||||
inline constexpr int ElementsKindToByteSize(ElementsKind elements_kind) {
|
||||
return 1 << ElementsKindToShiftSize(elements_kind);
|
||||
|
Loading…
Reference in New Issue
Block a user